@lucern/graph-primitives 0.3.0-alpha.17 → 0.3.0-alpha.3

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-DZ6tkLYq.d.ts → beliefDecay-Q_26RTc-.d.ts} +1 -1
  2. package/dist/beliefDecay.d.ts +1 -1
  3. package/dist/beliefDecay.js +47 -158
  4. package/dist/beliefDecay.js.map +1 -1
  5. package/dist/{beliefEvidenceLinks-CWOXxxJg.d.ts → beliefEvidenceLinks-42FlR48t.d.ts} +1 -1
  6. package/dist/beliefEvidenceLinks.d.ts +1 -1
  7. package/dist/beliefEvidenceLinks.js +45 -141
  8. package/dist/beliefEvidenceLinks.js.map +1 -1
  9. package/dist/{beliefLifecycle-y8WLXqQj.d.ts → beliefLifecycle-C-AehZgF.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 +3 -1
  13. package/dist/confidencePropagationDispatch.js.map +1 -1
  14. package/dist/{contradictions-51VLsESq.d.ts → contradictions-Hdwl7zid.d.ts} +1 -1
  15. package/dist/contradictions.d.ts +1 -1
  16. package/dist/contradictions.js +8 -67
  17. package/dist/contradictions.js.map +1 -1
  18. package/dist/edges/contradicts.js.map +1 -1
  19. package/dist/edges/dependsOn.js.map +1 -1
  20. package/dist/edges/elaborates.js.map +1 -1
  21. package/dist/edges/index.js +3 -1
  22. package/dist/edges/index.js.map +1 -1
  23. package/dist/edges/informs.js +3 -1
  24. package/dist/edges/informs.js.map +1 -1
  25. package/dist/edges/refutes.js +3 -1
  26. package/dist/edges/refutes.js.map +1 -1
  27. package/dist/edges/supports.js.map +1 -1
  28. package/dist/edges/utils.d.ts +3 -3
  29. package/dist/edges/utils.js +4 -2
  30. package/dist/edges/utils.js.map +1 -1
  31. package/dist/embeddingTrigger.js +1 -21
  32. package/dist/embeddingTrigger.js.map +1 -1
  33. package/dist/entityBridge.js +1 -1
  34. package/dist/entityBridge.js.map +1 -1
  35. package/dist/{entityLifecycle-CvgSK5FV.d.ts → entityLifecycle-BkhRJ-XI.d.ts} +1 -1
  36. package/dist/entityLifecycle.d.ts +1 -1
  37. package/dist/entityLifecycle.js +47 -134
  38. package/dist/entityLifecycle.js.map +1 -1
  39. package/dist/{epistemicAnswers-C5ib4z6_.d.ts → epistemicAnswers-DSP1slZ9.d.ts} +1 -1
  40. package/dist/epistemicAnswers.d.ts +1 -1
  41. package/dist/epistemicAnswers.js +8 -67
  42. package/dist/epistemicAnswers.js.map +1 -1
  43. package/dist/{epistemicBeliefs-DzKjZAeC.d.ts → epistemicBeliefs-DtFVTp-k.d.ts} +3 -3
  44. package/dist/epistemicBeliefs.d.ts +2 -2
  45. package/dist/epistemicBeliefs.js +114 -289
  46. package/dist/epistemicBeliefs.js.map +1 -1
  47. package/dist/epistemicContracts.d.ts +1 -1
  48. package/dist/epistemicContracts.js +115 -297
  49. package/dist/epistemicContracts.js.map +1 -1
  50. package/dist/{epistemicEdges-CvlKnEyy.d.ts → epistemicEdges-DcA8ErUG.d.ts} +1 -1
  51. package/dist/epistemicEdges.d.ts +1 -1
  52. package/dist/epistemicEdges.js +60 -192
  53. package/dist/epistemicEdges.js.map +1 -1
  54. package/dist/{epistemicEvidence-xw6UUrwh.d.ts → epistemicEvidence-Bo638XDP.d.ts} +1 -1
  55. package/dist/epistemicEvidence.d.ts +1 -1
  56. package/dist/epistemicEvidence.js +49 -163
  57. package/dist/epistemicEvidence.js.map +1 -1
  58. package/dist/{epistemicHelpers-DevrYgPN.d.ts → epistemicHelpers-Bd9xbaib.d.ts} +1 -1
  59. package/dist/epistemicHelpers.d.ts +1 -1
  60. package/dist/{epistemicLinking-CfE00tHJ.d.ts → epistemicLinking-CyeLOIzN.d.ts} +1 -1
  61. package/dist/epistemicLinking.d.ts +1 -1
  62. package/dist/epistemicLinking.js +1 -1
  63. package/dist/{epistemicNodes-DjSUfvyD.d.ts → epistemicNodes-BpD6Koud.d.ts} +1 -1
  64. package/dist/epistemicNodes.d.ts +1 -1
  65. package/dist/epistemicNodes.js +33 -163
  66. package/dist/epistemicNodes.js.map +1 -1
  67. package/dist/{epistemicQuestions-B_nUclrH.d.ts → epistemicQuestions-CmEeY6zQ.d.ts} +1 -1
  68. package/dist/epistemicQuestions.d.ts +1 -1
  69. package/dist/epistemicQuestions.js +62 -311
  70. package/dist/epistemicQuestions.js.map +1 -1
  71. package/dist/{epistemicSources-dlKj58Jp.d.ts → epistemicSources-ZazxHOK1.d.ts} +1 -1
  72. package/dist/epistemicSources.d.ts +1 -1
  73. package/dist/epistemicSources.js +8 -65
  74. package/dist/epistemicSources.js.map +1 -1
  75. package/dist/evaluators/index.js +115 -297
  76. package/dist/evaluators/index.js.map +1 -1
  77. package/dist/evaluators/lintCheckerEvaluator.js.map +1 -1
  78. package/dist/evaluators/sentryCheckerEvaluator.js.map +1 -1
  79. package/dist/evaluators/shared.js +1 -20
  80. package/dist/evaluators/shared.js.map +1 -1
  81. package/dist/evaluators/testRunnerEvaluator.js +1 -20
  82. package/dist/evaluators/testRunnerEvaluator.js.map +1 -1
  83. package/dist/evaluators/tscCheckerEvaluator.js.map +1 -1
  84. package/dist/index.d.ts +20 -20
  85. package/dist/index.js +206 -729
  86. package/dist/index.js.map +1 -1
  87. package/dist/{ontology-matching-C6rrz2VP.d.ts → ontology-matching-Buhu23ss.d.ts} +1 -1
  88. package/dist/ontology-matching.d.ts +1 -1
  89. package/dist/{ontologyApproval-CFYmqKmk.d.ts → ontologyApproval-Ba0Jjk1k.d.ts} +1 -1
  90. package/dist/ontologyApproval.d.ts +1 -1
  91. package/dist/ontologyDefinitions.js +3 -4
  92. package/dist/ontologyDefinitions.js.map +1 -1
  93. package/dist/ontologyHelpers.d.ts +1 -1
  94. package/dist/ontologyHelpers.js +3 -4
  95. package/dist/ontologyHelpers.js.map +1 -1
  96. package/dist/{projectionReconciliation-jww2fBI0.d.ts → projectionReconciliation-CxrXYGaB.d.ts} +1 -1
  97. package/dist/projectionReconciliation.d.ts +1 -1
  98. package/dist/projectionReconciliation.js +20 -14
  99. package/dist/projectionReconciliation.js.map +1 -1
  100. package/dist/{projectionStaleness-CmdbpjVK.d.ts → projectionStaleness-CAdpIsaW.d.ts} +1 -1
  101. package/dist/projectionStaleness.d.ts +1 -1
  102. package/dist/{questionEvidenceLinks-DFlyPpAj.d.ts → questionEvidenceLinks-BdQD0TkM.d.ts} +1 -1
  103. package/dist/questionEvidenceLinks.d.ts +1 -1
  104. package/dist/questionEvidenceLinks.js +45 -144
  105. package/dist/questionEvidenceLinks.js.map +1 -1
  106. package/dist/resolvers.js +37 -86
  107. package/dist/resolvers.js.map +1 -1
  108. package/dist/scopeResolverCompat.js +7 -64
  109. package/dist/scopeResolverCompat.js.map +1 -1
  110. package/dist/{text-matching-DNg4M5Wd.d.ts → text-matching-CMn2WnVD.d.ts} +1 -1
  111. package/dist/text-matching.d.ts +1 -1
  112. package/dist/topicProjectOverlay.js +13 -56
  113. package/dist/topicProjectOverlay.js.map +1 -1
  114. package/dist/topicScope.js +6 -55
  115. package/dist/topicScope.js.map +1 -1
  116. package/dist/workflowBridge.js +6 -55
  117. package/dist/workflowBridge.js.map +1 -1
  118. package/dist/workspaceIsolation.js +6 -55
  119. package/dist/workspaceIsolation.js.map +1 -1
  120. package/package.json +5 -5
  121. package/dist/debug.d.ts +0 -4
  122. package/dist/debug.js +0 -34
  123. package/dist/debug.js.map +0 -1
@@ -2,7 +2,7 @@ import { v } from 'convex/values';
2
2
  import { checkScopeAccess, checkProjectAccess } from '@lucern/access-control/access';
3
3
  import { getCurrentUserId } from '@lucern/access-control/auth';
4
4
  import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
5
- import { componentsGeneric, anyApi, internalMutationGeneric, mutationGeneric, queryGeneric, internalQueryGeneric } from 'convex/server';
5
+ import { componentsGeneric, internalMutationGeneric, mutationGeneric, anyApi, queryGeneric, internalQueryGeneric } from 'convex/server';
6
6
  import { normalizeTupleContradictionPolicy, mkOpinion, createInheritedContractRecord, confidenceFromSL, conditionalDeduction, project, dampedDependencyCascade, hasProjectedOpinionChanged, detectTupleContradiction, evaluateTupleContradictionTransition, readOpinionFromRecord, deriveContractModulationPlan, deriveContractStatus, trustDiscount, applyNegativeSupport, cumulativeFusion, applyNegativeEvidence, parseEvidentialEvaluatorConfig, compareMetricValue, buildEvidentialRationale, parseMetricCheckerConfig, getEvaluatorInputRecord, pickFiniteNumber, resolveComparisonResult, buildComparisonRationale, parseReferenceCheckCounterConfig, parseTemporalDeadlineConfig, parseMarketIndexComparatorConfig } from '@lucern/confidence';
7
7
  import { canAudienceClassAccess, normalizeAudienceKey, classFromAudienceKey } from '@lucern/access-control/audience';
8
8
  import { listAudienceRegistryRows } from '@lucern/access-control/audienceRegistry';
@@ -169,7 +169,9 @@ function propagateNegativeSupportWithMetadata(sourceOpinion, targetOpinion, edge
169
169
  readEdgeMetadata(edge)
170
170
  );
171
171
  }
