@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
@@ -1,5 +1,5 @@
1
1
  import { v } from 'convex/values';
2
- import { componentsGeneric, mutationGeneric, queryGeneric, anyApi } from 'convex/server';
2
+ import { componentsGeneric, anyApi, mutationGeneric, queryGeneric } from 'convex/server';
3
3
  import { checkProjectAccess } from '@lucern/access-control/access';
4
4
  import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
5
5
 
@@ -41,6 +41,20 @@ componentsGeneric();
41
41
  var internal = anyApi;
42
42
  var mutation = mutationGeneric;
43
43
  var query = queryGeneric;
44
+
45
+ // src/debug.ts
46
+ function isGraphPrimitiveDebugEnabled() {
47
+ const env = globalThis.process?.env;
48
+ return env?.LUCERN_COMPAT_FALLBACK_DEBUG === "1" || env?.LUCERN_GRAPH_DEBUG === "1";
49
+ }
50
+ function debugGraphPrimitiveFallback(message, context) {
51
+ if (!isGraphPrimitiveDebugEnabled()) {
52
+ return;
53
+ }
54
+ console.debug(message, context ?? {});
55
+ }
56
+
57
+ // src/topicScope.ts
44
58
  var LEGACY_SCOPE_FIELD = "graphScopeProjectId";
