@lucern/graph-primitives 0.3.0-alpha.1 → 0.3.0-alpha.10

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.
Files changed (123) hide show
  1. package/dist/{beliefDecay-Q_26RTc-.d.ts → beliefDecay-DZ6tkLYq.d.ts} +1 -1
  2. package/dist/beliefDecay.d.ts +1 -1
  3. package/dist/beliefDecay.js +158 -47
  4. package/dist/beliefDecay.js.map +1 -1
  5. package/dist/{beliefEvidenceLinks-42FlR48t.d.ts → beliefEvidenceLinks-CWOXxxJg.d.ts} +1 -1
  6. package/dist/beliefEvidenceLinks.d.ts +1 -1
  7. package/dist/beliefEvidenceLinks.js +141 -45
  8. package/dist/beliefEvidenceLinks.js.map +1 -1
  9. package/dist/{beliefLifecycle-C-AehZgF.d.ts → beliefLifecycle-y8WLXqQj.d.ts} +1 -1
  10. package/dist/beliefLifecycle.d.ts +1 -1
  11. package/dist/confidencePropagationDispatch.d.ts +1 -1
  12. package/dist/confidencePropagationDispatch.js +1 -3
  13. package/dist/confidencePropagationDispatch.js.map +1 -1
  14. package/dist/{contradictions-Hdwl7zid.d.ts → contradictions-51VLsESq.d.ts} +1 -1
  15. package/dist/contradictions.d.ts +1 -1
  16. package/dist/contradictions.js +67 -8
  17. package/dist/contradictions.js.map +1 -1
  18. package/dist/debug.d.ts +4 -0
  19. package/dist/debug.js +34 -0
  20. package/dist/debug.js.map +1 -0
  21. package/dist/edges/contradicts.js.map +1 -1
  22. package/dist/edges/dependsOn.js.map +1 -1
  23. package/dist/edges/elaborates.js.map +1 -1
  24. package/dist/edges/index.js +1 -3
  25. package/dist/edges/index.js.map +1 -1
  26. package/dist/edges/informs.js +1 -3
  27. package/dist/edges/informs.js.map +1 -1
  28. package/dist/edges/refutes.js +1 -3
  29. package/dist/edges/refutes.js.map +1 -1
  30. package/dist/edges/supports.js.map +1 -1
  31. package/dist/edges/utils.d.ts +3 -3
  32. package/dist/edges/utils.js +2 -4
  33. package/dist/edges/utils.js.map +1 -1
  34. package/dist/embeddingTrigger.js +21 -1
  35. package/dist/embeddingTrigger.js.map +1 -1
  36. package/dist/entityBridge.js +1 -1
  37. package/dist/entityBridge.js.map +1 -1
  38. package/dist/{entityLifecycle-BkhRJ-XI.d.ts → entityLifecycle-CvgSK5FV.d.ts} +1 -1
  39. package/dist/entityLifecycle.d.ts +1 -1
  40. package/dist/entityLifecycle.js +134 -47
  41. package/dist/entityLifecycle.js.map +1 -1
  42. package/dist/{epistemicAnswers-DSP1slZ9.d.ts → epistemicAnswers-C5ib4z6_.d.ts} +1 -1
  43. package/dist/epistemicAnswers.d.ts +1 -1
  44. package/dist/epistemicAnswers.js +67 -8
  45. package/dist/epistemicAnswers.js.map +1 -1
  46. package/dist/{epistemicBeliefs-DtFVTp-k.d.ts → epistemicBeliefs-DzKjZAeC.d.ts} +3 -3
  47. package/dist/epistemicBeliefs.d.ts +2 -2
  48. package/dist/epistemicBeliefs.js +289 -114
  49. package/dist/epistemicBeliefs.js.map +1 -1
  50. package/dist/epistemicContracts.d.ts +1 -1
  51. package/dist/epistemicContracts.js +297 -115
  52. package/dist/epistemicContracts.js.map +1 -1
  53. package/dist/{epistemicEdges-DcA8ErUG.d.ts → epistemicEdges-CD5vxmlH.d.ts} +3 -3
  54. package/dist/epistemicEdges.d.ts +1 -1
  55. package/dist/epistemicEdges.js +192 -60
  56. package/dist/epistemicEdges.js.map +1 -1
  57. package/dist/{epistemicEvidence-Bo638XDP.d.ts → epistemicEvidence-xw6UUrwh.d.ts} +1 -1
  58. package/dist/epistemicEvidence.d.ts +1 -1
  59. package/dist/epistemicEvidence.js +163 -49
  60. package/dist/epistemicEvidence.js.map +1 -1
  61. package/dist/{epistemicHelpers-Bd9xbaib.d.ts → epistemicHelpers-DevrYgPN.d.ts} +1 -1
  62. package/dist/epistemicHelpers.d.ts +1 -1
  63. package/dist/{epistemicLinking-CyeLOIzN.d.ts → epistemicLinking-CfE00tHJ.d.ts} +1 -1
  64. package/dist/epistemicLinking.d.ts +1 -1
  65. package/dist/epistemicLinking.js +1 -1
  66. package/dist/{epistemicNodes-BpD6Koud.d.ts → epistemicNodes-NBrPW7fk.d.ts} +2 -2
  67. package/dist/epistemicNodes.d.ts +1 -1
  68. package/dist/epistemicNodes.js +163 -33
  69. package/dist/epistemicNodes.js.map +1 -1
  70. package/dist/{epistemicQuestions-CmEeY6zQ.d.ts → epistemicQuestions-B_nUclrH.d.ts} +1 -1
  71. package/dist/epistemicQuestions.d.ts +1 -1
  72. package/dist/epistemicQuestions.js +311 -62
  73. package/dist/epistemicQuestions.js.map +1 -1
  74. package/dist/{epistemicSources-ZazxHOK1.d.ts → epistemicSources-dlKj58Jp.d.ts} +1 -1
  75. package/dist/epistemicSources.d.ts +1 -1
  76. package/dist/epistemicSources.js +65 -8
  77. package/dist/epistemicSources.js.map +1 -1
  78. package/dist/evaluators/index.js +297 -115
  79. package/dist/evaluators/index.js.map +1 -1
  80. package/dist/evaluators/lintCheckerEvaluator.js.map +1 -1
  81. package/dist/evaluators/sentryCheckerEvaluator.js.map +1 -1
  82. package/dist/evaluators/shared.js +20 -1
  83. package/dist/evaluators/shared.js.map +1 -1
  84. package/dist/evaluators/testRunnerEvaluator.js +20 -1
  85. package/dist/evaluators/testRunnerEvaluator.js.map +1 -1
  86. package/dist/evaluators/tscCheckerEvaluator.js.map +1 -1
  87. package/dist/index.d.ts +20 -20
  88. package/dist/index.js +729 -206
  89. package/dist/index.js.map +1 -1
  90. package/dist/{ontology-matching-Buhu23ss.d.ts → ontology-matching-C6rrz2VP.d.ts} +1 -1
  91. package/dist/ontology-matching.d.ts +1 -1
  92. package/dist/{ontologyApproval-Ba0Jjk1k.d.ts → ontologyApproval-CFYmqKmk.d.ts} +1 -1
  93. package/dist/ontologyApproval.d.ts +1 -1
  94. package/dist/ontologyDefinitions.js +4 -3
  95. package/dist/ontologyDefinitions.js.map +1 -1
  96. package/dist/ontologyHelpers.d.ts +1 -1
  97. package/dist/ontologyHelpers.js +4 -3
  98. package/dist/ontologyHelpers.js.map +1 -1
  99. package/dist/{projectionReconciliation-CxrXYGaB.d.ts → projectionReconciliation-jww2fBI0.d.ts} +1 -1
  100. package/dist/projectionReconciliation.d.ts +1 -1
  101. package/dist/projectionReconciliation.js +14 -20
  102. package/dist/projectionReconciliation.js.map +1 -1
  103. package/dist/{projectionStaleness-CAdpIsaW.d.ts → projectionStaleness-CmdbpjVK.d.ts} +1 -1
  104. package/dist/projectionStaleness.d.ts +1 -1
  105. package/dist/{questionEvidenceLinks-BdQD0TkM.d.ts → questionEvidenceLinks-DFlyPpAj.d.ts} +1 -1
  106. package/dist/questionEvidenceLinks.d.ts +1 -1
  107. package/dist/questionEvidenceLinks.js +144 -45
  108. package/dist/questionEvidenceLinks.js.map +1 -1
  109. package/dist/resolvers.js +86 -37
  110. package/dist/resolvers.js.map +1 -1
  111. package/dist/scopeResolverCompat.js +64 -7
  112. package/dist/scopeResolverCompat.js.map +1 -1
  113. package/dist/{text-matching-CMn2WnVD.d.ts → text-matching-DNg4M5Wd.d.ts} +1 -1
  114. package/dist/text-matching.d.ts +1 -1
  115. package/dist/topicProjectOverlay.js +56 -13
  116. package/dist/topicProjectOverlay.js.map +1 -1
  117. package/dist/topicScope.js +55 -6
  118. package/dist/topicScope.js.map +1 -1
  119. package/dist/workflowBridge.js +55 -6
  120. package/dist/workflowBridge.js.map +1 -1
  121. package/dist/workspaceIsolation.js +55 -6
  122. package/dist/workspaceIsolation.js.map +1 -1
  123. package/package.json +5 -5