172
- var propagateNegativeInform = applyNegativeEvidence;
172
+ function propagateNegativeInform(sourceOpinion, targetOpinion, edgeWeight) {
173
+ return applyNegativeEvidence(sourceOpinion, targetOpinion, edgeWeight);
174
+ }
173
175
 
174
176
  // src/edges/contradicts.ts
175
177
  var contradictsPropagationSpec = {
@@ -392,20 +394,6 @@ function getTraversalDirections(direction) {
392
394
  }
393
395
  return ["outgoing", "incoming"];
394
396
  }
395
-
396
- // src/debug.ts
397
- function isGraphPrimitiveDebugEnabled() {
398
- const env = globalThis.process?.env;
399
- return env?.LUCERN_COMPAT_FALLBACK_DEBUG === "1" || env?.LUCERN_GRAPH_DEBUG === "1";
400
- }
401
- function debugGraphPrimitiveFallback(message, context) {
402
- if (!isGraphPrimitiveDebugEnabled()) {
403
- return;
404
- }
405
- console.debug(message, context ?? {});
406
- }
407
-
408
- // src/topicScope.ts
409
397
  var LEGACY_SCOPE_FIELD = "graphScopeProjectId";
410
398
  function asMappedProjectId(topic) {
411
399
  if (!topic) {
@@ -447,14 +435,7 @@ async function findTopicsByScopeAlias(ctx, scopeId) {
447
435
  "by_graph_scope_project",
448
436
  (q) => q.eq(LEGACY_SCOPE_FIELD, scopeId)
449
437
  ).collect();
450
- } catch (error) {
451
- debugGraphPrimitiveFallback(
452
- "[topicScope] Failed to resolve scope alias via index",
453
- {
454
- error,
455
- scopeId
456
- }
457
- );
438
+ } catch {
458
439
  const topics = await ctx.db.query("topics").collect();
459
440
  return topics.filter((topic) => {
460
441
  const normalizedGlobalId = normalizeScopeValue(topic.globalId);
@@ -471,14 +452,7 @@ async function tryResolveHostTopicById(ctx, topicId) {
471
452
  return await ctx.runQuery(api.topics.get, {
472
453
  id: topicId
473
454
  }) ?? null;
474
- } catch (error) {
475
- debugGraphPrimitiveFallback(
476
- "[topicScope] Failed to resolve topic by host query",
477
- {
478
- error,
479
- topicId
480
- }
481
- );
455
+ } catch {
482
456
  return null;
483
457
  }
484
458
  }
@@ -490,14 +464,7 @@ async function tryResolveHostTopicByLegacyScope(ctx, legacyScopeId) {
490
464
  return await ctx.runQuery(api.topics.getByLegacyScopeId, {
491
465
  projectId: legacyScopeId
492
466
  }) ?? null;
493
- } catch (error) {
494
- debugGraphPrimitiveFallback(
495
- "[topicScope] Failed to resolve topic by legacy scope",
496
- {
497
- error,
498
- legacyScopeId
499
- }
500
- );
467
+ } catch {
501
468
  return null;
502
469
  }
503
470
  }
@@ -526,17 +493,8 @@ async function resolveTopicProjectScope(ctx, args) {
526
493
  if (args.topicId) {
527
494
  let topic = null;
528
495
  try {
529
- topic = await ctx.db.get(
530
- args.topicId
531
- );
532
- } catch (error) {
533
- debugGraphPrimitiveFallback(
534
- "[topicScope] Failed to load topic by direct id",
535
- {
536
- error,
537
- topicId: args.topicId
538
- }
539
- );
496
+ topic = await ctx.db.get(args.topicId);
497
+ } catch {
540
498
  }
541
499
  if (!topic) {
542
500
  topic = await tryResolveHostTopicById(ctx, String(args.topicId));
@@ -573,14 +531,7 @@ async function resolveTopicProjectScope(ctx, args) {
573
531
  directTopic = await ctx.db.get(
574
532
  args.projectId
575
533
  );
576
- } catch (error) {
577
- debugGraphPrimitiveFallback(
578
- "[topicScope] Failed to load direct project topic",
579
- {
580
- error,
581
- projectId: args.projectId
582
- }
583
- );
534
+ } catch {
584
535
  }
585
536
  if (directTopic) {
586
537
  const inherited = await resolveInheritedWorkspaceScope(ctx, directTopic);
@@ -924,15 +875,7 @@ async function scheduleEmbeddingGeneration(args) {
924
875
  confidence: args.confidence
925
876
  }
926
877
  );
927
- } catch (error) {
928
- debugGraphPrimitiveFallback(
929
- "[embeddingTrigger] Failed to schedule embedding generation",
930
- {
931
- error,
932
- nodeId: String(args.nodeId),
933
- nodeType: args.nodeType
934
- }
935
- );
878
+ } catch {
936
879
  }
937
880
  }
938
881
 
@@ -1054,37 +997,19 @@ function isProjectLikeTopic(topic) {
1054
997
  return topic.type === "theme" || topic.type === "thematic" || topic.type === "deal" || topic.type === "monitoring" || readLegacyProjectId(topic) !== void 0 || readNonEmptyString(metadata.projectType) !== void 0;
1055
998
  }
1056
999
  function isMissingLucernChildComponentError(error) {
1057
- const message = getErrorMessage(error);
1000
+ const message = error instanceof Error ? error.message : String(error);
1058
1001
  return message.includes(
1059
1002
  'Child component ComponentName(Identifier("lucern")) not found'
1060
1003
  ) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
1061
1004
  }
1062
- function getErrorMessage(error) {
1063
- if (error instanceof Error) {
1064
- return error.message;
1065
- }
1066
- if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
1067
- return error.message;
1068
- }
1069
- return "unknown error";
1070
- }
1071
1005
  async function resolveTopicDoc(ctx, scopeId) {
1072
1006
  if (ctx?.db && typeof ctx.db.get === "function") {
1073
1007
  try {
1074
- const directTopic = await ctx.db.get(
1075
- scopeId
1076
- );
1008
+ const directTopic = await ctx.db.get(scopeId);
1077
1009
  if (directTopic) {
1078
1010
  return directTopic;
1079
1011
  }
1080
- } catch (error) {
1081
- debugGraphPrimitiveFallback(
1082
- "[topicProjectOverlay] Failed to resolve topic by direct ID",
1083
- {
1084
- error,
1085
- scopeId
1086
- }
1087
- );
1012
+ } catch {
1088
1013
  }
1089
1014
  }
1090
1015
  if (typeof ctx.runQuery !== "function") {
@@ -1097,14 +1022,7 @@ async function resolveTopicDoc(ctx, scopeId) {
1097
1022
  if (topic?.name !== void 0 && topic?.type !== void 0) {
1098
1023
  return topic;
1099
1024
  }
1100
- } catch (error) {
1101
- debugGraphPrimitiveFallback(
1102
- "[topicProjectOverlay] Failed to resolve topic by ID query",
1103
- {
1104
- error,
1105
- scopeId
1106
- }
1107
- );
1025
+ } catch {
1108
1026
  }
1109
1027
  try {
1110
1028
  const topic = await ctx.runQuery(api.topics.getByLegacyScopeId, {
@@ -1113,11 +1031,7 @@ async function resolveTopicDoc(ctx, scopeId) {
1113
1031
  if (topic?.name !== void 0 && topic?.type !== void 0) {
1114
1032
  return topic;
1115
1033
  }
1116
- } catch (error) {
1117
- debugGraphPrimitiveFallback(
1118
- "[topicProjectOverlay] Failed to resolve topic by legacy scope ID",
1119
- { error, scopeId }
1120
- );
1034
+ } catch {
1121
1035
  }
1122
1036
  return null;
1123
1037
  }
@@ -1171,11 +1085,7 @@ async function listTopicProjectOverlays(ctx, options = {}) {
1171
1085
  if (ctx?.db?.query && typeof ctx.db.query === "function") {
1172
1086
  try {
1173
1087
  allTopics = await ctx.db.query("topics").collect();
1174
- } catch (error) {
1175
- debugGraphPrimitiveFallback(
1176
- "[topicProjectOverlay] Failed to read topics table; falling back to API",
1177
- { error }
1178
- );
1088
+ } catch {
1179
1089
  allTopics = [];
1180
1090
  }
1181
1091
  }
@@ -1270,28 +1180,19 @@ async function patchTopicProjectOverlay(ctx, scopeId, value) {
1270
1180
  "Cannot patch topic without component adapter (ctx.runMutation unavailable)"
1271
1181
  );
1272
1182
  }
1273
- return materializeTopicProjectOverlay({
1274
- ...topic,
1275
- ...patch,
1276
- metadata: nextMetadata
1277
- });
1183
+ return materializeTopicProjectOverlay(
1184
+ {
1185
+ ...topic,
1186
+ ...patch,
1187
+ metadata: nextMetadata
1188
+ }
1189
+ );
1278
1190
  }
1279
1191
 
1280
1192
  // src/resolvers.ts
1281
1193
  function isMissingLucernChildComponentError2(error) {
1282
- const message = getErrorMessage2(error);
1283
- return message.includes(
1284
- 'Child component ComponentName(Identifier("lucern")) not found'
1285
- ) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
1286
- }
1287
- function getErrorMessage2(error) {
1288
- if (error instanceof Error) {
1289
- return error.message;
1290
- }
1291
- if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
1292
- return error.message;
1293
- }
1294
- return "unknown error";
1194
+ const message = error instanceof Error ? error.message : String(error);
1195
+ return message.includes('Child component ComponentName(Identifier("lucern")) not found') || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
1295
1196
  }
1296
1197
  function isAdvisoryTopicPatch(value) {
1297
1198
  const advisoryKeys = /* @__PURE__ */ new Set(["lastActivityAt", "updatedAt"]);
@@ -1305,27 +1206,32 @@ async function patchProjectWithTolerance(ctx, projectId, value) {
1305
1206
  if (!isAdvisoryTopicPatch(value) || !isMissingLucernChildComponentError2(error)) {
1306
1207
  throw error;
1307
1208
  }
1308
- console.warn(
1309
- "[lucern graph-primitives] Non-fatal advisory topic patch failure",
1310
- {
1311
- projectId,
1312
- keys: Object.keys(value),
1313
- error: getErrorMessage2(error)
1314
- }
1315
- );
1209
+ console.warn("[lucern graph-primitives] Non-fatal advisory topic patch failure", {
1210
+ projectId,
1211
+ keys: Object.keys(value),
1212
+ error: error instanceof Error ? error.message : error
1213
+ });
1316
1214
  }
1317
1215
  }
1318
1216
  function defaultResolvers() {
1319
1217
  return {
1320
- getProject: (ctx, projectId) => resolveTopicProjectOverlay(ctx, projectId, {
1321
- idMode: "legacy",
1322
- projectLikeOnly: false
1323
- }),
1324
- patchProject: (ctx, projectId, value) => patchProjectWithTolerance(ctx, projectId, value),
1325
- listTopics: (ctx) => listTopicProjectOverlays(ctx, {
1326
- idMode: "legacy"
1327
- }),
1328
- getFinalArtifact: (ctx, artifactId) => ctx.db.get(artifactId)
1218
+ async getProject(ctx, projectId) {
1219
+ return await resolveTopicProjectOverlay(ctx, projectId, {
1220
+ idMode: "legacy",
1221
+ projectLikeOnly: false
1222
+ });
1223
+ },
1224
+ async patchProject(ctx, projectId, value) {
1225
+ await patchProjectWithTolerance(ctx, projectId, value);
1226
+ },
1227
+ async listTopics(ctx) {
1228
+ return await listTopicProjectOverlays(ctx, {
1229
+ idMode: "legacy"
1230
+ });
1231
+ },
1232
+ async getFinalArtifact(ctx, artifactId) {
1233
+ return await ctx.db.get(artifactId);
1234
+ }
1329
1235
  };
1330
1236
  }
1331
1237
  var resolverOverrides = {};
@@ -1401,15 +1307,6 @@ function buildBeliefConfidenceRow(args) {
1401
1307
  ...args.triggeringWorktreeId ? { triggeringWorktreeId: args.triggeringWorktreeId } : {}
1402
1308
  };
1403
1309
  }
1404
- function buildBeliefStatusSuccessResult() {
1405
- return { success: true };
1406
- }
1407
- function buildBeliefEvidenceNotFoundResult() {
1408
- const result = {};
1409
- result.success = false;
1410
- result.message = "Evidence node not found";
1411
- return result;
1412
- }
1413
1310
  function deriveSyntheticBackfillOpinion(source) {
1414
1311
  const belief = readFiniteNumber(source.opinion_b) ?? readFiniteNumber(source.belief);
1415
1312
  const disbelief = readFiniteNumber(source.opinion_d) ?? readFiniteNumber(source.disbelief);
@@ -1418,13 +1315,7 @@ function deriveSyntheticBackfillOpinion(source) {
1418
1315
  if (belief !== void 0 || disbelief !== void 0 || uncertainty !== void 0 || baseRate !== void 0) {
1419
1316
  try {
1420
1317
  return readOpinionFromRecord(source);
1421
- } catch (error) {
1422
- debugGraphPrimitiveFallback(
1423
- "[epistemicBeliefs] Failed to decode legacy belief opinion",
1424
- {
1425
- error
1426
- }
1427
- );
1318
+ } catch {
1428
1319
  return mkOpinion(0, 0, 1, 0.5);
1429
1320
  }
1430
1321
  }
@@ -1452,14 +1343,7 @@ function readBeliefOpinionSnapshot(node, metadata) {
1452
1343
  opinion_u: node.opinion_u,
1453
1344
  opinion_a: node.opinion_a
1454
1345
  });
1455
- } catch (error) {
1456
- debugGraphPrimitiveFallback(
1457
- "[epistemicBeliefs] Failed to read belief opinion snapshot",
1458
- {
1459
- error,
1460
- beliefId: node._id
1461
- }
1462
- );
1346
+ } catch {
1463
1347
  return mkOpinion(0, 0, 1, 0.5);
1464
1348
  }
1465
1349
  }
@@ -1552,15 +1436,7 @@ async function resolveBeliefScopeOrNull(ctx, args) {
1552
1436
  projectId: args.projectId ?? void 0,
1553
1437
  topicId: args.topicId ?? void 0
1554
1438
  });
1555
- } catch (error) {
1556
- debugGraphPrimitiveFallback(
1557
- "[epistemicBeliefs] Failed to resolve belief scope",
1558
- {
1559
- error,
1560
- projectId: args.projectId,
1561
- topicId: args.topicId
1562
- }
1563
- );
1439
+ } catch {
1564
1440
  return null;
1565
1441
  }
