@lucern/graph-primitives 1.0.30 → 1.0.32
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/beliefEvidenceLinks.js.map +1 -1
- package/dist/beliefEvidenceLinks.operational.js.map +1 -1
- package/dist/contradictions.js +5 -5
- package/dist/contradictions.js.map +1 -1
- package/dist/entityLifecycle.js.map +1 -1
- package/dist/epistemicAnswers.js +1 -1
- package/dist/epistemicAnswers.js.map +1 -1
- package/dist/epistemicBeliefs.admin.js +2 -2
- package/dist/epistemicBeliefs.admin.js.map +1 -1
- package/dist/epistemicBeliefs.backfills.js +3 -3
- package/dist/epistemicBeliefs.backfills.js.map +1 -1
- package/dist/epistemicBeliefs.confidence.js +1 -4
- package/dist/epistemicBeliefs.confidence.js.map +1 -1
- package/dist/epistemicBeliefs.core.js +20 -30
- package/dist/epistemicBeliefs.core.js.map +1 -1
- package/dist/epistemicBeliefs.forkEvidence.js.map +1 -1
- package/dist/epistemicBeliefs.helpers.js +1 -1
- package/dist/epistemicBeliefs.helpers.js.map +1 -1
- package/dist/epistemicBeliefs.internal.js +15 -25
- package/dist/epistemicBeliefs.internal.js.map +1 -1
- package/dist/epistemicBeliefs.js +27 -40
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicBeliefs.lifecycle.js +1 -4
- package/dist/epistemicBeliefs.lifecycle.js.map +1 -1
- package/dist/epistemicBeliefs.links.js +1 -1
- package/dist/epistemicBeliefs.links.js.map +1 -1
- package/dist/epistemicBeliefs.queries.js.map +1 -1
- package/dist/epistemicBeliefs.topicAnchor.js +12 -22
- package/dist/epistemicBeliefs.topicAnchor.js.map +1 -1
- package/dist/epistemicContracts.evaluators.js +1 -4
- package/dist/epistemicContracts.evaluators.js.map +1 -1
- package/dist/epistemicContracts.handlers.js +1 -4
- package/dist/epistemicContracts.handlers.js.map +1 -1
- package/dist/epistemicContracts.js +1 -4
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/epistemicEdgeCreation.js.map +1 -1
- package/dist/epistemicEdges.handlers.js.map +1 -1
- package/dist/epistemicEdges.js +6 -7
- package/dist/epistemicEdges.js.map +1 -1
- package/dist/epistemicEdges.mutations.js +3 -4
- package/dist/epistemicEdges.mutations.js.map +1 -1
- package/dist/epistemicEdges.queries.js +3 -3
- package/dist/epistemicEdges.queries.js.map +1 -1
- package/dist/epistemicEvidence.js +10 -10
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/epistemicEvidenceHelpers.js +1 -1
- package/dist/epistemicEvidenceHelpers.js.map +1 -1
- package/dist/epistemicEvidenceMutations.js +5 -5
- package/dist/epistemicEvidenceMutations.js.map +1 -1
- package/dist/epistemicEvidenceQueries.js +6 -6
- package/dist/epistemicEvidenceQueries.js.map +1 -1
- package/dist/epistemicHelpers.js +4 -4
- package/dist/epistemicHelpers.js.map +1 -1
- package/dist/epistemicInsert.js.map +1 -1
- package/dist/epistemicLayerRules.js +2 -2
- package/dist/epistemicLayerRules.js.map +1 -1
- package/dist/epistemicLinking.js.map +1 -1
- package/dist/epistemicNodeCreation.js +2 -2
- package/dist/epistemicNodeCreation.js.map +1 -1
- package/dist/epistemicNodes.internal.js +2 -3
- package/dist/epistemicNodes.internal.js.map +1 -1
- package/dist/epistemicNodes.js +10 -12
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/epistemicNodes.mutations.js +3 -4
- package/dist/epistemicNodes.mutations.js.map +1 -1
- package/dist/epistemicNodes.queries.js +5 -5
- package/dist/epistemicNodes.queries.js.map +1 -1
- package/dist/epistemicQuestions.conviction.js +5 -5
- package/dist/epistemicQuestions.conviction.js.map +1 -1
- package/dist/epistemicQuestions.create.js +7 -7
- package/dist/epistemicQuestions.create.js.map +1 -1
- package/dist/epistemicQuestions.evidence.js +2 -2
- package/dist/epistemicQuestions.evidence.js.map +1 -1
- package/dist/epistemicQuestions.helpers.js +7 -4
- package/dist/epistemicQuestions.helpers.js.map +1 -1
- package/dist/epistemicQuestions.js +16 -13
- package/dist/epistemicQuestions.js.map +1 -1
- package/dist/epistemicQuestions.lifecycle.js.map +1 -1
- package/dist/epistemicQuestions.queries.js +2 -2
- package/dist/epistemicQuestions.queries.js.map +1 -1
- package/dist/epistemicQuestions.sprint.js +6 -3
- package/dist/epistemicQuestions.sprint.js.map +1 -1
- package/dist/epistemicQuestions.tail.js +2 -2
- package/dist/epistemicQuestions.tail.js.map +1 -1
- package/dist/epistemicSources.js.map +1 -1
- package/dist/index.js +79 -92
- package/dist/index.js.map +1 -1
- package/dist/proof-attestation.json +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { throwStructuredMutationError } from '@lucern/access-control/structuredM
|
|
|
10
10
|
import { isNodeType, getLayerForNodeType } from '@lucern/contracts/schema-helpers/spine/tables/epistemicNodes';
|
|
11
11
|
import { assertSchemaEnumValue } from '@lucern/contracts/schema-helpers/enumValidation';
|
|
12
12
|
import { REASONING_METHODS, assertEdgePolicyAllowed, edgePolicyManifest, EVIDENCE_SOURCE_QUALITY_VALUES, EVIDENCE_METHODOLOGY_VALUES, EVIDENCE_INFORMATION_ASYMMETRY_VALUES } from '@lucern/contracts';
|
|
13
|
-
import { generateGlobalId, assertUuidV7Identity, generateUuidV7, assertStorageEdgeVocabulary,
|
|
13
|
+
import { generateGlobalId, assertUuidV7Identity, generateUuidV7, assertStorageEdgeVocabulary, isUuidV7, assertUuidShapedEdgeEndpoint } from '@lucern/contracts/ids';
|
|
14
14
|
import { listAudienceRegistryRows } from '@lucern/access-control/audienceRegistry';
|
|
15
15
|
import { scoreEntityTypeMatch, scoreEntityConnection, rankEntityTypeMatches, rankEntityConnections } from '@lucern/contracts/v1/ontologies/v1';
|
|
16
16
|
import { wordTokenize, wordOverlapScore, tokenizeSearchText, tokenOverlapScore, stemToken, scoreLexicalSignals, scoreLexicalSignal, rerankLexicalWindow, rankWindowScore, prepareLexicalQuery, jaccardSimilarity, bigramTokenize } from '@lucern/contracts/text-matching.contract';
|
|
@@ -2288,7 +2288,7 @@ async function markBeliefGraphDirty(ctx, scope) {
|
|
|
2288
2288
|
);
|
|
2289
2289
|
}
|
|
2290
2290
|
async function resolveBeliefScopeOrNull(ctx, args) {
|
|
2291
|
-
if (!
|
|
2291
|
+
if (!args.topicId) {
|
|
2292
2292
|
return null;
|
|
2293
2293
|
}
|
|
2294
2294
|
try {
|
|
@@ -2818,7 +2818,7 @@ var getByPillar = query({
|
|
|
2818
2818
|
},
|
|
2819
2819
|
returns: permissiveReturn,
|
|
2820
2820
|
handler: async (ctx, args) => {
|
|
2821
|
-
if (!
|
|
2821
|
+
if (!args.topicId) {
|
|
2822
2822
|
return [];
|
|
2823
2823
|
}
|
|
2824
2824
|
let scope;
|
|
@@ -3249,7 +3249,7 @@ var getRecentConfidenceChanges = query({
|
|
|
3249
3249
|
if (!scope) {
|
|
3250
3250
|
return [];
|
|
3251
3251
|
}
|
|
3252
|
-
const scopeId = scope.topicId ? String(scope.topicId) :
|
|
3252
|
+
const scopeId = scope.topicId ? String(scope.topicId) : void 0;
|
|
3253
3253
|
if (!(scopeId && await checkScopeAccess(ctx, scopeId, args.userId))) {
|
|
3254
3254
|
return [];
|
|
3255
3255
|
}
|
|
@@ -3506,7 +3506,7 @@ var backfillScoredBeliefEdges = internalMutation({
|
|
|
3506
3506
|
returns: permissiveReturn,
|
|
3507
3507
|
handler: async (ctx, args) => {
|
|
3508
3508
|
const dryRun = args.dryRun ?? false;
|
|
3509
|
-
const scopeTopicId = args.topicId
|
|
3509
|
+
const scopeTopicId = args.topicId;
|
|
3510
3510
|
if (!scopeTopicId) {
|
|
3511
3511
|
return {
|
|
3512
3512
|
dryRun,
|
|
@@ -4179,10 +4179,7 @@ async function scheduleFirstScoringThemeEdges(ctx, args, node, state) {
|
|
|
4179
4179
|
if (!state.isFirstScoring) {
|
|
4180
4180
|
return;
|
|
4181
4181
|
}
|
|
4182
|
-
const themeNodes = await ctx.db.query("epistemicNodes").withIndex(
|
|
4183
|
-
"by_topic",
|
|
4184
|
-
(q) => q.eq("topicId", node.topicId || node.projectId)
|
|
4185
|
-
).filter((q) => q.eq(q.field("nodeType"), "theme")).collect();
|
|
4182
|
+
const themeNodes = await ctx.db.query("epistemicNodes").withIndex("by_topic", (q) => q.eq("topicId", node.topicId)).filter((q) => q.eq(q.field("nodeType"), "theme")).collect();
|
|
4186
4183
|
for (const theme of themeNodes) {
|
|
4187
4184
|
if (!(theme.globalId && node.globalId)) {
|
|
4188
4185
|
continue;
|
|
@@ -4551,36 +4548,26 @@ __export(globalId_exports, {
|
|
|
4551
4548
|
function cleanString(value) {
|
|
4552
4549
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
4553
4550
|
}
|
|
4554
|
-
function
|
|
4551
|
+
function requireTopicGlobalId(topicRef) {
|
|
4555
4552
|
const normalized = topicRef.trim();
|
|
4556
|
-
if (!normalized) {
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
if (normalized.startsWith("top_")) {
|
|
4561
|
-
candidates.push(normalized.slice(4));
|
|
4553
|
+
if (!(normalized && isUuidV7(normalized))) {
|
|
4554
|
+
throw new Error(
|
|
4555
|
+
"Belief creation topic anchors must be UUIDv7 epistemicNodes.globalId values."
|
|
4556
|
+
);
|
|
4562
4557
|
}
|
|
4563
|
-
return
|
|
4558
|
+
return normalized;
|
|
4564
4559
|
}
|
|
4565
4560
|
function readTopicNodeRef(args) {
|
|
4566
4561
|
return cleanString(args.topicGlobalId) ?? cleanString(args.topicNodeId) ?? cleanString(args.topicId);
|
|
4567
4562
|
}
|
|
4568
4563
|
async function resolveRequiredTopicAnchor(ctx, topicRef) {
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
return direct;
|
|
4574
|
-
}
|
|
4575
|
-
} catch {
|
|
4576
|
-
}
|
|
4577
|
-
const byGlobalId = await ctx.db.query("epistemicNodes").withIndex("by_globalId", (q) => q.eq("globalId", candidate)).first();
|
|
4578
|
-
if (byGlobalId?.nodeType === "topic" && cleanString(byGlobalId.globalId)) {
|
|
4579
|
-
return byGlobalId;
|
|
4580
|
-
}
|
|
4564
|
+
const topicGlobalId = requireTopicGlobalId(topicRef);
|
|
4565
|
+
const byGlobalId = await ctx.db.query("epistemicNodes").withIndex("by_globalId", (q) => q.eq("globalId", topicGlobalId)).first();
|
|
4566
|
+
if (byGlobalId?.nodeType === "topic" && cleanString(byGlobalId.globalId)) {
|
|
4567
|
+
return byGlobalId;
|
|
4581
4568
|
}
|
|
4582
4569
|
throw new Error(
|
|
4583
|
-
"Belief creation requires
|
|
4570
|
+
"Belief creation requires a UUIDv7 topicGlobalId for a topic node in epistemicNodes. Legacy topics-table IDs are not valid belief anchors."
|
|
4584
4571
|
);
|
|
4585
4572
|
}
|
|
4586
4573
|
function scopeFromTopicAnchor(topicNode) {
|
|
@@ -5091,7 +5078,7 @@ var create = mutation({
|
|
|
5091
5078
|
projectId: scope.projectId,
|
|
5092
5079
|
topicId: String(scope.topicId)
|
|
5093
5080
|
});
|
|
5094
|
-
if (scope.
|
|
5081
|
+
if (scope.topicId) {
|
|
5095
5082
|
await ctx.scheduler.runAfter(
|
|
5096
5083
|
0,
|
|
5097
5084
|
"embeddingActions:generateEpistemicNodeEmbedding",
|
|
@@ -5110,7 +5097,7 @@ Rationale: ${args.rationale}` : args.formulation
|
|
|
5110
5097
|
}
|
|
5111
5098
|
);
|
|
5112
5099
|
}
|
|
5113
|
-
if (scope.
|
|
5100
|
+
if (scope.topicId) {
|
|
5114
5101
|
await ctx.scheduler.runAfter(
|
|
5115
5102
|
2e3,
|
|
5116
5103
|
// 2 second delay
|
|
@@ -5123,7 +5110,7 @@ Rationale: ${args.rationale}` : args.formulation
|
|
|
5123
5110
|
}
|
|
5124
5111
|
);
|
|
5125
5112
|
}
|
|
5126
|
-
if (pillar === "other" &&
|
|
5113
|
+
if (pillar === "other" && scope.topicId) {
|
|
5127
5114
|
await ctx.scheduler.runAfter(
|
|
5128
5115
|
2500,
|
|
5129
5116
|
"beliefCategorization:autoCategorizeBelief",
|
|
@@ -5134,7 +5121,7 @@ Rationale: ${args.rationale}` : args.formulation
|
|
|
5134
5121
|
}
|
|
5135
5122
|
);
|
|
5136
5123
|
}
|
|
5137
|
-
if (scope.
|
|
5124
|
+
if (scope.topicId) {
|
|
5138
5125
|
await ctx.scheduler.runAfter(
|
|
5139
5126
|
3e3,
|
|
5140
5127
|
// 3 second delay — after entity extraction
|
|
@@ -5402,7 +5389,7 @@ var getByProject = query({
|
|
|
5402
5389
|
},
|
|
5403
5390
|
returns: permissiveReturn,
|
|
5404
5391
|
handler: async (ctx, args) => {
|
|
5405
|
-
if (!
|
|
5392
|
+
if (!args.topicId) {
|
|
5406
5393
|
return [];
|
|
5407
5394
|
}
|
|
5408
5395
|
const pageSize = clampBeliefLimit(args.limit);
|
|
@@ -5425,7 +5412,7 @@ var getByProject = query({
|
|
|
5425
5412
|
return [];
|
|
5426
5413
|
}
|
|
5427
5414
|
if (args.userId) {
|
|
5428
|
-
const scopeId = scope.topicId ? String(scope.topicId) :
|
|
5415
|
+
const scopeId = scope.topicId ? String(scope.topicId) : void 0;
|
|
5429
5416
|
if (!scopeId) {
|
|
5430
5417
|
return [];
|
|
5431
5418
|
}
|
|
@@ -5582,7 +5569,7 @@ var forkBelief = mutation({
|
|
|
5582
5569
|
supersededBy: newNodeId,
|
|
5583
5570
|
updatedAt: now,
|
|
5584
5571
|
metadata: {
|
|
5585
|
-
...metadata
|
|
5572
|
+
...metadata,
|
|
5586
5573
|
status: "superseded",
|
|
5587
5574
|
beliefStatus: "superseded",
|
|
5588
5575
|
epistemicStatus: "superseded",
|
|
@@ -5662,7 +5649,7 @@ var forkBelief = mutation({
|
|
|
5662
5649
|
projectId: parent.projectId,
|
|
5663
5650
|
topicId: parent.topicId
|
|
5664
5651
|
});
|
|
5665
|
-
if (parent.
|
|
5652
|
+
if (parent.topicId) {
|
|
5666
5653
|
const inheritedPillar = normalizePillar(
|
|
5667
5654
|
String(metadata?.pillar || metadata?.topic || "")
|
|
5668
5655
|
);
|
|
@@ -6068,7 +6055,7 @@ async function insertInternalBeliefAudit(ctx, args) {
|
|
|
6068
6055
|
});
|
|
6069
6056
|
}
|
|
6070
6057
|
async function scheduleInternalBeliefEmbedding(ctx, args) {
|
|
6071
|
-
if (!
|
|
6058
|
+
if (!args.scope.topicId) {
|
|
6072
6059
|
return;
|
|
6073
6060
|
}
|
|
6074
6061
|
await ctx.scheduler.runAfter(0, EMBEDDING_GENERATION_ACTION, {
|
|
@@ -6096,7 +6083,7 @@ function numericRequestedConfidence(confidence) {
|
|
|
6096
6083
|
return 0.5;
|
|
6097
6084
|
}
|
|
6098
6085
|
async function scheduleInternalBeliefCategorization(ctx, args) {
|
|
6099
|
-
if (normalizePillar(args.args.pillar || args.args.topic) !== "other" || !
|
|
6086
|
+
if (normalizePillar(args.args.pillar || args.args.topic) !== "other" || !args.scope.topicId) {
|
|
6100
6087
|
return;
|
|
6101
6088
|
}
|
|
6102
6089
|
await ctx.scheduler.runAfter(2500, BELIEF_CATEGORIZATION_ACTION, {
|
|
@@ -7277,9 +7264,9 @@ function shouldContinueTraversal2(currentLayer, targetLayer, options) {
|
|
|
7277
7264
|
}
|
|
7278
7265
|
switch (options.mode) {
|
|
7279
7266
|
case "anchor_down":
|
|
7280
|
-
return targetDepth
|
|
7267
|
+
return targetDepth <= currentDepth;
|
|
7281
7268
|
case "anchor_up":
|
|
7282
|
-
return targetDepth
|
|
7269
|
+
return targetDepth >= currentDepth;
|
|
7283
7270
|
case "same_layer":
|
|
7284
7271
|
return targetDepth === currentDepth;
|
|
7285
7272
|
case "decision_trace":
|
|
@@ -8003,7 +7990,7 @@ async function createEpistemicNodeForBelief(ctx, beliefId, belief) {
|
|
|
8003
7990
|
if (existingBeliefNode?.status === "active") {
|
|
8004
7991
|
await ctx.db.patch(existingBeliefNode._id, {
|
|
8005
7992
|
metadata: {
|
|
8006
|
-
...existingBeliefNode.metadata
|
|
7993
|
+
...existingBeliefNode.metadata,
|
|
8007
7994
|
sourceBeliefId: beliefId
|
|
8008
7995
|
},
|
|
8009
7996
|
updatedAt: now
|
|
@@ -8114,7 +8101,7 @@ async function createEpistemicNodeForArtifact(ctx, artifactId, artifact) {
|
|
|
8114
8101
|
if (existingArtifactNode?.status === "active") {
|
|
8115
8102
|
await ctx.db.patch(existingArtifactNode._id, {
|
|
8116
8103
|
metadata: {
|
|
8117
|
-
...existingArtifactNode.metadata
|
|
8104
|
+
...existingArtifactNode.metadata,
|
|
8118
8105
|
legacyArtifactId: artifactId
|
|
8119
8106
|
},
|
|
8120
8107
|
updatedAt: now
|
|
@@ -9898,7 +9885,7 @@ var getByProject3 = query({
|
|
|
9898
9885
|
contradictions = readRowList7(
|
|
9899
9886
|
await ctx.db.query("contradictions").withIndex(
|
|
9900
9887
|
"by_topic_status",
|
|
9901
|
-
(q) => q.eq("topicId", String(scope.topicId
|
|
9888
|
+
(q) => q.eq("topicId", String(scope.topicId)).eq("status", status)
|
|
9902
9889
|
).order("desc").take(scanLimit),
|
|
9903
9890
|
readContradictionRow
|
|
9904
9891
|
);
|
|
@@ -9906,7 +9893,7 @@ var getByProject3 = query({
|
|
|
9906
9893
|
contradictions = readRowList7(
|
|
9907
9894
|
await ctx.db.query("contradictions").withIndex(
|
|
9908
9895
|
"by_topicId",
|
|
9909
|
-
(q) => q.eq("topicId", String(scope.topicId
|
|
9896
|
+
(q) => q.eq("topicId", String(scope.topicId))
|
|
9910
9897
|
).order("desc").take(scanLimit),
|
|
9911
9898
|
readContradictionRow
|
|
9912
9899
|
);
|
|
@@ -9950,7 +9937,7 @@ var getUnresolvedCount = query({
|
|
|
9950
9937
|
const contradictions = readRowList7(
|
|
9951
9938
|
await ctx.db.query("contradictions").withIndex(
|
|
9952
9939
|
"by_topic_status",
|
|
9953
|
-
(q) => q.eq("topicId", String(scope.topicId
|
|
9940
|
+
(q) => q.eq("topicId", String(scope.topicId)).eq("status", "unresolved")
|
|
9954
9941
|
).collect(),
|
|
9955
9942
|
readContradictionRow
|
|
9956
9943
|
);
|
|
@@ -10075,7 +10062,7 @@ var create3 = mutation({
|
|
|
10075
10062
|
}
|
|
10076
10063
|
return await ctx.db.insert("contradictions", {
|
|
10077
10064
|
projectId,
|
|
10078
|
-
topicId: String(scope.topicId
|
|
10065
|
+
topicId: String(scope.topicId),
|
|
10079
10066
|
beliefId: args.beliefId,
|
|
10080
10067
|
...args.beliefBId ? { beliefBId: args.beliefBId } : {},
|
|
10081
10068
|
supportingInsightIds: args.supportingInsightIds,
|
|
@@ -10321,7 +10308,7 @@ var scanAndCreateContradictions = mutation({
|
|
|
10321
10308
|
if (!existing) {
|
|
10322
10309
|
await ctx.db.insert("contradictions", {
|
|
10323
10310
|
projectId,
|
|
10324
|
-
topicId: String(scope.topicId
|
|
10311
|
+
topicId: String(scope.topicId),
|
|
10325
10312
|
beliefId: belief._id,
|
|
10326
10313
|
supportingInsightIds,
|
|
10327
10314
|
contradictingInsightIds,
|
|
@@ -12196,7 +12183,7 @@ function getNextAnswerVersion(activeAnswers) {
|
|
|
12196
12183
|
async function supersedeActiveAnswers(ctx, activeAnswers, now, clearSupersededByBeforeInsert) {
|
|
12197
12184
|
for (const activeAnswer of activeAnswers) {
|
|
12198
12185
|
const metadata = {
|
|
12199
|
-
...activeAnswer.metadata
|
|
12186
|
+
...activeAnswer.metadata,
|
|
12200
12187
|
isLatest: false
|
|
12201
12188
|
};
|
|
12202
12189
|
await ctx.db.patch(activeAnswer._id, {
|
|
@@ -13390,9 +13377,8 @@ var create5 = mutation({
|
|
|
13390
13377
|
await ctx.db.get(args.toNodeId),
|
|
13391
13378
|
"Create edge target"
|
|
13392
13379
|
);
|
|
13393
|
-
const resolvedScope = args.topicId
|
|
13394
|
-
topicId: args.topicId
|
|
13395
|
-
projectId: args.projectId
|
|
13380
|
+
const resolvedScope = args.topicId ? await resolveTopicProjectScope(ctx, {
|
|
13381
|
+
topicId: args.topicId
|
|
13396
13382
|
}) : void 0;
|
|
13397
13383
|
const resolvedProjectId = resolvedScope?.projectId ?? args.projectId;
|
|
13398
13384
|
if (resolvedProjectId) {
|
|
@@ -13695,7 +13681,7 @@ var cleanupDeprecatedEdges = mutation({
|
|
|
13695
13681
|
returns: permissiveReturn,
|
|
13696
13682
|
handler: async (ctx, args) => {
|
|
13697
13683
|
const DEPRECATED_TYPES = ["contradicts"];
|
|
13698
|
-
const scopeId = args.topicId
|
|
13684
|
+
const scopeId = args.topicId;
|
|
13699
13685
|
const allEdges = scopeId ? await ctx.db.query("epistemicEdges").withIndex(
|
|
13700
13686
|
"by_topic",
|
|
13701
13687
|
(q) => q.eq("topicId", scopeId)
|
|
@@ -14163,7 +14149,7 @@ var getByProjectAndType = query({
|
|
|
14163
14149
|
},
|
|
14164
14150
|
returns: permissiveReturn,
|
|
14165
14151
|
handler: async (ctx, args) => {
|
|
14166
|
-
if (!
|
|
14152
|
+
if (!args.topicId) {
|
|
14167
14153
|
return [];
|
|
14168
14154
|
}
|
|
14169
14155
|
let scope;
|
|
@@ -14197,7 +14183,7 @@ var getByProject4 = query({
|
|
|
14197
14183
|
},
|
|
14198
14184
|
returns: permissiveReturn,
|
|
14199
14185
|
handler: async (ctx, args) => {
|
|
14200
|
-
if (!
|
|
14186
|
+
if (!args.topicId) {
|
|
14201
14187
|
return [];
|
|
14202
14188
|
}
|
|
14203
14189
|
let scope;
|
|
@@ -14220,7 +14206,7 @@ var getByProject4 = query({
|
|
|
14220
14206
|
if (args.userId) {
|
|
14221
14207
|
const hasAccess = await checkScopeAccess(
|
|
14222
14208
|
ctx,
|
|
14223
|
-
String(scope.topicId
|
|
14209
|
+
String(scope.topicId),
|
|
14224
14210
|
args.userId
|
|
14225
14211
|
);
|
|
14226
14212
|
if (!hasAccess) {
|
|
@@ -14533,7 +14519,7 @@ function resolveEvidenceLinkedWorktreeId(metadata) {
|
|
|
14533
14519
|
return typeof sprintId === "string" && sprintId.trim().length > 0 ? sprintId : void 0;
|
|
14534
14520
|
}
|
|
14535
14521
|
async function resolveEvidenceScopeOrNull(ctx, args) {
|
|
14536
|
-
if (!
|
|
14522
|
+
if (!args.topicId) {
|
|
14537
14523
|
return null;
|
|
14538
14524
|
}
|
|
14539
14525
|
try {
|
|
@@ -14917,7 +14903,7 @@ async function createEvidenceBeliefEdge(ctx, args) {
|
|
|
14917
14903
|
weight: args.weight,
|
|
14918
14904
|
confidence,
|
|
14919
14905
|
createdBy: args.userId,
|
|
14920
|
-
topicId: args.
|
|
14906
|
+
topicId: args.topicId,
|
|
14921
14907
|
fromNodeType: "evidence",
|
|
14922
14908
|
toNodeType: "belief",
|
|
14923
14909
|
fromLayer: "L2",
|
|
@@ -15051,7 +15037,7 @@ var create6 = mutation({
|
|
|
15051
15037
|
weight: impact.weight
|
|
15052
15038
|
}
|
|
15053
15039
|
});
|
|
15054
|
-
if (scope.
|
|
15040
|
+
if (scope.topicId) {
|
|
15055
15041
|
await ctx.scheduler.runAfter(0, EMBEDDING_GENERATION_ACTION2, {
|
|
15056
15042
|
nodeId,
|
|
15057
15043
|
projectId: scope.projectId,
|
|
@@ -15061,7 +15047,7 @@ var create6 = mutation({
|
|
|
15061
15047
|
text: args.text
|
|
15062
15048
|
});
|
|
15063
15049
|
}
|
|
15064
|
-
if (scope.
|
|
15050
|
+
if (scope.topicId) {
|
|
15065
15051
|
await ctx.scheduler.runAfter(
|
|
15066
15052
|
2e3,
|
|
15067
15053
|
internal.nodeClassification.scheduleClassification,
|
|
@@ -15332,7 +15318,7 @@ var internalCreate2 = internalMutation({
|
|
|
15332
15318
|
projectId: scope.projectId ? String(scope.projectId) : void 0,
|
|
15333
15319
|
rationale: args.rationale
|
|
15334
15320
|
});
|
|
15335
|
-
if (scope.
|
|
15321
|
+
if (scope.topicId) {
|
|
15336
15322
|
await ctx.scheduler.runAfter(0, EMBEDDING_GENERATION_ACTION2, {
|
|
15337
15323
|
nodeId,
|
|
15338
15324
|
projectId: scope.projectId,
|
|
@@ -15791,7 +15777,7 @@ var getByProject5 = query({
|
|
|
15791
15777
|
},
|
|
15792
15778
|
returns: permissiveReturn,
|
|
15793
15779
|
handler: async (ctx, args) => {
|
|
15794
|
-
if (!
|
|
15780
|
+
if (!args.topicId) {
|
|
15795
15781
|
return [];
|
|
15796
15782
|
}
|
|
15797
15783
|
const pageSize = clampEvidenceLimit(args.limit);
|
|
@@ -15814,7 +15800,7 @@ var getByProject5 = query({
|
|
|
15814
15800
|
return [];
|
|
15815
15801
|
}
|
|
15816
15802
|
if (args.userId) {
|
|
15817
|
-
const scopeId = scope.topicId ? String(scope.topicId) :
|
|
15803
|
+
const scopeId = scope.topicId ? String(scope.topicId) : void 0;
|
|
15818
15804
|
if (!scopeId) {
|
|
15819
15805
|
return [];
|
|
15820
15806
|
}
|
|
@@ -15906,7 +15892,7 @@ var internalGetByProject2 = internalQuery({
|
|
|
15906
15892
|
return [];
|
|
15907
15893
|
}
|
|
15908
15894
|
const audienceMode = args.audienceMode ?? "internal";
|
|
15909
|
-
const projectScopeId = scope.topicId ? String(scope.topicId) :
|
|
15895
|
+
const projectScopeId = scope.topicId ? String(scope.topicId) : void 0;
|
|
15910
15896
|
if (!projectScopeId) {
|
|
15911
15897
|
return [];
|
|
15912
15898
|
}
|
|
@@ -16065,7 +16051,7 @@ var getEvidenceBalance = query({
|
|
|
16065
16051
|
topicId: args.topicId,
|
|
16066
16052
|
projectId: args.projectId
|
|
16067
16053
|
});
|
|
16068
|
-
const scopeId = scope.topicId ? String(scope.topicId) :
|
|
16054
|
+
const scopeId = scope.topicId ? String(scope.topicId) : void 0;
|
|
16069
16055
|
if (!scopeId) {
|
|
16070
16056
|
return { supporting: 0, challenging: 0, total: 0 };
|
|
16071
16057
|
}
|
|
@@ -16073,7 +16059,7 @@ var getEvidenceBalance = query({
|
|
|
16073
16059
|
if (!hasAccess) {
|
|
16074
16060
|
return { supporting: 0, challenging: 0, total: 0 };
|
|
16075
16061
|
}
|
|
16076
|
-
const resolvedTopicId = scope.topicId
|
|
16062
|
+
const resolvedTopicId = scope.topicId;
|
|
16077
16063
|
const edges2 = resolvedTopicId ? readEvidenceEdgeRows(
|
|
16078
16064
|
await ctx.db.query("epistemicEdges").withIndex(
|
|
16079
16065
|
"by_topic",
|
|
@@ -16645,7 +16631,7 @@ var getByProjectAndType2 = query({
|
|
|
16645
16631
|
},
|
|
16646
16632
|
returns: permissiveReturn,
|
|
16647
16633
|
handler: async (ctx, args) => {
|
|
16648
|
-
if (!
|
|
16634
|
+
if (!args.topicId) {
|
|
16649
16635
|
return [];
|
|
16650
16636
|
}
|
|
16651
16637
|
const queryCtx = asEpistemicNodesQueryCtx(ctx);
|
|
@@ -16687,7 +16673,7 @@ var getByProjectAndTypeLite = query({
|
|
|
16687
16673
|
},
|
|
16688
16674
|
returns: permissiveReturn,
|
|
16689
16675
|
handler: async (ctx, args) => {
|
|
16690
|
-
if (!
|
|
16676
|
+
if (!args.topicId) {
|
|
16691
16677
|
return [];
|
|
16692
16678
|
}
|
|
16693
16679
|
const queryCtx = asEpistemicNodesQueryCtx(ctx);
|
|
@@ -16729,7 +16715,7 @@ var getByProject6 = query({
|
|
|
16729
16715
|
},
|
|
16730
16716
|
returns: permissiveReturn,
|
|
16731
16717
|
handler: async (ctx, args) => {
|
|
16732
|
-
if (!
|
|
16718
|
+
if (!args.topicId) {
|
|
16733
16719
|
return [];
|
|
16734
16720
|
}
|
|
16735
16721
|
const queryCtx = asEpistemicNodesQueryCtx(ctx);
|
|
@@ -16755,7 +16741,7 @@ var getByProject6 = query({
|
|
|
16755
16741
|
if (args.userId) {
|
|
16756
16742
|
const hasAccess = await checkScopeAccess(
|
|
16757
16743
|
ctx,
|
|
16758
|
-
String(scope.topicId
|
|
16744
|
+
String(scope.topicId),
|
|
16759
16745
|
args.userId
|
|
16760
16746
|
);
|
|
16761
16747
|
if (!hasAccess) {
|
|
@@ -16794,7 +16780,7 @@ var search = query({
|
|
|
16794
16780
|
const queryCtx = asEpistemicNodesQueryCtx(ctx);
|
|
16795
16781
|
const pageSize = clampNodeLimit(args.limit, 100);
|
|
16796
16782
|
let scope;
|
|
16797
|
-
if (args.
|
|
16783
|
+
if (args.topicId) {
|
|
16798
16784
|
try {
|
|
16799
16785
|
scope = await resolveTopicProjectScope(queryCtx, {
|
|
16800
16786
|
projectId: args.projectId,
|
|
@@ -17218,11 +17204,10 @@ var createInternal2 = internalMutation({
|
|
|
17218
17204
|
returns: permissiveReturn,
|
|
17219
17205
|
handler: async (ctx, args) => {
|
|
17220
17206
|
const now = Date.now();
|
|
17221
|
-
const resolvedScope = args.topicId
|
|
17207
|
+
const resolvedScope = args.topicId ? await (async () => {
|
|
17222
17208
|
try {
|
|
17223
17209
|
return await resolveTopicProjectScope(ctx, {
|
|
17224
|
-
topicId: args.topicId
|
|
17225
|
-
projectId: args.projectId
|
|
17210
|
+
topicId: args.topicId
|
|
17226
17211
|
});
|
|
17227
17212
|
} catch (error) {
|
|
17228
17213
|
debugGraphPrimitiveFallback(
|
|
@@ -17560,9 +17545,8 @@ var create7 = mutation({
|
|
|
17560
17545
|
return { nodeId: existingNode._id, isDuplicate: true };
|
|
17561
17546
|
}
|
|
17562
17547
|
const epistemicLayer = getNodeLayer(args.nodeType);
|
|
17563
|
-
const resolvedScope = args.topicId
|
|
17564
|
-
topicId: args.topicId
|
|
17565
|
-
projectId: args.projectId
|
|
17548
|
+
const resolvedScope = args.topicId ? await resolveTopicProjectScope(ctx, {
|
|
17549
|
+
topicId: args.topicId
|
|
17566
17550
|
}) : void 0;
|
|
17567
17551
|
if (resolvedScope) {
|
|
17568
17552
|
assertWorkspaceScopedEpistemicNodeScope({
|
|
@@ -17930,7 +17914,7 @@ var batchCreate2 = mutation({
|
|
|
17930
17914
|
returns: permissiveReturn,
|
|
17931
17915
|
handler: async (ctx, args) => {
|
|
17932
17916
|
const resolveNodeScope = async (node) => {
|
|
17933
|
-
if (!
|
|
17917
|
+
if (!node.topicId) {
|
|
17934
17918
|
return;
|
|
17935
17919
|
}
|
|
17936
17920
|
try {
|
|
@@ -18155,16 +18139,16 @@ function normalizeQuestionTopicId(topicId2) {
|
|
|
18155
18139
|
return typeof topicId2 === "string" && topicId2.trim().length > 0 ? topicId2 : void 0;
|
|
18156
18140
|
}
|
|
18157
18141
|
function resolveQuestionScopeId(scope) {
|
|
18158
|
-
return normalizeQuestionTopicId(scope.topicId)
|
|
18142
|
+
return normalizeQuestionTopicId(scope.topicId);
|
|
18159
18143
|
}
|
|
18160
18144
|
function logQuestionFallback(message, error, context) {
|
|
18161
18145
|
debugGraphPrimitiveFallback(message, {
|
|
18162
18146
|
error: formatGraphPrimitiveError(error),
|
|
18163
|
-
...context
|
|
18147
|
+
...context
|
|
18164
18148
|
});
|
|
18165
18149
|
}
|
|
18166
18150
|
async function resolveQuestionScopeOrNull(ctx, args) {
|
|
18167
|
-
if (!
|
|
18151
|
+
if (!args.topicId) {
|
|
18168
18152
|
return null;
|
|
18169
18153
|
}
|
|
18170
18154
|
try {
|
|
@@ -18197,9 +18181,12 @@ async function getQuestionNodesForScope(ctx, scope, args) {
|
|
|
18197
18181
|
);
|
|
18198
18182
|
}
|
|
18199
18183
|
async function getQuestionEdgesForScope(ctx, scope) {
|
|
18184
|
+
if (!scope.topicId) {
|
|
18185
|
+
return [];
|
|
18186
|
+
}
|
|
18200
18187
|
const query2 = ctx.db.query("epistemicEdges").withIndex(
|
|
18201
18188
|
"by_topic",
|
|
18202
|
-
(q) => q.eq("topicId", scope.topicId
|
|
18189
|
+
(q) => q.eq("topicId", scope.topicId)
|
|
18203
18190
|
);
|
|
18204
18191
|
return await query2.collect();
|
|
18205
18192
|
}
|
|
@@ -18422,7 +18409,7 @@ function resolveLinkedBeliefNodeIdFromMetadata(meta) {
|
|
|
18422
18409
|
return readOptionalString27(meta.linkedBeliefNodeId) || readOptionalString27(meta.linkedBeliefId) || readOptionalString27(meta.beliefId);
|
|
18423
18410
|
}
|
|
18424
18411
|
async function scheduleEvidenceCreationFromScoredQuestion(ctx, options) {
|
|
18425
|
-
if (!
|
|
18412
|
+
if (!options.topicId) {
|
|
18426
18413
|
return;
|
|
18427
18414
|
}
|
|
18428
18415
|
const linkedBeliefId = resolveLinkedBeliefNodeIdFromMetadata(
|
|
@@ -18534,7 +18521,7 @@ async function syncBeliefTestEdge(ctx, questionNode, beliefNode, args) {
|
|
|
18534
18521
|
toGlobalId: beliefGlobalId,
|
|
18535
18522
|
edgeType: "tests",
|
|
18536
18523
|
context: args.testType || "tests",
|
|
18537
|
-
topicId: normalizeQuestionTopicId(questionNode.topicId)
|
|
18524
|
+
topicId: normalizeQuestionTopicId(questionNode.topicId),
|
|
18538
18525
|
createdBy: args.userId,
|
|
18539
18526
|
fromNodeType: "question",
|
|
18540
18527
|
toNodeType: "belief",
|
|
@@ -19290,7 +19277,7 @@ var create8 = mutation({
|
|
|
19290
19277
|
createdBy: args.userId,
|
|
19291
19278
|
questionGlobalId: globalId,
|
|
19292
19279
|
testType: args.testType,
|
|
19293
|
-
topicId: normalizeQuestionTopicId(scope.topicId)
|
|
19280
|
+
topicId: normalizeQuestionTopicId(scope.topicId)
|
|
19294
19281
|
});
|
|
19295
19282
|
}
|
|
19296
19283
|
await ctx.db.insert("epistemicAudit", {
|
|
@@ -19307,7 +19294,7 @@ var create8 = mutation({
|
|
|
19307
19294
|
priority: args.priority || "medium"
|
|
19308
19295
|
}
|
|
19309
19296
|
});
|
|
19310
|
-
if (scope.
|
|
19297
|
+
if (scope.topicId) {
|
|
19311
19298
|
await ctx.scheduler.runAfter(0, EMBEDDING_GENERATION_ACTION3, {
|
|
19312
19299
|
nodeId,
|
|
19313
19300
|
projectId: scope.projectId,
|
|
@@ -19318,7 +19305,7 @@ var create8 = mutation({
|
|
|
19318
19305
|
hasAnswer: false
|
|
19319
19306
|
});
|
|
19320
19307
|
}
|
|
19321
|
-
if (scope.
|
|
19308
|
+
if (scope.topicId) {
|
|
19322
19309
|
await ctx.scheduler.runAfter(
|
|
19323
19310
|
2e3,
|
|
19324
19311
|
// 2 second delay
|
|
@@ -19436,7 +19423,7 @@ var createBatch = mutation({
|
|
|
19436
19423
|
createdBy: args.userId,
|
|
19437
19424
|
questionGlobalId: globalId,
|
|
19438
19425
|
testType: q.testType,
|
|
19439
|
-
topicId: normalizeQuestionTopicId(scope.topicId)
|
|
19426
|
+
topicId: normalizeQuestionTopicId(scope.topicId)
|
|
19440
19427
|
});
|
|
19441
19428
|
}
|
|
19442
19429
|
}
|
|
@@ -19523,10 +19510,10 @@ var internalCreate3 = internalMutation({
|
|
|
19523
19510
|
createdBy: args.userId,
|
|
19524
19511
|
questionGlobalId: globalId,
|
|
19525
19512
|
testType: args.testType,
|
|
19526
|
-
topicId: normalizeQuestionTopicId(scope.topicId)
|
|
19513
|
+
topicId: normalizeQuestionTopicId(scope.topicId)
|
|
19527
19514
|
});
|
|
19528
19515
|
}
|
|
19529
|
-
if (scope.
|
|
19516
|
+
if (scope.topicId) {
|
|
19530
19517
|
await ctx.scheduler.runAfter(0, EMBEDDING_GENERATION_ACTION3, {
|
|
19531
19518
|
nodeId,
|
|
19532
19519
|
projectId: scope.projectId,
|
|
@@ -19702,7 +19689,7 @@ function readBeliefNodeRow2(value) {
|
|
|
19702
19689
|
return id && globalId && nodeType ? { _id: id, globalId, nodeType } : null;
|
|
19703
19690
|
}
|
|
19704
19691
|
function resolveCanonicalEdgeTopicId(args) {
|
|
19705
|
-
return normalizeQuestionTopicId(args.topicId)
|
|
19692
|
+
return normalizeQuestionTopicId(args.topicId);
|
|
19706
19693
|
}
|
|
19707
19694
|
var createEvidenceFromScoredQuestion = internalMutation({
|
|
19708
19695
|
args: {
|