@@ -326,4 +326,4 @@ declare namespace epistemicHelpers {
326
326
  export { epistemicHelpers_EDGE_LAYER_RULES as EDGE_LAYER_RULES, type epistemicHelpers_EpistemicLayer as EpistemicLayer, epistemicHelpers_LAYER_TRAVERSAL_RULES as LAYER_TRAVERSAL_RULES, type epistemicHelpers_TraversalMode as TraversalMode, type epistemicHelpers_TraversalOptions as TraversalOptions, epistemicHelpers_canTraverseToLayer as canTraverseToLayer, epistemicHelpers_createEdgeForInsightQuestionLink as createEdgeForInsightQuestionLink, epistemicHelpers_createEpistemicEdge as createEpistemicEdge, epistemicHelpers_createEpistemicNodeForArtifact as createEpistemicNodeForArtifact, epistemicHelpers_createEpistemicNodeForBelief as createEpistemicNodeForBelief, epistemicHelpers_createEpistemicNodeForInsight as createEpistemicNodeForInsight, epistemicHelpers_createEpistemicNodeForQuestion as createEpistemicNodeForQuestion, epistemicHelpers_getDefaultEdgeTypesForMode as getDefaultEdgeTypesForMode, epistemicHelpers_getDefaultMinLayer as getDefaultMinLayer, epistemicHelpers_getLayerDepth as getLayerDepth, epistemicHelpers_getNeo4jLabel as getNeo4jLabel, epistemicHelpers_getNeo4jRelType as getNeo4jRelType, epistemicHelpers_getNodeLayer as getNodeLayer, epistemicHelpers_isDeprecatedEdgeType as isDeprecatedEdgeType, epistemicHelpers_isValidLayerConnection as isValidLayerConnection, epistemicHelpers_normalizeConfidence as normalizeConfidence, epistemicHelpers_shouldContinueTraversal as shouldContinueTraversal, epistemicHelpers_validateEdgeLayers as validateEdgeLayers };
327
327
  }
