@lucern/graph-primitives 0.3.0-alpha.16 → 0.3.0-alpha.2
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-DZ6tkLYq.d.ts → beliefDecay-Q_26RTc-.d.ts} +1 -1
- package/dist/beliefDecay.d.ts +1 -1
- package/dist/beliefDecay.js +47 -158
- package/dist/beliefDecay.js.map +1 -1
- package/dist/{beliefEvidenceLinks-CWOXxxJg.d.ts → beliefEvidenceLinks-42FlR48t.d.ts} +1 -1
- package/dist/beliefEvidenceLinks.d.ts +1 -1
- package/dist/beliefEvidenceLinks.js +45 -141
- package/dist/beliefEvidenceLinks.js.map +1 -1
- package/dist/{beliefLifecycle-y8WLXqQj.d.ts → beliefLifecycle-C-AehZgF.d.ts} +1 -1
- package/dist/beliefLifecycle.d.ts +1 -1
- package/dist/confidencePropagationDispatch.d.ts +1 -1
- package/dist/confidencePropagationDispatch.js +3 -1
- package/dist/confidencePropagationDispatch.js.map +1 -1
- package/dist/{contradictions-51VLsESq.d.ts → contradictions-Hdwl7zid.d.ts} +1 -1
- package/dist/contradictions.d.ts +1 -1
- package/dist/contradictions.js +8 -67
- package/dist/contradictions.js.map +1 -1
- 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 +3 -1
- package/dist/edges/index.js.map +1 -1
- package/dist/edges/informs.js +3 -1
- package/dist/edges/informs.js.map +1 -1
- package/dist/edges/refutes.js +3 -1
- 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 +4 -2
- package/dist/edges/utils.js.map +1 -1
- package/dist/embeddingTrigger.js +1 -21
- package/dist/embeddingTrigger.js.map +1 -1
- package/dist/entityBridge.js +1 -1
- package/dist/entityBridge.js.map +1 -1
- package/dist/{entityLifecycle-CvgSK5FV.d.ts → entityLifecycle-BkhRJ-XI.d.ts} +1 -1
- package/dist/entityLifecycle.d.ts +1 -1
- package/dist/entityLifecycle.js +47 -134
- package/dist/entityLifecycle.js.map +1 -1
- package/dist/{epistemicAnswers-C5ib4z6_.d.ts → epistemicAnswers-DSP1slZ9.d.ts} +1 -1
- package/dist/epistemicAnswers.d.ts +1 -1
- package/dist/epistemicAnswers.js +8 -67
- package/dist/epistemicAnswers.js.map +1 -1
- package/dist/{epistemicBeliefs-DzKjZAeC.d.ts → epistemicBeliefs-DtFVTp-k.d.ts} +3 -3
- package/dist/epistemicBeliefs.d.ts +2 -2
- package/dist/epistemicBeliefs.js +114 -289
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicContracts.d.ts +1 -1
- package/dist/epistemicContracts.js +115 -297
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/{epistemicEdges-CvlKnEyy.d.ts → epistemicEdges-DcA8ErUG.d.ts} +1 -1
- package/dist/epistemicEdges.d.ts +1 -1
- package/dist/epistemicEdges.js +60 -192
- package/dist/epistemicEdges.js.map +1 -1
- package/dist/{epistemicEvidence-xw6UUrwh.d.ts → epistemicEvidence-Bo638XDP.d.ts} +1 -1
- package/dist/epistemicEvidence.d.ts +1 -1
- package/dist/epistemicEvidence.js +49 -163
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/{epistemicHelpers-DevrYgPN.d.ts → epistemicHelpers-Bd9xbaib.d.ts} +1 -1
- package/dist/epistemicHelpers.d.ts +1 -1
- package/dist/{epistemicLinking-CfE00tHJ.d.ts → epistemicLinking-CyeLOIzN.d.ts} +1 -1
- package/dist/epistemicLinking.d.ts +1 -1
- package/dist/epistemicLinking.js +1 -1
- package/dist/{epistemicNodes-DjSUfvyD.d.ts → epistemicNodes-BpD6Koud.d.ts} +1 -1
- package/dist/epistemicNodes.d.ts +1 -1
- package/dist/epistemicNodes.js +33 -163
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/{epistemicQuestions-B_nUclrH.d.ts → epistemicQuestions-CmEeY6zQ.d.ts} +1 -1
- package/dist/epistemicQuestions.d.ts +1 -1
- package/dist/epistemicQuestions.js +62 -311
- package/dist/epistemicQuestions.js.map +1 -1
- package/dist/{epistemicSources-dlKj58Jp.d.ts → epistemicSources-ZazxHOK1.d.ts} +1 -1
- package/dist/epistemicSources.d.ts +1 -1
- package/dist/epistemicSources.js +8 -65
- package/dist/epistemicSources.js.map +1 -1
- package/dist/evaluators/index.js +115 -297
- 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 +1 -20
- package/dist/evaluators/shared.js.map +1 -1
- package/dist/evaluators/testRunnerEvaluator.js +1 -20
- 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 +206 -729
- package/dist/index.js.map +1 -1
- package/dist/{ontology-matching-C6rrz2VP.d.ts → ontology-matching-Buhu23ss.d.ts} +1 -1
- package/dist/ontology-matching.d.ts +1 -1
- package/dist/{ontologyApproval-CFYmqKmk.d.ts → ontologyApproval-Ba0Jjk1k.d.ts} +1 -1
- package/dist/ontologyApproval.d.ts +1 -1
- package/dist/ontologyDefinitions.js +3 -4
- package/dist/ontologyDefinitions.js.map +1 -1
- package/dist/ontologyHelpers.d.ts +1 -1
- package/dist/ontologyHelpers.js +3 -4
- package/dist/ontologyHelpers.js.map +1 -1
- package/dist/{projectionReconciliation-jww2fBI0.d.ts → projectionReconciliation-CxrXYGaB.d.ts} +1 -1
- package/dist/projectionReconciliation.d.ts +1 -1
- package/dist/projectionReconciliation.js +20 -14
- package/dist/projectionReconciliation.js.map +1 -1
- package/dist/{projectionStaleness-CmdbpjVK.d.ts → projectionStaleness-CAdpIsaW.d.ts} +1 -1
- package/dist/projectionStaleness.d.ts +1 -1
- package/dist/{questionEvidenceLinks-DFlyPpAj.d.ts → questionEvidenceLinks-BdQD0TkM.d.ts} +1 -1
- package/dist/questionEvidenceLinks.d.ts +1 -1
- package/dist/questionEvidenceLinks.js +45 -144
- package/dist/questionEvidenceLinks.js.map +1 -1
- package/dist/resolvers.js +37 -86
- package/dist/resolvers.js.map +1 -1
- package/dist/scopeResolverCompat.js +7 -64
- package/dist/scopeResolverCompat.js.map +1 -1
- package/dist/{text-matching-DNg4M5Wd.d.ts → text-matching-CMn2WnVD.d.ts} +1 -1
- package/dist/text-matching.d.ts +1 -1
- package/dist/topicProjectOverlay.js +13 -56
- package/dist/topicProjectOverlay.js.map +1 -1
- package/dist/topicScope.js +6 -55
- package/dist/topicScope.js.map +1 -1
- package/dist/workflowBridge.js +6 -55
- package/dist/workflowBridge.js.map +1 -1
- package/dist/workspaceIsolation.js +6 -55
- package/dist/workspaceIsolation.js.map +1 -1
- package/package.json +5 -5
- package/dist/debug.d.ts +0 -4
- package/dist/debug.js +0 -34
- package/dist/debug.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { v } from 'convex/values';
|
|
|
2
2
|
import { getRescoringSchedule, 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, computeEffectiveDecay, computeDeadlineUrgency, computeBaseDecay, bayesianUpdate, DECAY_TIERS, DEADLINE_URGENCY } from '@lucern/confidence';
|
|
3
3
|
import { getAccessibleProjectIds, checkProjectAccess, requireProjectAccess, checkScopeAccess } from '@lucern/access-control/access';
|
|
4
4
|
import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
|
|
5
|
-
import { componentsGeneric,
|
|
5
|
+
import { componentsGeneric, queryGeneric, mutationGeneric, anyApi, internalMutationGeneric, internalQueryGeneric, internalActionGeneric } from 'convex/server';
|
|
6
6
|
import { getCurrentUserId } from '@lucern/access-control/auth';
|
|
7
7
|
import { canAudienceClassAccess, normalizeAudienceKey, classFromAudienceKey } from '@lucern/access-control/audience';
|
|
8
8
|
import { listAudienceRegistryRows } from '@lucern/access-control/audienceRegistry';
|
|
@@ -40,37 +40,6 @@ var internalQuery = internalQueryGeneric;
|
|
|
40
40
|
var mutation = mutationGeneric;
|
|
41
41
|
var query = queryGeneric;
|
|
42
42
|
|
|
43
|
-
// src/debug.ts
|
|
44
|
-
function isGraphPrimitiveDebugEnabled() {
|
|
45
|
-
const env = globalThis.process?.env;
|
|
46
|
-
return env?.LUCERN_COMPAT_FALLBACK_DEBUG === "1" || env?.LUCERN_GRAPH_DEBUG === "1";
|
|
47
|
-
}
|
|
48
|
-
function formatGraphPrimitiveError(error) {
|
|
49
|
-
if (error instanceof Error) {
|
|
50
|
-
return `${error.name}: ${error.message}`;
|
|
51
|
-
}
|
|
52
|
-
if (typeof error === "string") {
|
|
53
|
-
return error;
|
|
54
|
-
}
|
|
55
|
-
if (error === null) {
|
|
56
|
-
return "null";
|
|
57
|
-
}
|
|
58
|
-
if (error === void 0) {
|
|
59
|
-
return "undefined";
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
return JSON.stringify(error);
|
|
63
|
-
} catch {
|
|
64
|
-
return Object.prototype.toString.call(error);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function debugGraphPrimitiveFallback(message, context) {
|
|
68
|
-
if (!isGraphPrimitiveDebugEnabled()) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
console.debug(message, context ?? {});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
43
|
// src/resolvers.ts
|
|
75
44
|
var resolvers_exports = {};
|
|
76
45
|
__export(resolvers_exports, {
|
|
@@ -124,37 +93,19 @@ function isProjectLikeTopic(topic) {
|
|
|
124
93
|
return topic.type === "theme" || topic.type === "thematic" || topic.type === "deal" || topic.type === "monitoring" || readLegacyProjectId(topic) !== void 0 || readNonEmptyString(metadata.projectType) !== void 0;
|
|
125
94
|
}
|
|
126
95
|
function isMissingLucernChildComponentError(error) {
|
|
127
|
-
const message =
|
|
96
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
128
97
|
return message.includes(
|
|
129
98
|
'Child component ComponentName(Identifier("lucern")) not found'
|
|
130
99
|
) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
|
|
131
100
|
}
|
|
132
|
-
function getErrorMessage(error) {
|
|
133
|
-
if (error instanceof Error) {
|
|
134
|
-
return error.message;
|
|
135
|
-
}
|
|
136
|
-
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
137
|
-
return error.message;
|
|
138
|
-
}
|
|
139
|
-
return "unknown error";
|
|
140
|
-
}
|
|
141
101
|
async function resolveTopicDoc(ctx, scopeId) {
|
|
142
102
|
if (ctx?.db && typeof ctx.db.get === "function") {
|
|
143
103
|
try {
|
|
144
|
-
const directTopic = await ctx.db.get(
|
|
145
|
-
scopeId
|
|
146
|
-
);
|
|
104
|
+
const directTopic = await ctx.db.get(scopeId);
|
|
147
105
|
if (directTopic) {
|
|
148
106
|
return directTopic;
|
|
149
107
|
}
|
|
150
|
-
} catch
|
|
151
|
-
debugGraphPrimitiveFallback(
|
|
152
|
-
"[topicProjectOverlay] Failed to resolve topic by direct ID",
|
|
153
|
-
{
|
|
154
|
-
error,
|
|
155
|
-
scopeId
|
|
156
|
-
}
|
|
157
|
-
);
|
|
108
|
+
} catch {
|
|
158
109
|
}
|
|
159
110
|
}
|
|
160
111
|
if (typeof ctx.runQuery !== "function") {
|
|
@@ -167,14 +118,7 @@ async function resolveTopicDoc(ctx, scopeId) {
|
|
|
167
118
|
if (topic?.name !== void 0 && topic?.type !== void 0) {
|
|
168
119
|
return topic;
|
|
169
120
|
}
|
|
170
|
-
} catch
|
|
171
|
-
debugGraphPrimitiveFallback(
|
|
172
|
-
"[topicProjectOverlay] Failed to resolve topic by ID query",
|
|
173
|
-
{
|
|
174
|
-
error,
|
|
175
|
-
scopeId
|
|
176
|
-
}
|
|
177
|
-
);
|
|
121
|
+
} catch {
|
|
178
122
|
}
|
|
179
123
|
try {
|
|
180
124
|
const topic = await ctx.runQuery(api.topics.getByLegacyScopeId, {
|
|
@@ -183,11 +127,7 @@ async function resolveTopicDoc(ctx, scopeId) {
|
|
|
183
127
|
if (topic?.name !== void 0 && topic?.type !== void 0) {
|
|
184
128
|
return topic;
|
|
185
129
|
}
|
|
186
|
-
} catch
|
|
187
|
-
debugGraphPrimitiveFallback(
|
|
188
|
-
"[topicProjectOverlay] Failed to resolve topic by legacy scope ID",
|
|
189
|
-
{ error, scopeId }
|
|
190
|
-
);
|
|
130
|
+
} catch {
|
|
191
131
|
}
|
|
192
132
|
return null;
|
|
193
133
|
}
|
|
@@ -241,11 +181,7 @@ async function listTopicProjectOverlays(ctx, options = {}) {
|
|
|
241
181
|
if (ctx?.db?.query && typeof ctx.db.query === "function") {
|
|
242
182
|
try {
|
|
243
183
|
allTopics = await ctx.db.query("topics").collect();
|
|
244
|
-
} catch
|
|
245
|
-
debugGraphPrimitiveFallback(
|
|
246
|
-
"[topicProjectOverlay] Failed to read topics table; falling back to API",
|
|
247
|
-
{ error }
|
|
248
|
-
);
|
|
184
|
+
} catch {
|
|
249
185
|
allTopics = [];
|
|
250
186
|
}
|
|
251
187
|
}
|
|
@@ -340,28 +276,19 @@ async function patchTopicProjectOverlay(ctx, scopeId, value) {
|
|
|
340
276
|
"Cannot patch topic without component adapter (ctx.runMutation unavailable)"
|
|
341
277
|
);
|
|
342
278
|
}
|
|
343
|
-
return materializeTopicProjectOverlay(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
279
|
+
return materializeTopicProjectOverlay(
|
|
280
|
+
{
|
|
281
|
+
...topic,
|
|
282
|
+
...patch,
|
|
283
|
+
metadata: nextMetadata
|
|
284
|
+
}
|
|
285
|
+
);
|
|
348
286
|
}
|
|
349
287
|
|
|
350
288
|
// src/resolvers.ts
|
|
351
289
|
function isMissingLucernChildComponentError2(error) {
|
|
352
|
-
const message =
|
|
353
|
-
return message.includes(
|
|
354
|
-
'Child component ComponentName(Identifier("lucern")) not found'
|
|
355
|
-
) || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
|
|
356
|
-
}
|
|
357
|
-
function getErrorMessage2(error) {
|
|
358
|
-
if (error instanceof Error) {
|
|
359
|
-
return error.message;
|
|
360
|
-
}
|
|
361
|
-
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
362
|
-
return error.message;
|
|
363
|
-
}
|
|
364
|
-
return "unknown error";
|
|
290
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
291
|
+
return message.includes('Child component ComponentName(Identifier("lucern")) not found') || message.includes("Child component") && message.includes("lucern") && message.includes("not found");
|
|
365
292
|
}
|
|
366
293
|
function isAdvisoryTopicPatch(value) {
|
|
367
294
|
const advisoryKeys = /* @__PURE__ */ new Set(["lastActivityAt", "updatedAt"]);
|
|
@@ -375,27 +302,32 @@ async function patchProjectWithTolerance(ctx, projectId, value) {
|
|
|
375
302
|
if (!isAdvisoryTopicPatch(value) || !isMissingLucernChildComponentError2(error)) {
|
|
376
303
|
throw error;
|
|
377
304
|
}
|
|
378
|
-
console.warn(
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
error: getErrorMessage2(error)
|
|
384
|
-
}
|
|
385
|
-
);
|
|
305
|
+
console.warn("[lucern graph-primitives] Non-fatal advisory topic patch failure", {
|
|
306
|
+
projectId,
|
|
307
|
+
keys: Object.keys(value),
|
|
308
|
+
error: error instanceof Error ? error.message : error
|
|
309
|
+
});
|
|
386
310
|
}
|
|
387
311
|
}
|
|
388
312
|
function defaultResolvers() {
|
|
389
313
|
return {
|
|
390
|
-
getProject
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
314
|
+
async getProject(ctx, projectId) {
|
|
315
|
+
return await resolveTopicProjectOverlay(ctx, projectId, {
|
|
316
|
+
idMode: "legacy",
|
|
317
|
+
projectLikeOnly: false
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
async patchProject(ctx, projectId, value) {
|
|
321
|
+
await patchProjectWithTolerance(ctx, projectId, value);
|
|
322
|
+
},
|
|
323
|
+
async listTopics(ctx) {
|
|
324
|
+
return await listTopicProjectOverlays(ctx, {
|
|
325
|
+
idMode: "legacy"
|
|
326
|
+
});
|
|
327
|
+
},
|
|
328
|
+
async getFinalArtifact(ctx, artifactId) {
|
|
329
|
+
return await ctx.db.get(artifactId);
|
|
330
|
+
}
|
|
399
331
|
};
|
|
400
332
|
}
|
|
401
333
|
var resolverOverrides = {};
|
|
@@ -463,14 +395,7 @@ async function findTopicsByScopeAlias(ctx, scopeId) {
|
|
|
463
395
|
"by_graph_scope_project",
|
|
464
396
|
(q) => q.eq(LEGACY_SCOPE_FIELD2, scopeId)
|
|
465
397
|
).collect();
|
|
466
|
-
} catch
|
|
467
|
-
debugGraphPrimitiveFallback(
|
|
468
|
-
"[topicScope] Failed to resolve scope alias via index",
|
|
469
|
-
{
|
|
470
|
-
error,
|
|
471
|
-
scopeId
|
|
472
|
-
}
|
|
473
|
-
);
|
|
398
|
+
} catch {
|
|
474
399
|
const topics = await ctx.db.query("topics").collect();
|
|
475
400
|
return topics.filter((topic) => {
|
|
476
401
|
const normalizedGlobalId = normalizeScopeValue(topic.globalId);
|
|
@@ -487,14 +412,7 @@ async function tryResolveHostTopicById(ctx, topicId) {
|
|
|
487
412
|
return await ctx.runQuery(api.topics.get, {
|
|
488
413
|
id: topicId
|
|
489
414
|
}) ?? null;
|
|
490
|
-
} catch
|
|
491
|
-
debugGraphPrimitiveFallback(
|
|
492
|
-
"[topicScope] Failed to resolve topic by host query",
|
|
493
|
-
{
|
|
494
|
-
error,
|
|
495
|
-
topicId
|
|
496
|
-
}
|
|
497
|
-
);
|
|
415
|
+
} catch {
|
|
498
416
|
return null;
|
|
499
417
|
}
|
|
500
418
|
}
|
|
@@ -506,14 +424,7 @@ async function tryResolveHostTopicByLegacyScope(ctx, legacyScopeId) {
|
|
|
506
424
|
return await ctx.runQuery(api.topics.getByLegacyScopeId, {
|
|
507
425
|
projectId: legacyScopeId
|
|
508
426
|
}) ?? null;
|
|
509
|
-
} catch
|
|
510
|
-
debugGraphPrimitiveFallback(
|
|
511
|
-
"[topicScope] Failed to resolve topic by legacy scope",
|
|
512
|
-
{
|
|
513
|
-
error,
|
|
514
|
-
legacyScopeId
|
|
515
|
-
}
|
|
516
|
-
);
|
|
427
|
+
} catch {
|
|
517
428
|
return null;
|
|
518
429
|
}
|
|
519
430
|
}
|
|
@@ -550,17 +461,8 @@ async function resolveTopicProjectScope(ctx, args) {
|
|
|
550
461
|
if (args.topicId) {
|
|
551
462
|
let topic = null;
|
|
552
463
|
try {
|
|
553
|
-
topic = await ctx.db.get(
|
|
554
|
-
|
|
555
|
-
);
|
|
556
|
-
} catch (error) {
|
|
557
|
-
debugGraphPrimitiveFallback(
|
|
558
|
-
"[topicScope] Failed to load topic by direct id",
|
|
559
|
-
{
|
|
560
|
-
error,
|
|
561
|
-
topicId: args.topicId
|
|
562
|
-
}
|
|
563
|
-
);
|
|
464
|
+
topic = await ctx.db.get(args.topicId);
|
|
465
|
+
} catch {
|
|
564
466
|
}
|
|
565
467
|
if (!topic) {
|
|
566
468
|
topic = await tryResolveHostTopicById(ctx, String(args.topicId));
|
|
@@ -597,14 +499,7 @@ async function resolveTopicProjectScope(ctx, args) {
|
|
|
597
499
|
directTopic = await ctx.db.get(
|
|
598
500
|
args.projectId
|
|
599
501
|
);
|
|
600
|
-
} catch
|
|
601
|
-
debugGraphPrimitiveFallback(
|
|
602
|
-
"[topicScope] Failed to load direct project topic",
|
|
603
|
-
{
|
|
604
|
-
error,
|
|
605
|
-
projectId: args.projectId
|
|
606
|
-
}
|
|
607
|
-
);
|
|
502
|
+
} catch {
|
|
608
503
|
}
|
|
609
504
|
if (directTopic) {
|
|
610
505
|
const inherited = await resolveInheritedWorkspaceScope(ctx, directTopic);
|
|
@@ -672,20 +567,7 @@ var identifyBeliefsNeedingRescore = query({
|
|
|
672
567
|
returns: permissiveReturn,
|
|
673
568
|
handler: async (ctx, args) => {
|
|
674
569
|
const { maxResults = 20, minPriority = "medium" } = args;
|
|
675
|
-
|
|
676
|
-
try {
|
|
677
|
-
scope = await resolveTopicProjectScope(ctx, args);
|
|
678
|
-
} catch (error) {
|
|
679
|
-
debugGraphPrimitiveFallback(
|
|
680
|
-
"[beliefDecay] Failed to resolve scope for identify beliefs",
|
|
681
|
-
{
|
|
682
|
-
error,
|
|
683
|
-
projectId: args.projectId,
|
|
684
|
-
topicId: args.topicId
|
|
685
|
-
}
|
|
686
|
-
);
|
|
687
|
-
scope = null;
|
|
688
|
-
}
|
|
570
|
+
const scope = await resolveTopicProjectScope(ctx, args).catch(() => null);
|
|
689
571
|
if (!scope) {
|
|
690
572
|
return [];
|
|
691
573
|
}
|
|
@@ -788,21 +670,9 @@ var getGlobalBeliefHealth = query({
|
|
|
788
670
|
);
|
|
789
671
|
const allResults = [];
|
|
790
672
|
for (const project3 of accessibleProjects.slice(0, 20)) {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
projectId: String(project3._id)
|
|
795
|
-
});
|
|
796
|
-
} catch (error) {
|
|
797
|
-
debugGraphPrimitiveFallback(
|
|
798
|
-
"[beliefDecay] Failed to resolve project scope in health query",
|
|
799
|
-
{
|
|
800
|
-
error,
|
|
801
|
-
projectId: String(project3._id)
|
|
802
|
-
}
|
|
803
|
-
);
|
|
804
|
-
continue;
|
|
805
|
-
}
|
|
673
|
+
const scope = await resolveTopicProjectScope(ctx, {
|
|
674
|
+
projectId: String(project3._id)
|
|
675
|
+
}).catch(() => null);
|
|
806
676
|
if (!scope) {
|
|
807
677
|
continue;
|
|
808
678
|
}
|
|
@@ -1000,15 +870,7 @@ async function resolveScope(ctx, args) {
|
|
|
1000
870
|
topicId,
|
|
1001
871
|
projectId
|
|
1002
872
|
});
|
|
1003
|
-
} catch
|
|
1004
|
-
debugGraphPrimitiveFallback(
|
|
1005
|
-
"[scopeResolverCompat] Failed to resolve scope",
|
|
1006
|
-
{
|
|
1007
|
-
error,
|
|
1008
|
-
topicId,
|
|
1009
|
-
projectId
|
|
1010
|
-
}
|
|
1011
|
-
);
|
|
873
|
+
} catch {
|
|
1012
874
|
return null;
|
|
1013
875
|
}
|
|
1014
876
|
}
|
|
@@ -2372,7 +2234,9 @@ function propagateNegativeSupportWithMetadata(sourceOpinion, targetOpinion, edge
|
|
|
2372
2234
|
readEdgeMetadata(edge)
|
|
2373
2235
|
);
|
|
2374
2236
|
}
|
|
2375
|
-
|
|
2237
|
+
function propagateNegativeInform(sourceOpinion, targetOpinion, edgeWeight) {
|
|
2238
|
+
return applyNegativeEvidence(sourceOpinion, targetOpinion, edgeWeight);
|
|
2239
|
+
}
|
|
2376
2240
|
|
|
2377
2241
|
// src/edges/contradicts.ts
|
|
2378
2242
|
var contradictsPropagationSpec = {
|
|
@@ -3583,10 +3447,9 @@ var ONTOLOGICAL_NODE_TYPES = [
|
|
|
3583
3447
|
"function",
|
|
3584
3448
|
"value_chain"
|
|
3585
3449
|
];
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
);
|
|
3450
|
+
function isOntologicalNodeType(nodeType) {
|
|
3451
|
+
return ONTOLOGICAL_NODE_TYPES.includes(nodeType);
|
|
3452
|
+
}
|
|
3590
3453
|
function normalizeCanonicalEntityText(value) {
|
|
3591
3454
|
return value.trim().toLowerCase().replace(/\s+/g, " ");
|
|
3592
3455
|
}
|
|
@@ -4556,15 +4419,7 @@ async function scheduleEmbeddingGeneration(args) {
|
|
|
4556
4419
|
confidence: args.confidence
|
|
4557
4420
|
}
|
|
4558
4421
|
);
|
|
4559
|
-
} catch
|
|
4560
|
-
debugGraphPrimitiveFallback(
|
|
4561
|
-
"[embeddingTrigger] Failed to schedule embedding generation",
|
|
4562
|
-
{
|
|
4563
|
-
error,
|
|
4564
|
-
nodeId: String(args.nodeId),
|
|
4565
|
-
nodeType: args.nodeType
|
|
4566
|
-
}
|
|
4567
|
-
);
|
|
4422
|
+
} catch {
|
|
4568
4423
|
}
|
|
4569
4424
|
}
|
|
4570
4425
|
|
|
@@ -4698,15 +4553,6 @@ function buildBeliefConfidenceRow(args) {
|
|
|
4698
4553
|
...args.triggeringWorktreeId ? { triggeringWorktreeId: args.triggeringWorktreeId } : {}
|
|
4699
4554
|
};
|
|
4700
4555
|
}
|
|
4701
|
-
function buildBeliefStatusSuccessResult() {
|
|
4702
|
-
return { success: true };
|
|
4703
|
-
}
|
|
4704
|
-
function buildBeliefEvidenceNotFoundResult() {
|
|
4705
|
-
const result = {};
|
|
4706
|
-
result.success = false;
|
|
4707
|
-
result.message = "Evidence node not found";
|
|
4708
|
-
return result;
|
|
4709
|
-
}
|
|
4710
4556
|
function deriveSyntheticBackfillOpinion(source) {
|
|
4711
4557
|
const belief = readFiniteNumber(source.opinion_b) ?? readFiniteNumber(source.belief);
|
|
4712
4558
|
const disbelief = readFiniteNumber(source.opinion_d) ?? readFiniteNumber(source.disbelief);
|
|
@@ -4715,13 +4561,7 @@ function deriveSyntheticBackfillOpinion(source) {
|
|
|
4715
4561
|
if (belief !== void 0 || disbelief !== void 0 || uncertainty !== void 0 || baseRate !== void 0) {
|
|
4716
4562
|
try {
|
|
4717
4563
|
return readOpinionFromRecord(source);
|
|
4718
|
-
} catch
|
|
4719
|
-
debugGraphPrimitiveFallback(
|
|
4720
|
-
"[epistemicBeliefs] Failed to decode legacy belief opinion",
|
|
4721
|
-
{
|
|
4722
|
-
error
|
|
4723
|
-
}
|
|
4724
|
-
);
|
|
4564
|
+
} catch {
|
|
4725
4565
|
return mkOpinion(0, 0, 1, 0.5);
|
|
4726
4566
|
}
|
|
4727
4567
|
}
|
|
@@ -4749,14 +4589,7 @@ function readBeliefOpinionSnapshot(node, metadata) {
|
|
|
4749
4589
|
opinion_u: node.opinion_u,
|
|
4750
4590
|
opinion_a: node.opinion_a
|
|
4751
4591
|
});
|
|
4752
|
-
} catch
|
|
4753
|
-
debugGraphPrimitiveFallback(
|
|
4754
|
-
"[epistemicBeliefs] Failed to read belief opinion snapshot",
|
|
4755
|
-
{
|
|
4756
|
-
error,
|
|
4757
|
-
beliefId: node._id
|
|
4758
|
-
}
|
|
4759
|
-
);
|
|
4592
|
+
} catch {
|
|
4760
4593
|
return mkOpinion(0, 0, 1, 0.5);
|
|
4761
4594
|
}
|
|
4762
4595
|
}
|
|
@@ -4849,15 +4682,7 @@ async function resolveBeliefScopeOrNull(ctx, args) {
|
|
|
4849
4682
|
projectId: args.projectId ?? void 0,
|
|
4850
4683
|
topicId: args.topicId ?? void 0
|
|
4851
4684
|
});
|
|
4852
|
-
} catch
|
|
4853
|
-
debugGraphPrimitiveFallback(
|
|
4854
|
-
"[epistemicBeliefs] Failed to resolve belief scope",
|
|
4855
|
-
{
|
|
4856
|
-
error,
|
|
4857
|
-
projectId: args.projectId,
|
|
4858
|
-
topicId: args.topicId
|
|
4859
|
-
}
|
|
4860
|
-
);
|
|
4685
|
+
} catch {
|
|
4861
4686
|
return null;
|
|
4862
4687
|
}
|
|
4863
4688
|
}
|
|
@@ -4957,13 +4782,7 @@ async function getActiveConfidencePolicy(ctx) {
|
|
|
4957
4782
|
activeConfig?.tupleContradictionPolicy
|
|
4958
4783
|
)
|
|
4959
4784
|
};
|
|
4960
|
-
} catch
|
|
4961
|
-
debugGraphPrimitiveFallback(
|
|
4962
|
-
"[epistemicBeliefs] Failed to load active confidence policy",
|
|
4963
|
-
{
|
|
4964
|
-
error
|
|
4965
|
-
}
|
|
4966
|
-
);
|
|
4785
|
+
} catch {
|
|
4967
4786
|
return DEFAULT_CONFIDENCE_POLICY;
|
|
4968
4787
|
}
|
|
4969
4788
|
}
|
|
@@ -5000,11 +4819,7 @@ async function applyBeliefConfidenceChange(ctx, args) {
|
|
|
5000
4819
|
details: { nodeId: args.nodeId }
|
|
5001
4820
|
});
|
|
5002
4821
|
}
|
|
5003
|
-
await requireProjectWriteAccess2(
|
|
5004
|
-
ctx,
|
|
5005
|
-
node.projectId,
|
|
5006
|
-
args.authenticatedUserId
|
|
5007
|
-
);
|
|
4822
|
+
await requireProjectWriteAccess2(ctx, node.projectId, args.authenticatedUserId);
|
|
5008
4823
|
const existingMetadata = node.metadata || {};
|
|
5009
4824
|
const currentBeliefStatus = resolveBeliefStatus(node, existingMetadata);
|
|
5010
4825
|
const confidencePolicy = await getActiveConfidencePolicy(ctx);
|
|
@@ -5048,29 +4863,29 @@ async function applyBeliefConfidenceChange(ctx, args) {
|
|
|
5048
4863
|
opinion: nextOpinion,
|
|
5049
4864
|
policy: tupleTransition.policy
|
|
5050
4865
|
});
|
|
5051
|
-
const newBeliefStatus = promoteBeliefStatusAfterScoring(
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
4866
|
+
const newBeliefStatus = promoteBeliefStatusAfterScoring(
|
|
4867
|
+
currentBeliefStatus,
|
|
4868
|
+
{
|
|
4869
|
+
confidence: derivedConfidence,
|
|
4870
|
+
predictionMeta,
|
|
4871
|
+
metadata: existingMetadata
|
|
4872
|
+
}
|
|
4873
|
+
);
|
|
5056
4874
|
let tupleContradictionId;
|
|
5057
4875
|
if (tupleTransition.crossedIntoTupleContradiction) {
|
|
5058
|
-
tupleContradictionId = await ctx.runMutation(
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
createdBy: args.authenticatedUserId
|
|
5072
|
-
}
|
|
5073
|
-
);
|
|
4876
|
+
tupleContradictionId = await ctx.runMutation("contradictions:create", {
|
|
4877
|
+
projectId: node.projectId,
|
|
4878
|
+
topicId: node.topicId,
|
|
4879
|
+
beliefId: args.nodeId,
|
|
4880
|
+
beliefBId: args.nodeId,
|
|
4881
|
+
supportingInsightIds: [],
|
|
4882
|
+
contradictingInsightIds: [],
|
|
4883
|
+
severity: deriveTupleContradictionSeverity(node),
|
|
4884
|
+
source: "tuple_space",
|
|
4885
|
+
detectionMethod: "agent",
|
|
4886
|
+
description: tupleContradictionDescription,
|
|
4887
|
+
createdBy: args.authenticatedUserId
|
|
4888
|
+
});
|
|
5074
4889
|
}
|
|
5075
4890
|
await ctx.db.patch(args.nodeId, {
|
|
5076
4891
|
confidence: derivedConfidence,
|
|
@@ -5094,10 +4909,7 @@ async function applyBeliefConfidenceChange(ctx, args) {
|
|
|
5094
4909
|
});
|
|
5095
4910
|
if (isFirstScoring) {
|
|
5096
4911
|
const nodeTopicId = node.topicId;
|
|
5097
|
-
const themeNodes = await ctx.db.query("epistemicNodes").withIndex(
|
|
5098
|
-
"by_topic",
|
|
5099
|
-
(q) => q.eq("topicId", nodeTopicId || node.projectId)
|
|
5100
|
-
).filter((q) => q.eq(q.field("nodeType"), "theme")).collect();
|
|
4912
|
+
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();
|
|
5101
4913
|
for (const theme of themeNodes) {
|
|
5102
4914
|
if (theme.globalId && node.globalId) {
|
|
5103
4915
|
await ctx.scheduler.runAfter(0, internal.neo4jEdgeAPI.createEdge, {
|
|
@@ -5695,15 +5507,7 @@ var getByProject3 = query({
|
|
|
5695
5507
|
projectId: args.projectId,
|
|
5696
5508
|
topicId: args.topicId
|
|
5697
5509
|
});
|
|
5698
|
-
} catch
|
|
5699
|
-
debugGraphPrimitiveFallback(
|
|
5700
|
-
"[epistemicBeliefs] Failed to resolve project scope",
|
|
5701
|
-
{
|
|
5702
|
-
error,
|
|
5703
|
-
projectId: args.projectId,
|
|
5704
|
-
topicId: args.topicId
|
|
5705
|
-
}
|
|
5706
|
-
);
|
|
5510
|
+
} catch {
|
|
5707
5511
|
return [];
|
|
5708
5512
|
}
|
|
5709
5513
|
if (args.userId) {
|
|
@@ -5747,9 +5551,7 @@ var getByTopic = query({
|
|
|
5747
5551
|
handler: async (ctx, args) => {
|
|
5748
5552
|
const pageSize = clampBeliefLimit(args.limit);
|
|
5749
5553
|
const scanLimit = Math.min(pageSize * 3, MAX_PROJECT_BELIEF_LIMIT);
|
|
5750
|
-
const scope = await resolveTopicProjectScope(ctx, {
|
|
5751
|
-
topicId: args.topicId
|
|
5752
|
-
});
|
|
5554
|
+
const scope = await resolveTopicProjectScope(ctx, { topicId: args.topicId });
|
|
5753
5555
|
const query2 = ctx.db.query("epistemicNodes").withIndex(
|
|
5754
5556
|
"by_topic_type",
|
|
5755
5557
|
(q) => q.eq("topicId", args.topicId).eq("nodeType", "belief")
|
|
@@ -5975,18 +5777,16 @@ var modulateConfidence = mutation({
|
|
|
5975
5777
|
rationale: v.optional(v.string()),
|
|
5976
5778
|
userId: v.string(),
|
|
5977
5779
|
// SL operator provenance (optional — defaults to manual_assessment)
|
|
5978
|
-
slOperator: v.optional(
|
|
5979
|
-
v.
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
)
|
|
5989
|
-
),
|
|
5780
|
+
slOperator: v.optional(v.union(
|
|
5781
|
+
v.literal("cumulative_fusion"),
|
|
5782
|
+
v.literal("averaging_fusion"),
|
|
5783
|
+
v.literal("trust_discount"),
|
|
5784
|
+
v.literal("conditional_deduction"),
|
|
5785
|
+
v.literal("dependency_cascade"),
|
|
5786
|
+
v.literal("negation"),
|
|
5787
|
+
v.literal("constraint_fusion"),
|
|
5788
|
+
v.literal("manual_assessment")
|
|
5789
|
+
)),
|
|
5990
5790
|
triggeringEvidenceId: v.optional(v.id("epistemicNodes")),
|
|
5991
5791
|
triggeringWorktreeId: v.optional(v.string())
|
|
5992
5792
|
},
|
|
@@ -6217,7 +6017,10 @@ var getConfidenceHistory = query({
|
|
|
6217
6017
|
if (!node || node.nodeType !== "belief") {
|
|
6218
6018
|
return [];
|
|
6219
6019
|
}
|
|
6220
|
-
return await ctx.db.query("beliefConfidence").withIndex(
|
|
6020
|
+
return await ctx.db.query("beliefConfidence").withIndex(
|
|
6021
|
+
"by_beliefId_time",
|
|
6022
|
+
(q) => q.eq("beliefId", args.nodeId)
|
|
6023
|
+
).order("asc").collect();
|
|
6221
6024
|
}
|
|
6222
6025
|
});
|
|
6223
6026
|
var getLineage = query({
|
|
@@ -6521,7 +6324,7 @@ var unlinkEvidence = mutation({
|
|
|
6521
6324
|
const now = Date.now();
|
|
6522
6325
|
const evidenceNode = await ctx.db.get(args.insightId);
|
|
6523
6326
|
if (!evidenceNode || evidenceNode.nodeType !== "evidence") {
|
|
6524
|
-
return
|
|
6327
|
+
return { success: false, message: "Evidence node not found" };
|
|
6525
6328
|
}
|
|
6526
6329
|
if (!evidenceNode.projectId) {
|
|
6527
6330
|
throw new Error("Evidence has no project scope");
|
|
@@ -6562,7 +6365,7 @@ var unlinkEvidence = mutation({
|
|
|
6562
6365
|
projectId: evidenceNode.projectId
|
|
6563
6366
|
});
|
|
6564
6367
|
}
|
|
6565
|
-
return
|
|
6368
|
+
return { success: true };
|
|
6566
6369
|
}
|
|
6567
6370
|
});
|
|
6568
6371
|
var getWithEvidence = query({
|
|
@@ -6674,7 +6477,7 @@ var deleteRelationship = mutation({
|
|
|
6674
6477
|
changedAt: now,
|
|
6675
6478
|
projectId: edge.projectId
|
|
6676
6479
|
});
|
|
6677
|
-
return
|
|
6480
|
+
return { success: true };
|
|
6678
6481
|
}
|
|
6679
6482
|
});
|
|
6680
6483
|
var updateCriticality = mutation({
|
|
@@ -6803,23 +6606,13 @@ var batchUpdateCriticality = mutation({
|
|
|
6803
6606
|
changedAt: now,
|
|
6804
6607
|
projectId: node.projectId
|
|
6805
6608
|
});
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
} catch
|
|
6812
|
-
|
|
6813
|
-
"[epistemicBeliefs] Failed to update belief criticality",
|
|
6814
|
-
{
|
|
6815
|
-
error,
|
|
6816
|
-
beliefId: update5.beliefId
|
|
6817
|
-
}
|
|
6818
|
-
);
|
|
6819
|
-
const result = {};
|
|
6820
|
-
result.beliefId = update5.beliefId;
|
|
6821
|
-
result.success = false;
|
|
6822
|
-
results.push(result);
|
|
6609
|
+
results.push({
|
|
6610
|
+
beliefId: update5.beliefId,
|
|
6611
|
+
nodeId: node._id,
|
|
6612
|
+
success: true
|
|
6613
|
+
});
|
|
6614
|
+
} catch {
|
|
6615
|
+
results.push({ beliefId: update5.beliefId, success: false });
|
|
6823
6616
|
}
|
|
6824
6617
|
}
|
|
6825
6618
|
return { results, updatedCount: results.filter((r) => r.success).length };
|
|
@@ -6934,15 +6727,7 @@ var getByPillar = query({
|
|
|
6934
6727
|
projectId: args.projectId,
|
|
6935
6728
|
topicId: args.topicId
|
|
6936
6729
|
});
|
|
6937
|
-
} catch
|
|
6938
|
-
debugGraphPrimitiveFallback(
|
|
6939
|
-
"[epistemicBeliefs] Failed to resolve criticality scope",
|
|
6940
|
-
{
|
|
6941
|
-
error,
|
|
6942
|
-
projectId: args.projectId,
|
|
6943
|
-
topicId: args.topicId
|
|
6944
|
-
}
|
|
6945
|
-
);
|
|
6730
|
+
} catch {
|
|
6946
6731
|
return [];
|
|
6947
6732
|
}
|
|
6948
6733
|
const nodes = await ctx.db.query("epistemicNodes").withIndex(
|
|
@@ -7063,9 +6848,7 @@ var internalGetByTopic = internalQuery({
|
|
|
7063
6848
|
const pageSize = clampBeliefLimit(args.limit, 500);
|
|
7064
6849
|
const scanLimit = Math.min(pageSize * 3, MAX_PROJECT_BELIEF_LIMIT);
|
|
7065
6850
|
const audienceMode = args.audienceMode ?? "internal";
|
|
7066
|
-
const scope = await resolveTopicProjectScope(ctx, {
|
|
7067
|
-
topicId: args.topicId
|
|
7068
|
-
});
|
|
6851
|
+
const scope = await resolveTopicProjectScope(ctx, { topicId: args.topicId });
|
|
7069
6852
|
const registryRows = await listAudienceRegistryRows(ctx, {
|
|
7070
6853
|
tenantId: scope.tenantId,
|
|
7071
6854
|
workspaceId: scope.workspaceId
|
|
@@ -7410,9 +7193,7 @@ var backfillSyntheticOpinionHistory = internalMutation({
|
|
|
7410
7193
|
skippedHasHistory++;
|
|
7411
7194
|
continue;
|
|
7412
7195
|
}
|
|
7413
|
-
const opinion = deriveSyntheticBackfillOpinion(
|
|
7414
|
-
node
|
|
7415
|
-
);
|
|
7196
|
+
const opinion = deriveSyntheticBackfillOpinion(node);
|
|
7416
7197
|
await ctx.db.insert(
|
|
7417
7198
|
"beliefConfidence",
|
|
7418
7199
|
buildBeliefConfidenceRow({
|
|
@@ -7718,13 +7499,7 @@ var getBeliefClusterPositions = query({
|
|
|
7718
7499
|
return {
|
|
7719
7500
|
positions: {},
|
|
7720
7501
|
hasClusters: false,
|
|
7721
|
-
counts: {
|
|
7722
|
-
raw: 0,
|
|
7723
|
-
hypothesis: 0,
|
|
7724
|
-
conditional: 0,
|
|
7725
|
-
unprocessed: 0,
|
|
7726
|
-
total: 0
|
|
7727
|
-
}
|
|
7502
|
+
counts: { raw: 0, hypothesis: 0, conditional: 0, unprocessed: 0, total: 0 }
|
|
7728
7503
|
};
|
|
7729
7504
|
}
|
|
7730
7505
|
const allBeliefNodes = await getBeliefNodesForScope(ctx, scope);
|
|
@@ -7786,8 +7561,14 @@ var reassignBeliefsTopic = mutation({
|
|
|
7786
7561
|
let connectedReassigned = 0;
|
|
7787
7562
|
const alreadyReassigned = /* @__PURE__ */ new Set();
|
|
7788
7563
|
for (const beliefId of movedBeliefIds) {
|
|
7789
|
-
const outbound = await ctx.db.query("epistemicEdges").withIndex(
|
|
7790
|
-
|
|
7564
|
+
const outbound = await ctx.db.query("epistemicEdges").withIndex(
|
|
7565
|
+
"by_from",
|
|
7566
|
+
(q) => q.eq("fromNodeId", beliefId)
|
|
7567
|
+
).collect();
|
|
7568
|
+
const inbound = await ctx.db.query("epistemicEdges").withIndex(
|
|
7569
|
+
"by_to",
|
|
7570
|
+
(q) => q.eq("toNodeId", beliefId)
|
|
7571
|
+
).collect();
|
|
7791
7572
|
const connectedNodeIds = /* @__PURE__ */ new Set();
|
|
7792
7573
|
for (const edge of outbound) {
|
|
7793
7574
|
if (edge.toNodeId) connectedNodeIds.add(String(edge.toNodeId));
|
|
@@ -7810,14 +7591,7 @@ var reassignBeliefsTopic = mutation({
|
|
|
7810
7591
|
alreadyReassigned.add(connectedId);
|
|
7811
7592
|
connectedReassigned++;
|
|
7812
7593
|
}
|
|
7813
|
-
} catch
|
|
7814
|
-
debugGraphPrimitiveFallback(
|
|
7815
|
-
"[epistemicBeliefs] Failed to reassign connected node",
|
|
7816
|
-
{
|
|
7817
|
-
error,
|
|
7818
|
-
connectedId
|
|
7819
|
-
}
|
|
7820
|
-
);
|
|
7594
|
+
} catch {
|
|
7821
7595
|
}
|
|
7822
7596
|
}
|
|
7823
7597
|
}
|
|
@@ -9115,14 +8889,7 @@ function parseJsonCandidate(value) {
|
|
|
9115
8889
|
}
|
|
9116
8890
|
try {
|
|
9117
8891
|
return JSON.parse(value);
|
|
9118
|
-
} catch
|
|
9119
|
-
debugGraphPrimitiveFallback(
|
|
9120
|
-
"[evaluators/shared] Failed to parse JSON candidate",
|
|
9121
|
-
{
|
|
9122
|
-
error,
|
|
9123
|
-
valueType: typeof value
|
|
9124
|
-
}
|
|
9125
|
-
);
|
|
8892
|
+
} catch {
|
|
9126
8893
|
return null;
|
|
9127
8894
|
}
|
|
9128
8895
|
}
|
|
@@ -10410,34 +10177,6 @@ var edgeTypeValidator = v.union(
|
|
|
10410
10177
|
v.literal("competes_with")
|
|
10411
10178
|
// Company → Company (ontological → ontological)
|
|
10412
10179
|
);
|
|
10413
|
-
function buildEdgeStatusSuccessResult() {
|
|
10414
|
-
return { success: true };
|
|
10415
|
-
}
|
|
10416
|
-
function buildEdgeNotFoundResult() {
|
|
10417
|
-
const result = {};
|
|
10418
|
-
result.success = false;
|
|
10419
|
-
result.error = "Edge not found";
|
|
10420
|
-
return result;
|
|
10421
|
-
}
|
|
10422
|
-
function buildEdgeMirrorSkippedResult() {
|
|
10423
|
-
return {
|
|
10424
|
-
success: false,
|
|
10425
|
-
reason: "source_not_in_convex"
|
|
10426
|
-
};
|
|
10427
|
-
}
|
|
10428
|
-
function buildEdgeMirrorMissingResult() {
|
|
10429
|
-
return {
|
|
10430
|
-
success: false,
|
|
10431
|
-
reason: "not_found"
|
|
10432
|
-
};
|
|
10433
|
-
}
|
|
10434
|
-
function buildEdgeMirrorWriteResult(edgeId, existed) {
|
|
10435
|
-
return {
|
|
10436
|
-
success: true,
|
|
10437
|
-
edgeId,
|
|
10438
|
-
existed
|
|
10439
|
-
};
|
|
10440
|
-
}
|
|
10441
10180
|
var get = query({
|
|
10442
10181
|
args: { edgeId: v.id("epistemicEdges") },
|
|
10443
10182
|
returns: permissiveReturn,
|
|
@@ -10589,15 +10328,7 @@ var getByProjectAndType = query({
|
|
|
10589
10328
|
projectId: args.projectId,
|
|
10590
10329
|
topicId: args.topicId
|
|
10591
10330
|
});
|
|
10592
|
-
} catch
|
|
10593
|
-
debugGraphPrimitiveFallback(
|
|
10594
|
-
"[epistemicEdges] Failed to resolve getAll scope",
|
|
10595
|
-
{
|
|
10596
|
-
error,
|
|
10597
|
-
projectId: args.projectId,
|
|
10598
|
-
topicId: args.topicId
|
|
10599
|
-
}
|
|
10600
|
-
);
|
|
10331
|
+
} catch {
|
|
10601
10332
|
return [];
|
|
10602
10333
|
}
|
|
10603
10334
|
const projectEdges = await collectScopedEdges(ctx, scope, 5e3);
|
|
@@ -10623,15 +10354,7 @@ var getByProject4 = query({
|
|
|
10623
10354
|
projectId: args.projectId,
|
|
10624
10355
|
topicId: args.topicId
|
|
10625
10356
|
});
|
|
10626
|
-
} catch
|
|
10627
|
-
debugGraphPrimitiveFallback(
|
|
10628
|
-
"[epistemicEdges] Failed to resolve getByProject scope",
|
|
10629
|
-
{
|
|
10630
|
-
error,
|
|
10631
|
-
projectId: args.projectId,
|
|
10632
|
-
topicId: args.topicId
|
|
10633
|
-
}
|
|
10634
|
-
);
|
|
10357
|
+
} catch {
|
|
10635
10358
|
return [];
|
|
10636
10359
|
}
|
|
10637
10360
|
if (args.userId) {
|
|
@@ -10645,11 +10368,7 @@ var getByProject4 = query({
|
|
|
10645
10368
|
}
|
|
10646
10369
|
}
|
|
10647
10370
|
const pageSize = Math.max(1, Math.min(Math.floor(args.limit ?? 500), 2e3));
|
|
10648
|
-
const edges = await collectScopedEdges(
|
|
10649
|
-
ctx,
|
|
10650
|
-
scope,
|
|
10651
|
-
Math.min(pageSize * 3, 6e3)
|
|
10652
|
-
);
|
|
10371
|
+
const edges = await collectScopedEdges(ctx, scope, Math.min(pageSize * 3, 6e3));
|
|
10653
10372
|
return edges.filter((edge) => edgeMatchesWorkspaceReasoningScope2(edge, scope)).slice(0, pageSize);
|
|
10654
10373
|
}
|
|
10655
10374
|
});
|
|
@@ -10883,7 +10602,7 @@ var update2 = mutation({
|
|
|
10883
10602
|
projectId: edge.projectId
|
|
10884
10603
|
});
|
|
10885
10604
|
}
|
|
10886
|
-
return
|
|
10605
|
+
return { success: true };
|
|
10887
10606
|
}
|
|
10888
10607
|
});
|
|
10889
10608
|
var remove2 = mutation({
|
|
@@ -10895,7 +10614,7 @@ var remove2 = mutation({
|
|
|
10895
10614
|
handler: async (ctx, args) => {
|
|
10896
10615
|
const edge = await ctx.db.get(args.edgeId);
|
|
10897
10616
|
if (!edge) {
|
|
10898
|
-
return
|
|
10617
|
+
return { success: false, error: "Edge not found" };
|
|
10899
10618
|
}
|
|
10900
10619
|
if (edge.projectId && args.userId) {
|
|
10901
10620
|
await requireProjectAccess(ctx, edge.projectId, args.userId);
|
|
@@ -10930,7 +10649,7 @@ var remove2 = mutation({
|
|
|
10930
10649
|
globalId: edge.globalId
|
|
10931
10650
|
});
|
|
10932
10651
|
await ctx.db.delete(args.edgeId);
|
|
10933
|
-
return
|
|
10652
|
+
return { success: true };
|
|
10934
10653
|
}
|
|
10935
10654
|
});
|
|
10936
10655
|
var removeBetween = mutation({
|
|
@@ -11090,7 +10809,9 @@ var getLineage2 = query({
|
|
|
11090
10809
|
}
|
|
11091
10810
|
visited.add(nodeIdStr);
|
|
11092
10811
|
const edges = await ctx.db.query("epistemicEdges").withIndex("by_from", (q) => q.eq("fromNodeId", current.nodeId)).collect();
|
|
11093
|
-
const lineageEdges = edges.filter(
|
|
10812
|
+
const lineageEdges = edges.filter(
|
|
10813
|
+
(e) => e.edgeType === "derived_from"
|
|
10814
|
+
);
|
|
11094
10815
|
for (const edge of lineageEdges) {
|
|
11095
10816
|
if (!edge.toNodeId) {
|
|
11096
10817
|
continue;
|
|
@@ -11291,13 +11012,13 @@ var mirrorEdgeToConvex = internalMutation({
|
|
|
11291
11012
|
console.log(
|
|
11292
11013
|
`[Dual-Write] Skipping mirror - source node not in Convex: ${args.fromGlobalId}`
|
|
11293
11014
|
);
|
|
11294
|
-
return
|
|
11015
|
+
return { success: false, reason: "source_not_in_convex" };
|
|
11295
11016
|
}
|
|
11296
11017
|
const toNode = await ctx.db.query("epistemicNodes").withIndex("by_globalId", (q) => q.eq("globalId", args.toGlobalId)).first();
|
|
11297
11018
|
const existing = await ctx.db.query("epistemicEdges").withIndex("by_globalId", (q) => q.eq("globalId", args.globalId)).first();
|
|
11298
11019
|
if (existing) {
|
|
11299
11020
|
console.log(`[Dual-Write] Edge already exists: ${args.globalId}`);
|
|
11300
|
-
return
|
|
11021
|
+
return { success: true, edgeId: existing._id, existed: true };
|
|
11301
11022
|
}
|
|
11302
11023
|
const now = Date.now();
|
|
11303
11024
|
const edgeId = await ctx.db.insert("epistemicEdges", {
|
|
@@ -11338,7 +11059,7 @@ var mirrorEdgeToConvex = internalMutation({
|
|
|
11338
11059
|
console.log(
|
|
11339
11060
|
`[Dual-Write] Mirrored edge to Convex: ${args.globalId} (${args.edgeType})`
|
|
11340
11061
|
);
|
|
11341
|
-
return
|
|
11062
|
+
return { success: true, edgeId, existed: false };
|
|
11342
11063
|
}
|
|
11343
11064
|
});
|
|
11344
11065
|
var deleteEdgeFromConvex = internalMutation({
|
|
@@ -11349,11 +11070,11 @@ var deleteEdgeFromConvex = internalMutation({
|
|
|
11349
11070
|
handler: async (ctx, args) => {
|
|
11350
11071
|
const existing = await ctx.db.query("epistemicEdges").withIndex("by_globalId", (q) => q.eq("globalId", args.globalId)).first();
|
|
11351
11072
|
if (!existing) {
|
|
11352
|
-
return
|
|
11073
|
+
return { success: false, reason: "not_found" };
|
|
11353
11074
|
}
|
|
11354
11075
|
await ctx.db.delete(existing._id);
|
|
11355
11076
|
console.log(`[Dual-Write] Deleted edge from Convex: ${args.globalId}`);
|
|
11356
|
-
return
|
|
11077
|
+
return { success: true };
|
|
11357
11078
|
}
|
|
11358
11079
|
});
|
|
11359
11080
|
var updateEdgeInConvex = internalMutation({
|
|
@@ -11374,7 +11095,7 @@ var updateEdgeInConvex = internalMutation({
|
|
|
11374
11095
|
handler: async (ctx, args) => {
|
|
11375
11096
|
const existing = await ctx.db.query("epistemicEdges").withIndex("by_globalId", (q) => q.eq("globalId", args.globalId)).first();
|
|
11376
11097
|
if (!existing) {
|
|
11377
|
-
return
|
|
11098
|
+
return { success: false, reason: "not_found" };
|
|
11378
11099
|
}
|
|
11379
11100
|
const updates = {
|
|
11380
11101
|
updatedAt: Date.now()
|
|
@@ -11411,7 +11132,7 @@ var updateEdgeInConvex = internalMutation({
|
|
|
11411
11132
|
}
|
|
11412
11133
|
await ctx.db.patch(existing._id, updates);
|
|
11413
11134
|
console.log(`[Dual-Write] Updated edge in Convex: ${args.globalId}`);
|
|
11414
|
-
return
|
|
11135
|
+
return { success: true };
|
|
11415
11136
|
}
|
|
11416
11137
|
});
|
|
11417
11138
|
|
|
@@ -11544,15 +11265,7 @@ async function resolveEvidenceScopeOrNull(ctx, args) {
|
|
|
11544
11265
|
projectId: args.projectId ?? void 0,
|
|
11545
11266
|
topicId: args.topicId ?? void 0
|
|
11546
11267
|
});
|
|
11547
|
-
} catch
|
|
11548
|
-
debugGraphPrimitiveFallback(
|
|
11549
|
-
"[epistemicEvidence] Failed to resolve evidence scope",
|
|
11550
|
-
{
|
|
11551
|
-
error,
|
|
11552
|
-
projectId: args.projectId,
|
|
11553
|
-
topicId: args.topicId
|
|
11554
|
-
}
|
|
11555
|
-
);
|
|
11268
|
+
} catch {
|
|
11556
11269
|
return null;
|
|
11557
11270
|
}
|
|
11558
11271
|
}
|
|
@@ -11928,15 +11641,7 @@ var getByProject5 = query({
|
|
|
11928
11641
|
projectId: args.projectId,
|
|
11929
11642
|
topicId: args.topicId
|
|
11930
11643
|
});
|
|
11931
|
-
} catch
|
|
11932
|
-
debugGraphPrimitiveFallback(
|
|
11933
|
-
"[epistemicEvidence] Failed to resolve getByProject scope",
|
|
11934
|
-
{
|
|
11935
|
-
error,
|
|
11936
|
-
projectId: args.projectId,
|
|
11937
|
-
topicId: args.topicId
|
|
11938
|
-
}
|
|
11939
|
-
);
|
|
11644
|
+
} catch {
|
|
11940
11645
|
return [];
|
|
11941
11646
|
}
|
|
11942
11647
|
if (args.userId) {
|
|
@@ -11971,9 +11676,7 @@ var getByTopic3 = query({
|
|
|
11971
11676
|
handler: async (ctx, args) => {
|
|
11972
11677
|
const pageSize = clampEvidenceLimit(args.limit);
|
|
11973
11678
|
const scanLimit = Math.min(pageSize * 3, MAX_EVIDENCE_PAGE_SIZE);
|
|
11974
|
-
const scope = await resolveTopicProjectScope(ctx, {
|
|
11975
|
-
topicId: args.topicId
|
|
11976
|
-
});
|
|
11679
|
+
const scope = await resolveTopicProjectScope(ctx, { topicId: args.topicId });
|
|
11977
11680
|
const topicNodes = await ctx.db.query("epistemicNodes").withIndex(
|
|
11978
11681
|
"by_topic_type",
|
|
11979
11682
|
(q) => q.eq("topicId", scope.topicId).eq("nodeType", "evidence")
|
|
@@ -12083,9 +11786,7 @@ var internalGetByTopic2 = internalQuery({
|
|
|
12083
11786
|
const pageSize = clampEvidenceLimit(args.limit, 500);
|
|
12084
11787
|
const scanLimit = Math.min(pageSize * 3, MAX_EVIDENCE_PAGE_SIZE);
|
|
12085
11788
|
const audienceMode = args.audienceMode ?? "internal";
|
|
12086
|
-
const scope = await resolveTopicProjectScope(ctx, {
|
|
12087
|
-
topicId: args.topicId
|
|
12088
|
-
});
|
|
11789
|
+
const scope = await resolveTopicProjectScope(ctx, { topicId: args.topicId });
|
|
12089
11790
|
const registryRows = await listAudienceRegistryRows(ctx, {
|
|
12090
11791
|
tenantId: scope.tenantId,
|
|
12091
11792
|
workspaceId: scope.workspaceId
|
|
@@ -14161,15 +13862,7 @@ var getByProjectAndType2 = query({
|
|
|
14161
13862
|
projectId: args.projectId,
|
|
14162
13863
|
topicId: args.topicId
|
|
14163
13864
|
});
|
|
14164
|
-
} catch
|
|
14165
|
-
debugGraphPrimitiveFallback(
|
|
14166
|
-
"[epistemicNodes] Failed to resolve getByProjectAndType scope",
|
|
14167
|
-
{
|
|
14168
|
-
error,
|
|
14169
|
-
projectId: args.projectId,
|
|
14170
|
-
topicId: args.topicId
|
|
14171
|
-
}
|
|
14172
|
-
);
|
|
13865
|
+
} catch {
|
|
14173
13866
|
return [];
|
|
14174
13867
|
}
|
|
14175
13868
|
const pageSize = clampNodeLimit(args.limit);
|
|
@@ -14206,15 +13899,7 @@ var getByProjectAndTypeLite = query({
|
|
|
14206
13899
|
projectId: args.projectId,
|
|
14207
13900
|
topicId: args.topicId
|
|
14208
13901
|
});
|
|
14209
|
-
} catch
|
|
14210
|
-
debugGraphPrimitiveFallback(
|
|
14211
|
-
"[epistemicNodes] Failed to resolve getByNodeType scope",
|
|
14212
|
-
{
|
|
14213
|
-
error,
|
|
14214
|
-
projectId: args.projectId,
|
|
14215
|
-
topicId: args.topicId
|
|
14216
|
-
}
|
|
14217
|
-
);
|
|
13902
|
+
} catch {
|
|
14218
13903
|
return [];
|
|
14219
13904
|
}
|
|
14220
13905
|
const pageSize = clampNodeLimit(args.limit);
|
|
@@ -14246,27 +13931,6 @@ function clampNodeLimit(limit, fallback = DEFAULT_NODE_PAGE_SIZE) {
|
|
|
14246
13931
|
}
|
|
14247
13932
|
return Math.max(1, Math.min(Math.floor(limit), MAX_NODE_PAGE_SIZE));
|
|
14248
13933
|
}
|
|
14249
|
-
function buildNodeStatusSuccessResult() {
|
|
14250
|
-
return { success: true };
|
|
14251
|
-
}
|
|
14252
|
-
function buildNodeArchivedResult() {
|
|
14253
|
-
return {
|
|
14254
|
-
success: true,
|
|
14255
|
-
effectiveStatus: "archived"
|
|
14256
|
-
};
|
|
14257
|
-
}
|
|
14258
|
-
function buildNodeNotFoundResult() {
|
|
14259
|
-
const result = {};
|
|
14260
|
-
result.success = false;
|
|
14261
|
-
result.error = "Node not found";
|
|
14262
|
-
return result;
|
|
14263
|
-
}
|
|
14264
|
-
function buildNodeDeletedResult(deletedEdgeCount) {
|
|
14265
|
-
return {
|
|
14266
|
-
success: true,
|
|
14267
|
-
deletedEdgeCount
|
|
14268
|
-
};
|
|
14269
|
-
}
|
|
14270
13934
|
function dedupeWorkspaceNodes(nodes) {
|
|
14271
13935
|
const seen = /* @__PURE__ */ new Set();
|
|
14272
13936
|
const deduped = [];
|
|
@@ -14298,13 +13962,14 @@ async function collectScopedNodes(ctx, scope, args) {
|
|
|
14298
13962
|
args.nodeType ? ctx.db.query("epistemicNodes").withIndex(
|
|
14299
13963
|
"by_topic_type",
|
|
14300
13964
|
(q) => q.eq("topicId", scope.projectId).eq("nodeType", args.nodeType)
|
|
14301
|
-
).order("desc").take(args.scanLimit) : ctx.db.query("epistemicNodes").withIndex(
|
|
13965
|
+
).order("desc").take(args.scanLimit) : ctx.db.query("epistemicNodes").withIndex(
|
|
13966
|
+
"by_topic",
|
|
13967
|
+
(q) => q.eq("topicId", scope.projectId)
|
|
13968
|
+
).order("desc").take(args.scanLimit)
|
|
14302
13969
|
);
|
|
14303
13970
|
}
|
|
14304
13971
|
const combined = dedupeWorkspaceNodes((await Promise.all(queries)).flat());
|
|
14305
|
-
return combined.filter(
|
|
14306
|
-
(node) => nodeMatchesWorkspaceReasoningScope2(node, scope)
|
|
14307
|
-
);
|
|
13972
|
+
return combined.filter((node) => nodeMatchesWorkspaceReasoningScope2(node, scope));
|
|
14308
13973
|
}
|
|
14309
13974
|
var getByProject6 = query({
|
|
14310
13975
|
args: {
|
|
@@ -14326,15 +13991,7 @@ var getByProject6 = query({
|
|
|
14326
13991
|
projectId: args.projectId,
|
|
14327
13992
|
topicId: args.topicId
|
|
14328
13993
|
});
|
|
14329
|
-
} catch
|
|
14330
|
-
debugGraphPrimitiveFallback(
|
|
14331
|
-
"[epistemicNodes] Failed to resolve list scope",
|
|
14332
|
-
{
|
|
14333
|
-
error,
|
|
14334
|
-
projectId: args.projectId,
|
|
14335
|
-
topicId: args.topicId
|
|
14336
|
-
}
|
|
14337
|
-
);
|
|
13994
|
+
} catch {
|
|
14338
13995
|
return [];
|
|
14339
13996
|
}
|
|
14340
13997
|
if (args.userId) {
|
|
@@ -14388,15 +14045,7 @@ var search = query({
|
|
|
14388
14045
|
projectId: args.projectId,
|
|
14389
14046
|
topicId: args.topicId
|
|
14390
14047
|
});
|
|
14391
|
-
} catch
|
|
14392
|
-
debugGraphPrimitiveFallback(
|
|
14393
|
-
"[epistemicNodes] Failed to resolve search scope",
|
|
14394
|
-
{
|
|
14395
|
-
error,
|
|
14396
|
-
projectId: args.projectId,
|
|
14397
|
-
topicId: args.topicId
|
|
14398
|
-
}
|
|
14399
|
-
);
|
|
14048
|
+
} catch {
|
|
14400
14049
|
return [];
|
|
14401
14050
|
}
|
|
14402
14051
|
}
|
|
@@ -14623,7 +14272,7 @@ var update4 = mutation({
|
|
|
14623
14272
|
nodeId,
|
|
14624
14273
|
operation: "upsert"
|
|
14625
14274
|
});
|
|
14626
|
-
return
|
|
14275
|
+
return { success: true };
|
|
14627
14276
|
}
|
|
14628
14277
|
});
|
|
14629
14278
|
var supersede = mutation({
|
|
@@ -14745,7 +14394,7 @@ var archive2 = mutation({
|
|
|
14745
14394
|
projectId: node.projectId
|
|
14746
14395
|
});
|
|
14747
14396
|
}
|
|
14748
|
-
return
|
|
14397
|
+
return { success: true, effectiveStatus: "archived" };
|
|
14749
14398
|
}
|
|
14750
14399
|
});
|
|
14751
14400
|
var hardDelete = internalMutation({
|
|
@@ -14759,7 +14408,7 @@ var hardDelete = internalMutation({
|
|
|
14759
14408
|
handler: async (ctx, args) => {
|
|
14760
14409
|
const node = await ctx.db.get(args.nodeId);
|
|
14761
14410
|
if (!node) {
|
|
14762
|
-
return
|
|
14411
|
+
return { success: false, error: "Node not found" };
|
|
14763
14412
|
}
|
|
14764
14413
|
assertBeliefNodeHardDeleteAllowed({
|
|
14765
14414
|
node,
|
|
@@ -14795,7 +14444,10 @@ var hardDelete = internalMutation({
|
|
|
14795
14444
|
await ctx.db.delete(edge._id);
|
|
14796
14445
|
}
|
|
14797
14446
|
await ctx.db.delete(args.nodeId);
|
|
14798
|
-
return
|
|
14447
|
+
return {
|
|
14448
|
+
success: true,
|
|
14449
|
+
deletedEdgeCount: uniqueEdges.size
|
|
14450
|
+
};
|
|
14799
14451
|
}
|
|
14800
14452
|
});
|
|
14801
14453
|
var verify = mutation({
|
|
@@ -14842,7 +14494,7 @@ var verify = mutation({
|
|
|
14842
14494
|
projectId: node.projectId,
|
|
14843
14495
|
triggeringAction: "epistemicNodes.verify"
|
|
14844
14496
|
});
|
|
14845
|
-
return
|
|
14497
|
+
return { success: true };
|
|
14846
14498
|
}
|
|
14847
14499
|
});
|
|
14848
14500
|
var batchCreate2 = mutation({
|
|
@@ -14880,27 +14532,6 @@ var batchCreate2 = mutation({
|
|
|
14880
14532
|
},
|
|
14881
14533
|
returns: permissiveReturn,
|
|
14882
14534
|
handler: async (ctx, args) => {
|
|
14883
|
-
const resolveNodeScope = async (node) => {
|
|
14884
|
-
if (!(node.topicId || node.projectId)) {
|
|
14885
|
-
return void 0;
|
|
14886
|
-
}
|
|
14887
|
-
try {
|
|
14888
|
-
return await resolveTopicProjectScope(ctx, {
|
|
14889
|
-
topicId: node.topicId,
|
|
14890
|
-
projectId: node.projectId
|
|
14891
|
-
});
|
|
14892
|
-
} catch (error) {
|
|
14893
|
-
debugGraphPrimitiveFallback(
|
|
14894
|
-
"[epistemicNodes] Failed to resolve scope for batch create node",
|
|
14895
|
-
{
|
|
14896
|
-
error,
|
|
14897
|
-
topicId: node.topicId,
|
|
14898
|
-
projectId: node.projectId
|
|
14899
|
-
}
|
|
14900
|
-
);
|
|
14901
|
-
return void 0;
|
|
14902
|
-
}
|
|
14903
|
-
};
|
|
14904
14535
|
const now = Date.now();
|
|
14905
14536
|
const results = [];
|
|
14906
14537
|
for (const node of args.nodes) {
|
|
@@ -14909,7 +14540,10 @@ var batchCreate2 = mutation({
|
|
|
14909
14540
|
mutationName: "epistemicNodes.batchCreate"
|
|
14910
14541
|
});
|
|
14911
14542
|
const epistemicLayer = getNodeLayer(node.nodeType);
|
|
14912
|
-
const resolvedScope = await
|
|
14543
|
+
const resolvedScope = node.topicId || node.projectId ? await resolveTopicProjectScope(ctx, {
|
|
14544
|
+
topicId: node.topicId,
|
|
14545
|
+
projectId: node.projectId
|
|
14546
|
+
}).catch(() => void 0) : void 0;
|
|
14913
14547
|
const nodeId = await ctx.db.insert("epistemicNodes", {
|
|
14914
14548
|
...node,
|
|
14915
14549
|
epistemicLayer,
|
|
@@ -14991,24 +14625,10 @@ var createInternal2 = internalMutation({
|
|
|
14991
14625
|
returns: permissiveReturn,
|
|
14992
14626
|
handler: async (ctx, args) => {
|
|
14993
14627
|
const now = Date.now();
|
|
14994
|
-
const resolvedScope = args.topicId || args.projectId ? await (
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
projectId: args.projectId
|
|
14999
|
-
});
|
|
15000
|
-
} catch (error) {
|
|
15001
|
-
debugGraphPrimitiveFallback(
|
|
15002
|
-
"[epistemicNodes] Failed to resolve create scope",
|
|
15003
|
-
{
|
|
15004
|
-
error,
|
|
15005
|
-
topicId: args.topicId,
|
|
15006
|
-
projectId: args.projectId
|
|
15007
|
-
}
|
|
15008
|
-
);
|
|
15009
|
-
return void 0;
|
|
15010
|
-
}
|
|
15011
|
-
})() : void 0;
|
|
14628
|
+
const resolvedScope = args.topicId || args.projectId ? await resolveTopicProjectScope(ctx, {
|
|
14629
|
+
topicId: args.topicId,
|
|
14630
|
+
projectId: args.projectId
|
|
14631
|
+
}).catch(() => void 0) : void 0;
|
|
15012
14632
|
const contentHash = args.contentHash || `${args.nodeType}:${args.canonicalText}`.slice(0, 64);
|
|
15013
14633
|
const epistemicLayer = args.epistemicLayer || getNodeLayer(args.nodeType);
|
|
15014
14634
|
const nodeId = await ctx.db.insert("epistemicNodes", {
|
|
@@ -15075,7 +14695,7 @@ var updateSyncStatus = internalMutation({
|
|
|
15075
14695
|
updates.syncError = args.syncError;
|
|
15076
14696
|
}
|
|
15077
14697
|
await ctx.db.patch(args.nodeId, updates);
|
|
15078
|
-
return
|
|
14698
|
+
return { success: true };
|
|
15079
14699
|
}
|
|
15080
14700
|
});
|
|
15081
14701
|
var backfillTopicId = internalMutation({
|
|
@@ -15347,12 +14967,6 @@ function normalizeQuestionTopicId(topicId) {
|
|
|
15347
14967
|
function resolveQuestionScopeId(scope) {
|
|
15348
14968
|
return normalizeQuestionTopicId(scope.topicId) ?? scope.projectId ?? void 0;
|
|
15349
14969
|
}
|
|
15350
|
-
function logQuestionFallback(message, error, context) {
|
|
15351
|
-
debugGraphPrimitiveFallback(message, {
|
|
15352
|
-
error: formatGraphPrimitiveError(error),
|
|
15353
|
-
...context ?? {}
|
|
15354
|
-
});
|
|
15355
|
-
}
|
|
15356
14970
|
async function resolveQuestionScopeOrNull(ctx, args) {
|
|
15357
14971
|
if (!args.projectId && !args.topicId) {
|
|
15358
14972
|
return null;
|
|
@@ -15362,15 +14976,7 @@ async function resolveQuestionScopeOrNull(ctx, args) {
|
|
|
15362
14976
|
projectId: args.projectId ?? void 0,
|
|
15363
14977
|
topicId: args.topicId ?? void 0
|
|
15364
14978
|
});
|
|
15365
|
-
} catch
|
|
15366
|
-
debugGraphPrimitiveFallback(
|
|
15367
|
-
"[epistemicQuestions] Failed to resolve question scope",
|
|
15368
|
-
{
|
|
15369
|
-
error: formatGraphPrimitiveError(error),
|
|
15370
|
-
projectId: args.projectId,
|
|
15371
|
-
topicId: args.topicId
|
|
15372
|
-
}
|
|
15373
|
-
);
|
|
14979
|
+
} catch {
|
|
15374
14980
|
return null;
|
|
15375
14981
|
}
|
|
15376
14982
|
}
|
|
@@ -15574,7 +15180,9 @@ var create8 = mutation({
|
|
|
15574
15180
|
source: args.source || "ai_suggested",
|
|
15575
15181
|
questionStatus: "open",
|
|
15576
15182
|
linkedBeliefNodeId: args.linkedBeliefNodeId,
|
|
15577
|
-
...buildLinkedWorktreeMetadata(
|
|
15183
|
+
...buildLinkedWorktreeMetadata(
|
|
15184
|
+
args.linkedWorktreeId
|
|
15185
|
+
),
|
|
15578
15186
|
testType: args.testType,
|
|
15579
15187
|
importance: args.importance,
|
|
15580
15188
|
epistemicUnlock: args.epistemicUnlock,
|
|
@@ -15985,9 +15593,7 @@ var getByTopic5 = query({
|
|
|
15985
15593
|
handler: async (ctx, args) => {
|
|
15986
15594
|
const pageSize = clampQuestionLimit(args.limit);
|
|
15987
15595
|
const scanLimit = Math.min(pageSize * 3, MAX_QUESTION_PAGE_SIZE);
|
|
15988
|
-
const scope = await resolveTopicProjectScope(ctx, {
|
|
15989
|
-
topicId: args.topicId
|
|
15990
|
-
});
|
|
15596
|
+
const scope = await resolveTopicProjectScope(ctx, { topicId: args.topicId });
|
|
15991
15597
|
const scopedNodes = await getQuestionNodesForScope(ctx, scope, {
|
|
15992
15598
|
scanLimit
|
|
15993
15599
|
});
|
|
@@ -16011,7 +15617,7 @@ var getByCategory = query({
|
|
|
16011
15617
|
const nodes = await getQuestionNodesForScope(ctx, scope);
|
|
16012
15618
|
return nodes.filter((n) => {
|
|
16013
15619
|
const metadata = n.metadata || {};
|
|
16014
|
-
return questionMatchesScope(n, scope) && isActiveQuestionNode(n) && metadata.category === normalizeCategory(args.category);
|
|
15620
|
+
return questionMatchesScope(n, scope) && (isActiveQuestionNode(n) && metadata.category === normalizeCategory(args.category));
|
|
16015
15621
|
});
|
|
16016
15622
|
}
|
|
16017
15623
|
});
|
|
@@ -16107,9 +15713,7 @@ var internalGetByTopic3 = internalQuery({
|
|
|
16107
15713
|
const pageSize = clampQuestionLimit(args.limit, 500);
|
|
16108
15714
|
const scanLimit = Math.min(pageSize * 3, MAX_QUESTION_PAGE_SIZE);
|
|
16109
15715
|
const audienceMode = args.audienceMode ?? "internal";
|
|
16110
|
-
const scope = await resolveTopicProjectScope(ctx, {
|
|
16111
|
-
topicId: args.topicId
|
|
16112
|
-
});
|
|
15716
|
+
const scope = await resolveTopicProjectScope(ctx, { topicId: args.topicId });
|
|
16113
15717
|
const registryRows = await listAudienceRegistryRows(ctx, {
|
|
16114
15718
|
tenantId: scope.tenantId,
|
|
16115
15719
|
workspaceId: scope.workspaceId
|
|
@@ -16439,14 +16043,7 @@ A: ${args.answerText}`;
|
|
|
16439
16043
|
if (node?.nodeType === "belief") {
|
|
16440
16044
|
return node;
|
|
16441
16045
|
}
|
|
16442
|
-
} catch
|
|
16443
|
-
debugGraphPrimitiveFallback(
|
|
16444
|
-
"[epistemicQuestions] Failed to resolve belief node",
|
|
16445
|
-
{
|
|
16446
|
-
error: formatGraphPrimitiveError(error),
|
|
16447
|
-
beliefId: bId
|
|
16448
|
-
}
|
|
16449
|
-
);
|
|
16046
|
+
} catch {
|
|
16450
16047
|
return null;
|
|
16451
16048
|
}
|
|
16452
16049
|
return null;
|
|
@@ -16852,14 +16449,7 @@ var getInConviction = query({
|
|
|
16852
16449
|
exclusiveWithCount: 0
|
|
16853
16450
|
};
|
|
16854
16451
|
}
|
|
16855
|
-
} catch
|
|
16856
|
-
debugGraphPrimitiveFallback(
|
|
16857
|
-
"[epistemicQuestions] Failed to hydrate linked belief",
|
|
16858
|
-
{
|
|
16859
|
-
error: formatGraphPrimitiveError(error),
|
|
16860
|
-
beliefId
|
|
16861
|
-
}
|
|
16862
|
-
);
|
|
16452
|
+
} catch {
|
|
16863
16453
|
}
|
|
16864
16454
|
return null;
|
|
16865
16455
|
})
|
|
@@ -16957,14 +16547,6 @@ var advanceToConviction = mutation({
|
|
|
16957
16547
|
triggeringAction: "question_advanced_to_conviction"
|
|
16958
16548
|
});
|
|
16959
16549
|
} catch (e) {
|
|
16960
|
-
logQuestionFallback(
|
|
16961
|
-
"[epistemicQuestions] Failed to log advanceToConviction audit",
|
|
16962
|
-
e,
|
|
16963
|
-
{
|
|
16964
|
-
questionId: args.questionId,
|
|
16965
|
-
projectId: node.projectId
|
|
16966
|
-
}
|
|
16967
|
-
);
|
|
16968
16550
|
console.error("[EpistemicAudit] Failed to log advanceToConviction:", e);
|
|
16969
16551
|
}
|
|
16970
16552
|
await markProjectGraphDirty3(ctx, node.projectId, node.topicId);
|
|
@@ -17091,14 +16673,6 @@ var finalizeConviction = mutation({
|
|
|
17091
16673
|
triggeringAction: "question_conviction_finalized"
|
|
17092
16674
|
});
|
|
17093
16675
|
} catch (e) {
|
|
17094
|
-
logQuestionFallback(
|
|
17095
|
-
"[epistemicQuestions] Failed to log finalizeConviction audit",
|
|
17096
|
-
e,
|
|
17097
|
-
{
|
|
17098
|
-
questionId: args.questionId,
|
|
17099
|
-
projectId: node.projectId
|
|
17100
|
-
}
|
|
17101
|
-
);
|
|
17102
16676
|
console.error("[EpistemicAudit] Failed to log finalizeConviction:", e);
|
|
17103
16677
|
}
|
|
17104
16678
|
if (node.projectId || node.topicId) {
|
|
@@ -17122,15 +16696,6 @@ var finalizeConviction = mutation({
|
|
|
17122
16696
|
}
|
|
17123
16697
|
);
|
|
17124
16698
|
} catch (e) {
|
|
17125
|
-
logQuestionFallback(
|
|
17126
|
-
"[epistemicQuestions] Failed to schedule evidence creation from scored question",
|
|
17127
|
-
e,
|
|
17128
|
-
{
|
|
17129
|
-
questionId: args.questionId,
|
|
17130
|
-
beliefId,
|
|
17131
|
-
projectId: node.projectId
|
|
17132
|
-
}
|
|
17133
|
-
);
|
|
17134
16699
|
console.error(
|
|
17135
16700
|
"[finalizeConviction] Failed to schedule evidence creation:",
|
|
17136
16701
|
e
|
|
@@ -17160,24 +16725,10 @@ var getByBeliefWithAccess = query({
|
|
|
17160
16725
|
let beliefNode = null;
|
|
17161
16726
|
try {
|
|
17162
16727
|
beliefNode = await ctx.db.get(args.beliefId);
|
|
17163
|
-
} catch
|
|
17164
|
-
debugGraphPrimitiveFallback(
|
|
17165
|
-
"[epistemicQuestions] Failed to resolve belief node directly",
|
|
17166
|
-
{
|
|
17167
|
-
error: formatGraphPrimitiveError(error),
|
|
17168
|
-
beliefId: args.beliefId
|
|
17169
|
-
}
|
|
17170
|
-
);
|
|
16728
|
+
} catch {
|
|
17171
16729
|
try {
|
|
17172
16730
|
beliefNode = await ctx.db.get(args.beliefId);
|
|
17173
|
-
} catch
|
|
17174
|
-
debugGraphPrimitiveFallback(
|
|
17175
|
-
"[epistemicQuestions] Failed to resolve legacy belief node",
|
|
17176
|
-
{
|
|
17177
|
-
error: formatGraphPrimitiveError(legacyError),
|
|
17178
|
-
beliefId: args.beliefId
|
|
17179
|
-
}
|
|
17180
|
-
);
|
|
16731
|
+
} catch {
|
|
17181
16732
|
return [];
|
|
17182
16733
|
}
|
|
17183
16734
|
}
|
|
@@ -17321,24 +16872,10 @@ var linkToBelief = mutation({
|
|
|
17321
16872
|
let beliefNode = null;
|
|
17322
16873
|
try {
|
|
17323
16874
|
beliefNode = await ctx.db.get(args.beliefId);
|
|
17324
|
-
} catch
|
|
17325
|
-
debugGraphPrimitiveFallback(
|
|
17326
|
-
"[epistemicQuestions] Failed to resolve belief node directly",
|
|
17327
|
-
{
|
|
17328
|
-
error: formatGraphPrimitiveError(error),
|
|
17329
|
-
beliefId: args.beliefId
|
|
17330
|
-
}
|
|
17331
|
-
);
|
|
16875
|
+
} catch {
|
|
17332
16876
|
try {
|
|
17333
16877
|
beliefNode = await ctx.db.get(args.beliefId);
|
|
17334
|
-
} catch
|
|
17335
|
-
debugGraphPrimitiveFallback(
|
|
17336
|
-
"[epistemicQuestions] Failed to resolve legacy belief node",
|
|
17337
|
-
{
|
|
17338
|
-
error: formatGraphPrimitiveError(legacyError),
|
|
17339
|
-
beliefId: args.beliefId
|
|
17340
|
-
}
|
|
17341
|
-
);
|
|
16878
|
+
} catch {
|
|
17342
16879
|
throw new Error("Belief not found");
|
|
17343
16880
|
}
|
|
17344
16881
|
}
|
|
@@ -17399,14 +16936,6 @@ var linkToBelief = mutation({
|
|
|
17399
16936
|
});
|
|
17400
16937
|
}
|
|
17401
16938
|
} catch (e) {
|
|
17402
|
-
logQuestionFallback(
|
|
17403
|
-
"[epistemicQuestions] Failed to create tests edge",
|
|
17404
|
-
e,
|
|
17405
|
-
{
|
|
17406
|
-
questionId: args.questionId,
|
|
17407
|
-
beliefId: args.beliefId
|
|
17408
|
-
}
|
|
17409
|
-
);
|
|
17410
16939
|
console.error("[linkToBelief] Failed to create tests edge:", e);
|
|
17411
16940
|
}
|
|
17412
16941
|
await markProjectGraphDirty3(
|
|
@@ -17545,14 +17074,6 @@ var unlinkInsight = mutation({
|
|
|
17545
17074
|
}
|
|
17546
17075
|
}
|
|
17547
17076
|
} catch (e) {
|
|
17548
|
-
logQuestionFallback(
|
|
17549
|
-
"[epistemicQuestions] Failed to remove questionEvidenceLink",
|
|
17550
|
-
e,
|
|
17551
|
-
{
|
|
17552
|
-
questionId: args.questionId,
|
|
17553
|
-
insightId: args.insightId
|
|
17554
|
-
}
|
|
17555
|
-
);
|
|
17556
17077
|
console.error(
|
|
17557
17078
|
"[unlinkInsight] Failed to remove questionEvidenceLink:",
|
|
17558
17079
|
e
|
|
@@ -17575,14 +17096,6 @@ var unlinkInsight = mutation({
|
|
|
17575
17096
|
}
|
|
17576
17097
|
}
|
|
17577
17098
|
} catch (e) {
|
|
17578
|
-
logQuestionFallback(
|
|
17579
|
-
"[epistemicQuestions] Failed to remove derived edge",
|
|
17580
|
-
e,
|
|
17581
|
-
{
|
|
17582
|
-
questionId: args.questionId,
|
|
17583
|
-
insightId: args.insightId
|
|
17584
|
-
}
|
|
17585
|
-
);
|
|
17586
17099
|
console.error("[unlinkInsight] Failed to remove edge:", e);
|
|
17587
17100
|
}
|
|
17588
17101
|
await markProjectGraphDirty3(
|
|
@@ -17753,14 +17266,7 @@ var consolidate = mutation({
|
|
|
17753
17266
|
args.questionIds.map(async (qid) => {
|
|
17754
17267
|
try {
|
|
17755
17268
|
return await ctx.db.get(qid);
|
|
17756
|
-
} catch
|
|
17757
|
-
debugGraphPrimitiveFallback(
|
|
17758
|
-
"[epistemicQuestions] Failed to load original question",
|
|
17759
|
-
{
|
|
17760
|
-
error: formatGraphPrimitiveError(error),
|
|
17761
|
-
questionId: qid
|
|
17762
|
-
}
|
|
17763
|
-
);
|
|
17269
|
+
} catch {
|
|
17764
17270
|
return null;
|
|
17765
17271
|
}
|
|
17766
17272
|
})
|
|
@@ -17821,14 +17327,7 @@ var consolidate = mutation({
|
|
|
17821
17327
|
const bMeta = belief.metadata || {};
|
|
17822
17328
|
category = bMeta.category || bMeta.pillar || "other";
|
|
17823
17329
|
}
|
|
17824
|
-
} catch
|
|
17825
|
-
debugGraphPrimitiveFallback(
|
|
17826
|
-
"[epistemicQuestions] Failed to read first linked belief metadata",
|
|
17827
|
-
{
|
|
17828
|
-
error: formatGraphPrimitiveError(error),
|
|
17829
|
-
beliefId: firstBeliefId
|
|
17830
|
-
}
|
|
17831
|
-
);
|
|
17330
|
+
} catch {
|
|
17832
17331
|
}
|
|
17833
17332
|
}
|
|
17834
17333
|
const now = Date.now();
|
|
@@ -17878,14 +17377,7 @@ var consolidate = mutation({
|
|
|
17878
17377
|
}
|
|
17879
17378
|
});
|
|
17880
17379
|
}
|
|
17881
|
-
} catch
|
|
17882
|
-
debugGraphPrimitiveFallback(
|
|
17883
|
-
"[epistemicQuestions] Failed to archive linked question",
|
|
17884
|
-
{
|
|
17885
|
-
error: formatGraphPrimitiveError(error),
|
|
17886
|
-
questionId: qid
|
|
17887
|
-
}
|
|
17888
|
-
);
|
|
17380
|
+
} catch {
|
|
17889
17381
|
}
|
|
17890
17382
|
}
|
|
17891
17383
|
await ctx.scheduler.runAfter(0, internal.neo4jSync.syncNodeToNeo4j, {
|
|
@@ -18017,15 +17509,7 @@ var getQuestionClusterPositions = query({
|
|
|
18017
17509
|
projectId: args.projectId,
|
|
18018
17510
|
topicId: args.topicId
|
|
18019
17511
|
});
|
|
18020
|
-
} catch
|
|
18021
|
-
debugGraphPrimitiveFallback(
|
|
18022
|
-
"[epistemicQuestions] Failed to resolve question cluster scope",
|
|
18023
|
-
{
|
|
18024
|
-
error: formatGraphPrimitiveError(error),
|
|
18025
|
-
projectId: args.projectId,
|
|
18026
|
-
topicId: args.topicId
|
|
18027
|
-
}
|
|
18028
|
-
);
|
|
17512
|
+
} catch {
|
|
18029
17513
|
return {
|
|
18030
17514
|
positions: {},
|
|
18031
17515
|
counts: {
|
|
@@ -18861,6 +18345,9 @@ function shouldFailClosedForProjection(envelope) {
|
|
|
18861
18345
|
}
|
|
18862
18346
|
|
|
18863
18347
|
// src/projectionReconciliation.ts
|
|
18348
|
+
async function collectQueueByStatus(ctx, status) {
|
|
18349
|
+
return await ctx.db.query("neo4jSyncQueue").withIndex("by_status", (q) => q.eq("status", status)).collect();
|
|
18350
|
+
}
|
|
18864
18351
|
function maxTimestamp(rows, field) {
|
|
18865
18352
|
let maxValue;
|
|
18866
18353
|
for (const row of rows) {
|
|
@@ -18889,10 +18376,10 @@ function minTimestamp(rows, field) {
|
|
|
18889
18376
|
}
|
|
18890
18377
|
async function getQueueSnapshot(ctx) {
|
|
18891
18378
|
const [pendingRows, inProgressRows, failedRows, succeededRows] = await Promise.all([
|
|
18892
|
-
ctx
|
|
18893
|
-
ctx
|
|
18894
|
-
ctx
|
|
18895
|
-
ctx
|
|
18379
|
+
collectQueueByStatus(ctx, "pending"),
|
|
18380
|
+
collectQueueByStatus(ctx, "in_progress"),
|
|
18381
|
+
collectQueueByStatus(ctx, "failed"),
|
|
18382
|
+
collectQueueByStatus(ctx, "succeeded")
|
|
18896
18383
|
]);
|
|
18897
18384
|
const now = Date.now();
|
|
18898
18385
|
const backlogOldestCreatedAt = minTimestamp(
|
|
@@ -18952,13 +18439,6 @@ function buildEndpointAssessments(snapshot) {
|
|
|
18952
18439
|
nonGraph
|
|
18953
18440
|
};
|
|
18954
18441
|
}
|
|
18955
|
-
function buildProjectionReconciliationStatus(snapshot) {
|
|
18956
|
-
return {
|
|
18957
|
-
...snapshot,
|
|
18958
|
-
endpointAssessments: buildEndpointAssessments(snapshot),
|
|
18959
|
-
generatedAt: snapshot.now
|
|
18960
|
-
};
|
|
18961
|
-
}
|
|
18962
18442
|
function assertAuthenticated(clerkId) {
|
|
18963
18443
|
if (!clerkId) {
|
|
18964
18444
|
throw new Error("Authentication required");
|
|
@@ -18970,7 +18450,12 @@ var getProjectionReconciliationStatusInternal = internalQuery({
|
|
|
18970
18450
|
returns: permissiveReturn,
|
|
18971
18451
|
handler: async (ctx) => {
|
|
18972
18452
|
const snapshot = await getQueueSnapshot(ctx);
|
|
18973
|
-
|
|
18453
|
+
const assessments = buildEndpointAssessments(snapshot);
|
|
18454
|
+
return {
|
|
18455
|
+
...snapshot,
|
|
18456
|
+
endpointAssessments: assessments,
|
|
18457
|
+
generatedAt: snapshot.now
|
|
18458
|
+
};
|
|
18974
18459
|
}
|
|
18975
18460
|
});
|
|
18976
18461
|
var getProjectionReconciliationStatus = query({
|
|
@@ -18979,7 +18464,12 @@ var getProjectionReconciliationStatus = query({
|
|
|
18979
18464
|
handler: async (ctx) => {
|
|
18980
18465
|
assertAuthenticated(await getCurrentUserId(ctx));
|
|
18981
18466
|
const snapshot = await getQueueSnapshot(ctx);
|
|
18982
|
-
|
|
18467
|
+
const assessments = buildEndpointAssessments(snapshot);
|
|
18468
|
+
return {
|
|
18469
|
+
...snapshot,
|
|
18470
|
+
endpointAssessments: assessments,
|
|
18471
|
+
generatedAt: snapshot.now
|
|
18472
|
+
};
|
|
18983
18473
|
}
|
|
18984
18474
|
});
|
|
18985
18475
|
var assessProjectionStaleness = query({
|
|
@@ -19548,20 +19038,7 @@ var getByProject8 = query({
|
|
|
19548
19038
|
if (!hasAccess) {
|
|
19549
19039
|
return [];
|
|
19550
19040
|
}
|
|
19551
|
-
|
|
19552
|
-
try {
|
|
19553
|
-
scope = await resolveTopicProjectScope(ctx, args);
|
|
19554
|
-
} catch (error) {
|
|
19555
|
-
debugGraphPrimitiveFallback(
|
|
19556
|
-
"[questionEvidenceLinks] Failed to resolve topic scope",
|
|
19557
|
-
{
|
|
19558
|
-
error,
|
|
19559
|
-
projectId: args.projectId,
|
|
19560
|
-
topicId: args.topicId
|
|
19561
|
-
}
|
|
19562
|
-
);
|
|
19563
|
-
scope = null;
|
|
19564
|
-
}
|
|
19041
|
+
const scope = await resolveTopicProjectScope(ctx, args).catch(() => null);
|
|
19565
19042
|
if (!scope) {
|
|
19566
19043
|
return [];
|
|
19567
19044
|
}
|