1566
1442
  }
@@ -1660,13 +1536,7 @@ async function getActiveConfidencePolicy(ctx) {
1660
1536
  activeConfig?.tupleContradictionPolicy
1661
1537
  )
1662
1538
  };
1663
- } catch (error) {
1664
- debugGraphPrimitiveFallback(
1665
- "[epistemicBeliefs] Failed to load active confidence policy",
1666
- {
1667
- error
1668
- }
1669
- );
1539
+ } catch {
1670
1540
  return DEFAULT_CONFIDENCE_POLICY;
1671
1541
  }
1672
1542
  }
@@ -1703,11 +1573,7 @@ async function applyBeliefConfidenceChange(ctx, args) {
1703
1573
  details: { nodeId: args.nodeId }
1704
1574
  });
1705
1575
  }
1706
- await requireProjectWriteAccess(
1707
- ctx,
1708
- node.projectId,
1709
- args.authenticatedUserId
1710
- );
1576
+ await requireProjectWriteAccess(ctx, node.projectId, args.authenticatedUserId);
1711
1577
  const existingMetadata = node.metadata || {};
1712
1578
  const currentBeliefStatus = resolveBeliefStatus(node, existingMetadata);
1713
1579
  const confidencePolicy = await getActiveConfidencePolicy(ctx);