328
328
 
329
- export { type EpistemicLayer as E, LAYER_TRAVERSAL_RULES as L, type TraversalMode as T, getLayerDepth as a, type TraversalOptions as b, canTraverseToLayer as c, getDefaultMinLayer as d, epistemicHelpers as e, getDefaultEdgeTypesForMode as f, getNodeLayer as g, EDGE_LAYER_RULES as h, isValidLayerConnection as i, createEpistemicNodeForInsight as j, createEpistemicNodeForBelief as k, createEpistemicNodeForQuestion as l, createEpistemicNodeForArtifact as m, normalizeConfidence as n, createEpistemicEdge as o, createEdgeForInsightQuestionLink as p, shouldContinueTraversal as s, validateEdgeLayers as v };
329
+ export { EDGE_LAYER_RULES as E, LAYER_TRAVERSAL_RULES as L, type TraversalMode as T, type EpistemicLayer as a, type TraversalOptions as b, canTraverseToLayer as c, createEdgeForInsightQuestionLink as d, epistemicHelpers as e, createEpistemicEdge as f, createEpistemicNodeForArtifact as g, createEpistemicNodeForBelief as h, createEpistemicNodeForInsight as i, createEpistemicNodeForQuestion as j, getDefaultEdgeTypesForMode as k, getDefaultMinLayer as l, getLayerDepth as m, getNodeLayer as n, isValidLayerConnection as o, normalizeConfidence as p, shouldContinueTraversal as s, validateEdgeLayers as v };
@@ -1,4 +1,4 @@
1
1
  import './convex.js';
2
2
  export { a as getNeo4jLabel, b as getNeo4jRelType, i as isDeprecatedEdgeType } from './graphTypes-CpgIuCdo.js';
3
- export { h as EDGE_LAYER_RULES, E as EpistemicLayer, L as LAYER_TRAVERSAL_RULES, T as TraversalMode, b as TraversalOptions, c as canTraverseToLayer, p as createEdgeForInsightQuestionLink, o as createEpistemicEdge, m as createEpistemicNodeForArtifact, k as createEpistemicNodeForBelief, j as createEpistemicNodeForInsight, l as createEpistemicNodeForQuestion, f as getDefaultEdgeTypesForMode, d as getDefaultMinLayer, a as getLayerDepth, g as getNodeLayer, i as isValidLayerConnection, n as normalizeConfidence, s as shouldContinueTraversal, v as validateEdgeLayers } from './epistemicHelpers-Bd9xbaib.js';
3
+ export { E as EDGE_LAYER_RULES, a as EpistemicLayer, L as LAYER_TRAVERSAL_RULES, T as TraversalMode, b as TraversalOptions, c as canTraverseToLayer, d as createEdgeForInsightQuestionLink, f as createEpistemicEdge, g as createEpistemicNodeForArtifact, h as createEpistemicNodeForBelief, i as createEpistemicNodeForInsight, j as createEpistemicNodeForQuestion, k as getDefaultEdgeTypesForMode, l as getDefaultMinLayer, m as getLayerDepth, n as getNodeLayer, o as isValidLayerConnection, p as normalizeConfidence, s as shouldContinueTraversal, v as validateEdgeLayers } from './epistemicHelpers-DevrYgPN.js';
4
4
  import 'convex/values';
