@lucern/graph-primitives 0.3.0-alpha.6 → 0.3.0-alpha.8

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-CvlKnEyy.d.ts} +1 -1
  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-DjSUfvyD.d.ts} +1 -1
  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
@@ -69,4 +69,4 @@ declare namespace beliefDecay {
69
69
  export { beliefDecay_DEADLINE_URGENCY as DEADLINE_URGENCY, beliefDecay_DECAY_TIERS as DECAY_TIERS, beliefDecay_bayesianUpdate as bayesianUpdate, beliefDecay_computeBaseDecay as computeBaseDecay, beliefDecay_computeDeadlineUrgency as computeDeadlineUrgency, beliefDecay_computeEffectiveDecay as computeEffectiveDecay, beliefDecay_getBeliefDecayInfo as getBeliefDecayInfo, beliefDecay_getGlobalBeliefHealth as getGlobalBeliefHealth, beliefDecay_getRescoringSchedule as getRescoringSchedule, beliefDecay_identifyBeliefsNeedingRescore as identifyBeliefsNeedingRescore };
70
70
  }
71
71
 
72
- export { getBeliefDecayInfo as a, beliefDecay as b, getGlobalBeliefHealth as g, identifyBeliefsNeedingRescore as i };
72
+ export { getGlobalBeliefHealth as a, beliefDecay as b, getBeliefDecayInfo as g, identifyBeliefsNeedingRescore as i };
@@ -1,2 +1,2 @@
1
1
  export { DEADLINE_URGENCY, DECAY_TIERS, bayesianUpdate, computeBaseDecay, computeDeadlineUrgency, computeEffectiveDecay, getRescoringSchedule } from '@lucern/confidence';
2
- export { a as getBeliefDecayInfo, g as getGlobalBeliefHealth, i as identifyBeliefsNeedingRescore } from './beliefDecay-Q_26RTc-.js';
2
+ export { g as getBeliefDecayInfo, a as getGlobalBeliefHealth, i as identifyBeliefsNeedingRescore } from './beliefDecay-DZ6tkLYq.js';
@@ -10,6 +10,18 @@ var api = anyApi;
10
10
  componentsGeneric();
11
11
  var query = queryGeneric;
12
12
 
13
+ // src/debug.ts
14
+ function isGraphPrimitiveDebugEnabled() {
15
+ const env = globalThis.process?.env;
16
+ return env?.LUCERN_COMPAT_FALLBACK_DEBUG === "1" || env?.LUCERN_GRAPH_DEBUG === "1";
17
+ }
18
+ function debugGraphPrimitiveFallback(message, context) {
19
+ if (!isGraphPrimitiveDebugEnabled()) {
20
+ return;
21
+ }
22
+ console.debug(message, context ?? {});
23
+ }
24
+
13
25
  // src/topicProjectOverlay.ts
14
26
  var LEGACY_SCOPE_FIELD = "graphScopeProjectId";
