@lucern/graph-primitives 0.3.0-alpha.17 → 0.3.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{beliefDecay-DZ6tkLYq.d.ts → beliefDecay-Q_26RTc-.d.ts} +1 -1
- package/dist/beliefDecay.d.ts +1 -1
- package/dist/beliefDecay.js +47 -158
- package/dist/beliefDecay.js.map +1 -1
- package/dist/{beliefEvidenceLinks-CWOXxxJg.d.ts → beliefEvidenceLinks-42FlR48t.d.ts} +1 -1
- package/dist/beliefEvidenceLinks.d.ts +1 -1
- package/dist/beliefEvidenceLinks.js +45 -141
- package/dist/beliefEvidenceLinks.js.map +1 -1
- package/dist/{beliefLifecycle-y8WLXqQj.d.ts → beliefLifecycle-C-AehZgF.d.ts} +1 -1
- package/dist/beliefLifecycle.d.ts +1 -1
- package/dist/confidencePropagationDispatch.d.ts +1 -1
- package/dist/confidencePropagationDispatch.js +3 -1
- package/dist/confidencePropagationDispatch.js.map +1 -1
- package/dist/{contradictions-51VLsESq.d.ts → contradictions-Hdwl7zid.d.ts} +1 -1
- package/dist/contradictions.d.ts +1 -1
- package/dist/contradictions.js +8 -67
- package/dist/contradictions.js.map +1 -1
- package/dist/edges/contradicts.js.map +1 -1
- package/dist/edges/dependsOn.js.map +1 -1
- package/dist/edges/elaborates.js.map +1 -1
- package/dist/edges/index.js +3 -1
- package/dist/edges/index.js.map +1 -1
- package/dist/edges/informs.js +3 -1
- package/dist/edges/informs.js.map +1 -1
- package/dist/edges/refutes.js +3 -1
- package/dist/edges/refutes.js.map +1 -1
- package/dist/edges/supports.js.map +1 -1
- package/dist/edges/utils.d.ts +3 -3
- package/dist/edges/utils.js +4 -2
- package/dist/edges/utils.js.map +1 -1
- package/dist/embeddingTrigger.js +1 -21
- package/dist/embeddingTrigger.js.map +1 -1
- package/dist/entityBridge.js +1 -1
- package/dist/entityBridge.js.map +1 -1
- package/dist/{entityLifecycle-CvgSK5FV.d.ts → entityLifecycle-BkhRJ-XI.d.ts} +1 -1
- package/dist/entityLifecycle.d.ts +1 -1
- package/dist/entityLifecycle.js +47 -134
- package/dist/entityLifecycle.js.map +1 -1
- package/dist/{epistemicAnswers-C5ib4z6_.d.ts → epistemicAnswers-DSP1slZ9.d.ts} +1 -1
- package/dist/epistemicAnswers.d.ts +1 -1
- package/dist/epistemicAnswers.js +8 -67
- package/dist/epistemicAnswers.js.map +1 -1
- package/dist/{epistemicBeliefs-DzKjZAeC.d.ts → epistemicBeliefs-DtFVTp-k.d.ts} +3 -3
- package/dist/epistemicBeliefs.d.ts +2 -2
- package/dist/epistemicBeliefs.js +114 -289
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicContracts.d.ts +1 -1
- package/dist/epistemicContracts.js +115 -297
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/{epistemicEdges-CvlKnEyy.d.ts → epistemicEdges-DcA8ErUG.d.ts} +1 -1
- package/dist/epistemicEdges.d.ts +1 -1
- package/dist/epistemicEdges.js +60 -192
- package/dist/epistemicEdges.js.map +1 -1
- package/dist/{epistemicEvidence-xw6UUrwh.d.ts → epistemicEvidence-Bo638XDP.d.ts} +1 -1
- package/dist/epistemicEvidence.d.ts +1 -1
- package/dist/epistemicEvidence.js +49 -163
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/{epistemicHelpers-DevrYgPN.d.ts → epistemicHelpers-Bd9xbaib.d.ts} +1 -1
- package/dist/epistemicHelpers.d.ts +1 -1
- package/dist/{epistemicLinking-CfE00tHJ.d.ts → epistemicLinking-CyeLOIzN.d.ts} +1 -1
- package/dist/epistemicLinking.d.ts +1 -1
- package/dist/epistemicLinking.js +1 -1
- package/dist/{epistemicNodes-DjSUfvyD.d.ts → epistemicNodes-BpD6Koud.d.ts} +1 -1
- package/dist/epistemicNodes.d.ts +1 -1
- package/dist/epistemicNodes.js +33 -163
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/{epistemicQuestions-B_nUclrH.d.ts → epistemicQuestions-CmEeY6zQ.d.ts} +1 -1
- package/dist/epistemicQuestions.d.ts +1 -1
- package/dist/epistemicQuestions.js +62 -311
- package/dist/epistemicQuestions.js.map +1 -1
- package/dist/{epistemicSources-dlKj58Jp.d.ts → epistemicSources-ZazxHOK1.d.ts} +1 -1
- package/dist/epistemicSources.d.ts +1 -1
- package/dist/epistemicSources.js +8 -65
- package/dist/epistemicSources.js.map +1 -1
- package/dist/evaluators/index.js +115 -297
- package/dist/evaluators/index.js.map +1 -1
- package/dist/evaluators/lintCheckerEvaluator.js.map +1 -1
- package/dist/evaluators/sentryCheckerEvaluator.js.map +1 -1
- package/dist/evaluators/shared.js +1 -20
- package/dist/evaluators/shared.js.map +1 -1
- package/dist/evaluators/testRunnerEvaluator.js +1 -20
- package/dist/evaluators/testRunnerEvaluator.js.map +1 -1
- package/dist/evaluators/tscCheckerEvaluator.js.map +1 -1
- package/dist/index.d.ts +20 -20
- package/dist/index.js +206 -729
- package/dist/index.js.map +1 -1
- package/dist/{ontology-matching-C6rrz2VP.d.ts → ontology-matching-Buhu23ss.d.ts} +1 -1
- package/dist/ontology-matching.d.ts +1 -1
- package/dist/{ontologyApproval-CFYmqKmk.d.ts → ontologyApproval-Ba0Jjk1k.d.ts} +1 -1
- package/dist/ontologyApproval.d.ts +1 -1
- package/dist/ontologyDefinitions.js +3 -4
- package/dist/ontologyDefinitions.js.map +1 -1
- package/dist/ontologyHelpers.d.ts +1 -1
- package/dist/ontologyHelpers.js +3 -4
- package/dist/ontologyHelpers.js.map +1 -1
- package/dist/{projectionReconciliation-jww2fBI0.d.ts → projectionReconciliation-CxrXYGaB.d.ts} +1 -1
- package/dist/projectionReconciliation.d.ts +1 -1
- package/dist/projectionReconciliation.js +20 -14
- package/dist/projectionReconciliation.js.map +1 -1
- package/dist/{projectionStaleness-CmdbpjVK.d.ts → projectionStaleness-CAdpIsaW.d.ts} +1 -1
- package/dist/projectionStaleness.d.ts +1 -1
- package/dist/{questionEvidenceLinks-DFlyPpAj.d.ts → questionEvidenceLinks-BdQD0TkM.d.ts} +1 -1
- package/dist/questionEvidenceLinks.d.ts +1 -1
- package/dist/questionEvidenceLinks.js +45 -144
- package/dist/questionEvidenceLinks.js.map +1 -1
- package/dist/resolvers.js +37 -86
- package/dist/resolvers.js.map +1 -1
- package/dist/scopeResolverCompat.js +7 -64
- package/dist/scopeResolverCompat.js.map +1 -1
- package/dist/{text-matching-DNg4M5Wd.d.ts → text-matching-CMn2WnVD.d.ts} +1 -1
- package/dist/text-matching.d.ts +1 -1
- package/dist/topicProjectOverlay.js +13 -56
- package/dist/topicProjectOverlay.js.map +1 -1
- package/dist/topicScope.js +6 -55
- package/dist/topicScope.js.map +1 -1
- package/dist/workflowBridge.js +6 -55
- package/dist/workflowBridge.js.map +1 -1
- package/dist/workspaceIsolation.js +6 -55
- package/dist/workspaceIsolation.js.map +1 -1
- package/package.json +5 -5
- package/dist/debug.d.ts +0 -4
- package/dist/debug.js +0 -34
- package/dist/debug.js.map +0 -1
|
@@ -188,4 +188,4 @@ declare namespace epistemicEdges {
|
|
|
188
188
|
export { epistemicEdges_batchCreate as batchCreate, epistemicEdges_cleanupDeprecatedEdges as cleanupDeprecatedEdges, epistemicEdges_create as create, epistemicEdges_deleteEdgeFromConvex as deleteEdgeFromConvex, epistemicEdges_deleteEdges as deleteEdges, epistemicEdges_edgeTypeValidator as edgeTypeValidator, epistemicEdges_epistemicLayerValidator as epistemicLayerValidator, epistemicEdges_findContradictions as findContradictions, epistemicEdges_findSupport as findSupport, epistemicEdges_get as get, epistemicEdges_getBetween as getBetween, epistemicEdges_getByGlobalId as getByGlobalId, epistemicEdges_getByNodes as getByNodes, epistemicEdges_getByProject as getByProject, epistemicEdges_getByProjectAndType as getByProjectAndType, epistemicEdges_getBySourceNode as getBySourceNode, epistemicEdges_getByTargetNode as getByTargetNode, epistemicEdges_getByTopic as getByTopic, epistemicEdges_getClusterEdges as getClusterEdges, epistemicEdges_getEvidenceForBelief as getEvidenceForBelief, epistemicEdges_getFromNode as getFromNode, epistemicEdges_getLineage as getLineage, epistemicEdges_getToNode as getToNode, epistemicEdges_listAll as listAll, epistemicEdges_mirrorEdgeToConvex as mirrorEdgeToConvex, epistemicEdges_remove as remove, epistemicEdges_removeBetween as removeBetween, epistemicEdges_update as update, epistemicEdges_updateEdgeInConvex as updateEdgeInConvex };
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
export {
|
|
191
|
+
export { getClusterEdges as A, mirrorEdgeToConvex as B, deleteEdgeFromConvex as C, updateEdgeInConvex as D, epistemicLayerValidator as a, edgeTypeValidator as b, getByGlobalId as c, getFromNode as d, epistemicEdges as e, getToNode as f, get as g, getBySourceNode as h, getByTargetNode as i, getBetween as j, getByNodes as k, getByProjectAndType as l, getByProject as m, getByTopic as n, listAll as o, findContradictions as p, findSupport as q, create as r, remove as s, removeBetween as t, update as u, batchCreate as v, getLineage as w, getEvidenceForBelief as x, cleanupDeprecatedEdges as y, deleteEdges as z };
|
package/dist/epistemicEdges.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'convex/values';
|
|
2
|
-
export {
|
|
2
|
+
export { v as batchCreate, y as cleanupDeprecatedEdges, r as create, C as deleteEdgeFromConvex, z as deleteEdges, b as edgeTypeValidator, a as epistemicLayerValidator, p as findContradictions, q as findSupport, g as get, j as getBetween, c as getByGlobalId, k as getByNodes, m as getByProject, l as getByProjectAndType, h as getBySourceNode, i as getByTargetNode, n as getByTopic, A as getClusterEdges, x as getEvidenceForBelief, d as getFromNode, w as getLineage, f as getToNode, o as listAll, B as mirrorEdgeToConvex, s as remove, t as removeBetween, u as update, D as updateEdgeInConvex } from './epistemicEdges-DcA8ErUG.js';
|
package/dist/epistemicEdges.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v } from 'convex/values';
|
|
2
2
|
import { checkScopeAccess, requireProjectAccess } from '@lucern/access-control/access';
|
|
3
3
|
import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
|
|
4
|
-
import { componentsGeneric,
|
|
4
|
+
import { componentsGeneric, queryGeneric, mutationGeneric, anyApi, internalMutationGeneric } from 'convex/server';
|
|
5
5
|
|
|
6
6
|
// src/epistemicEdges.ts
|
|
7
7
|
var api = anyApi;
|
|
@@ -11,18 +11,6 @@ var internalMutation = internalMutationGeneric;
|
|
|
11
11
|
var mutation = mutationGeneric;
|
|
12
12
|
var query = queryGeneric;
|
|
13
13
|
|
|
14
|
-
// src/debug.ts
|
|
15
|
-
function isGraphPrimitiveDebugEnabled() {
|
|
16
|
-
const env = globalThis.process?.env;
|
|
17
|
-
return env?.LUCERN_COMPAT_FALLBACK_DEBUG === "1" || env?.LUCERN_GRAPH_DEBUG === "1";
|
|
18
|
-
}
|
|
19
|
-
function debugGraphPrimitiveFallback(message, context) {
|
|
20
|
-
if (!isGraphPrimitiveDebugEnabled()) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
console.debug(message, context ?? {});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
14
|
// src/graphTypes.ts
|
|
27
15
|
var EDGE_TYPE_TO_REL = {
|
|
28
16
|
// === THE SIX CANONICAL EPISTEMIC EDGE TYPES ===
|
|
@@ -406,37 +394,19 @@ function isProjectLikeTopic(topic) {
|
|
|
406
394
|
return topic.type === "theme" || topic.type === "thematic" || topic.type === "deal" || topic.type === "monitoring" || readLegacyProjectId(topic) !== void 0 || readNonEmptyString(metadata.projectType) !== void 0;
|
|
407
395
|
}
|
|
408
396
|
function isMissingLucernChildComponentError(error) {
|
|
409
|
-
const message =
|
|
397
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
410
398
|
return message.includes(
|
|
411
399
|
'Child component ComponentName(Identifier("lucern")) not found'
|
|
412
400
|
) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
|
|
413
401
|
}
|
|
414
|
-
function getErrorMessage(error) {
|
|
415
|
-
if (error instanceof Error) {
|
|
416
|
-
return error.message;
|
|
417
|
-
}
|
|
418
|
-
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
419
|
-
return error.message;
|
|
420
|
-
}
|
|
421
|
-
return "unknown error";
|
|
422
|
-
}
|
|
423
402
|
async function resolveTopicDoc(ctx, scopeId) {
|
|
424
403
|
if (ctx?.db && typeof ctx.db.get === "function") {
|
|
425
404
|
try {
|
|
426
|
-
const directTopic = await ctx.db.get(
|
|
427
|
-
scopeId
|
|
428
|
-
);
|
|
405
|
+
const directTopic = await ctx.db.get(scopeId);
|
|
429
406
|
if (directTopic) {
|
|
430
407
|
return directTopic;
|
|
431
408
|
}
|
|
432
|
-
} catch
|
|
433
|
-
debugGraphPrimitiveFallback(
|
|
434
|
-
"[topicProjectOverlay] Failed to resolve topic by direct ID",
|
|
435
|
-
{
|
|
436
|
-
error,
|
|
437
|
-
scopeId
|
|
438
|
-
}
|
|
439
|
-
);
|
|
409
|
+
} catch {
|
|
440
410
|
}
|
|
441
411
|
}
|
|
442
412
|
if (typeof ctx.runQuery !== "function") {
|
|
@@ -449,14 +419,7 @@ async function resolveTopicDoc(ctx, scopeId) {
|
|
|
449
419
|
if (topic?.name !== void 0 && topic?.type !== void 0) {
|
|
450
420
|
return topic;
|
|
451
421
|
}
|
|
452
|
-
} catch
|
|
453
|
-
debugGraphPrimitiveFallback(
|
|
454
|
-
"[topicProjectOverlay] Failed to resolve topic by ID query",
|
|
455
|
-
{
|
|
456
|
-
error,
|
|
457
|
-
scopeId
|
|
458
|
-
}
|
|
459
|
-
);
|
|
422
|
+
} catch {
|
|
460
423
|
}
|
|
461
424
|
try {
|
|
462
425
|
const topic = await ctx.runQuery(api.topics.getByLegacyScopeId, {
|
|
@@ -465,11 +428,7 @@ async function resolveTopicDoc(ctx, scopeId) {
|
|
|
465
428
|
if (topic?.name !== void 0 && topic?.type !== void 0) {
|
|
466
429
|
return topic;
|
|
467
430
|
}
|
|
468
|
-
} catch
|
|
469
|
-
debugGraphPrimitiveFallback(
|
|
470
|
-
"[topicProjectOverlay] Failed to resolve topic by legacy scope ID",
|
|
471
|
-
{ error, scopeId }
|
|
472
|
-
);
|
|
431
|
+
} catch {
|
|
473
432
|
}
|
|
474
433
|
return null;
|
|
475
434
|
}
|
|
@@ -523,11 +482,7 @@ async function listTopicProjectOverlays(ctx, options = {}) {
|
|
|
523
482
|
if (ctx?.db?.query && typeof ctx.db.query === "function") {
|
|
524
483
|
try {
|
|
525
484
|
allTopics = await ctx.db.query("topics").collect();
|
|
526
|
-
} catch
|
|
527
|
-
debugGraphPrimitiveFallback(
|
|
528
|
-
"[topicProjectOverlay] Failed to read topics table; falling back to API",
|
|
529
|
-
{ error }
|
|
530
|
-
);
|
|
485
|
+
} catch {
|
|
531
486
|
allTopics = [];
|
|
532
487
|
}
|
|
533
488
|
}
|
|
@@ -622,28 +577,19 @@ async function patchTopicProjectOverlay(ctx, scopeId, value) {
|
|
|
622
577
|
"Cannot patch topic without component adapter (ctx.runMutation unavailable)"
|
|
623
578
|
);
|
|
624
579
|
}
|
|
625
|
-
return materializeTopicProjectOverlay(
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
580
|
+
return materializeTopicProjectOverlay(
|
|
581
|
+
{
|
|
582
|
+
...topic,
|
|
583
|
+
...patch,
|
|
584
|
+
metadata: nextMetadata
|
|
585
|
+
}
|
|
586
|
+
);
|
|
630
587
|
}
|
|
631
588
|
|
|
632
589
|
// src/resolvers.ts
|
|
633
590
|
function isMissingLucernChildComponentError2(error) {
|
|
634
|
-
const message =
|
|
635
|
-
return message.includes(
|
|
636
|
-
'Child component ComponentName(Identifier("lucern")) not found'
|
|
637
|
-
) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
|
|
638
|
-
}
|
|
639
|
-
function getErrorMessage2(error) {
|
|
640
|
-
if (error instanceof Error) {
|
|
641
|
-
return error.message;
|
|
642
|
-
}
|
|
643
|
-
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
644
|
-
return error.message;
|
|
645
|
-
}
|
|
646
|
-
return "unknown error";
|
|
591
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
592
|
+
return message.includes('Child component ComponentName(Identifier("lucern")) not found') || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
|
|
647
593
|
}
|
|
648
594
|
function isAdvisoryTopicPatch(value) {
|
|
649
595
|
const advisoryKeys = /* @__PURE__ */ new Set(["lastActivityAt", "updatedAt"]);
|
|
@@ -657,27 +603,32 @@ async function patchProjectWithTolerance(ctx, projectId, value) {
|
|
|
657
603
|
if (!isAdvisoryTopicPatch(value) || !isMissingLucernChildComponentError2(error)) {
|
|
658
604
|
throw error;
|
|
659
605
|
}
|
|
660
|
-
console.warn(
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
error: getErrorMessage2(error)
|
|
666
|
-
}
|
|
667
|
-
);
|
|
606
|
+
console.warn("[lucern graph-primitives] Non-fatal advisory topic patch failure", {
|
|
607
|
+
projectId,
|
|
608
|
+
keys: Object.keys(value),
|
|
609
|
+
error: error instanceof Error ? error.message : error
|
|
610
|
+
});
|
|
668
611
|
}
|
|
669
612
|
}
|
|
670
613
|
function defaultResolvers() {
|
|
671
614
|
return {
|
|
672
|
-
getProject
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
615
|
+
async getProject(ctx, projectId) {
|
|
616
|
+
return await resolveTopicProjectOverlay(ctx, projectId, {
|
|
617
|
+
idMode: "legacy",
|
|
618
|
+
projectLikeOnly: false
|
|
619
|
+
});
|
|
620
|
+
},
|
|
621
|
+
async patchProject(ctx, projectId, value) {
|
|
622
|
+
await patchProjectWithTolerance(ctx, projectId, value);
|
|
623
|
+
},
|
|
624
|
+
async listTopics(ctx) {
|
|
625
|
+
return await listTopicProjectOverlays(ctx, {
|
|
626
|
+
idMode: "legacy"
|
|
627
|
+
});
|
|
628
|
+
},
|
|
629
|
+
async getFinalArtifact(ctx, artifactId) {
|
|
630
|
+
return await ctx.db.get(artifactId);
|
|
631
|
+
}
|
|
681
632
|
};
|
|
682
633
|
}
|
|
683
634
|
var resolverOverrides = {};
|
|
@@ -728,14 +679,7 @@ async function findTopicsByScopeAlias(ctx, scopeId) {
|
|
|
728
679
|
"by_graph_scope_project",
|
|
729
680
|
(q) => q.eq(LEGACY_SCOPE_FIELD2, scopeId)
|
|
730
681
|
).collect();
|
|
731
|
-
} catch
|
|
732
|
-
debugGraphPrimitiveFallback(
|
|
733
|
-
"[topicScope] Failed to resolve scope alias via index",
|
|
734
|
-
{
|
|
735
|
-
error,
|
|
736
|
-
scopeId
|
|
737
|
-
}
|
|
738
|
-
);
|
|
682
|
+
} catch {
|
|
739
683
|
const topics = await ctx.db.query("topics").collect();
|
|
740
684
|
return topics.filter((topic) => {
|
|
741
685
|
const normalizedGlobalId = normalizeScopeValue(topic.globalId);
|
|
@@ -752,14 +696,7 @@ async function tryResolveHostTopicById(ctx, topicId) {
|
|
|
752
696
|
return await ctx.runQuery(api.topics.get, {
|
|
753
697
|
id: topicId
|
|
754
698
|
}) ?? null;
|
|
755
|
-
} catch
|
|
756
|
-
debugGraphPrimitiveFallback(
|
|
757
|
-
"[topicScope] Failed to resolve topic by host query",
|
|
758
|
-
{
|
|
759
|
-
error,
|
|
760
|
-
topicId
|
|
761
|
-
}
|
|
762
|
-
);
|
|
699
|
+
} catch {
|
|
763
700
|
return null;
|
|
764
701
|
}
|
|
765
702
|
}
|
|
@@ -771,14 +708,7 @@ async function tryResolveHostTopicByLegacyScope(ctx, legacyScopeId) {
|
|
|
771
708
|
return await ctx.runQuery(api.topics.getByLegacyScopeId, {
|
|
772
709
|
projectId: legacyScopeId
|
|
773
710
|
}) ?? null;
|
|
774
|
-
} catch
|
|
775
|
-
debugGraphPrimitiveFallback(
|
|
776
|
-
"[topicScope] Failed to resolve topic by legacy scope",
|
|
777
|
-
{
|
|
778
|
-
error,
|
|
779
|
-
legacyScopeId
|
|
780
|
-
}
|
|
781
|
-
);
|
|
711
|
+
} catch {
|
|
782
712
|
return null;
|
|
783
713
|
}
|
|
784
714
|
}
|
|
@@ -807,17 +737,8 @@ async function resolveTopicProjectScope(ctx, args) {
|
|
|
807
737
|
if (args.topicId) {
|
|
808
738
|
let topic = null;
|
|
809
739
|
try {
|
|
810
|
-
topic = await ctx.db.get(
|
|
811
|
-
|
|
812
|
-
);
|
|
813
|
-
} catch (error) {
|
|
814
|
-
debugGraphPrimitiveFallback(
|
|
815
|
-
"[topicScope] Failed to load topic by direct id",
|
|
816
|
-
{
|
|
817
|
-
error,
|
|
818
|
-
topicId: args.topicId
|
|
819
|
-
}
|
|
820
|
-
);
|
|
740
|
+
topic = await ctx.db.get(args.topicId);
|
|
741
|
+
} catch {
|
|
821
742
|
}
|
|
822
743
|
if (!topic) {
|
|
823
744
|
topic = await tryResolveHostTopicById(ctx, String(args.topicId));
|
|
@@ -854,14 +775,7 @@ async function resolveTopicProjectScope(ctx, args) {
|
|
|
854
775
|
directTopic = await ctx.db.get(
|
|
855
776
|
args.projectId
|
|
856
777
|
);
|
|
857
|
-
} catch
|
|
858
|
-
debugGraphPrimitiveFallback(
|
|
859
|
-
"[topicScope] Failed to load direct project topic",
|
|
860
|
-
{
|
|
861
|
-
error,
|
|
862
|
-
projectId: args.projectId
|
|
863
|
-
}
|
|
864
|
-
);
|
|
778
|
+
} catch {
|
|
865
779
|
}
|
|
866
780
|
if (directTopic) {
|
|
867
781
|
const inherited = await resolveInheritedWorkspaceScope(ctx, directTopic);
|
|
@@ -1068,34 +982,6 @@ var edgeTypeValidator = v.union(
|
|
|
1068
982
|
v.literal("competes_with")
|
|
1069
983
|
// Company → Company (ontological → ontological)
|
|
1070
984
|
);
|
|
1071
|
-
function buildEdgeStatusSuccessResult() {
|
|
1072
|
-
return { success: true };
|
|
1073
|
-
}
|
|
1074
|
-
function buildEdgeNotFoundResult() {
|
|
1075
|
-
const result = {};
|
|
1076
|
-
result.success = false;
|
|
1077
|
-
result.error = "Edge not found";
|
|
1078
|
-
return result;
|
|
1079
|
-
}
|
|
1080
|
-
function buildEdgeMirrorSkippedResult() {
|
|
1081
|
-
return {
|
|
1082
|
-
success: false,
|
|
1083
|
-
reason: "source_not_in_convex"
|
|
1084
|
-
};
|
|
1085
|
-
}
|
|
1086
|
-
function buildEdgeMirrorMissingResult() {
|
|
1087
|
-
return {
|
|
1088
|
-
success: false,
|
|
1089
|
-
reason: "not_found"
|
|
1090
|
-
};
|
|
1091
|
-
}
|
|
1092
|
-
function buildEdgeMirrorWriteResult(edgeId, existed) {
|
|
1093
|
-
return {
|
|
1094
|
-
success: true,
|
|
1095
|
-
edgeId,
|
|
1096
|
-
existed
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
985
|
var get = query({
|
|
1100
986
|
args: { edgeId: v.id("epistemicEdges") },
|
|
1101
987
|
returns: permissiveReturn,
|
|
@@ -1247,15 +1133,7 @@ var getByProjectAndType = query({
|
|
|
1247
1133
|
projectId: args.projectId,
|
|
1248
1134
|
topicId: args.topicId
|
|
1249
1135
|
});
|
|
1250
|
-
} catch
|
|
1251
|
-
debugGraphPrimitiveFallback(
|
|
1252
|
-
"[epistemicEdges] Failed to resolve getAll scope",
|
|
1253
|
-
{
|
|
1254
|
-
error,
|
|
1255
|
-
projectId: args.projectId,
|
|
1256
|
-
topicId: args.topicId
|
|
1257
|
-
}
|
|
1258
|
-
);
|
|
1136
|
+
} catch {
|
|
1259
1137
|
return [];
|
|
1260
1138
|
}
|
|
1261
1139
|
const projectEdges = await collectScopedEdges(ctx, scope, 5e3);
|
|
@@ -1281,15 +1159,7 @@ var getByProject = query({
|
|
|
1281
1159
|
projectId: args.projectId,
|
|
1282
1160
|
topicId: args.topicId
|
|
1283
1161
|
});
|
|
1284
|
-
} catch
|
|
1285
|
-
debugGraphPrimitiveFallback(
|
|
1286
|
-
"[epistemicEdges] Failed to resolve getByProject scope",
|
|
1287
|
-
{
|
|
1288
|
-
error,
|
|
1289
|
-
projectId: args.projectId,
|
|
1290
|
-
topicId: args.topicId
|
|
1291
|
-
}
|
|
1292
|
-
);
|
|
1162
|
+
} catch {
|
|
1293
1163
|
return [];
|
|
1294
1164
|
}
|
|
1295
1165
|
if (args.userId) {
|
|
@@ -1303,11 +1173,7 @@ var getByProject = query({
|
|
|
1303
1173
|
}
|
|
1304
1174
|
}
|
|
1305
1175
|
const pageSize = Math.max(1, Math.min(Math.floor(args.limit ?? 500), 2e3));
|
|
1306
|
-
const edges = await collectScopedEdges(
|
|
1307
|
-
ctx,
|
|
1308
|
-
scope,
|
|
1309
|
-
Math.min(pageSize * 3, 6e3)
|
|
1310
|
-
);
|
|
1176
|
+
const edges = await collectScopedEdges(ctx, scope, Math.min(pageSize * 3, 6e3));
|
|
1311
1177
|
return edges.filter((edge) => edgeMatchesWorkspaceReasoningScope(edge, scope)).slice(0, pageSize);
|
|
1312
1178
|
}
|
|
1313
1179
|
});
|
|
@@ -1541,7 +1407,7 @@ var update = mutation({
|
|
|
1541
1407
|
projectId: edge.projectId
|
|
1542
1408
|
});
|
|
1543
1409
|
}
|
|
1544
|
-
return
|
|
1410
|
+
return { success: true };
|
|
1545
1411
|
}
|
|
1546
1412
|
});
|
|
1547
1413
|
var remove = mutation({
|
|
@@ -1553,7 +1419,7 @@ var remove = mutation({
|
|
|
1553
1419
|
handler: async (ctx, args) => {
|
|
1554
1420
|
const edge = await ctx.db.get(args.edgeId);
|
|
1555
1421
|
if (!edge) {
|
|
1556
|
-
return
|
|
1422
|
+
return { success: false, error: "Edge not found" };
|
|
1557
1423
|
}
|
|
1558
1424
|
if (edge.projectId && args.userId) {
|
|
1559
1425
|
await requireProjectAccess(ctx, edge.projectId, args.userId);
|
|
@@ -1588,7 +1454,7 @@ var remove = mutation({
|
|
|
1588
1454
|
globalId: edge.globalId
|
|
1589
1455
|
});
|
|
1590
1456
|
await ctx.db.delete(args.edgeId);
|
|
1591
|
-
return
|
|
1457
|
+
return { success: true };
|
|
1592
1458
|
}
|
|
1593
1459
|
});
|
|
1594
1460
|
var removeBetween = mutation({
|
|
@@ -1748,7 +1614,9 @@ var getLineage = query({
|
|
|
1748
1614
|
}
|
|
1749
1615
|
visited.add(nodeIdStr);
|
|
1750
1616
|
const edges = await ctx.db.query("epistemicEdges").withIndex("by_from", (q) => q.eq("fromNodeId", current.nodeId)).collect();
|
|
1751
|
-
const lineageEdges = edges.filter(
|
|
1617
|
+
const lineageEdges = edges.filter(
|
|
1618
|
+
(e) => e.edgeType === "derived_from"
|
|
1619
|
+
);
|
|
1752
1620
|
for (const edge of lineageEdges) {
|
|
1753
1621
|
if (!edge.toNodeId) {
|
|
1754
1622
|
continue;
|
|
@@ -1949,13 +1817,13 @@ var mirrorEdgeToConvex = internalMutation({
|
|
|
1949
1817
|
console.log(
|
|
1950
1818
|
`[Dual-Write] Skipping mirror - source node not in Convex: ${args.fromGlobalId}`
|
|
1951
1819
|
);
|
|
1952
|
-
return
|
|
1820
|
+
return { success: false, reason: "source_not_in_convex" };
|
|
1953
1821
|
}
|
|
1954
1822
|
const toNode = await ctx.db.query("epistemicNodes").withIndex("by_globalId", (q) => q.eq("globalId", args.toGlobalId)).first();
|
|
1955
1823
|
const existing = await ctx.db.query("epistemicEdges").withIndex("by_globalId", (q) => q.eq("globalId", args.globalId)).first();
|
|
1956
1824
|
if (existing) {
|
|
1957
1825
|
console.log(`[Dual-Write] Edge already exists: ${args.globalId}`);
|
|
1958
|
-
return
|
|
1826
|
+
return { success: true, edgeId: existing._id, existed: true };
|
|
1959
1827
|
}
|
|
1960
1828
|
const now = Date.now();
|
|
1961
1829
|
const edgeId = await ctx.db.insert("epistemicEdges", {
|
|
@@ -1996,7 +1864,7 @@ var mirrorEdgeToConvex = internalMutation({
|
|
|
1996
1864
|
console.log(
|
|
1997
1865
|
`[Dual-Write] Mirrored edge to Convex: ${args.globalId} (${args.edgeType})`
|
|
1998
1866
|
);
|
|
1999
|
-
return
|
|
1867
|
+
return { success: true, edgeId, existed: false };
|
|
2000
1868
|
}
|
|
2001
1869
|
});
|
|
2002
1870
|
var deleteEdgeFromConvex = internalMutation({
|
|
@@ -2007,11 +1875,11 @@ var deleteEdgeFromConvex = internalMutation({
|
|
|
2007
1875
|
handler: async (ctx, args) => {
|
|
2008
1876
|
const existing = await ctx.db.query("epistemicEdges").withIndex("by_globalId", (q) => q.eq("globalId", args.globalId)).first();
|
|
2009
1877
|
if (!existing) {
|
|
2010
|
-
return
|
|
1878
|
+
return { success: false, reason: "not_found" };
|
|
2011
1879
|
}
|
|
2012
1880
|
await ctx.db.delete(existing._id);
|
|
2013
1881
|
console.log(`[Dual-Write] Deleted edge from Convex: ${args.globalId}`);
|
|
2014
|
-
return
|
|
1882
|
+
return { success: true };
|
|
2015
1883
|
}
|
|
2016
1884
|
});
|
|
2017
1885
|
var updateEdgeInConvex = internalMutation({
|
|
@@ -2032,7 +1900,7 @@ var updateEdgeInConvex = internalMutation({
|
|
|
2032
1900
|
handler: async (ctx, args) => {
|
|
2033
1901
|
const existing = await ctx.db.query("epistemicEdges").withIndex("by_globalId", (q) => q.eq("globalId", args.globalId)).first();
|
|
2034
1902
|
if (!existing) {
|
|
2035
|
-
return
|
|
1903
|
+
return { success: false, reason: "not_found" };
|
|
2036
1904
|
}
|
|
2037
1905
|
const updates = {
|
|
2038
1906
|
updatedAt: Date.now()
|
|
@@ -2069,7 +1937,7 @@ var updateEdgeInConvex = internalMutation({
|
|
|
2069
1937
|
}
|
|
2070
1938
|
await ctx.db.patch(existing._id, updates);
|
|
2071
1939
|
console.log(`[Dual-Write] Updated edge in Convex: ${args.globalId}`);
|
|
2072
|
-
return
|
|
1940
|
+
return { success: true };
|
|
2073
1941
|
}
|
|
2074
1942
|
});
|
|
2075
1943
|
|