@@ -32,4 +32,4 @@ declare namespace epistemicLinking {
32
32
  export { epistemicLinking_linkBeliefToBelief as linkBeliefToBelief, epistemicLinking_linkEvidenceToEvidence as linkEvidenceToEvidence, epistemicLinking_linkQuestionToQuestion as linkQuestionToQuestion };
33
33
  }
34
34
 
35
- export { linkQuestionToQuestion as a, linkEvidenceToEvidence as b, epistemicLinking as e, linkBeliefToBelief as l };
35
+ export { linkEvidenceToEvidence as a, linkQuestionToQuestion as b, epistemicLinking as e, linkBeliefToBelief as l };
@@ -1 +1 @@
1
- export { l as linkBeliefToBelief, b as linkEvidenceToEvidence, a as linkQuestionToQuestion } from './epistemicLinking-CyeLOIzN.js';
1
+ export { l as linkBeliefToBelief, a as linkEvidenceToEvidence, b as linkQuestionToQuestion } from './epistemicLinking-CfE00tHJ.js';
@@ -1,5 +1,5 @@
1
1
  import { v } from 'convex/values';
2
- import { componentsGeneric, mutationGeneric, anyApi } from 'convex/server';
2
+ import { componentsGeneric, anyApi, mutationGeneric } from 'convex/server';
3
3
  import { checkProjectAccess } from '@lucern/access-control/access';
4
4
  import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
5
5
 
@@ -15,7 +15,7 @@ import * as convex_values from 'convex/values';
15
15
  * L2: Claims, evidence, synthesis - compression boundary
16
16
  * L1: Atomic facts, excerpts, sources - terminal leaves
17
17
  */
18
- declare const epistemicLayerValidator: convex_values.VUnion<"L4" | "L3" | "L2" | "L1" | "ontological" | "organizational", [convex_values.VLiteral<"L4", "required">, convex_values.VLiteral<"L3", "required">, convex_values.VLiteral<"L2", "required">, convex_values.VLiteral<"L1", "required">, convex_values.VLiteral<"ontological", "required">, convex_values.VLiteral<"organizational", "required">], "required", never>;
18
+ declare const epistemicLayerValidator: convex_values.VUnion<"ontological" | "L4" | "L3" | "L2" | "L1" | "organizational", [convex_values.VLiteral<"L4", "required">, convex_values.VLiteral<"L3", "required">, convex_values.VLiteral<"L2", "required">, convex_values.VLiteral<"L1", "required">, convex_values.VLiteral<"ontological", "required">, convex_values.VLiteral<"organizational", "required">], "required", never>;
19
19
  declare const l4NodeTypeValidator: convex_values.VUnion<"decision", [convex_values.VLiteral<"decision", "required">], "required", never>;
20
20
  declare const l3NodeTypeValidator: convex_values.VUnion<"belief" | "question" | "theme" | "deal", [convex_values.VLiteral<"belief", "required">, convex_values.VLiteral<"question", "required">, convex_values.VLiteral<"theme", "required">, convex_values.VLiteral<"deal", "required">], "required", never>;
21
21
  declare const l2NodeTypeValidator: convex_values.VUnion<"evidence" | "synthesis" | "claim", [convex_values.VLiteral<"claim", "required">, convex_values.VLiteral<"evidence", "required">, convex_values.VLiteral<"synthesis", "required">], "required", never>;
@@ -164,4 +164,4 @@ declare namespace epistemicNodes {
164
164
  export { epistemicNodes_archive as archive, epistemicNodes_backfillTopicId as backfillTopicId, epistemicNodes_batchCreate as batchCreate, epistemicNodes_create as create, epistemicNodes_createInternal as createInternal, epistemicNodes_epistemicLayerValidator as epistemicLayerValidator, epistemicNodes_epistemicNodeTypeValidator as epistemicNodeTypeValidator, epistemicNodes_get as get, epistemicNodes_getByContentHash as getByContentHash, epistemicNodes_getByGlobalId as getByGlobalId, epistemicNodes_getByProject as getByProject, epistemicNodes_getByProjectAndType as getByProjectAndType, epistemicNodes_getByProjectAndTypeLite as getByProjectAndTypeLite, epistemicNodes_getByTopic as getByTopic, epistemicNodes_getInternal as getInternal, epistemicNodes_getNodesPendingEdgeSync as getNodesPendingEdgeSync, epistemicNodes_hardDelete as hardDelete, epistemicNodes_l1NodeTypeValidator as l1NodeTypeValidator, epistemicNodes_l2NodeTypeValidator as l2NodeTypeValidator, epistemicNodes_l3NodeTypeValidator as l3NodeTypeValidator, epistemicNodes_l4NodeTypeValidator as l4NodeTypeValidator, epistemicNodes_listAll as listAll, epistemicNodes_nodeTypeValidator as nodeTypeValidator, epistemicNodes_ontologicalNodeTypeValidator as ontologicalNodeTypeValidator, epistemicNodes_organizationalNodeTypeValidator as organizationalNodeTypeValidator, epistemicNodes_search as search, epistemicNodes_sourceTypeValidator as sourceTypeValidator, epistemicNodes_statusValidator as statusValidator, epistemicNodes_supersede as supersede, epistemicNodes_update as update, epistemicNodes_updateSyncStatus as updateSyncStatus, epistemicNodes_verificationStatusValidator as verificationStatusValidator, epistemicNodes_verify as verify };
165
165
  }