15
27
  function readNonEmptyString(value) {
@@ -55,19 +67,37 @@ function isProjectLikeTopic(topic) {
55
67
  return topic.type === "theme" || topic.type === "thematic" || topic.type === "deal" || topic.type === "monitoring" || readLegacyProjectId(topic) !== void 0 || readNonEmptyString(metadata.projectType) !== void 0;
56
68
  }
57
69
  function isMissingLucernChildComponentError(error) {
58
- const message = error instanceof Error ? error.message : String(error);
70
+ const message = getErrorMessage(error);
59
71
  return message.includes(
60
72
  'Child component ComponentName(Identifier("lucern")) not found'
61
73
  ) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
62
74
  }
75
+ function getErrorMessage(error) {
76
+ if (error instanceof Error) {
77
+ return error.message;
78
+ }
79
+ if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
80
+ return error.message;
81
+ }
82
+ return "unknown error";
83
+ }
63
84
  async function resolveTopicDoc(ctx, scopeId) {
64
85
  if (ctx?.db && typeof ctx.db.get === "function") {
65
86
  try {
66
- const directTopic = await ctx.db.get(scopeId);
87
+ const directTopic = await ctx.db.get(
88
+ scopeId
89
+ );
67
90
  if (directTopic) {
68
91
  return directTopic;
69
92
  }
70
- } catch {
93
+ } catch (error) {
94
+ debugGraphPrimitiveFallback(
95
+ "[topicProjectOverlay] Failed to resolve topic by direct ID",
96
+ {
97
+ error,
98
+ scopeId
99
+ }
100
+ );
71
101
  }
72
102
  }
73
103
  if (typeof ctx.runQuery !== "function") {
@@ -80,7 +110,14 @@ async function resolveTopicDoc(ctx, scopeId) {
80
110
  if (topic?.name !== void 0 && topic?.type !== void 0) {
81
111
  return topic;
82
112
  }
83
- } catch {
113
+ } catch (error) {
114
+ debugGraphPrimitiveFallback(
115
+ "[topicProjectOverlay] Failed to resolve topic by ID query",
116
+ {
117
+ error,
118
+ scopeId
119
+ }
120
+ );
84
121
  }
85
122
  try {
86
123
  const topic = await ctx.runQuery(api.topics.getByLegacyScopeId, {
@@ -89,7 +126,11 @@ async function resolveTopicDoc(ctx, scopeId) {
89
126
  if (topic?.name !== void 0 && topic?.type !== void 0) {
90
127
  return topic;
91
128
  }
92
- } catch {
129
+ } catch (error) {
130
+ debugGraphPrimitiveFallback(
131
+ "[topicProjectOverlay] Failed to resolve topic by legacy scope ID",
132
+ { error, scopeId }
133
+ );
93
134
  }
94
135
  return null;
95
136
  }
@@ -143,7 +184,11 @@ async function listTopicProjectOverlays(ctx, options = {}) {
143
184
  if (ctx?.db?.query && typeof ctx.db.query === "function") {
144
185
  try {
145
186
  allTopics = await ctx.db.query("topics").collect();
146
- } catch {
187
+ } catch (error) {
188
+ debugGraphPrimitiveFallback(
189
+ "[topicProjectOverlay] Failed to read topics table; falling back to API",
190
+ { error }
191
+ );
147
192
  allTopics = [];
148
193
  }
149
194
  }
@@ -238,19 +283,28 @@ async function patchTopicProjectOverlay(ctx, scopeId, value) {
238
283
  "Cannot patch topic without component adapter (ctx.runMutation unavailable)"
239
284
  );
240
285
  }
241
- return materializeTopicProjectOverlay(
242
- {
243
- ...topic,
244
- ...patch,
245
- metadata: nextMetadata
246
- }
247
- );
286
+ return materializeTopicProjectOverlay({
287
+ ...topic,
288
+ ...patch,
289
+ metadata: nextMetadata
290
+ });
248
291
  }
249
292
 
250
293
  // src/resolvers.ts
251
294
  function isMissingLucernChildComponentError2(error) {
252
- const message = error instanceof Error ? error.message : String(error);
253
- return message.includes('Child component ComponentName(Identifier("lucern")) not found') || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
295
+ const message = getErrorMessage2(error);
296
+ return message.includes(
297
+ 'Child component ComponentName(Identifier("lucern")) not found'
298
+ ) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
299
+ }
300
+ function getErrorMessage2(error) {
301
+ if (error instanceof Error) {
302
+ return error.message;
303
+ }
304
+ if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
305
+ return error.message;
306
+ }
307
+ return "unknown error";
254
308
  }
255
309
  function isAdvisoryTopicPatch(value) {
256
310
  const advisoryKeys = /* @__PURE__ */ new Set(["lastActivityAt", "updatedAt"]);
@@ -264,32 +318,27 @@ async function patchProjectWithTolerance(ctx, projectId, value) {
264
318
  if (!isAdvisoryTopicPatch(value) || !isMissingLucernChildComponentError2(error)) {
265
319
  throw error;
266
320
  }
267
- console.warn("[lucern graph-primitives] Non-fatal advisory topic patch failure", {
268
- projectId,
269
- keys: Object.keys(value),
270
- error: error instanceof Error ? error.message : error
271
- });
321
+ console.warn(
322
+ "[lucern graph-primitives] Non-fatal advisory topic patch failure",
323
+ {
324
+ projectId,
325
+ keys: Object.keys(value),
326
+ error: getErrorMessage2(error)
327
+ }
328
+ );
272
329
  }
273
330
  }
274
331
  function defaultResolvers() {
275
332
  return {
276
- async getProject(ctx, projectId) {
277
- return await resolveTopicProjectOverlay(ctx, projectId, {
278
- idMode: "legacy",
279
- projectLikeOnly: false
280
- });
281
- },
282
- async patchProject(ctx, projectId, value) {
283
- await patchProjectWithTolerance(ctx, projectId, value);
284
- },
285
- async listTopics(ctx) {
286
- return await listTopicProjectOverlays(ctx, {
287
- idMode: "legacy"
288
- });
289
- },
290
- async getFinalArtifact(ctx, artifactId) {
291
- return await ctx.db.get(artifactId);
292
- }
333
+ getProject: (ctx, projectId) => resolveTopicProjectOverlay(ctx, projectId, {
334
+ idMode: "legacy",
335
+ projectLikeOnly: false
336
+ }),
337
+ patchProject: (ctx, projectId, value) => patchProjectWithTolerance(ctx, projectId, value),
338
+ listTopics: (ctx) => listTopicProjectOverlays(ctx, {
339
+ idMode: "legacy"
340
+ }),
341
+ getFinalArtifact: (ctx, artifactId) => ctx.db.get(artifactId)
293
342
  };
294
343
  }
295
344
  var resolverOverrides = {};
@@ -340,7 +389,14 @@ async function findTopicsByScopeAlias(ctx, scopeId) {
340
389
  "by_graph_scope_project",
341
390
  (q) => q.eq(LEGACY_SCOPE_FIELD2, scopeId)
342
391
  ).collect();
343
- } catch {
392
+ } catch (error) {
393
+ debugGraphPrimitiveFallback(
394
+ "[topicScope] Failed to resolve scope alias via index",
395
+ {
396
+ error,
397
+ scopeId
398
+ }
399
+ );
344
400
  const topics = await ctx.db.query("topics").collect();
345
401
  return topics.filter((topic) => {
346
402
  const normalizedGlobalId = normalizeScopeValue(topic.globalId);
@@ -357,7 +413,14 @@ async function tryResolveHostTopicById(ctx, topicId) {
357
413
  return await ctx.runQuery(api.topics.get, {
358
414
  id: topicId
359
415
  }) ?? null;
360
- } catch {
416
+ } catch (error) {
417
+ debugGraphPrimitiveFallback(
418
+ "[topicScope] Failed to resolve topic by host query",
419
+ {
420
+ error,
421
+ topicId
422
+ }
423
+ );
361
424
  return null;
362
425
  }
363
426
  }
@@ -369,7 +432,14 @@ async function tryResolveHostTopicByLegacyScope(ctx, legacyScopeId) {
369
432
  return await ctx.runQuery(api.topics.getByLegacyScopeId, {
370
433
  projectId: legacyScopeId
371
434
  }) ?? null;
372
- } catch {
435
+ } catch (error) {
436
+ debugGraphPrimitiveFallback(
437
+ "[topicScope] Failed to resolve topic by legacy scope",
438
+ {
439
+ error,
440
+ legacyScopeId
441
+ }
442
+ );
373
443
  return null;
374
444
  }
375
445
  }
@@ -398,8 +468,17 @@ async function resolveTopicProjectScope(ctx, args) {
398
468
  if (args.topicId) {
399
469
  let topic = null;
400
470
  try {
401
- topic = await ctx.db.get(args.topicId);
402
- } catch {
471
+ topic = await ctx.db.get(
472
+ args.topicId
473
+ );
474
+ } catch (error) {
475
+ debugGraphPrimitiveFallback(
476
+ "[topicScope] Failed to load topic by direct id",
477
+ {
478
+ error,
479
+ topicId: args.topicId
480
+ }
481
+ );
403
482
  }
404
483
  if (!topic) {
405
484
  topic = await tryResolveHostTopicById(ctx, String(args.topicId));
@@ -436,7 +515,14 @@ async function resolveTopicProjectScope(ctx, args) {
436
515
  directTopic = await ctx.db.get(
437
516
  args.projectId
438
517
  );
439
- } catch {
518
+ } catch (error) {
519
+ debugGraphPrimitiveFallback(
520
+ "[topicScope] Failed to load direct project topic",
521
+ {
522
+ error,
523
+ projectId: args.projectId
524
+ }
525
+ );
440
526
  }
441
527
  if (directTopic) {
442
528
  const inherited = await resolveInheritedWorkspaceScope(ctx, directTopic);
@@ -504,7 +590,20 @@ var identifyBeliefsNeedingRescore = query({
504
590
  returns: permissiveReturn,
505
591
  handler: async (ctx, args) => {
506
592
  const { maxResults = 20, minPriority = "medium" } = args;
507
- const scope = await resolveTopicProjectScope(ctx, args).catch(() => null);
593
+ let scope;
594
+ try {
595
+ scope = await resolveTopicProjectScope(ctx, args);
596
+ } catch (error) {
597
+ debugGraphPrimitiveFallback(
598
+ "[beliefDecay] Failed to resolve scope for identify beliefs",
599
+ {
600
+ error,
601
+ projectId: args.projectId,
602
+ topicId: args.topicId
603
+ }
604
+ );
605
+ scope = null;
606
+ }
508
607
  if (!scope) {
509
608
  return [];
510
609
  }
@@ -607,9 +706,21 @@ var getGlobalBeliefHealth = query({
607
706
  );
608
707
  const allResults = [];
609
708
  for (const project of accessibleProjects.slice(0, 20)) {
610
- const scope = await resolveTopicProjectScope(ctx, {
611
- projectId: String(project._id)
612
- }).catch(() => null);
709
+ let scope;
710
+ try {
711
+ scope = await resolveTopicProjectScope(ctx, {
712
+ projectId: String(project._id)
713
+ });
714
+ } catch (error) {
715
+ debugGraphPrimitiveFallback(
716
+ "[beliefDecay] Failed to resolve project scope in health query",
717
+ {
718
+ error,
719
+ projectId: String(project._id)
720
+ }
721
+ );
722
+ continue;
723
+ }
613
724
  if (!scope) {
614
725
  continue;
615
726
  }