@@ -1751,29 +1617,29 @@ async function applyBeliefConfidenceChange(ctx, args) {
1751
1617
  opinion: nextOpinion,
1752
1618
  policy: tupleTransition.policy
1753
1619
  });
1754
- const newBeliefStatus = promoteBeliefStatusAfterScoring(currentBeliefStatus, {
1755
- confidence: derivedConfidence,
1756
- predictionMeta,
1757
- metadata: existingMetadata
1758
- });
1620
+ const newBeliefStatus = promoteBeliefStatusAfterScoring(
1621
+ currentBeliefStatus,
1622
+ {
1623
+ confidence: derivedConfidence,
1624
+ predictionMeta,
1625
+ metadata: existingMetadata
1626
+ }
1627
+ );
1759
1628
  let tupleContradictionId;
1760
1629
  if (tupleTransition.crossedIntoTupleContradiction) {
1761
- tupleContradictionId = await ctx.runMutation(
1762
- "contradictions:create",
1763
- {
1764
- projectId: node.projectId,
1765
- topicId: node.topicId,
1766
- beliefId: args.nodeId,
1767
- beliefBId: args.nodeId,
1768
- supportingInsightIds: [],
1769
- contradictingInsightIds: [],
1770
- severity: deriveTupleContradictionSeverity(node),
1771
- source: "tuple_space",
1772
- detectionMethod: "agent",
1773
- description: tupleContradictionDescription,
1774
- createdBy: args.authenticatedUserId
1775
- }
1776
- );
1630
+ tupleContradictionId = await ctx.runMutation("contradictions:create", {
1631
+ projectId: node.projectId,
1632
+ topicId: node.topicId,
1633
+ beliefId: args.nodeId,
1634
+ beliefBId: args.nodeId,
1635
+ supportingInsightIds: [],
1636
+ contradictingInsightIds: [],
1637
+ severity: deriveTupleContradictionSeverity(node),
1638
+ source: "tuple_space",
1639
+ detectionMethod: "agent",
1640
+ description: tupleContradictionDescription,
1641
+ createdBy: args.authenticatedUserId
1642
+ });
1777
1643
  }