166
166
 
167
- export { hardDelete as A, verify as B, batchCreate as C, createInternal as D, getInternal as E, updateSyncStatus as F, backfillTopicId as G, getNodesPendingEdgeSync as H, epistemicLayerValidator as a, l3NodeTypeValidator as b, l2NodeTypeValidator as c, l1NodeTypeValidator as d, epistemicNodes as e, epistemicNodeTypeValidator as f, organizationalNodeTypeValidator as g, statusValidator as h, get as i, getByGlobalId as j, getByContentHash as k, l4NodeTypeValidator as l, getByProjectAndType as m, nodeTypeValidator as n, ontologicalNodeTypeValidator as o, getByProjectAndTypeLite as p, getByProject as q, getByTopic as r, sourceTypeValidator as s, listAll as t, search as u, verificationStatusValidator as v, create as w, update as x, supersede as y, archive as z };
167
+ export { search as A, sourceTypeValidator as B, statusValidator as C, supersede as D, update as E, updateSyncStatus as F, verificationStatusValidator as G, verify as H, archive as a, backfillTopicId as b, batchCreate as c, create as d, epistemicNodes as e, createInternal as f, epistemicLayerValidator as g, epistemicNodeTypeValidator as h, get as i, getByContentHash as j, getByGlobalId as k, getByProject as l, getByProjectAndType as m, getByProjectAndTypeLite as n, getByTopic as o, getInternal as p, getNodesPendingEdgeSync as q, hardDelete as r, l1NodeTypeValidator as s, l2NodeTypeValidator as t, l3NodeTypeValidator as u, l4NodeTypeValidator as v, listAll as w, nodeTypeValidator as x, ontologicalNodeTypeValidator as y, organizationalNodeTypeValidator as z };
@@ -1,2 +1,2 @@
1
1
  import 'convex/values';
2
- export { z as archive, G as backfillTopicId, C as batchCreate, w as create, D as createInternal, a as epistemicLayerValidator, f as epistemicNodeTypeValidator, i as get, k as getByContentHash, j as getByGlobalId, q as getByProject, m as getByProjectAndType, p as getByProjectAndTypeLite, r as getByTopic, E as getInternal, H as getNodesPendingEdgeSync, A as hardDelete, d as l1NodeTypeValidator, c as l2NodeTypeValidator, b as l3NodeTypeValidator, l as l4NodeTypeValidator, t as listAll, n as nodeTypeValidator, o as ontologicalNodeTypeValidator, g as organizationalNodeTypeValidator, u as search, s as sourceTypeValidator, h as statusValidator, y as supersede, x as update, F as updateSyncStatus, v as verificationStatusValidator, B as verify } from './epistemicNodes-BpD6Koud.js';
2
+ export { a as archive, b as backfillTopicId, c as batchCreate, d as create, f as createInternal, g as epistemicLayerValidator, h as epistemicNodeTypeValidator, i as get, j as getByContentHash, k as getByGlobalId, l as getByProject, m as getByProjectAndType, n as getByProjectAndTypeLite, o as getByTopic, p as getInternal, q as getNodesPendingEdgeSync, r as hardDelete, s as l1NodeTypeValidator, t as l2NodeTypeValidator, u as l3NodeTypeValidator, v as l4NodeTypeValidator, w as listAll, x as nodeTypeValidator, y as ontologicalNodeTypeValidator, z as organizationalNodeTypeValidator, A as search, B as sourceTypeValidator, C as statusValidator, D as supersede, E as update, F as updateSyncStatus, G as verificationStatusValidator, H as verify } from './epistemicNodes-NBrPW7fk.js';
@@ -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, anyApi, internalMutationGeneric, internalQueryGeneric } from 'convex/server';
4
+ import { componentsGeneric, anyApi, queryGeneric, mutationGeneric, internalMutationGeneric, internalQueryGeneric } from 'convex/server';
5
5
  import { isNodeType, getLayerForNodeType } from '@lucern/contracts/schema-helpers/spine/tables/epistemicNodes';