45
59
  function asMappedProjectId(topic) {
46
60
  if (!topic) {
@@ -82,7 +96,14 @@ async function findTopicsByScopeAlias(ctx, scopeId) {
82
96
  "by_graph_scope_project",
83
97
  (q) => q.eq(LEGACY_SCOPE_FIELD, scopeId)
84
98
  ).collect();
85
- } catch {
99
+ } catch (error) {
100
+ debugGraphPrimitiveFallback(
101
+ "[topicScope] Failed to resolve scope alias via index",
102
+ {
103
+ error,
104
+ scopeId
105
+ }
106
+ );
86
107
  const topics = await ctx.db.query("topics").collect();
87
108
  return topics.filter((topic) => {
88
109
  const normalizedGlobalId = normalizeScopeValue(topic.globalId);
@@ -99,7 +120,14 @@ async function tryResolveHostTopicById(ctx, topicId) {
99
120
  return await ctx.runQuery(api.topics.get, {
100
121
  id: topicId
101
122
  }) ?? null;
102
- } catch {
123
+ } catch (error) {
124
+ debugGraphPrimitiveFallback(
125
+ "[topicScope] Failed to resolve topic by host query",
126
+ {
127
+ error,
128
+ topicId
129
+ }
130
+ );
103
131
  return null;
104
132
  }
105
133
  }
@@ -111,7 +139,14 @@ async function tryResolveHostTopicByLegacyScope(ctx, legacyScopeId) {
111
139
  return await ctx.runQuery(api.topics.getByLegacyScopeId, {
112
140
  projectId: legacyScopeId
113
141
  }) ?? null;
114
- } catch {
142
+ } catch (error) {
143
+ debugGraphPrimitiveFallback(
144
+ "[topicScope] Failed to resolve topic by legacy scope",
145
+ {
146
+ error,
147
+ legacyScopeId
148
+ }
149
+ );
115
150
  return null;
116
151
  }
117
152
  }
@@ -140,8 +175,17 @@ async function resolveTopicProjectScope(ctx, args) {
140
175
  if (args.topicId) {
141
176
  let topic = null;
142
177
  try {
143
- topic = await ctx.db.get(args.topicId);
144
- } catch {
178
+ topic = await ctx.db.get(
179
+ args.topicId
180
+ );
181
+ } catch (error) {
182
+ debugGraphPrimitiveFallback(
183
+ "[topicScope] Failed to load topic by direct id",
184
+ {
185
+ error,
186
+ topicId: args.topicId
187
+ }
188
+ );
145
189
  }
146
190
  if (!topic) {
147
191
  topic = await tryResolveHostTopicById(ctx, String(args.topicId));
@@ -178,7 +222,14 @@ async function resolveTopicProjectScope(ctx, args) {
178
222
  directTopic = await ctx.db.get(
179
223
  args.projectId
180
224
  );
181
- } catch {
225
+ } catch (error) {
226
+ debugGraphPrimitiveFallback(
227
+ "[topicScope] Failed to load direct project topic",
228
+ {
229
+ error,
230
+ projectId: args.projectId
231
+ }
232
+ );
182
233
  }
183
234
  if (directTopic) {
184
235
  const inherited = await resolveInheritedWorkspaceScope(ctx, directTopic);
@@ -248,7 +299,15 @@ async function resolveScope(ctx, args) {
248
299
  topicId,
249
300
  projectId
250
301
  });
251
- } catch {
302
+ } catch (error) {
303
+ debugGraphPrimitiveFallback(
304
+ "[scopeResolverCompat] Failed to resolve scope",
305
+ {
306
+ error,
307
+ topicId,
308
+ projectId
309
+ }
310
+ );
252
311
  return null;
253
312
  }
254
313
  }
@@ -317,19 +376,37 @@ function isProjectLikeTopic(topic) {
317
376
  return topic.type === "theme" || topic.type === "thematic" || topic.type === "deal" || topic.type === "monitoring" || readLegacyProjectId(topic) !== void 0 || readNonEmptyString(metadata.projectType) !== void 0;
318
377
  }
319
378
  function isMissingLucernChildComponentError(error) {
320
- const message = error instanceof Error ? error.message : String(error);
379
+ const message = getErrorMessage(error);
321
380
  return message.includes(
322
381
  'Child component ComponentName(Identifier("lucern")) not found'
323
382
  ) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
324
383
  }
384
+ function getErrorMessage(error) {
385
+ if (error instanceof Error) {
386
+ return error.message;
387
+ }
388
+ if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
389
+ return error.message;
390
+ }
391
+ return "unknown error";
392
+ }
325
393
  async function resolveTopicDoc(ctx, scopeId) {
326
394
  if (ctx?.db && typeof ctx.db.get === "function") {
327
395
  try {
328
- const directTopic = await ctx.db.get(scopeId);
396
+ const directTopic = await ctx.db.get(
397
+ scopeId
398
+ );
329
399
  if (directTopic) {
330
400
  return directTopic;
331
401
  }
332
- } catch {
402
+ } catch (error) {
403
+ debugGraphPrimitiveFallback(
404
+ "[topicProjectOverlay] Failed to resolve topic by direct ID",
405
+ {
406
+ error,
407
+ scopeId
408
+ }
409
+ );
333
410
  }
334
411
  }
335
412
  if (typeof ctx.runQuery !== "function") {
@@ -342,7 +419,14 @@ async function resolveTopicDoc(ctx, scopeId) {
342
419
  if (topic?.name !== void 0 && topic?.type !== void 0) {
343
420
  return topic;
344
421
  }
345
- } catch {
422
+ } catch (error) {
423
+ debugGraphPrimitiveFallback(
424
+ "[topicProjectOverlay] Failed to resolve topic by ID query",
425
+ {
426
+ error,
427
+ scopeId
428
+ }
429
+ );
346
430
  }
347
431
  try {
348
432
  const topic = await ctx.runQuery(api.topics.getByLegacyScopeId, {
@@ -351,7 +435,11 @@ async function resolveTopicDoc(ctx, scopeId) {
351
435
  if (topic?.name !== void 0 && topic?.type !== void 0) {
352
436
  return topic;
353
437
  }
354
- } catch {
438
+ } catch (error) {
439
+ debugGraphPrimitiveFallback(
440
+ "[topicProjectOverlay] Failed to resolve topic by legacy scope ID",
441
+ { error, scopeId }
442
+ );
355
443
  }
356
444
  return null;
357
445
  }
@@ -405,7 +493,11 @@ async function listTopicProjectOverlays(ctx, options = {}) {
405
493
  if (ctx?.db?.query && typeof ctx.db.query === "function") {
406
494
  try {
407
495
  allTopics = await ctx.db.query("topics").collect();
408
- } catch {
496
+ } catch (error) {
497
+ debugGraphPrimitiveFallback(
498
+ "[topicProjectOverlay] Failed to read topics table; falling back to API",
499
+ { error }
500
+ );
409
501
  allTopics = [];
410
502
  }
411
503
  }
@@ -500,19 +592,28 @@ async function patchTopicProjectOverlay(ctx, scopeId, value) {
500
592
  "Cannot patch topic without component adapter (ctx.runMutation unavailable)"
501
593
  );
502
594
  }
503
- return materializeTopicProjectOverlay(
504
- {
505
- ...topic,
506
- ...patch,
507
- metadata: nextMetadata
508
- }
509
- );
595
+ return materializeTopicProjectOverlay({
596
+ ...topic,
597
+ ...patch,
598
+ metadata: nextMetadata
599
+ });
510
600
  }
511
601
 
512
602
  // src/resolvers.ts
513
603
  function isMissingLucernChildComponentError2(error) {
514
- const message = error instanceof Error ? error.message : String(error);
515
- return message.includes('Child component ComponentName(Identifier("lucern")) not found') || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
604
+ const message = getErrorMessage2(error);
605
+ return message.includes(
606
+ 'Child component ComponentName(Identifier("lucern")) not found'
607
+ ) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
608
+ }
609
+ function getErrorMessage2(error) {
610
+ if (error instanceof Error) {
611
+ return error.message;
612
+ }
613
+ if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
614
+ return error.message;
615
+ }
616
+ return "unknown error";
516
617
  }
517
618
  function isAdvisoryTopicPatch(value) {
518
619
  const advisoryKeys = /* @__PURE__ */ new Set(["lastActivityAt", "updatedAt"]);
@@ -526,32 +627,27 @@ async function patchProjectWithTolerance(ctx, projectId, value) {
526
627
  if (!isAdvisoryTopicPatch(value) || !isMissingLucernChildComponentError2(error)) {
527
628
  throw error;
528
629
  }
529
- console.warn("[lucern graph-primitives] Non-fatal advisory topic patch failure", {
530
- projectId,
531
- keys: Object.keys(value),
532
- error: error instanceof Error ? error.message : error
533
- });
630
+ console.warn(
631
+ "[lucern graph-primitives] Non-fatal advisory topic patch failure",
632
+ {
633
+ projectId,
634
+ keys: Object.keys(value),
635
+ error: getErrorMessage2(error)
636
+ }
637
+ );
534
638
  }
535
639
  }
536
640
  function defaultResolvers() {
537
641
  return {
538
- async getProject(ctx, projectId) {
539
- return await resolveTopicProjectOverlay(ctx, projectId, {
540
- idMode: "legacy",
541
- projectLikeOnly: false
542
- });
543
- },
544
- async patchProject(ctx, projectId, value) {
545
- await patchProjectWithTolerance(ctx, projectId, value);
546
- },
547
- async listTopics(ctx) {
548
- return await listTopicProjectOverlays(ctx, {
549
- idMode: "legacy"
550
- });
551
- },
552
- async getFinalArtifact(ctx, artifactId) {
553
- return await ctx.db.get(artifactId);
554
- }
642
+ getProject: (ctx, projectId) => resolveTopicProjectOverlay(ctx, projectId, {
643
+ idMode: "legacy",
644
+ projectLikeOnly: false
645
+ }),
646
+ patchProject: (ctx, projectId, value) => patchProjectWithTolerance(ctx, projectId, value),
647
+ listTopics: (ctx) => listTopicProjectOverlays(ctx, {
648
+ idMode: "legacy"
649
+ }),
650
+ getFinalArtifact: (ctx, artifactId) => ctx.db.get(artifactId)
555
651
  };
556
652
  }
557
653
  var resolverOverrides = {};