1778
1644
  await ctx.db.patch(args.nodeId, {
1779
1645
  confidence: derivedConfidence,
@@ -1797,10 +1663,7 @@ async function applyBeliefConfidenceChange(ctx, args) {
1797
1663
  });
1798
1664
  if (isFirstScoring) {
1799
1665
  const nodeTopicId = node.topicId;
1800
- const themeNodes = await ctx.db.query("epistemicNodes").withIndex(
1801
- "by_topic",
1802
- (q) => q.eq("topicId", nodeTopicId || node.projectId)
1803
- ).filter((q) => q.eq(q.field("nodeType"), "theme")).collect();
1666
+ const themeNodes = await ctx.db.query("epistemicNodes").withIndex("by_topic", (q) => q.eq("topicId", nodeTopicId || node.projectId)).filter((q) => q.eq(q.field("nodeType"), "theme")).collect();
1804
1667
  for (const theme of themeNodes) {
1805
1668
  if (theme.globalId && node.globalId) {
1806
1669
  await ctx.scheduler.runAfter(0, internal.neo4jEdgeAPI.createEdge, {
@@ -2398,15 +2261,7 @@ query({
2398
2261
  projectId: args.projectId,
2399
2262
  topicId: args.topicId
2400
2263
  });
2401
- } catch (error) {
2402
- debugGraphPrimitiveFallback(
2403
- "[epistemicBeliefs] Failed to resolve project scope",
2404
- {
2405
- error,
2406
- projectId: args.projectId,
2407
- topicId: args.topicId
2408
- }
2409
- );
2264
+ } catch {
2410
2265
  return [];
2411
2266
  }
2412
2267
  if (args.userId) {
@@ -2450,9 +2305,7 @@ query({
2450
2305
  handler: async (ctx, args) => {
2451
2306
  const pageSize = clampBeliefLimit(args.limit);
2452
2307
  const scanLimit = Math.min(pageSize * 3, MAX_PROJECT_BELIEF_LIMIT);
2453
- const scope = await resolveTopicProjectScope(ctx, {
2454
- topicId: args.topicId
2455
- });
2308
+ const scope = await resolveTopicProjectScope(ctx, { topicId: args.topicId });
2456
2309
  const query2 = ctx.db.query("epistemicNodes").withIndex(
2457
2310
  "by_topic_type",
2458
2311
  (q) => q.eq("topicId", args.topicId).eq("nodeType", "belief")
@@ -2678,18 +2531,16 @@ mutation({
2678
2531
  rationale: v.optional(v.string()),
2679
2532
  userId: v.string(),
2680
2533
  // SL operator provenance (optional — defaults to manual_assessment)
2681
- slOperator: v.optional(
2682
- v.union(
2683
- v.literal("cumulative_fusion"),
2684
- v.literal("averaging_fusion"),
2685
- v.literal("trust_discount"),
2686
- v.literal("conditional_deduction"),
2687
- v.literal("dependency_cascade"),
2688
- v.literal("negation"),
2689
- v.literal("constraint_fusion"),
2690
- v.literal("manual_assessment")
2691
- )
2692
- ),
2534
+ slOperator: v.optional(v.union(
2535
+ v.literal("cumulative_fusion"),
2536
+ v.literal("averaging_fusion"),
2537
+ v.literal("trust_discount"),
2538
+ v.literal("conditional_deduction"),
2539
+ v.literal("dependency_cascade"),
2540
+ v.literal("negation"),
2541
+ v.literal("constraint_fusion"),
2542
+ v.literal("manual_assessment")
2543
+ )),
2693
2544
  triggeringEvidenceId: v.optional(v.id("epistemicNodes")),
2694
2545
  triggeringWorktreeId: v.optional(v.string())
2695
2546
  },
@@ -2920,7 +2771,10 @@ query({
2920
2771
  if (!node || node.nodeType !== "belief") {
2921
2772
  return [];
2922
2773
  }
2923
- return await ctx.db.query("beliefConfidence").withIndex("by_beliefId_time", (q) => q.eq("beliefId", args.nodeId)).order("asc").collect();
2774
+ return await ctx.db.query("beliefConfidence").withIndex(
2775
+ "by_beliefId_time",
2776
+ (q) => q.eq("beliefId", args.nodeId)
2777
+ ).order("asc").collect();
2924
2778
  }
2925
2779
  });
2926
2780
  query({
@@ -3224,7 +3078,7 @@ mutation({
3224
3078
  const now = Date.now();
3225
3079
  const evidenceNode = await ctx.db.get(args.insightId);
3226
3080
  if (!evidenceNode || evidenceNode.nodeType !== "evidence") {
3227
- return buildBeliefEvidenceNotFoundResult();
3081
+ return { success: false, message: "Evidence node not found" };
3228
3082
  }
3229
3083
  if (!evidenceNode.projectId) {
3230
3084
  throw new Error("Evidence has no project scope");
@@ -3265,7 +3119,7 @@ mutation({
3265
3119
  projectId: evidenceNode.projectId
3266
3120
  });
3267
3121
  }
3268
- return buildBeliefStatusSuccessResult();
3122
+ return { success: true };
3269
3123
  }
3270
3124
  });
3271
3125
  query({
@@ -3377,7 +3231,7 @@ mutation({
3377
3231
  changedAt: now,
3378
3232
  projectId: edge.projectId
3379
3233
  });
3380
- return buildBeliefStatusSuccessResult();
3234
+ return { success: true };
3381
3235
  }
3382
3236
  });
3383
3237
  mutation({
@@ -3506,23 +3360,13 @@ mutation({
3506
3360
  changedAt: now,
3507
3361
  projectId: node.projectId
3508
3362
  });
3509
- const result = {};
3510
- result.beliefId = update.beliefId;
3511
- result.nodeId = node._id;
3512
- result.success = true;
3513
- results.push(result);
3514
- } catch (error) {
3515
- debugGraphPrimitiveFallback(
3516
- "[epistemicBeliefs] Failed to update belief criticality",
3517
- {
3518
- error,
3519
- beliefId: update.beliefId
3520
- }
3521
- );
3522
- const result = {};
3523
- result.beliefId = update.beliefId;
3524
- result.success = false;
3525
- results.push(result);
3363
+ results.push({
3364
+ beliefId: update.beliefId,
3365
+ nodeId: node._id,
3366
+ success: true
3367
+ });
3368
+ } catch {
3369
+ results.push({ beliefId: update.beliefId, success: false });
3526
3370
  }
3527
3371
  }
3528
3372
  return { results, updatedCount: results.filter((r) => r.success).length };
@@ -3637,15 +3481,7 @@ query({
3637
3481
  projectId: args.projectId,
3638
3482
  topicId: args.topicId
3639
3483
  });
3640
- } catch (error) {
3641
- debugGraphPrimitiveFallback(
3642
- "[epistemicBeliefs] Failed to resolve criticality scope",
3643
- {
3644
- error,
3645
- projectId: args.projectId,
3646
- topicId: args.topicId
3647
- }
3648
- );
3484
+ } catch {
3649
3485
  return [];
3650
3486
  }
3651
3487
  const nodes = await ctx.db.query("epistemicNodes").withIndex(
@@ -3766,9 +3602,7 @@ internalQuery({
3766
3602
  const pageSize = clampBeliefLimit(args.limit, 500);
3767
3603
  const scanLimit = Math.min(pageSize * 3, MAX_PROJECT_BELIEF_LIMIT);
3768
3604
  const audienceMode = args.audienceMode ?? "internal";
3769
- const scope = await resolveTopicProjectScope(ctx, {
3770
- topicId: args.topicId
3771
- });
3605
+ const scope = await resolveTopicProjectScope(ctx, { topicId: args.topicId });
3772
3606
  const registryRows = await listAudienceRegistryRows(ctx, {
3773
3607
  tenantId: scope.tenantId,
3774
3608
  workspaceId: scope.workspaceId
@@ -4113,9 +3947,7 @@ internalMutation({
4113
3947
  skippedHasHistory++;
4114
3948
  continue;
4115
3949
  }
4116
- const opinion = deriveSyntheticBackfillOpinion(
4117
- node
4118
- );
3950
+ const opinion = deriveSyntheticBackfillOpinion(node);
4119
3951
  await ctx.db.insert(
4120
3952
  "beliefConfidence",
4121
3953
  buildBeliefConfidenceRow({
@@ -4421,13 +4253,7 @@ query({
4421
4253
  return {
4422
4254
  positions: {},
4423
4255
  hasClusters: false,
4424
- counts: {
4425
- raw: 0,
4426
- hypothesis: 0,
4427
- conditional: 0,
4428
- unprocessed: 0,
4429
- total: 0
4430
- }
4256
+ counts: { raw: 0, hypothesis: 0, conditional: 0, unprocessed: 0, total: 0 }
4431
4257
  };
4432
4258
  }
4433
4259
  const allBeliefNodes = await getBeliefNodesForScope(ctx, scope);
@@ -4489,8 +4315,14 @@ mutation({
4489
4315
  let connectedReassigned = 0;
4490
4316
  const alreadyReassigned = /* @__PURE__ */ new Set();
4491
4317
  for (const beliefId of movedBeliefIds) {
4492
- const outbound = await ctx.db.query("epistemicEdges").withIndex("by_from", (q) => q.eq("fromNodeId", beliefId)).collect();
4493
- const inbound = await ctx.db.query("epistemicEdges").withIndex("by_to", (q) => q.eq("toNodeId", beliefId)).collect();
4318
+ const outbound = await ctx.db.query("epistemicEdges").withIndex(
4319
+ "by_from",
4320
+ (q) => q.eq("fromNodeId", beliefId)
4321
+ ).collect();
4322
+ const inbound = await ctx.db.query("epistemicEdges").withIndex(
4323
+ "by_to",
4324
+ (q) => q.eq("toNodeId", beliefId)
4325
+ ).collect();
4494
4326
  const connectedNodeIds = /* @__PURE__ */ new Set();
4495
4327
  for (const edge of outbound) {
4496
4328
  if (edge.toNodeId) connectedNodeIds.add(String(edge.toNodeId));
@@ -4513,14 +4345,7 @@ mutation({
4513
4345
  alreadyReassigned.add(connectedId);
4514
4346
  connectedReassigned++;
4515
4347
  }
4516
- } catch (error) {
4517
- debugGraphPrimitiveFallback(
4518
- "[epistemicBeliefs] Failed to reassign connected node",
4519
- {
4520
- error,
4521
- connectedId
4522
- }
4523
- );
4348
+ } catch {
4524
4349
  }
4525
4350
  }
4526
4351
  }
@@ -5818,14 +5643,7 @@ function parseJsonCandidate(value) {
5818
5643
  }
5819
5644
  try {
5820
5645
  return JSON.parse(value);
5821
- } catch (error) {
5822
- debugGraphPrimitiveFallback(
5823
- "[evaluators/shared] Failed to parse JSON candidate",
5824
- {
5825
- error,
5826
- valueType: typeof value
5827
- }
5828
- );
5646
+ } catch {
5829
5647
  return null;
5830
5648
  }
5831
5649
  }