6
6
 
7
7
  // src/epistemicNodes.ts
@@ -13,6 +13,18 @@ var internalQuery = internalQueryGeneric;
13
13
  var mutation = mutationGeneric;
14
14
  var query = queryGeneric;
15
15
 
16
+ // src/debug.ts
17
+ function isGraphPrimitiveDebugEnabled() {
18
+ const env = globalThis.process?.env;
19
+ return env?.LUCERN_COMPAT_FALLBACK_DEBUG === "1" || env?.LUCERN_GRAPH_DEBUG === "1";
20
+ }
21
+ function debugGraphPrimitiveFallback(message, context) {
22
+ if (!isGraphPrimitiveDebugEnabled()) {
23
+ return;
24
+ }
25
+ console.debug(message, context ?? {});
26
+ }
27
+
16
28
  // src/graphTypes.ts
17
29
  function getNodeLayer(nodeType) {
18
30
  const L4_TYPES = ["decision"];
@@ -317,7 +329,14 @@ async function findTopicsByScopeAlias(ctx, scopeId) {
317
329
  "by_graph_scope_project",
318
330
  (q) => q.eq(LEGACY_SCOPE_FIELD, scopeId)
319
331
  ).collect();
320
- } catch {
332
+ } catch (error) {
333
+ debugGraphPrimitiveFallback(
334
+ "[topicScope] Failed to resolve scope alias via index",
335
+ {
336
+ error,
337
+ scopeId
338
+ }
339
+ );
321
340
  const topics = await ctx.db.query("topics").collect();
322
341
  return topics.filter((topic) => {
323
342
  const normalizedGlobalId = normalizeScopeValue(topic.globalId);
@@ -334,7 +353,14 @@ async function tryResolveHostTopicById(ctx, topicId) {
334
353
  return await ctx.runQuery(api.topics.get, {
335
354
  id: topicId
336
355
  }) ?? null;
337
- } catch {
356
+ } catch (error) {
357
+ debugGraphPrimitiveFallback(
358
+ "[topicScope] Failed to resolve topic by host query",
359
+ {
360
+ error,
361
+ topicId
362
+ }
363
+ );
338
364
  return null;
339
365
  }
340
366
  }
@@ -346,7 +372,14 @@ async function tryResolveHostTopicByLegacyScope(ctx, legacyScopeId) {
346
372
  return await ctx.runQuery(api.topics.getByLegacyScopeId, {
347
373
  projectId: legacyScopeId
348
374
  }) ?? null;
349
- } catch {
375
+ } catch (error) {
376
+ debugGraphPrimitiveFallback(
377
+ "[topicScope] Failed to resolve topic by legacy scope",
378
+ {
379
+ error,
380
+ legacyScopeId
381
+ }
382
+ );
350
383
  return null;
351
384
  }
352
385
  }
@@ -375,8 +408,17 @@ async function resolveTopicProjectScope(ctx, args) {
375
408
  if (args.topicId) {
376
409
  let topic = null;
377
410
  try {
378
- topic = await ctx.db.get(args.topicId);
379
- } catch {
411
+ topic = await ctx.db.get(
412
+ args.topicId
413
+ );
414
+ } catch (error) {
415
+ debugGraphPrimitiveFallback(
416
+ "[topicScope] Failed to load topic by direct id",
417
+ {
418
+ error,
419
+ topicId: args.topicId
420
+ }
421
+ );
380
422
  }
381
423
  if (!topic) {
382
424
  topic = await tryResolveHostTopicById(ctx, String(args.topicId));
@@ -413,7 +455,14 @@ async function resolveTopicProjectScope(ctx, args) {
413
455
  directTopic = await ctx.db.get(
414
456
  args.projectId
415
457
  );
416
- } catch {
458
+ } catch (error) {
459
+ debugGraphPrimitiveFallback(
460
+ "[topicScope] Failed to load direct project topic",
461
+ {
462
+ error,
463
+ projectId: args.projectId
464
+ }
465
+ );
417
466
  }
418
467
  if (directTopic) {
419
468
  const inherited = await resolveInheritedWorkspaceScope(ctx, directTopic);
@@ -672,7 +721,15 @@ var getByProjectAndType = query({
672
721
  projectId: args.projectId,
673
722
  topicId: args.topicId
674
723
  });
675
- } catch {
724
+ } catch (error) {
725
+ debugGraphPrimitiveFallback(
726
+ "[epistemicNodes] Failed to resolve getByProjectAndType scope",
727
+ {
728
+ error,
729
+ projectId: args.projectId,
730
+ topicId: args.topicId
731
+ }
732
+ );
676
733
  return [];
677
734
  }
678
735
  const pageSize = clampNodeLimit(args.limit);
@@ -709,7 +766,15 @@ var getByProjectAndTypeLite = query({
709
766
  projectId: args.projectId,
710
767
  topicId: args.topicId
711
768
  });
712
- } catch {
769
+ } catch (error) {
770
+ debugGraphPrimitiveFallback(
771
+ "[epistemicNodes] Failed to resolve getByNodeType scope",
772
+ {
773
+ error,
774
+ projectId: args.projectId,
775
+ topicId: args.topicId
776
+ }
777
+ );
713
778
  return [];
714
779
  }
715
780
  const pageSize = clampNodeLimit(args.limit);
@@ -741,6 +806,27 @@ function clampNodeLimit(limit, fallback = DEFAULT_NODE_PAGE_SIZE) {
741
806
  }
742
807
  return Math.max(1, Math.min(Math.floor(limit), MAX_NODE_PAGE_SIZE));
743
808
  }
809
+ function buildNodeStatusSuccessResult() {
810
+ return { success: true };
811
+ }
812
+ function buildNodeArchivedResult() {
813
+ return {
814
+ success: true,
815
+ effectiveStatus: "archived"
816
+ };
817
+ }
818
+ function buildNodeNotFoundResult() {
819
+ const result = {};
820
+ result.success = false;
821
+ result.error = "Node not found";
822
+ return result;
823
+ }
824
+ function buildNodeDeletedResult(deletedEdgeCount) {
825
+ return {
826
+ success: true,
827
+ deletedEdgeCount
828
+ };
829
+ }
744
830
  function dedupeWorkspaceNodes(nodes) {
745
831
  const seen = /* @__PURE__ */ new Set();
746
832
  const deduped = [];
@@ -772,14 +858,13 @@ async function collectScopedNodes(ctx, scope, args) {
772
858
  args.nodeType ? ctx.db.query("epistemicNodes").withIndex(
773
859
  "by_topic_type",
774
860
  (q) => q.eq("topicId", scope.projectId).eq("nodeType", args.nodeType)
775
- ).order("desc").take(args.scanLimit) : ctx.db.query("epistemicNodes").withIndex(
776
- "by_topic",
777
- (q) => q.eq("topicId", scope.projectId)
778
- ).order("desc").take(args.scanLimit)
861
+ ).order("desc").take(args.scanLimit) : ctx.db.query("epistemicNodes").withIndex("by_topic", (q) => q.eq("topicId", scope.projectId)).order("desc").take(args.scanLimit)
779
862
  );
780
863
  }
781
864
  const combined = dedupeWorkspaceNodes((await Promise.all(queries)).flat());
782
- return combined.filter((node) => nodeMatchesWorkspaceReasoningScope(node, scope));
865
+ return combined.filter(
866
+ (node) => nodeMatchesWorkspaceReasoningScope(node, scope)
867
+ );
783
868
  }
