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