@lucern/graph-primitives 0.3.0-alpha.1 → 0.3.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{beliefDecay-Q_26RTc-.d.ts → beliefDecay-DZ6tkLYq.d.ts} +1 -1
- package/dist/beliefDecay.d.ts +1 -1
- package/dist/beliefDecay.js +158 -47
- package/dist/beliefDecay.js.map +1 -1
- package/dist/{beliefEvidenceLinks-42FlR48t.d.ts → beliefEvidenceLinks-CWOXxxJg.d.ts} +1 -1
- package/dist/beliefEvidenceLinks.d.ts +1 -1
- package/dist/beliefEvidenceLinks.js +141 -45
- package/dist/beliefEvidenceLinks.js.map +1 -1
- package/dist/{beliefLifecycle-C-AehZgF.d.ts → beliefLifecycle-y8WLXqQj.d.ts} +1 -1
- package/dist/beliefLifecycle.d.ts +1 -1
- package/dist/confidencePropagationDispatch.d.ts +1 -1
- package/dist/confidencePropagationDispatch.js +1 -3
- package/dist/confidencePropagationDispatch.js.map +1 -1
- package/dist/{contradictions-Hdwl7zid.d.ts → contradictions-51VLsESq.d.ts} +1 -1
- package/dist/contradictions.d.ts +1 -1
- package/dist/contradictions.js +67 -8
- package/dist/contradictions.js.map +1 -1
- package/dist/debug.d.ts +4 -0
- package/dist/debug.js +34 -0
- package/dist/debug.js.map +1 -0
- package/dist/edges/contradicts.js.map +1 -1
- package/dist/edges/dependsOn.js.map +1 -1
- package/dist/edges/elaborates.js.map +1 -1
- package/dist/edges/index.js +1 -3
- package/dist/edges/index.js.map +1 -1
- package/dist/edges/informs.js +1 -3
- package/dist/edges/informs.js.map +1 -1
- package/dist/edges/refutes.js +1 -3
- package/dist/edges/refutes.js.map +1 -1
- package/dist/edges/supports.js.map +1 -1
- package/dist/edges/utils.d.ts +3 -3
- package/dist/edges/utils.js +2 -4
- package/dist/edges/utils.js.map +1 -1
- package/dist/embeddingTrigger.js +21 -1
- package/dist/embeddingTrigger.js.map +1 -1
- package/dist/entityBridge.js +1 -1
- package/dist/entityBridge.js.map +1 -1
- package/dist/{entityLifecycle-BkhRJ-XI.d.ts → entityLifecycle-CvgSK5FV.d.ts} +1 -1
- package/dist/entityLifecycle.d.ts +1 -1
- package/dist/entityLifecycle.js +134 -47
- package/dist/entityLifecycle.js.map +1 -1
- package/dist/{epistemicAnswers-DSP1slZ9.d.ts → epistemicAnswers-C5ib4z6_.d.ts} +1 -1
- package/dist/epistemicAnswers.d.ts +1 -1
- package/dist/epistemicAnswers.js +67 -8
- package/dist/epistemicAnswers.js.map +1 -1
- package/dist/{epistemicBeliefs-DtFVTp-k.d.ts → epistemicBeliefs-DzKjZAeC.d.ts} +3 -3
- package/dist/epistemicBeliefs.d.ts +2 -2
- package/dist/epistemicBeliefs.js +289 -114
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicContracts.d.ts +1 -1
- package/dist/epistemicContracts.js +297 -115
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/{epistemicEdges-DcA8ErUG.d.ts → epistemicEdges-CvlKnEyy.d.ts} +1 -1
- package/dist/epistemicEdges.d.ts +1 -1
- package/dist/epistemicEdges.js +192 -60
- package/dist/epistemicEdges.js.map +1 -1
- package/dist/{epistemicEvidence-Bo638XDP.d.ts → epistemicEvidence-xw6UUrwh.d.ts} +1 -1
- package/dist/epistemicEvidence.d.ts +1 -1
- package/dist/epistemicEvidence.js +163 -49
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/{epistemicHelpers-Bd9xbaib.d.ts → epistemicHelpers-DevrYgPN.d.ts} +1 -1
- package/dist/epistemicHelpers.d.ts +1 -1
- package/dist/{epistemicLinking-CyeLOIzN.d.ts → epistemicLinking-CfE00tHJ.d.ts} +1 -1
- package/dist/epistemicLinking.d.ts +1 -1
- package/dist/epistemicLinking.js +1 -1
- package/dist/{epistemicNodes-BpD6Koud.d.ts → epistemicNodes-DjSUfvyD.d.ts} +1 -1
- package/dist/epistemicNodes.d.ts +1 -1
- package/dist/epistemicNodes.js +163 -33
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/{epistemicQuestions-CmEeY6zQ.d.ts → epistemicQuestions-B_nUclrH.d.ts} +1 -1
- package/dist/epistemicQuestions.d.ts +1 -1
- package/dist/epistemicQuestions.js +311 -62
- package/dist/epistemicQuestions.js.map +1 -1
- package/dist/{epistemicSources-ZazxHOK1.d.ts → epistemicSources-dlKj58Jp.d.ts} +1 -1
- package/dist/epistemicSources.d.ts +1 -1
- package/dist/epistemicSources.js +65 -8
- package/dist/epistemicSources.js.map +1 -1
- package/dist/evaluators/index.js +297 -115
- package/dist/evaluators/index.js.map +1 -1
- package/dist/evaluators/lintCheckerEvaluator.js.map +1 -1
- package/dist/evaluators/sentryCheckerEvaluator.js.map +1 -1
- package/dist/evaluators/shared.js +20 -1
- package/dist/evaluators/shared.js.map +1 -1
- package/dist/evaluators/testRunnerEvaluator.js +20 -1
- package/dist/evaluators/testRunnerEvaluator.js.map +1 -1
- package/dist/evaluators/tscCheckerEvaluator.js.map +1 -1
- package/dist/index.d.ts +20 -20
- package/dist/index.js +729 -206
- package/dist/index.js.map +1 -1
- package/dist/{ontology-matching-Buhu23ss.d.ts → ontology-matching-C6rrz2VP.d.ts} +1 -1
- package/dist/ontology-matching.d.ts +1 -1
- package/dist/{ontologyApproval-Ba0Jjk1k.d.ts → ontologyApproval-CFYmqKmk.d.ts} +1 -1
- package/dist/ontologyApproval.d.ts +1 -1
- package/dist/ontologyDefinitions.js +4 -3
- package/dist/ontologyDefinitions.js.map +1 -1
- package/dist/ontologyHelpers.d.ts +1 -1
- package/dist/ontologyHelpers.js +4 -3
- package/dist/ontologyHelpers.js.map +1 -1
- package/dist/{projectionReconciliation-CxrXYGaB.d.ts → projectionReconciliation-jww2fBI0.d.ts} +1 -1
- package/dist/projectionReconciliation.d.ts +1 -1
- package/dist/projectionReconciliation.js +14 -20
- package/dist/projectionReconciliation.js.map +1 -1
- package/dist/{projectionStaleness-CAdpIsaW.d.ts → projectionStaleness-CmdbpjVK.d.ts} +1 -1
- package/dist/projectionStaleness.d.ts +1 -1
- package/dist/{questionEvidenceLinks-BdQD0TkM.d.ts → questionEvidenceLinks-DFlyPpAj.d.ts} +1 -1
- package/dist/questionEvidenceLinks.d.ts +1 -1
- package/dist/questionEvidenceLinks.js +144 -45
- package/dist/questionEvidenceLinks.js.map +1 -1
- package/dist/resolvers.js +86 -37
- package/dist/resolvers.js.map +1 -1
- package/dist/scopeResolverCompat.js +64 -7
- package/dist/scopeResolverCompat.js.map +1 -1
- package/dist/{text-matching-CMn2WnVD.d.ts → text-matching-DNg4M5Wd.d.ts} +1 -1
- package/dist/text-matching.d.ts +1 -1
- package/dist/topicProjectOverlay.js +56 -13
- package/dist/topicProjectOverlay.js.map +1 -1
- package/dist/topicScope.js +55 -6
- package/dist/topicScope.js.map +1 -1
- package/dist/workflowBridge.js +55 -6
- package/dist/workflowBridge.js.map +1 -1
- package/dist/workspaceIsolation.js +55 -6
- package/dist/workspaceIsolation.js.map +1 -1
- package/package.json +5 -5
|
@@ -211,4 +211,4 @@ declare namespace epistemicQuestions {
|
|
|
211
211
|
export { epistemicQuestions_addQuestion as addQuestion, epistemicQuestions_advanceToConviction as advanceToConviction, epistemicQuestions_backfillScoredQuestionEvidence as backfillScoredQuestionEvidence, epistemicQuestions_consolidate as consolidate, epistemicQuestions_create as create, epistemicQuestions_createBatch as createBatch, epistemicQuestions_createEvidenceFromScoredQuestion as createEvidenceFromScoredQuestion, epistemicQuestions_deleteQuestion as deleteQuestion, epistemicQuestions_finalizeConviction as finalizeConviction, epistemicQuestions_flattenQuestionNode as flattenQuestionNode, epistemicQuestions_getByBeliefWithAccess as getByBeliefWithAccess, epistemicQuestions_getByCategory as getByCategory, epistemicQuestions_getById as getById, epistemicQuestions_getByPillar as getByPillar, epistemicQuestions_getByProject as getByProject, epistemicQuestions_getByTopic as getByTopic, epistemicQuestions_getForBelief as getForBelief, epistemicQuestions_getForSprintCluster as getForSprintCluster, epistemicQuestions_getInConviction as getInConviction, epistemicQuestions_getQuestionClusterPositions as getQuestionClusterPositions, epistemicQuestions_internalCreate as internalCreate, epistemicQuestions_internalGetByProject as internalGetByProject, epistemicQuestions_internalGetByTopic as internalGetByTopic, epistemicQuestions_isActiveQuestionNode as isActiveQuestionNode, epistemicQuestions_linkToBelief as linkToBelief, epistemicQuestions_linkToInsight as linkToInsight, epistemicQuestions_list as list, epistemicQuestions_markAnsweredWithArtifact as markAnsweredWithArtifact, epistemicQuestions_matchesRequestedQuestionStatus as matchesRequestedQuestionStatus, epistemicQuestions_resolveLinkedWorktreeId as resolveLinkedWorktreeId, epistemicQuestions_unlinkInsight as unlinkInsight, epistemicQuestions_updateConviction as updateConviction, epistemicQuestions_updatePriority as updatePriority, epistemicQuestions_updateQuestion as updateQuestion, epistemicQuestions_updateStatus as updateStatus };
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
export {
|
|
214
|
+
export { linkToInsight as A, list as B, markAnsweredWithArtifact as C, matchesRequestedQuestionStatus as D, resolveLinkedWorktreeId as E, unlinkInsight as F, updateConviction as G, updatePriority as H, updateQuestion as I, updateStatus as J, addQuestion as a, advanceToConviction as b, backfillScoredQuestionEvidence as c, consolidate as d, epistemicQuestions as e, create as f, createBatch as g, createEvidenceFromScoredQuestion as h, deleteQuestion as i, finalizeConviction as j, flattenQuestionNode as k, getByBeliefWithAccess as l, getByCategory as m, getById as n, getByPillar as o, getByProject as p, getByTopic as q, getForBelief as r, getForSprintCluster as s, getInConviction as t, getQuestionClusterPositions as u, internalCreate as v, internalGetByProject as w, internalGetByTopic as x, isActiveQuestionNode as y, linkToBelief as z };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './convex.js';
|
|
2
|
-
export {
|
|
2
|
+
export { a as addQuestion, b as advanceToConviction, c as backfillScoredQuestionEvidence, d as consolidate, f as create, g as createBatch, h as createEvidenceFromScoredQuestion, i as deleteQuestion, j as finalizeConviction, k as flattenQuestionNode, l as getByBeliefWithAccess, m as getByCategory, n as getById, o as getByPillar, p as getByProject, q as getByTopic, r as getForBelief, s as getForSprintCluster, t as getInConviction, u as getQuestionClusterPositions, v as internalCreate, w as internalGetByProject, x as internalGetByTopic, y as isActiveQuestionNode, z as linkToBelief, A as linkToInsight, B as list, C as markAnsweredWithArtifact, D as matchesRequestedQuestionStatus, E as resolveLinkedWorktreeId, F as unlinkInsight, G as updateConviction, H as updatePriority, I as updateQuestion, J as updateStatus } from './epistemicQuestions-B_nUclrH.js';
|
|
3
3
|
import 'convex/values';
|
|
@@ -4,7 +4,7 @@ import { normalizeAudienceKey, canAudienceClassAccess, classFromAudienceKey } fr
|
|
|
4
4
|
import { listAudienceRegistryRows } from '@lucern/access-control/audienceRegistry';
|
|
5
5
|
import { getCurrentUserId } from '@lucern/access-control/auth';
|
|
6
6
|
import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
|
|
7
|
-
import { componentsGeneric,
|
|
7
|
+
import { componentsGeneric, anyApi, mutationGeneric, queryGeneric, internalQueryGeneric, internalMutationGeneric } from 'convex/server';
|
|
8
8
|
import { isNodeType, getLayerForNodeType } from '@lucern/contracts/schema-helpers/spine/tables/epistemicNodes';
|
|
9
9
|
|
|
10
10
|
// src/epistemicQuestions.ts
|
|
@@ -16,6 +16,37 @@ var internalQuery = internalQueryGeneric;
|
|
|
16
16
|
var mutation = mutationGeneric;
|
|
17
17
|
var query = queryGeneric;
|
|
18
18
|
|
|
19
|
+
// src/debug.ts
|
|
20
|
+
function isGraphPrimitiveDebugEnabled() {
|
|
21
|
+
const env = globalThis.process?.env;
|
|
22
|
+
return env?.LUCERN_COMPAT_FALLBACK_DEBUG === "1" || env?.LUCERN_GRAPH_DEBUG === "1";
|
|
23
|
+
}
|
|
24
|
+
function formatGraphPrimitiveError(error) {
|
|
25
|
+
if (error instanceof Error) {
|
|
26
|
+
return `${error.name}: ${error.message}`;
|
|
27
|
+
}
|
|
28
|
+
if (typeof error === "string") {
|
|
29
|
+
return error;
|
|
30
|
+
}
|
|
31
|
+
if (error === null) {
|
|
32
|
+
return "null";
|
|
33
|
+
}
|
|
34
|
+
if (error === void 0) {
|
|
35
|
+
return "undefined";
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
return JSON.stringify(error);
|
|
39
|
+
} catch {
|
|
40
|
+
return Object.prototype.toString.call(error);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function debugGraphPrimitiveFallback(message, context) {
|
|
44
|
+
if (!isGraphPrimitiveDebugEnabled()) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
console.debug(message, context ?? {});
|
|
48
|
+
}
|
|
49
|
+
|
|
19
50
|
// src/embeddingTrigger.ts
|
|
20
51
|
async function scheduleEmbeddingGeneration(args) {
|
|
21
52
|
try {
|
|
@@ -33,7 +64,15 @@ async function scheduleEmbeddingGeneration(args) {
|
|
|
33
64
|
confidence: args.confidence
|
|
34
65
|
}
|
|
35
66
|
);
|
|
36
|
-
} catch {
|
|
67
|
+
} catch (error) {
|
|
68
|
+
debugGraphPrimitiveFallback(
|
|
69
|
+
"[embeddingTrigger] Failed to schedule embedding generation",
|
|
70
|
+
{
|
|
71
|
+
error,
|
|
72
|
+
nodeId: String(args.nodeId),
|
|
73
|
+
nodeType: args.nodeType
|
|
74
|
+
}
|
|
75
|
+
);
|
|
37
76
|
}
|
|
38
77
|
}
|
|
39
78
|
|
|
@@ -94,19 +133,37 @@ function isProjectLikeTopic(topic) {
|
|
|
94
133
|
return topic.type === "theme" || topic.type === "thematic" || topic.type === "deal" || topic.type === "monitoring" || readLegacyProjectId(topic) !== void 0 || readNonEmptyString(metadata.projectType) !== void 0;
|
|
95
134
|
}
|
|
96
135
|
function isMissingLucernChildComponentError(error) {
|
|
97
|
-
const message =
|
|
136
|
+
const message = getErrorMessage(error);
|
|
98
137
|
return message.includes(
|
|
99
138
|
'Child component ComponentName(Identifier("lucern")) not found'
|
|
100
139
|
) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
|
|
101
140
|
}
|
|
141
|
+
function getErrorMessage(error) {
|
|
142
|
+
if (error instanceof Error) {
|
|
143
|
+
return error.message;
|
|
144
|
+
}
|
|
145
|
+
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
146
|
+
return error.message;
|
|
147
|
+
}
|
|
148
|
+
return "unknown error";
|
|
149
|
+
}
|
|
102
150
|
async function resolveTopicDoc(ctx, scopeId) {
|
|
103
151
|
if (ctx?.db && typeof ctx.db.get === "function") {
|
|
104
152
|
try {
|
|
105
|
-
const directTopic = await ctx.db.get(
|
|
153
|
+
const directTopic = await ctx.db.get(
|
|
154
|
+
scopeId
|
|
155
|
+
);
|
|
106
156
|
if (directTopic) {
|
|
107
157
|
return directTopic;
|
|
108
158
|
}
|
|
109
|
-
} catch {
|
|
159
|
+
} catch (error) {
|
|
160
|
+
debugGraphPrimitiveFallback(
|
|
161
|
+
"[topicProjectOverlay] Failed to resolve topic by direct ID",
|
|
162
|
+
{
|
|
163
|
+
error,
|
|
164
|
+
scopeId
|
|
165
|
+
}
|
|
166
|
+
);
|
|
110
167
|
}
|
|
111
168
|
}
|
|
112
169
|
if (typeof ctx.runQuery !== "function") {
|
|
@@ -119,7 +176,14 @@ async function resolveTopicDoc(ctx, scopeId) {
|
|
|
119
176
|
if (topic?.name !== void 0 && topic?.type !== void 0) {
|
|
120
177
|
return topic;
|
|
121
178
|
}
|
|
122
|
-
} catch {
|
|
179
|
+
} catch (error) {
|
|
180
|
+
debugGraphPrimitiveFallback(
|
|
181
|
+
"[topicProjectOverlay] Failed to resolve topic by ID query",
|
|
182
|
+
{
|
|
183
|
+
error,
|
|
184
|
+
scopeId
|
|
185
|
+
}
|
|
186
|
+
);
|
|
123
187
|
}
|
|
124
188
|
try {
|
|
125
189
|
const topic = await ctx.runQuery(api.topics.getByLegacyScopeId, {
|
|
@@ -128,7 +192,11 @@ async function resolveTopicDoc(ctx, scopeId) {
|
|
|
128
192
|
if (topic?.name !== void 0 && topic?.type !== void 0) {
|
|
129
193
|
return topic;
|
|
130
194
|
}
|
|
131
|
-
} catch {
|
|
195
|
+
} catch (error) {
|
|
196
|
+
debugGraphPrimitiveFallback(
|
|
197
|
+
"[topicProjectOverlay] Failed to resolve topic by legacy scope ID",
|
|
198
|
+
{ error, scopeId }
|
|
199
|
+
);
|
|
132
200
|
}
|
|
133
201
|
return null;
|
|
134
202
|
}
|
|
@@ -182,7 +250,11 @@ async function listTopicProjectOverlays(ctx, options = {}) {
|
|
|
182
250
|
if (ctx?.db?.query && typeof ctx.db.query === "function") {
|
|
183
251
|
try {
|
|
184
252
|
allTopics = await ctx.db.query("topics").collect();
|
|
185
|
-
} catch {
|
|
253
|
+
} catch (error) {
|
|
254
|
+
debugGraphPrimitiveFallback(
|
|
255
|
+
"[topicProjectOverlay] Failed to read topics table; falling back to API",
|
|
256
|
+
{ error }
|
|
257
|
+
);
|
|
186
258
|
allTopics = [];
|
|
187
259
|
}
|
|
188
260
|
}
|
|
@@ -277,19 +349,28 @@ async function patchTopicProjectOverlay(ctx, scopeId, value) {
|
|
|
277
349
|
"Cannot patch topic without component adapter (ctx.runMutation unavailable)"
|
|
278
350
|
);
|
|
279
351
|
}
|
|
280
|
-
return materializeTopicProjectOverlay(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
);
|
|
352
|
+
return materializeTopicProjectOverlay({
|
|
353
|
+
...topic,
|
|
354
|
+
...patch,
|
|
355
|
+
metadata: nextMetadata
|
|
356
|
+
});
|
|
287
357
|
}
|
|
288
358
|
|
|
289
359
|
// src/resolvers.ts
|
|
290
360
|
function isMissingLucernChildComponentError2(error) {
|
|
291
|
-
const message =
|
|
292
|
-
return message.includes(
|
|
361
|
+
const message = getErrorMessage2(error);
|
|
362
|
+
return message.includes(
|
|
363
|
+
'Child component ComponentName(Identifier("lucern")) not found'
|
|
364
|
+
) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
|
|
365
|
+
}
|
|
366
|
+
function getErrorMessage2(error) {
|
|
367
|
+
if (error instanceof Error) {
|
|
368
|
+
return error.message;
|
|
369
|
+
}
|
|
370
|
+
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
371
|
+
return error.message;
|
|
372
|
+
}
|
|
373
|
+
return "unknown error";
|
|
293
374
|
}
|
|
294
375
|
function isAdvisoryTopicPatch(value) {
|
|
295
376
|
const advisoryKeys = /* @__PURE__ */ new Set(["lastActivityAt", "updatedAt"]);
|
|
@@ -303,32 +384,27 @@ async function patchProjectWithTolerance(ctx, projectId, value) {
|
|
|
303
384
|
if (!isAdvisoryTopicPatch(value) || !isMissingLucernChildComponentError2(error)) {
|
|
304
385
|
throw error;
|
|
305
386
|
}
|
|
306
|
-
console.warn(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
387
|
+
console.warn(
|
|
388
|
+
"[lucern graph-primitives] Non-fatal advisory topic patch failure",
|
|
389
|
+
{
|
|
390
|
+
projectId,
|
|
391
|
+
keys: Object.keys(value),
|
|
392
|
+
error: getErrorMessage2(error)
|
|
393
|
+
}
|
|
394
|
+
);
|
|
311
395
|
}
|
|
312
396
|
}
|
|
313
397
|
function defaultResolvers() {
|
|
314
398
|
return {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
async listTopics(ctx) {
|
|
325
|
-
return await listTopicProjectOverlays(ctx, {
|
|
326
|
-
idMode: "legacy"
|
|
327
|
-
});
|
|
328
|
-
},
|
|
329
|
-
async getFinalArtifact(ctx, artifactId) {
|
|
330
|
-
return await ctx.db.get(artifactId);
|
|
331
|
-
}
|
|
399
|
+
getProject: (ctx, projectId) => resolveTopicProjectOverlay(ctx, projectId, {
|
|
400
|
+
idMode: "legacy",
|
|
401
|
+
projectLikeOnly: false
|
|
402
|
+
}),
|
|
403
|
+
patchProject: (ctx, projectId, value) => patchProjectWithTolerance(ctx, projectId, value),
|
|
404
|
+
listTopics: (ctx) => listTopicProjectOverlays(ctx, {
|
|
405
|
+
idMode: "legacy"
|
|
406
|
+
}),
|
|
407
|
+
getFinalArtifact: (ctx, artifactId) => ctx.db.get(artifactId)
|
|
332
408
|
};
|
|
333
409
|
}
|
|
334
410
|
var resolverOverrides = {};
|
|
@@ -379,7 +455,14 @@ async function findTopicsByScopeAlias(ctx, scopeId) {
|
|
|
379
455
|
"by_graph_scope_project",
|
|
380
456
|
(q) => q.eq(LEGACY_SCOPE_FIELD2, scopeId)
|
|
381
457
|
).collect();
|
|
382
|
-
} catch {
|
|
458
|
+
} catch (error) {
|
|
459
|
+
debugGraphPrimitiveFallback(
|
|
460
|
+
"[topicScope] Failed to resolve scope alias via index",
|
|
461
|
+
{
|
|
462
|
+
error,
|
|
463
|
+
scopeId
|
|
464
|
+
}
|
|
465
|
+
);
|
|
383
466
|
const topics = await ctx.db.query("topics").collect();
|
|
384
467
|
return topics.filter((topic) => {
|
|
385
468
|
const normalizedGlobalId = normalizeScopeValue(topic.globalId);
|
|
@@ -396,7 +479,14 @@ async function tryResolveHostTopicById(ctx, topicId) {
|
|
|
396
479
|
return await ctx.runQuery(api.topics.get, {
|
|
397
480
|
id: topicId
|
|
398
481
|
}) ?? null;
|
|
399
|
-
} catch {
|
|
482
|
+
} catch (error) {
|
|
483
|
+
debugGraphPrimitiveFallback(
|
|
484
|
+
"[topicScope] Failed to resolve topic by host query",
|
|
485
|
+
{
|
|
486
|
+
error,
|
|
487
|
+
topicId
|
|
488
|
+
}
|
|
489
|
+
);
|
|
400
490
|
return null;
|
|
401
491
|
}
|
|
402
492
|
}
|
|
@@ -408,7 +498,14 @@ async function tryResolveHostTopicByLegacyScope(ctx, legacyScopeId) {
|
|
|
408
498
|
return await ctx.runQuery(api.topics.getByLegacyScopeId, {
|
|
409
499
|
projectId: legacyScopeId
|
|
410
500
|
}) ?? null;
|
|
411
|
-
} catch {
|
|
501
|
+
} catch (error) {
|
|
502
|
+
debugGraphPrimitiveFallback(
|
|
503
|
+
"[topicScope] Failed to resolve topic by legacy scope",
|
|
504
|
+
{
|
|
505
|
+
error,
|
|
506
|
+
legacyScopeId
|
|
507
|
+
}
|
|
508
|
+
);
|
|
412
509
|
return null;
|
|
413
510
|
}
|
|
414
511
|
}
|
|
@@ -437,8 +534,17 @@ async function resolveTopicProjectScope(ctx, args) {
|
|
|
437
534
|
if (args.topicId) {
|
|
438
535
|
let topic = null;
|
|
439
536
|
try {
|
|
440
|
-
topic = await ctx.db.get(
|
|
441
|
-
|
|
537
|
+
topic = await ctx.db.get(
|
|
538
|
+
args.topicId
|
|
539
|
+
);
|
|
540
|
+
} catch (error) {
|
|
541
|
+
debugGraphPrimitiveFallback(
|
|
542
|
+
"[topicScope] Failed to load topic by direct id",
|
|
543
|
+
{
|
|
544
|
+
error,
|
|
545
|
+
topicId: args.topicId
|
|
546
|
+
}
|
|
547
|
+
);
|
|
442
548
|
}
|
|
443
549
|
if (!topic) {
|
|
444
550
|
topic = await tryResolveHostTopicById(ctx, String(args.topicId));
|
|
@@ -475,7 +581,14 @@ async function resolveTopicProjectScope(ctx, args) {
|
|
|
475
581
|
directTopic = await ctx.db.get(
|
|
476
582
|
args.projectId
|
|
477
583
|
);
|
|
478
|
-
} catch {
|
|
584
|
+
} catch (error) {
|
|
585
|
+
debugGraphPrimitiveFallback(
|
|
586
|
+
"[topicScope] Failed to load direct project topic",
|
|
587
|
+
{
|
|
588
|
+
error,
|
|
589
|
+
projectId: args.projectId
|
|
590
|
+
}
|
|
591
|
+
);
|
|
479
592
|
}
|
|
480
593
|
if (directTopic) {
|
|
481
594
|
const inherited = await resolveInheritedWorkspaceScope(ctx, directTopic);
|
|
@@ -850,6 +963,12 @@ function normalizeQuestionTopicId(topicId) {
|
|
|
850
963
|
function resolveQuestionScopeId(scope) {
|
|
851
964
|
return normalizeQuestionTopicId(scope.topicId) ?? scope.projectId ?? void 0;
|
|
852
965
|
}
|
|
966
|
+
function logQuestionFallback(message, error, context) {
|
|
967
|
+
debugGraphPrimitiveFallback(message, {
|
|
968
|
+
error: formatGraphPrimitiveError(error),
|
|
969
|
+
...context ?? {}
|
|
970
|
+
});
|
|
971
|
+
}
|
|
853
972
|
async function resolveQuestionScopeOrNull(ctx, args) {
|
|
854
973
|
if (!args.projectId && !args.topicId) {
|
|
855
974
|
return null;
|
|
@@ -859,7 +978,15 @@ async function resolveQuestionScopeOrNull(ctx, args) {
|
|
|
859
978
|
projectId: args.projectId ?? void 0,
|
|
860
979
|
topicId: args.topicId ?? void 0
|
|
861
980
|
});
|
|
862
|
-
} catch {
|
|
981
|
+
} catch (error) {
|
|
982
|
+
debugGraphPrimitiveFallback(
|
|
983
|
+
"[epistemicQuestions] Failed to resolve question scope",
|
|
984
|
+
{
|
|
985
|
+
error: formatGraphPrimitiveError(error),
|
|
986
|
+
projectId: args.projectId,
|
|
987
|
+
topicId: args.topicId
|
|
988
|
+
}
|
|
989
|
+
);
|
|
863
990
|
return null;
|
|
864
991
|
}
|
|
865
992
|
}
|
|
@@ -1063,9 +1190,7 @@ var create = mutation({
|
|
|
1063
1190
|
source: args.source || "ai_suggested",
|
|
1064
1191
|
questionStatus: "open",
|
|
1065
1192
|
linkedBeliefNodeId: args.linkedBeliefNodeId,
|
|
1066
|
-
...buildLinkedWorktreeMetadata(
|
|
1067
|
-
args.linkedWorktreeId
|
|
1068
|
-
),
|
|
1193
|
+
...buildLinkedWorktreeMetadata(args.linkedWorktreeId),
|
|
1069
1194
|
testType: args.testType,
|
|
1070
1195
|
importance: args.importance,
|
|
1071
1196
|
epistemicUnlock: args.epistemicUnlock,
|
|
@@ -1476,7 +1601,9 @@ var getByTopic = query({
|
|
|
1476
1601
|
handler: async (ctx, args) => {
|
|
1477
1602
|
const pageSize = clampQuestionLimit(args.limit);
|
|
1478
1603
|
const scanLimit = Math.min(pageSize * 3, MAX_QUESTION_PAGE_SIZE);
|
|
1479
|
-
const scope = await resolveTopicProjectScope(ctx, {
|
|
1604
|
+
const scope = await resolveTopicProjectScope(ctx, {
|
|
1605
|
+
topicId: args.topicId
|
|
1606
|
+
});
|
|
1480
1607
|
const scopedNodes = await getQuestionNodesForScope(ctx, scope, {
|
|
1481
1608
|
scanLimit
|
|
1482
1609
|
});
|
|
@@ -1500,7 +1627,7 @@ var getByCategory = query({
|
|
|
1500
1627
|
const nodes = await getQuestionNodesForScope(ctx, scope);
|
|
1501
1628
|
return nodes.filter((n) => {
|
|
1502
1629
|
const metadata = n.metadata || {};
|
|
1503
|
-
return questionMatchesScope(n, scope) &&
|
|
1630
|
+
return questionMatchesScope(n, scope) && isActiveQuestionNode(n) && metadata.category === normalizeCategory(args.category);
|
|
1504
1631
|
});
|
|
1505
1632
|
}
|
|
1506
1633
|
});
|
|
@@ -1596,7 +1723,9 @@ var internalGetByTopic = internalQuery({
|
|
|
1596
1723
|
const pageSize = clampQuestionLimit(args.limit, 500);
|
|
1597
1724
|
const scanLimit = Math.min(pageSize * 3, MAX_QUESTION_PAGE_SIZE);
|
|
1598
1725
|
const audienceMode = args.audienceMode ?? "internal";
|
|
1599
|
-
const scope = await resolveTopicProjectScope(ctx, {
|
|
1726
|
+
const scope = await resolveTopicProjectScope(ctx, {
|
|
1727
|
+
topicId: args.topicId
|
|
1728
|
+
});
|
|
1600
1729
|
const registryRows = await listAudienceRegistryRows(ctx, {
|
|
1601
1730
|
tenantId: scope.tenantId,
|
|
1602
1731
|
workspaceId: scope.workspaceId
|
|
@@ -1926,7 +2055,14 @@ A: ${args.answerText}`;
|
|
|
1926
2055
|
if (node?.nodeType === "belief") {
|
|
1927
2056
|
return node;
|
|
1928
2057
|
}
|
|
1929
|
-
} catch {
|
|
2058
|
+
} catch (error) {
|
|
2059
|
+
debugGraphPrimitiveFallback(
|
|
2060
|
+
"[epistemicQuestions] Failed to resolve belief node",
|
|
2061
|
+
{
|
|
2062
|
+
error: formatGraphPrimitiveError(error),
|
|
2063
|
+
beliefId: bId
|
|
2064
|
+
}
|
|
2065
|
+
);
|
|
1930
2066
|
return null;
|
|
1931
2067
|
}
|
|
1932
2068
|
return null;
|
|
@@ -2332,7 +2468,14 @@ var getInConviction = query({
|
|
|
2332
2468
|
exclusiveWithCount: 0
|
|
2333
2469
|
};
|
|
2334
2470
|
}
|
|
2335
|
-
} catch {
|
|
2471
|
+
} catch (error) {
|
|
2472
|
+
debugGraphPrimitiveFallback(
|
|
2473
|
+
"[epistemicQuestions] Failed to hydrate linked belief",
|
|
2474
|
+
{
|
|
2475
|
+
error: formatGraphPrimitiveError(error),
|
|
2476
|
+
beliefId
|
|
2477
|
+
}
|
|
2478
|
+
);
|
|
2336
2479
|
}
|
|
2337
2480
|
return null;
|
|
2338
2481
|
})
|
|
@@ -2430,6 +2573,14 @@ var advanceToConviction = mutation({
|
|
|
2430
2573
|
triggeringAction: "question_advanced_to_conviction"
|
|
2431
2574
|
});
|
|
2432
2575
|
} catch (e) {
|
|
2576
|
+
logQuestionFallback(
|
|
2577
|
+
"[epistemicQuestions] Failed to log advanceToConviction audit",
|
|
2578
|
+
e,
|
|
2579
|
+
{
|
|
2580
|
+
questionId: args.questionId,
|
|
2581
|
+
projectId: node.projectId
|
|
2582
|
+
}
|
|
2583
|
+
);
|
|
2433
2584
|
console.error("[EpistemicAudit] Failed to log advanceToConviction:", e);
|
|
2434
2585
|
}
|
|
2435
2586
|
await markProjectGraphDirty(ctx, node.projectId, node.topicId);
|
|
@@ -2556,6 +2707,14 @@ var finalizeConviction = mutation({
|
|
|
2556
2707
|
triggeringAction: "question_conviction_finalized"
|
|
2557
2708
|
});
|
|
2558
2709
|
} catch (e) {
|
|
2710
|
+
logQuestionFallback(
|
|
2711
|
+
"[epistemicQuestions] Failed to log finalizeConviction audit",
|
|
2712
|
+
e,
|
|
2713
|
+
{
|
|
2714
|
+
questionId: args.questionId,
|
|
2715
|
+
projectId: node.projectId
|
|
2716
|
+
}
|
|
2717
|
+
);
|
|
2559
2718
|
console.error("[EpistemicAudit] Failed to log finalizeConviction:", e);
|
|
2560
2719
|
}
|
|
2561
2720
|
if (node.projectId || node.topicId) {
|
|
@@ -2579,6 +2738,15 @@ var finalizeConviction = mutation({
|
|
|
2579
2738
|
}
|
|
2580
2739
|
);
|
|
2581
2740
|
} catch (e) {
|
|
2741
|
+
logQuestionFallback(
|
|
2742
|
+
"[epistemicQuestions] Failed to schedule evidence creation from scored question",
|
|
2743
|
+
e,
|
|
2744
|
+
{
|
|
2745
|
+
questionId: args.questionId,
|
|
2746
|
+
beliefId,
|
|
2747
|
+
projectId: node.projectId
|
|
2748
|
+
}
|
|
2749
|
+
);
|
|
2582
2750
|
console.error(
|
|
2583
2751
|
"[finalizeConviction] Failed to schedule evidence creation:",
|
|
2584
2752
|
e
|
|
@@ -2608,10 +2776,24 @@ var getByBeliefWithAccess = query({
|
|
|
2608
2776
|
let beliefNode = null;
|
|
2609
2777
|
try {
|
|
2610
2778
|
beliefNode = await ctx.db.get(args.beliefId);
|
|
2611
|
-
} catch {
|
|
2779
|
+
} catch (error) {
|
|
2780
|
+
debugGraphPrimitiveFallback(
|
|
2781
|
+
"[epistemicQuestions] Failed to resolve belief node directly",
|
|
2782
|
+
{
|
|
2783
|
+
error: formatGraphPrimitiveError(error),
|
|
2784
|
+
beliefId: args.beliefId
|
|
2785
|
+
}
|
|
2786
|
+
);
|
|
2612
2787
|
try {
|
|
2613
2788
|
beliefNode = await ctx.db.get(args.beliefId);
|
|
2614
|
-
} catch {
|
|
2789
|
+
} catch (legacyError) {
|
|
2790
|
+
debugGraphPrimitiveFallback(
|
|
2791
|
+
"[epistemicQuestions] Failed to resolve legacy belief node",
|
|
2792
|
+
{
|
|
2793
|
+
error: formatGraphPrimitiveError(legacyError),
|
|
2794
|
+
beliefId: args.beliefId
|
|
2795
|
+
}
|
|
2796
|
+
);
|
|
2615
2797
|
return [];
|
|
2616
2798
|
}
|
|
2617
2799
|
}
|
|
@@ -2755,10 +2937,24 @@ var linkToBelief = mutation({
|
|
|
2755
2937
|
let beliefNode = null;
|
|
2756
2938
|
try {
|
|
2757
2939
|
beliefNode = await ctx.db.get(args.beliefId);
|
|
2758
|
-
} catch {
|
|
2940
|
+
} catch (error) {
|
|
2941
|
+
debugGraphPrimitiveFallback(
|
|
2942
|
+
"[epistemicQuestions] Failed to resolve belief node directly",
|
|
2943
|
+
{
|
|
2944
|
+
error: formatGraphPrimitiveError(error),
|
|
2945
|
+
beliefId: args.beliefId
|
|
2946
|
+
}
|
|
2947
|
+
);
|
|
2759
2948
|
try {
|
|
2760
2949
|
beliefNode = await ctx.db.get(args.beliefId);
|
|
2761
|
-
} catch {
|
|
2950
|
+
} catch (legacyError) {
|
|
2951
|
+
debugGraphPrimitiveFallback(
|
|
2952
|
+
"[epistemicQuestions] Failed to resolve legacy belief node",
|
|
2953
|
+
{
|
|
2954
|
+
error: formatGraphPrimitiveError(legacyError),
|
|
2955
|
+
beliefId: args.beliefId
|
|
2956
|
+
}
|
|
2957
|
+
);
|
|
2762
2958
|
throw new Error("Belief not found");
|
|
2763
2959
|
}
|
|
2764
2960
|
}
|
|
@@ -2819,6 +3015,14 @@ var linkToBelief = mutation({
|
|
|
2819
3015
|
});
|
|
2820
3016
|
}
|
|
2821
3017
|
} catch (e) {
|
|
3018
|
+
logQuestionFallback(
|
|
3019
|
+
"[epistemicQuestions] Failed to create tests edge",
|
|
3020
|
+
e,
|
|
3021
|
+
{
|
|
3022
|
+
questionId: args.questionId,
|
|
3023
|
+
beliefId: args.beliefId
|
|
3024
|
+
}
|
|
3025
|
+
);
|
|
2822
3026
|
console.error("[linkToBelief] Failed to create tests edge:", e);
|
|
2823
3027
|
}
|
|
2824
3028
|
await markProjectGraphDirty(
|
|
@@ -2957,6 +3161,14 @@ var unlinkInsight = mutation({
|
|
|
2957
3161
|
}
|
|
2958
3162
|
}
|
|
2959
3163
|
} catch (e) {
|
|
3164
|
+
logQuestionFallback(
|
|
3165
|
+
"[epistemicQuestions] Failed to remove questionEvidenceLink",
|
|
3166
|
+
e,
|
|
3167
|
+
{
|
|
3168
|
+
questionId: args.questionId,
|
|
3169
|
+
insightId: args.insightId
|
|
3170
|
+
}
|
|
3171
|
+
);
|
|
2960
3172
|
console.error(
|
|
2961
3173
|
"[unlinkInsight] Failed to remove questionEvidenceLink:",
|
|
2962
3174
|
e
|
|
@@ -2979,6 +3191,14 @@ var unlinkInsight = mutation({
|
|
|
2979
3191
|
}
|
|
2980
3192
|
}
|
|
2981
3193
|
} catch (e) {
|
|
3194
|
+
logQuestionFallback(
|
|
3195
|
+
"[epistemicQuestions] Failed to remove derived edge",
|
|
3196
|
+
e,
|
|
3197
|
+
{
|
|
3198
|
+
questionId: args.questionId,
|
|
3199
|
+
insightId: args.insightId
|
|
3200
|
+
}
|
|
3201
|
+
);
|
|
2982
3202
|
console.error("[unlinkInsight] Failed to remove edge:", e);
|
|
2983
3203
|
}
|
|
2984
3204
|
await markProjectGraphDirty(
|
|
@@ -3149,7 +3369,14 @@ var consolidate = mutation({
|
|
|
3149
3369
|
args.questionIds.map(async (qid) => {
|
|
3150
3370
|
try {
|
|
3151
3371
|
return await ctx.db.get(qid);
|
|
3152
|
-
} catch {
|
|
3372
|
+
} catch (error) {
|
|
3373
|
+
debugGraphPrimitiveFallback(
|
|
3374
|
+
"[epistemicQuestions] Failed to load original question",
|
|
3375
|
+
{
|
|
3376
|
+
error: formatGraphPrimitiveError(error),
|
|
3377
|
+
questionId: qid
|
|
3378
|
+
}
|
|
3379
|
+
);
|
|
3153
3380
|
return null;
|
|
3154
3381
|
}
|
|
3155
3382
|
})
|
|
@@ -3210,7 +3437,14 @@ var consolidate = mutation({
|
|
|
3210
3437
|
const bMeta = belief.metadata || {};
|
|
3211
3438
|
category = bMeta.category || bMeta.pillar || "other";
|
|
3212
3439
|
}
|
|
3213
|
-
} catch {
|
|
3440
|
+
} catch (error) {
|
|
3441
|
+
debugGraphPrimitiveFallback(
|
|
3442
|
+
"[epistemicQuestions] Failed to read first linked belief metadata",
|
|
3443
|
+
{
|
|
3444
|
+
error: formatGraphPrimitiveError(error),
|
|
3445
|
+
beliefId: firstBeliefId
|
|
3446
|
+
}
|
|
3447
|
+
);
|
|
3214
3448
|
}
|
|
3215
3449
|
}
|
|
3216
3450
|
const now = Date.now();
|
|
@@ -3260,7 +3494,14 @@ var consolidate = mutation({
|
|
|
3260
3494
|
}
|
|
3261
3495
|
});
|
|
3262
3496
|
}
|
|
3263
|
-
} catch {
|
|
3497
|
+
} catch (error) {
|
|
3498
|
+
debugGraphPrimitiveFallback(
|
|
3499
|
+
"[epistemicQuestions] Failed to archive linked question",
|
|
3500
|
+
{
|
|
3501
|
+
error: formatGraphPrimitiveError(error),
|
|
3502
|
+
questionId: qid
|
|
3503
|
+
}
|
|
3504
|
+
);
|
|
3264
3505
|
}
|
|
3265
3506
|
}
|
|
3266
3507
|
await ctx.scheduler.runAfter(0, internal.neo4jSync.syncNodeToNeo4j, {
|
|
@@ -3392,7 +3633,15 @@ var getQuestionClusterPositions = query({
|
|
|
3392
3633
|
projectId: args.projectId,
|
|
3393
3634
|
topicId: args.topicId
|
|
3394
3635
|
});
|
|
3395
|
-
} catch {
|
|
3636
|
+
} catch (error) {
|
|
3637
|
+
debugGraphPrimitiveFallback(
|
|
3638
|
+
"[epistemicQuestions] Failed to resolve question cluster scope",
|
|
3639
|
+
{
|
|
3640
|
+
error: formatGraphPrimitiveError(error),
|
|
3641
|
+
projectId: args.projectId,
|
|
3642
|
+
topicId: args.topicId
|
|
3643
|
+
}
|
|
3644
|
+
);
|
|
3396
3645
|
return {
|
|
3397
3646
|
positions: {},
|
|
3398
3647
|
counts: {
|