784
869
  var getByProject = query({
785
870
  args: {
@@ -801,7 +886,15 @@ var getByProject = query({
801
886
  projectId: args.projectId,
802
887
  topicId: args.topicId
803
888
  });
804
- } catch {
889
+ } catch (error) {
890
+ debugGraphPrimitiveFallback(
891
+ "[epistemicNodes] Failed to resolve list scope",
892
+ {
893
+ error,
894
+ projectId: args.projectId,
895
+ topicId: args.topicId
896
+ }
897
+ );
805
898
  return [];
806
899
  }
807
900
  if (args.userId) {
@@ -855,7 +948,15 @@ var search = query({
855
948
  projectId: args.projectId,
856
949
  topicId: args.topicId
857
950
  });
858
- } catch {
951
+ } catch (error) {
952
+ debugGraphPrimitiveFallback(
953
+ "[epistemicNodes] Failed to resolve search scope",
954
+ {
955
+ error,
956
+ projectId: args.projectId,
957
+ topicId: args.topicId
958
+ }
959
+ );
859
960
  return [];
860
961
  }
861
962
  }
@@ -1082,7 +1183,7 @@ var update = mutation({
1082
1183
  nodeId,
1083
1184
  operation: "upsert"
1084
1185
  });
1085
- return { success: true };
1186
+ return buildNodeStatusSuccessResult();
1086
1187
  }
1087
1188
  });
1088
1189
  var supersede = mutation({
@@ -1204,7 +1305,7 @@ var archive = mutation({
1204
1305
  projectId: node.projectId
1205
1306
  });
1206
1307
  }
1207
- return { success: true, effectiveStatus: "archived" };
1308
+ return buildNodeArchivedResult();
1208
1309
  }
1209
1310
  });
1210
1311
  var hardDelete = internalMutation({
@@ -1218,7 +1319,7 @@ var hardDelete = internalMutation({
1218
1319
  handler: async (ctx, args) => {
1219
1320
  const node = await ctx.db.get(args.nodeId);
1220
1321
  if (!node) {
1221
- return { success: false, error: "Node not found" };
1322
+ return buildNodeNotFoundResult();
1222
1323
  }
1223
1324
  assertBeliefNodeHardDeleteAllowed({
1224
1325
  node,
@@ -1254,10 +1355,7 @@ var hardDelete = internalMutation({
1254
1355
  await ctx.db.delete(edge._id);
1255
1356
  }
1256
1357
  await ctx.db.delete(args.nodeId);
1257
- return {
1258
- success: true,
1259
- deletedEdgeCount: uniqueEdges.size
1260
- };
1358
+ return buildNodeDeletedResult(uniqueEdges.size);
1261
1359
  }
1262
1360
  });
1263
1361
  var verify = mutation({
@@ -1304,7 +1402,7 @@ var verify = mutation({
1304
1402
  projectId: node.projectId,
1305
1403
  triggeringAction: "epistemicNodes.verify"
1306
1404
  });
1307
- return { success: true };
1405
+ return buildNodeStatusSuccessResult();
1308
1406
  }
1309
1407
  });
1310
1408
  var batchCreate = mutation({
@@ -1342,6 +1440,27 @@ var batchCreate = mutation({
1342
1440
  },
1343
1441
  returns: permissiveReturn,
1344
1442
  handler: async (ctx, args) => {
1443
+ const resolveNodeScope = async (node) => {
1444
+ if (!(node.topicId || node.projectId)) {
1445
+ return void 0;
1446
+ }
1447
+ try {
1448
+ return await resolveTopicProjectScope(ctx, {
1449
+ topicId: node.topicId,
1450
+ projectId: node.projectId
1451
+ });
1452
+ } catch (error) {
1453
+ debugGraphPrimitiveFallback(
1454
+ "[epistemicNodes] Failed to resolve scope for batch create node",
1455
+ {
1456
+ error,
1457
+ topicId: node.topicId,
1458
+ projectId: node.projectId
1459
+ }
1460
+ );
1461
+ return void 0;
1462
+ }
1463
+ };
1345
1464
  const now = Date.now();
1346
1465
  const results = [];
1347
1466
  for (const node of args.nodes) {
@@ -1350,10 +1469,7 @@ var batchCreate = mutation({
1350
1469
  mutationName: "epistemicNodes.batchCreate"
1351
1470
  });
1352
1471
  const epistemicLayer = getNodeLayer(node.nodeType);
1353
- const resolvedScope = node.topicId || node.projectId ? await resolveTopicProjectScope(ctx, {
1354
- topicId: node.topicId,
1355
- projectId: node.projectId
1356
- }).catch(() => void 0) : void 0;
1472
+ const resolvedScope = await resolveNodeScope(node);
1357
1473
  const nodeId = await ctx.db.insert("epistemicNodes", {
1358
1474
  ...node,
1359
1475
  epistemicLayer,
@@ -1435,10 +1551,24 @@ var createInternal = internalMutation({
1435
1551
  returns: permissiveReturn,
1436
1552
  handler: async (ctx, args) => {
1437
1553
  const now = Date.now();
1438
- const resolvedScope = args.topicId || args.projectId ? await resolveTopicProjectScope(ctx, {
1439
- topicId: args.topicId,
1440
- projectId: args.projectId
1441
- }).catch(() => void 0) : void 0;
1554
+ const resolvedScope = args.topicId || args.projectId ? await (async () => {
1555
+ try {
1556
+ return await resolveTopicProjectScope(ctx, {
1557
+ topicId: args.topicId,
1558
+ projectId: args.projectId
1559
+ });
1560
+ } catch (error) {
1561
+ debugGraphPrimitiveFallback(
1562
+ "[epistemicNodes] Failed to resolve create scope",
1563
+ {
1564
+ error,
1565
+ topicId: args.topicId,
1566
+ projectId: args.projectId
1567
+ }
1568
+ );
1569
+ return void 0;
1570
+ }
1571
+ })() : void 0;
1442
1572
  const contentHash = args.contentHash || `${args.nodeType}:${args.canonicalText}`.slice(0, 64);
1443
1573
  const epistemicLayer = args.epistemicLayer || getNodeLayer(args.nodeType);
1444
1574
  const nodeId = await ctx.db.insert("epistemicNodes", {
@@ -1505,7 +1635,7 @@ var updateSyncStatus = internalMutation({
1505
1635
  updates.syncError = args.syncError;
1506
1636
  }
1507
1637
  await ctx.db.patch(args.nodeId, updates);
1508
- return { success: true };
1638
+ return buildNodeStatusSuccessResult();
1509
1639
  }
1510
1640
  });
1511
1641
  var backfillTopicId = internalMutation({