@lucern/graph-primitives 1.0.28 → 1.0.30
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-BmkEk5OJ.d.ts} +3 -3
- package/dist/beliefDecay.d.ts +1 -1
- package/dist/beliefDecay.js +448 -314
- package/dist/beliefDecay.js.map +1 -1
- package/dist/{beliefEvidenceLinks-CWOXxxJg.d.ts → beliefEvidenceLinks-BzfjON_6.d.ts} +13 -13
- package/dist/beliefEvidenceLinks.d.ts +1 -1
- package/dist/beliefEvidenceLinks.js +843 -624
- package/dist/beliefEvidenceLinks.js.map +1 -1
- package/dist/beliefEvidenceLinks.operational.d.ts +7 -5
- package/dist/beliefEvidenceLinks.operational.js +91 -18
- package/dist/beliefEvidenceLinks.operational.js.map +1 -1
- package/dist/beliefLifecycle.js.map +1 -1
- package/dist/confidencePropagationDispatch.d.ts +28 -27
- package/dist/confidencePropagationDispatch.js +157 -99
- package/dist/confidencePropagationDispatch.js.map +1 -1
- package/dist/{contradictions-51VLsESq.d.ts → contradictions-BATPuZTL.d.ts} +10 -10
- package/dist/contradictions.d.ts +1 -1
- package/dist/contradictions.js +398 -228
- package/dist/contradictions.js.map +1 -1
- package/dist/convex.d.ts +65 -30
- package/dist/convex.js +7 -3
- package/dist/convex.js.map +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/edgeValidation.js +293 -85
- package/dist/edgeValidation.js.map +1 -1
- package/dist/edges/contains.d.ts +1 -1
- package/dist/edges/contains.js.map +1 -1
- package/dist/edges/contradicts.d.ts +1 -1
- package/dist/edges/contradicts.js.map +1 -1
- package/dist/edges/{dependsOn.d.ts → depends-on.d.ts} +1 -1
- package/dist/edges/{dependsOn.js → depends-on.js} +4 -4
- package/dist/edges/depends-on.js.map +1 -0
- package/dist/edges/{derivedFrom.d.ts → derived-from.d.ts} +1 -1
- package/dist/edges/{derivedFrom.js → derived-from.js} +3 -3
- package/dist/edges/derived-from.js.map +1 -0
- package/dist/edges/elaborates.d.ts +1 -1
- package/dist/edges/elaborates.js.map +1 -1
- package/dist/edges/index.d.ts +7 -3
- package/dist/edges/index.js +7 -4
- package/dist/edges/index.js.map +1 -1
- package/dist/edges/informs.d.ts +1 -1
- package/dist/edges/informs.js.map +1 -1
- package/dist/edges/{propagationTypes.d.ts → propagation-types.d.ts} +14 -14
- package/dist/edges/{propagationTypes.js → propagation-types.js} +3 -3
- package/dist/edges/propagation-types.js.map +1 -0
- package/dist/edges/refutes.d.ts +1 -1
- package/dist/edges/refutes.js.map +1 -1
- package/dist/edges/supports.d.ts +1 -1
- package/dist/edges/supports.js.map +1 -1
- package/dist/edges/tests.d.ts +1 -1
- package/dist/edges/tests.js.map +1 -1
- package/dist/edges/utils.d.ts +1 -1
- package/dist/edges/utils.js.map +1 -1
- package/dist/embeddingTrigger.d.ts +14 -6
- package/dist/embeddingTrigger.js +11 -14
- package/dist/embeddingTrigger.js.map +1 -1
- package/dist/{entityBridge-DMaKooYn.d.ts → entityBridge-BhVDM3pc.d.ts} +5 -5
- package/dist/entityBridge.d.ts +1 -1
- package/dist/entityBridge.js +602 -225
- package/dist/entityBridge.js.map +1 -1
- package/dist/entityCanonicalMatch.d.ts +14 -12
- package/dist/entityCanonicalMatch.js.map +1 -1
- package/dist/{entityLifecycle-CvgSK5FV.d.ts → entityLifecycle-BsfCz9pS.d.ts} +5 -9
- package/dist/entityLifecycle.d.ts +1 -1
- package/dist/entityLifecycle.js +857 -515
- package/dist/entityLifecycle.js.map +1 -1
- package/dist/{entityValidation-KLZ_Xl2D.d.ts → entityValidation-B1yNEHJx.d.ts} +7 -6
- package/dist/entityValidation.d.ts +3 -1
- package/dist/entityValidation.js +60 -8
- package/dist/entityValidation.js.map +1 -1
- package/dist/{epistemicAnswers-C5ib4z6_.d.ts → epistemicAnswers-f47YMu9U.d.ts} +6 -6
- package/dist/epistemicAnswers.d.ts +1 -1
- package/dist/epistemicAnswers.js +587 -545
- package/dist/epistemicAnswers.js.map +1 -1
- package/dist/epistemicBeliefs.admin.d.ts +8 -8
- package/dist/epistemicBeliefs.admin.js +366 -203
- package/dist/epistemicBeliefs.admin.js.map +1 -1
- package/dist/epistemicBeliefs.backfills.d.ts +8 -8
- package/dist/epistemicBeliefs.backfills.js +655 -308
- package/dist/epistemicBeliefs.backfills.js.map +1 -1
- package/dist/epistemicBeliefs.confidence.d.ts +19 -14
- package/dist/epistemicBeliefs.confidence.js +634 -423
- package/dist/epistemicBeliefs.confidence.js.map +1 -1
- package/dist/epistemicBeliefs.core.d.ts +6 -6
- package/dist/epistemicBeliefs.core.js +719 -411
- package/dist/epistemicBeliefs.core.js.map +1 -1
- package/dist/epistemicBeliefs.d.ts +11 -8
- package/dist/epistemicBeliefs.forkEvidence.d.ts +2 -0
- package/dist/epistemicBeliefs.forkEvidence.js +8 -28
- package/dist/epistemicBeliefs.forkEvidence.js.map +1 -1
- package/dist/epistemicBeliefs.helpers.d.ts +69 -74
- package/dist/epistemicBeliefs.helpers.js +359 -248
- package/dist/epistemicBeliefs.helpers.js.map +1 -1
- package/dist/epistemicBeliefs.internal.d.ts +5 -5
- package/dist/epistemicBeliefs.internal.js +1246 -1044
- package/dist/epistemicBeliefs.internal.js.map +1 -1
- package/dist/epistemicBeliefs.js +4922 -3608
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicBeliefs.lifecycle.d.ts +5 -5
- package/dist/epistemicBeliefs.lifecycle.js +1137 -818
- package/dist/epistemicBeliefs.lifecycle.js.map +1 -1
- package/dist/epistemicBeliefs.links.d.ts +7 -7
- package/dist/epistemicBeliefs.links.js +408 -307
- package/dist/epistemicBeliefs.links.js.map +1 -1
- package/dist/epistemicBeliefs.queries.d.ts +4 -4
- package/dist/epistemicBeliefs.queries.js +175 -20
- package/dist/epistemicBeliefs.queries.js.map +1 -1
- package/dist/epistemicBeliefs.topicAnchor.d.ts +6 -4
- package/dist/epistemicBeliefs.topicAnchor.js +12 -5
- package/dist/epistemicBeliefs.topicAnchor.js.map +1 -1
- package/dist/epistemicContracts.d.ts +28 -3
- package/dist/epistemicContracts.evaluators.d.ts +2 -0
- package/dist/epistemicContracts.evaluators.js +1063 -613
- package/dist/epistemicContracts.evaluators.js.map +1 -1
- package/dist/epistemicContracts.handlers.d.ts +15 -32
- package/dist/epistemicContracts.handlers.js +2086 -1644
- package/dist/epistemicContracts.handlers.js.map +1 -1
- package/dist/epistemicContracts.js +1131 -672
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/epistemicContracts.metrics.d.ts +2 -0
- package/dist/epistemicContracts.metrics.js +375 -158
- package/dist/epistemicContracts.metrics.js.map +1 -1
- package/dist/epistemicContracts.types.d.ts +87 -81
- package/dist/epistemicEdgeCreation.d.ts +2 -0
- package/dist/epistemicEdgeCreation.js +87 -16
- package/dist/epistemicEdgeCreation.js.map +1 -1
- package/dist/{epistemicEdges-BF-cn4i3.d.ts → epistemicEdges-BGBh0QSP.d.ts} +4 -7
- package/dist/epistemicEdges.d.ts +6 -5
- package/dist/epistemicEdges.handlers.d.ts +3 -3
- package/dist/epistemicEdges.handlers.js +129 -24
- package/dist/epistemicEdges.handlers.js.map +1 -1
- package/dist/epistemicEdges.helpers.d.ts +6 -4
- package/dist/epistemicEdges.helpers.js +37 -2
- package/dist/epistemicEdges.helpers.js.map +1 -1
- package/dist/epistemicEdges.js +1969 -1205
- package/dist/epistemicEdges.js.map +1 -1
- package/dist/epistemicEdges.mutations.d.ts +7 -7
- package/dist/epistemicEdges.mutations.js +960 -583
- package/dist/epistemicEdges.mutations.js.map +1 -1
- package/dist/epistemicEdges.queries.d.ts +16 -16
- package/dist/epistemicEdges.queries.js +639 -367
- package/dist/epistemicEdges.queries.js.map +1 -1
- package/dist/epistemicEdges.types.d.ts +10 -8
- package/dist/epistemicEvidence.d.ts +4 -1
- package/dist/epistemicEvidence.js +937 -536
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/epistemicEvidenceHelpers.d.ts +26 -10
- package/dist/epistemicEvidenceHelpers.js +239 -200
- package/dist/epistemicEvidenceHelpers.js.map +1 -1
- package/dist/epistemicEvidenceMutations.d.ts +8 -8
- package/dist/epistemicEvidenceMutations.js +844 -696
- package/dist/epistemicEvidenceMutations.js.map +1 -1
- package/dist/epistemicEvidenceQueries.d.ts +8 -8
- package/dist/epistemicEvidenceQueries.js +514 -238
- package/dist/epistemicEvidenceQueries.js.map +1 -1
- package/dist/epistemicHelpers.d.ts +4 -2
- package/dist/epistemicHelpers.js +308 -134
- package/dist/epistemicHelpers.js.map +1 -1
- package/dist/epistemicInsert.d.ts +16 -4
- package/dist/epistemicInsert.js +6 -3
- package/dist/epistemicInsert.js.map +1 -1
- package/dist/epistemicLayerRules.d.ts +10 -8
- package/dist/epistemicLayerRules.js +1 -5
- package/dist/epistemicLayerRules.js.map +1 -1
- package/dist/{epistemicLinking-CfE00tHJ.d.ts → epistemicLinking-CsCDv2cN.d.ts} +3 -3
- package/dist/epistemicLinking.d.ts +1 -1
- package/dist/epistemicLinking.js +177 -100
- package/dist/epistemicLinking.js.map +1 -1
- package/dist/epistemicNodeCreation.d.ts +2 -0
- package/dist/epistemicNodeCreation.js +203 -40
- package/dist/epistemicNodeCreation.js.map +1 -1
- package/dist/{epistemicNodes-BCQxpYx_.d.ts → epistemicNodes-CokAgBHg.d.ts} +3 -3
- package/dist/epistemicNodes.d.ts +3 -3
- package/dist/epistemicNodes.helpers.d.ts +24 -15
- package/dist/epistemicNodes.helpers.js.map +1 -1
- package/dist/epistemicNodes.internal.d.ts +6 -6
- package/dist/epistemicNodes.internal.js +389 -319
- package/dist/epistemicNodes.internal.js.map +1 -1
- package/dist/epistemicNodes.js +704 -508
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/epistemicNodes.mutations.d.ts +6 -6
- package/dist/epistemicNodes.mutations.js +564 -467
- package/dist/epistemicNodes.mutations.js.map +1 -1
- package/dist/epistemicNodes.queries.d.ts +8 -8
- package/dist/epistemicNodes.queries.js +311 -314
- package/dist/epistemicNodes.queries.js.map +1 -1
- package/dist/epistemicNodes.validators.d.ts +2 -2
- package/dist/epistemicNodes.validators.js.map +1 -1
- package/dist/epistemicQuestions.conviction.d.ts +8 -8
- package/dist/epistemicQuestions.conviction.js +665 -484
- package/dist/epistemicQuestions.conviction.js.map +1 -1
- package/dist/epistemicQuestions.create.d.ts +4 -4
- package/dist/epistemicQuestions.create.js +640 -612
- package/dist/epistemicQuestions.create.js.map +1 -1
- package/dist/epistemicQuestions.d.ts +8 -5
- package/dist/epistemicQuestions.evidence.d.ts +2 -2
- package/dist/epistemicQuestions.evidence.js +475 -383
- package/dist/epistemicQuestions.evidence.js.map +1 -1
- package/dist/epistemicQuestions.helpers.d.ts +125 -24
- package/dist/epistemicQuestions.helpers.js +240 -209
- package/dist/epistemicQuestions.helpers.js.map +1 -1
- package/dist/epistemicQuestions.js +3474 -2823
- package/dist/epistemicQuestions.js.map +1 -1
- package/dist/epistemicQuestions.lifecycle.d.ts +2 -2
- package/dist/epistemicQuestions.lifecycle.js +607 -546
- package/dist/epistemicQuestions.lifecycle.js.map +1 -1
- package/dist/epistemicQuestions.queries.d.ts +12 -7
- package/dist/epistemicQuestions.queries.js +305 -244
- package/dist/epistemicQuestions.queries.js.map +1 -1
- package/dist/epistemicQuestions.sprint.d.ts +2 -2
- package/dist/epistemicQuestions.sprint.js +600 -394
- package/dist/epistemicQuestions.sprint.js.map +1 -1
- package/dist/epistemicQuestions.tail.d.ts +6 -6
- package/dist/epistemicQuestions.tail.js +572 -433
- package/dist/epistemicQuestions.tail.js.map +1 -1
- package/dist/{epistemicSources-dlKj58Jp.d.ts → epistemicSources-DQtaEkWs.d.ts} +4 -4
- package/dist/epistemicSources.d.ts +1 -1
- package/dist/epistemicSources.js +352 -312
- package/dist/epistemicSources.js.map +1 -1
- package/dist/evaluators/index.d.ts +8 -6
- package/dist/evaluators/index.js +399 -167
- package/dist/evaluators/index.js.map +1 -1
- package/dist/evaluators/lint-checker-evaluator.d.ts +16 -0
- package/dist/evaluators/{lintCheckerEvaluator.js → lint-checker-evaluator.js} +10 -5
- package/dist/evaluators/lint-checker-evaluator.js.map +1 -0
- package/dist/evaluators/{sentryCheckerEvaluator.d.ts → sentry-checker-evaluator.d.ts} +7 -2
- package/dist/evaluators/{sentryCheckerEvaluator.js → sentry-checker-evaluator.js} +3 -3
- package/dist/evaluators/sentry-checker-evaluator.js.map +1 -0
- package/dist/evaluators/shared.d.ts +2 -2
- package/dist/evaluators/shared.js +3 -1
- package/dist/evaluators/shared.js.map +1 -1
- package/dist/evaluators/{testRunnerEvaluator.d.ts → test-runner-evaluator.d.ts} +6 -1
- package/dist/evaluators/{testRunnerEvaluator.js → test-runner-evaluator.js} +6 -4
- package/dist/evaluators/test-runner-evaluator.js.map +1 -0
- package/dist/evaluators/tsc-checker-evaluator.d.ts +16 -0
- package/dist/evaluators/{tscCheckerEvaluator.js → tsc-checker-evaluator.js} +10 -5
- package/dist/evaluators/tsc-checker-evaluator.js.map +1 -0
- package/dist/graphTypes.js +6 -2
- package/dist/graphTypes.js.map +1 -1
- package/dist/helpers.d.ts +2 -0
- package/dist/helpers.js +313 -93
- package/dist/helpers.js.map +1 -1
- package/dist/{index-C-Kyd7hD.d.ts → index-DZxyC9Pb.d.ts} +7 -6
- package/dist/index.d.ts +87 -83
- package/dist/index.js +15677 -10594
- package/dist/index.js.map +1 -1
- package/dist/invariantEnforcement.d.ts +3 -3
- package/dist/invariantEnforcement.js.map +1 -1
- package/dist/logicalRoleInference.d.ts +2 -0
- package/dist/logicalRoleInference.js +1 -1
- package/dist/logicalRoleInference.js.map +1 -1
- package/dist/matcherFeedbackUtils.d.ts +2 -2
- package/dist/matcherFeedbackUtils.js.map +1 -1
- package/dist/{ontology-matching-C6rrz2VP.d.ts → ontology-matching-C-mYFrir.d.ts} +16 -16
- package/dist/ontology-matching.d.ts +1 -1
- package/dist/{ontologyApproval-CFYmqKmk.d.ts → ontologyApproval-BVt0feJi.d.ts} +10 -10
- package/dist/ontologyApproval.d.ts +1 -1
- package/dist/ontologyApproval.js +7 -1
- package/dist/ontologyApproval.js.map +1 -1
- package/dist/ontologyDefinitions.d.ts +14 -24
- package/dist/ontologyDefinitions.js +269 -34
- package/dist/ontologyDefinitions.js.map +1 -1
- package/dist/ontologyHelpers.d.ts +13 -13
- package/dist/ontologyHelpers.js.map +1 -1
- package/dist/{ontologyRegistry-B67rPJ16.d.ts → ontologyRegistry-CljS-ENv.d.ts} +2 -2
- package/dist/ontologyRegistry.d.ts +1 -1
- package/dist/ontologyRegistry.js +34 -6
- package/dist/ontologyRegistry.js.map +1 -1
- package/dist/{projectionReconciliation-jww2fBI0.d.ts → projectionReconciliation-DnrSgHSQ.d.ts} +4 -4
- package/dist/projectionReconciliation.d.ts +1 -1
- package/dist/projectionReconciliation.js +57 -10
- package/dist/projectionReconciliation.js.map +1 -1
- package/dist/{projectionStaleness-CmdbpjVK.d.ts → projectionStaleness-C8ImQ2zP.d.ts} +17 -17
- package/dist/projectionStaleness.d.ts +1 -1
- package/dist/projectionStaleness.js +8 -2
- package/dist/projectionStaleness.js.map +1 -1
- package/dist/proof-attestation.json +1 -1
- package/dist/{questionEvidenceLinks-DFlyPpAj.d.ts → questionEvidenceLinks-_nPRa-LY.d.ts} +10 -10
- package/dist/questionEvidenceLinks.d.ts +1 -1
- package/dist/questionEvidenceLinks.js +564 -347
- package/dist/questionEvidenceLinks.js.map +1 -1
- package/dist/{resolverTypes-CC8Ea2E2.d.ts → resolverTypes-BOXPxLET.d.ts} +8 -7
- package/dist/resolverTypes.d.ts +4 -2
- package/dist/{resolvers-Br1a6eLV.d.ts → resolvers-B1TIBmRO.d.ts} +3 -1
- package/dist/resolvers.d.ts +5 -3
- package/dist/resolvers.js +121 -77
- package/dist/resolvers.js.map +1 -1
- package/dist/scopeResolverCompat.d.ts +10 -7
- package/dist/scopeResolverCompat.js +106 -123
- package/dist/scopeResolverCompat.js.map +1 -1
- package/dist/{text-matching-DNg4M5Wd.d.ts → text-matching-DzFooju6.d.ts} +7 -7
- package/dist/text-matching.d.ts +1 -1
- package/dist/topicOntologyResolver.d.ts +22 -21
- package/dist/topicOntologyResolver.js +54 -32
- package/dist/topicOntologyResolver.js.map +1 -1
- package/dist/topicProjectOverlay.d.ts +30 -20
- package/dist/topicProjectOverlay.js +120 -76
- package/dist/topicProjectOverlay.js.map +1 -1
- package/dist/{topicScope-7zhyeGl7.d.ts → topicScope-DJVa0mLa.d.ts} +22 -7
- package/dist/topicScope.d.ts +3 -1
- package/dist/topicScope.js +104 -119
- package/dist/topicScope.js.map +1 -1
- package/dist/workflowBridge.d.ts +26 -15
- package/dist/workflowBridge.js +140 -144
- package/dist/workflowBridge.js.map +1 -1
- package/dist/workspaceIsolation.d.ts +14 -12
- package/dist/workspaceIsolation.js +108 -122
- package/dist/workspaceIsolation.js.map +1 -1
- package/package.json +4 -4
- package/dist/edges/dependsOn.js.map +0 -1
- package/dist/edges/derivedFrom.js.map +0 -1
- package/dist/edges/propagationTypes.js.map +0 -1
- package/dist/evaluators/lintCheckerEvaluator.d.ts +0 -11
- package/dist/evaluators/lintCheckerEvaluator.js.map +0 -1
- package/dist/evaluators/sentryCheckerEvaluator.js.map +0 -1
- package/dist/evaluators/testRunnerEvaluator.js.map +0 -1
- package/dist/evaluators/tscCheckerEvaluator.d.ts +0 -11
- package/dist/evaluators/tscCheckerEvaluator.js.map +0 -1
- package/dist/{epistemicQuestions-bwHd2FWE.d.ts → epistemicQuestions-Do1fhYm5.d.ts} +4 -4
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { MutationCtx, Id } from './convex.js';
|
|
2
|
+
import '@lucern/access-control/convex';
|
|
3
|
+
import '@lucern/contracts/convex/unsafeAnyApi';
|
|
2
4
|
import 'convex/values';
|
|
3
5
|
|
|
4
6
|
type BeliefEvidenceRelation = "supports" | "contradicts";
|
|
5
|
-
|
|
7
|
+
interface EpistemicNode {
|
|
6
8
|
_id: Id<"epistemicNodes">;
|
|
7
|
-
|
|
9
|
+
contradictingInsightIds?: Id<"epistemicNodes">[];
|
|
8
10
|
globalId?: string;
|
|
11
|
+
nodeType?: string;
|
|
9
12
|
projectId?: string;
|
|
10
|
-
topicId?: string | Id<"topics">;
|
|
11
13
|
supportingInsightIds?: Id<"epistemicNodes">[];
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
+
topicId?: string | Id<"topics">;
|
|
15
|
+
}
|
|
14
16
|
declare function applyOperationalLinkEffects(ctx: MutationCtx, args: {
|
|
15
17
|
beliefNode: EpistemicNode;
|
|
16
18
|
beliefId: Id<"epistemicNodes">;
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { unsafeConvexAnyApi } from '@lucern/contracts/convex/unsafeAnyApi';
|
|
2
|
+
import { componentsGeneric } from 'convex/server';
|
|
3
3
|
import { assertEdgePolicyAllowed, edgePolicyManifest } from '@lucern/contracts';
|
|
4
|
+
import { generateGlobalId, assertUuidV7Identity, assertStorageEdgeVocabulary, assertUuidShapedEdgeEndpoint } from '@lucern/contracts/ids';
|
|
4
5
|
|
|
5
6
|
// src/convex.ts
|
|
7
|
+
var unsafeApi = unsafeConvexAnyApi(
|
|
8
|
+
"graph-primitives top-level module bundle lacks a committed Convex _generated/api surface"
|
|
9
|
+
);
|
|
6
10
|
componentsGeneric();
|
|
7
|
-
var internal =
|
|
11
|
+
var internal = unsafeApi;
|
|
8
12
|
async function assertExistingNodeEndpoint(ctx, endpointRole, endpoint) {
|
|
9
13
|
assertUuidShapedEdgeEndpoint(endpointRole, endpoint);
|
|
10
|
-
const node = await ctx.db.query("epistemicNodes").withIndex(
|
|
14
|
+
const node = await ctx.db.query("epistemicNodes").withIndex(
|
|
15
|
+
"by_globalId",
|
|
16
|
+
(q) => q.eq("globalId", endpoint)
|
|
17
|
+
).first();
|
|
11
18
|
if (!node) {
|
|
12
19
|
throw new Error(
|
|
13
20
|
`edge_endpoint_not_canonical: epistemicEdges insert requires ${endpointRole} to be the globalId of an existing epistemicNodes row, received ${endpoint} (no node with that globalId)`
|
|
@@ -49,9 +56,72 @@ async function insertEpistemicEdge(ctx, doc) {
|
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
// src/beliefEvidenceLinks.operational.ts
|
|
59
|
+
function isRecord(value) {
|
|
60
|
+
return typeof value === "object" && value !== null;
|
|
61
|
+
}
|
|
62
|
+
function readConvexId(value) {
|
|
63
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
64
|
+
}
|
|
65
|
+
function readEpistemicEdgeDoc(value) {
|
|
66
|
+
if (!isRecord(value)) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const id = readConvexId(value._id);
|
|
70
|
+
if (!id || typeof value.edgeType !== "string" || typeof value.globalId !== "string") {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
_id: id,
|
|
75
|
+
edgeType: value.edgeType,
|
|
76
|
+
globalId: value.globalId
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function readInsightIdArray(value) {
|
|
80
|
+
if (!Array.isArray(value)) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
return value.flatMap((entry) => {
|
|
84
|
+
const id = readConvexId(entry);
|
|
85
|
+
return id ? [id] : [];
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function readInsightIdCollections(value) {
|
|
89
|
+
if (!isRecord(value)) {
|
|
90
|
+
return {
|
|
91
|
+
contradictingInsightIds: [],
|
|
92
|
+
supportingInsightIds: []
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
contradictingInsightIds: readInsightIdArray(value.contradictingInsightIds),
|
|
97
|
+
supportingInsightIds: readInsightIdArray(value.supportingInsightIds)
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function readSpineNodeDoc(value) {
|
|
101
|
+
if (!isRecord(value)) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const id = readConvexId(value._id);
|
|
105
|
+
if (!id || typeof value.globalId !== "string" || typeof value.nodeType !== "string") {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
_id: id,
|
|
110
|
+
globalId: value.globalId,
|
|
111
|
+
nodeType: value.nodeType
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function insertOperationalEpistemicEdge(ctx, doc) {
|
|
115
|
+
await insertEpistemicEdge(
|
|
116
|
+
ctx,
|
|
117
|
+
doc
|
|
118
|
+
);
|
|
119
|
+
}
|
|
52
120
|
function assertEvidenceImpact(args) {
|
|
53
121
|
if (!Number.isFinite(args.weight) || args.weight === 0 || args.weight < -1 || args.weight > 1) {
|
|
54
|
-
throw new Error(
|
|
122
|
+
throw new Error(
|
|
123
|
+
"Belief evidence links require explicit nonzero weight in [-1, 1]"
|
|
124
|
+
);
|
|
55
125
|
}
|
|
56
126
|
if (args.relation === "supports" && args.weight < 0) {
|
|
57
127
|
throw new Error("Supporting evidence links require positive weight");
|
|
@@ -81,13 +151,15 @@ async function applyOperationalLinkEffects(ctx, args) {
|
|
|
81
151
|
});
|
|
82
152
|
}
|
|
83
153
|
try {
|
|
84
|
-
const beliefSpineNode = await ctx.db.get(args.beliefId);
|
|
85
|
-
const evidenceSpineNode =
|
|
154
|
+
const beliefSpineNode = readSpineNodeDoc(await ctx.db.get(args.beliefId));
|
|
155
|
+
const evidenceSpineNode = readSpineNodeDoc(
|
|
156
|
+
await ctx.db.get(args.insightId)
|
|
157
|
+
);
|
|
86
158
|
if (beliefSpineNode?.nodeType === "belief" && evidenceSpineNode?.nodeType === "evidence") {
|
|
87
|
-
const existingEdges = await ctx.db.query("epistemicEdges").withIndex(
|
|
159
|
+
const existingEdges = (await ctx.db.query("epistemicEdges").withIndex(
|
|
88
160
|
"by_from_to",
|
|
89
161
|
(q) => q.eq("fromNodeId", evidenceSpineNode.globalId).eq("toNodeId", beliefSpineNode.globalId)
|
|
90
|
-
).collect();
|
|
162
|
+
).collect()).map(readEpistemicEdgeDoc).filter((edge) => edge !== null);
|
|
91
163
|
for (const edge of existingEdges) {
|
|
92
164
|
if (edge.edgeType === "informs") {
|
|
93
165
|
await ctx.scheduler.runAfter(0, internal.neo4jEdgeAPI.deleteEdge, {
|
|
@@ -98,7 +170,7 @@ async function applyOperationalLinkEffects(ctx, args) {
|
|
|
98
170
|
}
|
|
99
171
|
const globalId = generateGlobalId();
|
|
100
172
|
const context = args.rationale || `Linked as ${args.relation}`;
|
|
101
|
-
await
|
|
173
|
+
await insertOperationalEpistemicEdge(ctx, {
|
|
102
174
|
globalId,
|
|
103
175
|
// C2-RR.4 Defect E — canonical UUIDv7 endpoints, not Convex doc ids.
|
|
104
176
|
fromNodeId: evidenceSpineNode.globalId,
|
|
@@ -159,30 +231,31 @@ async function applyOperationalLinkEffects(ctx, args) {
|
|
|
159
231
|
async function removeOperationalLinkEffects(ctx, args) {
|
|
160
232
|
const belief = await ctx.db.get(args.beliefId);
|
|
161
233
|
if (belief) {
|
|
162
|
-
const
|
|
163
|
-
const currentContradicting = belief.contradictingInsightIds ?? [];
|
|
234
|
+
const { contradictingInsightIds, supportingInsightIds } = readInsightIdCollections(belief);
|
|
164
235
|
if (args.relation === "supports") {
|
|
165
236
|
await ctx.db.patch(args.beliefId, {
|
|
166
|
-
supportingInsightIds:
|
|
237
|
+
supportingInsightIds: supportingInsightIds.filter(
|
|
167
238
|
(id) => id !== args.insightId
|
|
168
239
|
)
|
|
169
240
|
});
|
|
170
241
|
} else {
|
|
171
242
|
await ctx.db.patch(args.beliefId, {
|
|
172
|
-
contradictingInsightIds:
|
|
243
|
+
contradictingInsightIds: contradictingInsightIds.filter(
|
|
173
244
|
(id) => id !== args.insightId
|
|
174
245
|
)
|
|
175
246
|
});
|
|
176
247
|
}
|
|
177
248
|
}
|
|
178
249
|
try {
|
|
179
|
-
const beliefSpineNode = await ctx.db.get(args.beliefId);
|
|
180
|
-
const evidenceSpineNode =
|
|
250
|
+
const beliefSpineNode = readSpineNodeDoc(await ctx.db.get(args.beliefId));
|
|
251
|
+
const evidenceSpineNode = readSpineNodeDoc(
|
|
252
|
+
await ctx.db.get(args.insightId)
|
|
253
|
+
);
|
|
181
254
|
if (beliefSpineNode?.nodeType === "belief" && evidenceSpineNode?.nodeType === "evidence") {
|
|
182
|
-
const edges = await ctx.db.query("epistemicEdges").withIndex(
|
|
255
|
+
const edges = (await ctx.db.query("epistemicEdges").withIndex(
|
|
183
256
|
"by_from_to",
|
|
184
257
|
(q) => q.eq("fromNodeId", evidenceSpineNode._id).eq("toNodeId", beliefSpineNode._id)
|
|
185
|
-
).collect();
|
|
258
|
+
).collect()).map(readEpistemicEdgeDoc).filter((edge) => edge !== null);
|
|
186
259
|
for (const edge of edges) {
|
|
187
260
|
if (edge.edgeType === "informs") {
|
|
188
261
|
await ctx.scheduler.runAfter(0, internal.neo4jEdgeAPI.deleteEdge, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/convex.ts","../src/epistemicInsert.ts","../src/beliefEvidenceLinks.operational.ts"],"names":[],"mappings":";;;;;AAyB0B,iBAAA;AACnB,IAAM,QAAA,GAAW,MAAA;ACKxB,eAAe,0BAAA,CACb,GAAA,EACA,YAAA,EACA,QAAA,EACe;AACf,EAAA,4BAAA,CAA6B,cAAc,QAAQ,CAAA;AACnD,EAAA,MAAM,OAAO,MAAM,GAAA,CAAI,EAAA,CACpB,KAAA,CAAM,gBAAgB,CAAA,CACtB,SAAA,CAAU,aAAA,EAAe,CAAC,MAAW,CAAA,CAAE,EAAA,CAAG,YAAY,QAAQ,CAAC,EAC/D,KAAA,EAAM;AACT,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,4DAAA,EAA+D,YAAY,CAAA,gEAAA,EAAmE,QAAQ,CAAA,6BAAA;AAAA,KACxJ;AAAA,EACF;AACF;AAEA,eAAsB,mBAAA,CACpB,KACA,GAAA,EAC+B;AA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AA,CAAK,GAAG,CAAA;AAAA,QAC9B;AAAA,MACF;AAAA,IACF;AAAA,EACF,SAAS,CAAA,EAAG;AACV,IAAA,OAAA,CAAQ,KAAA,CAAM,mDAAmD,CAAC,CAAA;AAAA,EACpE;AACF","file":"beliefEvidenceLinks.operational.js","sourcesContent":["import {\n actionGeneric,\n anyApi,\n componentsGeneric,\n httpActionGeneric,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n mutationGeneric,\n queryGeneric,\n} from \"convex/server\";\nimport type { GenericId } from \"convex/values\";\n\n// TODO(FR.11-structural): `api`/`internal`/`components` are `anyApi as any`\n// because this module source tree is bundled into the kernel host at deploy time\n// and has NO top-level Convex `_generated/` directory to import a typed surface\n// from. Every `api.*` / `internal.*` / string-literal cross-component ref in this\n// module (topicScope.ts, topicProjectOverlay.ts, questionEvidenceLinks.ts,\n// beliefEvidenceLinks*.ts, epistemicQuestions.helpers.ts) inherits `any` from\n// here. The fix is structural — generate a per-module typed surface or a shared\n// typed function-reference manifest (template: the typed `components.controlPlane`\n// in modules/control-plane/src/component/convex.ts and the\n// `KERNEL_API_REF_MANIFEST` pattern in packages/server-core/src/kernelApi.ts) —\n// owned by the FR.11 closing/synthesis pass, not a mechanical swap.\nexport const api = anyApi as any;\nexport const components = componentsGeneric() as any;\nexport const internal = anyApi as any;\n\nexport type TableNames = string;\nexport type Id<TableName extends TableNames = string> = GenericId<TableName>;\nexport type Doc<TableName extends TableNames = string> = any;\nexport type DataModel = any;\ntype IndexRangeBuilder = {\n field(fieldName: string): string;\n eq(fieldName: string, value: unknown): IndexRangeBuilder;\n gt(fieldName: string, value: unknown): IndexRangeBuilder;\n gte(fieldName: string, value: unknown): IndexRangeBuilder;\n lt(fieldName: string, value: unknown): IndexRangeBuilder;\n lte(fieldName: string, value: unknown): IndexRangeBuilder;\n};\ntype FilterBuilder = {\n eq(left: unknown, right: unknown): unknown;\n neq(left: unknown, right: unknown): unknown;\n gt(left: unknown, right: unknown): unknown;\n gte(left: unknown, right: unknown): unknown;\n lt(left: unknown, right: unknown): unknown;\n lte(left: unknown, right: unknown): unknown;\n and(...clauses: unknown[]): unknown;\n or(...clauses: unknown[]): unknown;\n field(fieldName: string): unknown;\n};\ntype QueryInitializer<TableName extends TableNames> = {\n withIndex(\n indexName: string,\n range?: (q: any) => unknown\n ): QueryInitializer<TableName>;\n filter(predicate: (q: any) => unknown): QueryInitializer<TableName>;\n order(direction: \"asc\" | \"desc\"): QueryInitializer<TableName>;\n collect(): Promise<Doc<TableName>[]>;\n take(limit: number): Promise<Doc<TableName>[]>;\n first(): Promise<Doc<TableName> | null>;\n unique(): Promise<Doc<TableName> | null>;\n};\nexport type DatabaseReader = {\n get<TableName extends TableNames>(\n id: Id<TableName>\n ): Promise<Doc<TableName> | null>;\n query<TableName extends TableNames>(\n tableName: TableName\n ): QueryInitializer<TableName>;\n normalizeId?<TableName extends TableNames>(\n tableName: TableName,\n id: string\n ): Id<TableName> | null;\n};\nexport type DatabaseWriter = DatabaseReader & {\n insert<TableName extends TableNames>(\n tableName: TableName,\n value: Record<string, unknown>\n ): Promise<Id<TableName>>;\n patch<TableName extends TableNames>(\n id: Id<TableName>,\n value: Record<string, unknown>\n ): Promise<void>;\n replace<TableName extends TableNames>(\n id: Id<TableName>,\n value: Record<string, unknown>\n ): Promise<void>;\n delete<TableName extends TableNames>(id: Id<TableName>): Promise<void>;\n};\ntype Scheduler = {\n runAfter(delayMs: number, functionReference: unknown, args?: unknown): Promise<void>;\n};\ntype AuthReader = {\n getUserIdentity(): Promise<unknown>;\n};\ntype RuntimeInvoker = {\n runQuery(functionReference: unknown, args?: unknown): Promise<any>;\n runMutation(functionReference: unknown, args?: unknown): Promise<any>;\n runAction(functionReference: unknown, args?: unknown): Promise<any>;\n};\nexport type QueryCtx = RuntimeInvoker & {\n auth: AuthReader;\n db: DatabaseReader;\n scheduler: Scheduler;\n};\nexport type MutationCtx = RuntimeInvoker & {\n auth: AuthReader;\n db: DatabaseWriter;\n scheduler: Scheduler;\n};\nexport type ActionCtx = RuntimeInvoker & {\n auth: AuthReader;\n scheduler: Scheduler;\n};\n\ntype ConvexFunctionBuilder<Ctx> = <\n Definition extends { handler?: (ctx: Ctx, args: any) => any },\n>(\n definition: Definition\n) => any;\n\nexport const action = actionGeneric as unknown as ConvexFunctionBuilder<ActionCtx>;\nexport const httpAction =\n httpActionGeneric as unknown as ConvexFunctionBuilder<ActionCtx>;\nexport const internalAction =\n internalActionGeneric as unknown as ConvexFunctionBuilder<ActionCtx>;\nexport const internalMutation =\n internalMutationGeneric as unknown as ConvexFunctionBuilder<MutationCtx>;\nexport const internalQuery =\n internalQueryGeneric as unknown as ConvexFunctionBuilder<QueryCtx>;\nexport const mutation =\n mutationGeneric as unknown as ConvexFunctionBuilder<MutationCtx>;\nexport const query = queryGeneric as unknown as ConvexFunctionBuilder<QueryCtx>;\n","import type { WithoutSystemFields } from \"convex/server\";\nimport {\n assertUuidV7Identity,\n assertStorageEdgeVocabulary,\n assertUuidShapedEdgeEndpoint,\n} from \"@lucern/contracts/ids\";\nimport {\n assertEdgePolicyAllowed,\n edgePolicyManifest,\n type EpistemicNodeType,\n} from \"@lucern/contracts\";\nimport type { Doc, Id, MutationCtx } from \"./convex\";\n\nexport async function insertEpistemicNode(\n ctx: MutationCtx,\n doc: WithoutSystemFields<Doc<\"epistemicNodes\">>,\n): Promise<Id<\"epistemicNodes\">> {\n assertUuidV7Identity(\"epistemicNodes\", doc.globalId);\n return ctx.db.insert(\"epistemicNodes\", doc);\n}\n\n/**\n * C2-RR.4b — REFERENTIAL edge-endpoint canonicality (amends RR.4's FORMAT guard).\n *\n * Proves an endpoint is the `globalId` of an EXISTING `epistemicNodes` row, not\n * that it has a v7 shape. Refuses doc-ids and fabricated/unknown endpoints while\n * keeping legacy v4-`globalId` nodes (the established prod corpus) linkable.\n * SHAPE pre-filter accepts both v4 and v7; the indexed `by_globalId` lookup is\n * the referential authority (no full scan). v7-format stays enforced only at new\n * identity minting (`assertUuidV7Identity`). See c2-rr4b-endpoint-referential.\n */\nasync function assertExistingNodeEndpoint(\n ctx: MutationCtx,\n endpointRole: \"fromNodeId\" | \"toNodeId\",\n endpoint: string,\n): Promise<void> {\n assertUuidShapedEdgeEndpoint(endpointRole, endpoint);\n const node = await ctx.db\n .query(\"epistemicNodes\")\n .withIndex(\"by_globalId\", (q: any) => q.eq(\"globalId\", endpoint))\n .first();\n if (!node) {\n throw new Error(\n `edge_endpoint_not_canonical: epistemicEdges insert requires ${endpointRole} to be the globalId of an existing epistemicNodes row, received ${endpoint} (no node with that globalId)`,\n );\n }\n}\n\nexport async function insertEpistemicEdge(\n ctx: MutationCtx,\n doc: WithoutSystemFields<Doc<\"epistemicEdges\">>,\n): Promise<Id<\"epistemicEdges\">> {\n assertUuidV7Identity(\"epistemicEdges\", doc.globalId);\n\n // R1.1a — STORAGE-VOCABULARY MEMBERSHIP\n assertStorageEdgeVocabulary(doc.edgeType);\n\n // R1.1b — ENDPOINT PRESENCE\n if (!doc.fromNodeId || typeof doc.fromNodeId !== \"string\") {\n throw new Error(\n \"edge_endpoint_missing: epistemicEdges insert requires a non-empty fromNodeId\"\n );\n }\n if (!doc.toNodeId || typeof doc.toNodeId !== \"string\") {\n throw new Error(\n \"edge_endpoint_missing: epistemicEdges insert requires a non-empty toNodeId\"\n );\n }\n\n // C2-RR.4b Defect E (REFERENTIAL) — ENDPOINT CANONICAL IDENTITY. Edge\n // endpoints must each be the globalId of an EXISTING epistemicNodes row,\n // never a Convex doc id, a legacy topic id, or a fabricated/unknown uuid.\n // This refuses the mixed _id/globalId endpoint writes at the floor while\n // keeping legacy v4-globalId nodes linkable (RR.4b prod-incident cure).\n await assertExistingNodeEndpoint(ctx, \"fromNodeId\", doc.fromNodeId);\n await assertExistingNodeEndpoint(ctx, \"toNodeId\", doc.toNodeId);\n\n // R1.1c — FULL POLICY ASSERT (when nodeTypes are present and edgeType is in public manifest)\n if (doc.fromNodeType && doc.toNodeType && doc.edgeType !== \"extracted_from\") {\n assertEdgePolicyAllowed(\n edgePolicyManifest,\n doc.edgeType,\n {\n kind: \"epistemic_node\",\n nodeId: doc.fromNodeId,\n nodeType: doc.fromNodeType as EpistemicNodeType,\n },\n {\n kind: \"epistemic_node\",\n nodeId: doc.toNodeId,\n nodeType: doc.toNodeType as EpistemicNodeType,\n }\n );\n }\n\n return ctx.db.insert(\"epistemicEdges\", doc);\n}\n","import type { Id, MutationCtx } from \"./convex\";\nimport { internal } from \"./convex\";\nimport { generateGlobalId } from \"./globalId\";\nimport { insertEpistemicEdge } from \"./epistemicInsert.js\";\n\ntype BeliefEvidenceRelation = \"supports\" | \"contradicts\";\ntype IndexRangeBuilder = {\n eq(fieldName: string, value: unknown): IndexRangeBuilder;\n};\ntype EpistemicNode = {\n _id: Id<\"epistemicNodes\">;\n nodeType?: string;\n globalId?: string;\n projectId?: string;\n topicId?: string | Id<\"topics\">;\n supportingInsightIds?: Id<\"epistemicNodes\">[];\n contradictingInsightIds?: Id<\"epistemicNodes\">[];\n};\n\nfunction assertEvidenceImpact(args: {\n relation: BeliefEvidenceRelation;\n weight: number;\n}) {\n if (\n !Number.isFinite(args.weight) ||\n args.weight === 0 ||\n args.weight < -1 ||\n args.weight > 1\n ) {\n throw new Error(\"Belief evidence links require explicit nonzero weight in [-1, 1]\");\n }\n if (args.relation === \"supports\" && args.weight < 0) {\n throw new Error(\"Supporting evidence links require positive weight\");\n }\n if (args.relation === \"contradicts\" && args.weight > 0) {\n throw new Error(\"Contradicting evidence links require negative weight\");\n }\n}\n\nexport async function applyOperationalLinkEffects(\n ctx: MutationCtx,\n args: {\n beliefNode: EpistemicNode;\n beliefId: Id<\"epistemicNodes\">;\n insightId: Id<\"epistemicNodes\">;\n relation: BeliefEvidenceRelation;\n weight: number;\n rationale?: string;\n createdBy: string;\n },\n): Promise<void> {\n assertEvidenceImpact({ relation: args.relation, weight: args.weight });\n const confidence = Math.abs(args.weight);\n const currentSupporting = args.beliefNode.supportingInsightIds ?? [];\n const currentContradicting = args.beliefNode.contradictingInsightIds ?? [];\n\n if (args.relation === \"supports\" && !currentSupporting.includes(args.insightId)) {\n await ctx.db.patch(args.beliefId, {\n supportingInsightIds: [...currentSupporting, args.insightId],\n contradictingInsightIds: currentContradicting.filter(\n (id: Id<\"epistemicNodes\">) => id !== args.insightId,\n ),\n });\n } else if (\n args.relation === \"contradicts\" &&\n !currentContradicting.includes(args.insightId)\n ) {\n await ctx.db.patch(args.beliefId, {\n contradictingInsightIds: [...currentContradicting, args.insightId],\n supportingInsightIds: currentSupporting.filter(\n (id: Id<\"epistemicNodes\">) => id !== args.insightId,\n ),\n });\n }\n\n try {\n const beliefSpineNode = await ctx.db.get(args.beliefId);\n const evidenceSpineNode = await ctx.db.get(args.insightId);\n\n if (\n beliefSpineNode?.nodeType === \"belief\" &&\n evidenceSpineNode?.nodeType === \"evidence\"\n ) {\n const existingEdges = await ctx.db\n .query(\"epistemicEdges\")\n .withIndex(\"by_from_to\", (q: IndexRangeBuilder) =>\n q\n .eq(\"fromNodeId\", evidenceSpineNode.globalId)\n .eq(\"toNodeId\", beliefSpineNode.globalId),\n )\n .collect();\n\n for (const edge of existingEdges) {\n if (edge.edgeType === \"informs\") {\n await ctx.scheduler.runAfter(0, internal.neo4jEdgeAPI.deleteEdge, {\n globalId: edge.globalId,\n });\n await ctx.db.delete(edge._id);\n }\n }\n\n const globalId = generateGlobalId();\n const context = args.rationale || `Linked as ${args.relation}`;\n await insertEpistemicEdge(ctx, {\n globalId,\n // C2-RR.4 Defect E — canonical UUIDv7 endpoints, not Convex doc ids.\n fromNodeId: evidenceSpineNode.globalId,\n toNodeId: beliefSpineNode.globalId,\n sourceGlobalId: evidenceSpineNode.globalId,\n targetGlobalId: beliefSpineNode.globalId,\n edgeType: \"informs\",\n weight: args.weight,\n confidence,\n context,\n reasoningMethod: \"testimonial\",\n derivationType: \"evidence_sl_scoring\",\n metadata: {\n relation: args.relation,\n confidence,\n impactScore: args.weight,\n invariant: \"evidence.belief_impact_required\",\n },\n createdBy: args.createdBy,\n createdAt: Date.now(),\n updatedAt: Date.now(),\n projectId: args.beliefNode.projectId,\n topicId: args.beliefNode.topicId ? String(args.beliefNode.topicId) : undefined,\n fromNodeType: \"evidence\",\n toNodeType: \"belief\",\n fromLayer: \"L2\",\n toLayer: \"L3\",\n });\n\n await ctx.scheduler.runAfter(0, internal.neo4jEdgeAPI.createEdge, {\n globalId,\n fromGlobalId: evidenceSpineNode.globalId,\n toGlobalId: beliefSpineNode.globalId,\n edgeType: \"informs\",\n weight: args.weight,\n confidence,\n context,\n projectId: args.beliefNode.projectId ? String(args.beliefNode.projectId) : undefined,\n createdBy: args.createdBy,\n fromNodeType: \"evidence\",\n toNodeType: \"belief\",\n fromLayer: \"L2\",\n toLayer: \"L3\",\n });\n }\n } catch (e) {\n console.error(\"[EpistemicSpine] Failed to create informs edge:\", e);\n }\n\n if (args.beliefNode.projectId) {\n await ctx.scheduler.runAfter(0, \"verificationActions:deepVerifyEvidence\", {\n insightId: args.insightId,\n targetType: \"belief\",\n targetId: args.beliefId,\n projectId: args.beliefNode.projectId,\n userId: args.createdBy,\n });\n }\n}\n\nexport async function removeOperationalLinkEffects(\n ctx: MutationCtx,\n args: {\n beliefId: Id<\"epistemicNodes\">;\n insightId: Id<\"epistemicNodes\">;\n relation: BeliefEvidenceRelation;\n },\n): Promise<void> {\n const belief = await ctx.db.get(args.beliefId);\n if (belief) {\n const currentSupporting = belief.supportingInsightIds ?? [];\n const currentContradicting = belief.contradictingInsightIds ?? [];\n\n if (args.relation === \"supports\") {\n await ctx.db.patch(args.beliefId, {\n supportingInsightIds: currentSupporting.filter(\n (id: Id<\"epistemicNodes\">) => id !== args.insightId,\n ),\n });\n } else {\n await ctx.db.patch(args.beliefId, {\n contradictingInsightIds: currentContradicting.filter(\n (id: Id<\"epistemicNodes\">) => id !== args.insightId,\n ),\n });\n }\n }\n\n try {\n const beliefSpineNode = await ctx.db.get(args.beliefId);\n const evidenceSpineNode = await ctx.db.get(args.insightId);\n\n if (\n beliefSpineNode?.nodeType === \"belief\" &&\n evidenceSpineNode?.nodeType === \"evidence\"\n ) {\n const edges = await ctx.db\n .query(\"epistemicEdges\")\n .withIndex(\"by_from_to\", (q: IndexRangeBuilder) =>\n q.eq(\"fromNodeId\", evidenceSpineNode._id).eq(\"toNodeId\", beliefSpineNode._id),\n )\n .collect();\n\n for (const edge of edges) {\n if (edge.edgeType === \"informs\") {\n await ctx.scheduler.runAfter(0, internal.neo4jEdgeAPI.deleteEdge, {\n globalId: edge.globalId,\n });\n await ctx.db.delete(edge._id);\n }\n }\n }\n } catch (e) {\n console.error(\"[EpistemicSpine] Failed to remove informs edge:\", e);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/convex.ts","../src/epistemicInsert.ts","../src/beliefEvidenceLinks.operational.ts"],"names":[],"mappings":";;;;;;AA4BA,IAAM,SAAA,GAAY,kBAAA;AAAA,EAChB;AACF,CAAA;AAGE,iBAAA;AACK,IAAM,QAAA,GAAW,SAAA;ACcxB,eAAe,0BAAA,CACb,GAAA,EACA,YAAA,EACA,QAAA,EACe;AACf,EAAA,4BAAA,CAA6B,cAAc,QAAQ,CAAA;AACnD,EAAA,MAAM,OAAO,MAAM,GAAA,CAAI,EAAA,CACpB,KAAA,CAAM,gBAAgB,CAAA,CACtB,SAAA;AAAA,IAAU,aAAA;AAAA,IAAe,CAAC,CAAA,KACzB,CAAA,CAAE,EAAA,CAAG,YAAY,QAAQ;AAAA,IAE1B,KAAA,EAAM;AACT,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,4DAAA,EAA+D,YAAY,CAAA,gEAAA,EAAmE,QAAQ,CAAA,6BAAA;AAAA,KACxJ;AAAA,EACF;AACF;AAEA,eAAsB,mBAAA,CACpB,KACA,GAAA,EAC+B;AAC/B,EAAA,oBAAA,CAAqB,gBAAA,EAAkB,IAAI,QAAQ,CAAA;AAGnD,EAAA,2BAAA,CAA4B,IAA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AAA,GAAoB,gBAAA;AAAA,MACxB,MAAM,GAAA,CAAI,EAAA,CAAG,GAAA,CAAI,KAAK,SAAS;AAAA,KACjC;AAEA,IAAA,IACE,eAAA,EAAiB,QAAA,KAAa,QAAA,IAC9B,iBAAA,EAAmB,aAAa,UAAA,EAChC;AACA,MAAA,MAAM,SACJ,MAAM,GAAA,CAAI,EAAA,CACP,KAAA,CAAM,gBAAgB,CAAA,CACtB,SAAA;AAAA,QAAU,YAAA;AAAA,QAAc,CAAC,CAAA,KACxB,CAAA,CACG,EAAA,CAAG,YAAA,EAAc,iBAAA,CAAkB,GAAG,CAAA,CACtC,EAAA,CAAG,UAAA,EAAY,eAAA,CAAgB,GAAG;AAAA,OACvC,CACC,OAAA,EAAQ,EAEV,GAAA,CAAI,oBAAoB,EACxB,MAAA,CAAO,CAAC,IAAA,KAAmC,IAAA,KAAS,IAAI,CAAA;AAE3D,MAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,QAAA,IAAI,IAAA,CAAK,aAAa,SAAA,EAAW;AAC/B,UAAA,MAAM,IAAI,SAAA,CAAU,QAAA,CAAS,CAAA,EAAG,QAAA,CAAS,aAAa,UAAA,EAAY;AAAA,YAChE,UAAU,IAAA,CAAK;AAAA,WAChB,CAAA;AACD,UAAA,MAAM,GAAA,CAAI,EAAA,CAAG,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA;AAAA,QAC9B;AAAA,MACF;AAAA,IACF;AAAA,EACF,SAAS,CAAA,EAAG;AACV,IAAA,OAAA,CAAQ,KAAA,CAAM,mDAAmD,CAAC,CAAA;AAAA,EACpE;AACF","file":"beliefEvidenceLinks.operational.js","sourcesContent":["import type { Doc as AccessControlDoc } from \"@lucern/access-control/convex\";\nimport {\n type UnsafeConvexAnyApi,\n unsafeConvexAnyApi,\n} from \"@lucern/contracts/convex/unsafeAnyApi\";\nimport {\n actionGeneric,\n componentsGeneric,\n httpActionGeneric,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n mutationGeneric,\n queryGeneric,\n} from \"convex/server\";\nimport type { GenericId } from \"convex/values\";\n\n// TODO(FR.11-structural): `api`/`internal`/`components` are `anyApi as any`\n// because this module source tree is bundled into the kernel host at deploy time\n// and has NO top-level Convex `_generated/` directory to import a typed surface\n// from. Every `api.*` / `internal.*` / string-literal cross-component ref in this\n// module (topicScope.ts, topicProjectOverlay.ts, questionEvidenceLinks.ts,\n// beliefEvidenceLinks*.ts, epistemicQuestions.helpers.ts) inherits `any` from\n// here. The fix is structural — generate a per-module typed surface or a shared\n// typed function-reference manifest (template: the typed `components.controlPlane`\n// in modules/control-plane/src/component/convex.ts and the\n// `KERNEL_API_REF_MANIFEST` pattern in packages/server-core/src/kernelApi.ts) —\n// owned by the FR.11 closing/synthesis pass, not a mechanical swap.\nconst unsafeApi = unsafeConvexAnyApi(\n \"graph-primitives top-level module bundle lacks a committed Convex _generated/api surface\"\n);\nexport const api = unsafeApi;\nexport const components =\n componentsGeneric() as unknown as UntypedFunctionReferenceSurface;\nexport const internal = unsafeApi;\n\ntype UntypedFunctionReferenceSurface = UnsafeConvexAnyApi;\ntype BoundaryValue = UntypedFunctionReferenceSurface[string];\n\nexport type TableNames = string;\nexport type Id<TableName extends TableNames = string> = GenericId<TableName>;\nexport type Doc<TableName extends TableNames = string> =\n AccessControlDoc<TableName>;\nexport type DataModel = Record<TableNames, unknown>;\ninterface IndexRangeBuilder {\n eq(fieldName: string, value: unknown): IndexRangeBuilder;\n field(fieldName: string): string;\n gt(fieldName: string, value: unknown): IndexRangeBuilder;\n gte(fieldName: string, value: unknown): IndexRangeBuilder;\n lt(fieldName: string, value: unknown): IndexRangeBuilder;\n lte(fieldName: string, value: unknown): IndexRangeBuilder;\n}\ninterface FilterBuilder {\n and(...clauses: unknown[]): FilterBuilder;\n eq(left: unknown, right: unknown): FilterBuilder;\n field(fieldName: string): string;\n gt(left: unknown, right: unknown): FilterBuilder;\n gte(left: unknown, right: unknown): FilterBuilder;\n lt(left: unknown, right: unknown): FilterBuilder;\n lte(left: unknown, right: unknown): FilterBuilder;\n neq(left: unknown, right: unknown): FilterBuilder;\n or(...clauses: unknown[]): FilterBuilder;\n [operator: string]: unknown;\n}\ninterface QueryInitializer<TableName extends TableNames> {\n collect(): Promise<Doc<TableName>[]>;\n filter(predicate: (q: FilterBuilder) => unknown): QueryInitializer<TableName>;\n first(): Promise<Doc<TableName> | null>;\n order(direction: \"asc\" | \"desc\"): QueryInitializer<TableName>;\n take(limit: number): Promise<Doc<TableName>[]>;\n unique(): Promise<Doc<TableName> | null>;\n withIndex(\n indexName: string,\n range?: (q: IndexRangeBuilder) => unknown\n ): QueryInitializer<TableName>;\n withSearchIndex(\n indexName: string,\n search?: (q: IndexRangeBuilder) => unknown\n ): QueryInitializer<TableName>;\n}\nexport interface DatabaseReader {\n get<TableName extends TableNames>(\n id: unknown\n ): Promise<Doc<TableName> | null>;\n normalizeId?<TableName extends TableNames>(\n tableName: TableName,\n id: string\n ): Id<TableName> | null;\n query<TableName extends TableNames>(\n tableName: TableName\n ): QueryInitializer<TableName>;\n}\nexport type DatabaseWriter = DatabaseReader & {\n insert<TableName extends TableNames>(\n tableName: TableName,\n value: Record<string, unknown>\n ): Promise<Id<TableName>>;\n patch<TableName extends TableNames>(\n id: Id<TableName>,\n value: Record<string, unknown>\n ): Promise<void>;\n replace<TableName extends TableNames>(\n id: Id<TableName>,\n value: Record<string, unknown>\n ): Promise<void>;\n delete<TableName extends TableNames>(id: Id<TableName>): Promise<void>;\n};\ninterface Scheduler {\n runAfter(\n delayMs: number,\n functionReference: unknown,\n args?: unknown\n ): Promise<void>;\n}\ninterface AuthReader {\n getUserIdentity(): Promise<{\n readonly subject: string;\n readonly [claimName: string]: unknown;\n } | null>;\n}\ninterface RuntimeInvoker {\n runAction<Result = unknown>(\n functionReference: unknown,\n args?: unknown\n ): Promise<Result>;\n runMutation<Result = unknown>(\n functionReference: unknown,\n args?: unknown\n ): Promise<Result>;\n runQuery<Result = unknown>(\n functionReference: unknown,\n args?: unknown\n ): Promise<Result>;\n}\nexport type QueryCtx = RuntimeInvoker & {\n auth: AuthReader;\n db: DatabaseReader;\n scheduler: Scheduler;\n};\nexport type MutationCtx = RuntimeInvoker & {\n auth: AuthReader;\n db: DatabaseWriter;\n scheduler: Scheduler;\n};\nexport type ActionCtx = RuntimeInvoker & {\n auth: AuthReader;\n scheduler: Scheduler;\n};\n\ntype ConvexFunctionBuilder<Ctx> = <\n Args = BoundaryValue,\n Result = BoundaryValue,\n>(definition: {\n args?: unknown;\n handler: (ctx: Ctx, args: Args) => Result;\n returns?: unknown;\n}) => unknown;\n\ntype OptionalHandlerConvexFunctionBuilder<Ctx> = <\n Args = BoundaryValue,\n Result = BoundaryValue,\n>(definition: {\n args?: unknown;\n handler?: (ctx: Ctx, args: Args) => Result;\n returns?: unknown;\n}) => unknown;\n\nexport const action =\n actionGeneric as unknown as ConvexFunctionBuilder<ActionCtx>;\nexport const httpAction =\n httpActionGeneric as unknown as ConvexFunctionBuilder<ActionCtx>;\nexport const internalAction =\n internalActionGeneric as unknown as ConvexFunctionBuilder<ActionCtx>;\nexport const internalMutation =\n internalMutationGeneric as unknown as OptionalHandlerConvexFunctionBuilder<MutationCtx>;\nexport const internalQuery =\n internalQueryGeneric as unknown as OptionalHandlerConvexFunctionBuilder<QueryCtx>;\nexport const mutation =\n mutationGeneric as unknown as ConvexFunctionBuilder<MutationCtx>;\nexport const query = queryGeneric as unknown as ConvexFunctionBuilder<QueryCtx>;\n","// biome-ignore-all lint/style/useFilenamingConvention: Public graph-primitives wildcard-export path; rename requires an export-map migration.\nimport {\n assertEdgePolicyAllowed,\n type EpistemicNodeType,\n edgePolicyManifest,\n} from \"@lucern/contracts\";\nimport {\n assertStorageEdgeVocabulary,\n assertUuidShapedEdgeEndpoint,\n assertUuidV7Identity,\n} from \"@lucern/contracts/ids\";\nimport type { Id, MutationCtx } from \"./convex\";\n\ninterface GlobalIdIndexQuery {\n eq(field: \"globalId\", value: string): GlobalIdIndexQuery;\n}\n\ninterface EpistemicNodeInsertDoc extends Record<string, unknown> {\n globalId: string;\n}\n\ninterface EpistemicEdgeInsertDoc extends Record<string, unknown> {\n edgeType: string;\n fromNodeId: string;\n fromNodeType?: string;\n globalId: string;\n toNodeId: string;\n toNodeType?: string;\n}\n\nexport function insertEpistemicNode(\n ctx: MutationCtx,\n doc: EpistemicNodeInsertDoc\n): Promise<Id<\"epistemicNodes\">> {\n assertUuidV7Identity(\"epistemicNodes\", doc.globalId);\n return ctx.db.insert(\"epistemicNodes\", doc);\n}\n\n/**\n * C2-RR.4b — REFERENTIAL edge-endpoint canonicality (amends RR.4's FORMAT guard).\n *\n * Proves an endpoint is the `globalId` of an EXISTING `epistemicNodes` row, not\n * that it has a v7 shape. Refuses doc-ids and fabricated/unknown endpoints while\n * keeping legacy v4-`globalId` nodes (the established prod corpus) linkable.\n * SHAPE pre-filter accepts both v4 and v7; the indexed `by_globalId` lookup is\n * the referential authority (no full scan). v7-format stays enforced only at new\n * identity minting (`assertUuidV7Identity`). See c2-rr4b-endpoint-referential.\n */\nasync function assertExistingNodeEndpoint(\n ctx: MutationCtx,\n endpointRole: \"fromNodeId\" | \"toNodeId\",\n endpoint: string\n): Promise<void> {\n assertUuidShapedEdgeEndpoint(endpointRole, endpoint);\n const node = await ctx.db\n .query(\"epistemicNodes\")\n .withIndex(\"by_globalId\", (q: GlobalIdIndexQuery) =>\n q.eq(\"globalId\", endpoint)\n )\n .first();\n if (!node) {\n throw new Error(\n `edge_endpoint_not_canonical: epistemicEdges insert requires ${endpointRole} to be the globalId of an existing epistemicNodes row, received ${endpoint} (no node with that globalId)`\n );\n }\n}\n\nexport async function insertEpistemicEdge(\n ctx: MutationCtx,\n doc: EpistemicEdgeInsertDoc\n): Promise<Id<\"epistemicEdges\">> {\n assertUuidV7Identity(\"epistemicEdges\", doc.globalId);\n\n // R1.1a — STORAGE-VOCABULARY MEMBERSHIP\n assertStorageEdgeVocabulary(doc.edgeType);\n\n // R1.1b — ENDPOINT PRESENCE\n if (!doc.fromNodeId || typeof doc.fromNodeId !== \"string\") {\n throw new Error(\n \"edge_endpoint_missing: epistemicEdges insert requires a non-empty fromNodeId\"\n );\n }\n if (!doc.toNodeId || typeof doc.toNodeId !== \"string\") {\n throw new Error(\n \"edge_endpoint_missing: epistemicEdges insert requires a non-empty toNodeId\"\n );\n }\n\n // C2-RR.4b Defect E (REFERENTIAL) — ENDPOINT CANONICAL IDENTITY. Edge\n // endpoints must each be the globalId of an EXISTING epistemicNodes row,\n // never a Convex doc id, a legacy topic id, or a fabricated/unknown uuid.\n // This refuses the mixed _id/globalId endpoint writes at the floor while\n // keeping legacy v4-globalId nodes linkable (RR.4b prod-incident cure).\n await assertExistingNodeEndpoint(ctx, \"fromNodeId\", doc.fromNodeId);\n await assertExistingNodeEndpoint(ctx, \"toNodeId\", doc.toNodeId);\n\n // R1.1c — FULL POLICY ASSERT (when nodeTypes are present and edgeType is in public manifest)\n if (doc.fromNodeType && doc.toNodeType && doc.edgeType !== \"extracted_from\") {\n assertEdgePolicyAllowed(\n edgePolicyManifest,\n doc.edgeType,\n {\n kind: \"epistemic_node\",\n nodeId: doc.fromNodeId,\n nodeType: doc.fromNodeType as EpistemicNodeType,\n },\n {\n kind: \"epistemic_node\",\n nodeId: doc.toNodeId,\n nodeType: doc.toNodeType as EpistemicNodeType,\n }\n );\n }\n\n return ctx.db.insert(\"epistemicEdges\", doc);\n}\n","// biome-ignore-all lint/style/useFilenamingConvention: Public graph-primitives wildcard-export path; rename requires an export-map migration.\nimport type { Id, MutationCtx } from \"./convex\";\nimport { internal } from \"./convex\";\nimport { insertEpistemicEdge } from \"./epistemicInsert.js\";\nimport { generateGlobalId } from \"./globalId\";\n\ntype BeliefEvidenceRelation = \"supports\" | \"contradicts\";\ninterface IndexRangeBuilder {\n eq(fieldName: string, value: unknown): IndexRangeBuilder;\n}\ninterface EpistemicNode {\n _id: Id<\"epistemicNodes\">;\n contradictingInsightIds?: Id<\"epistemicNodes\">[];\n globalId?: string;\n nodeType?: string;\n projectId?: string;\n supportingInsightIds?: Id<\"epistemicNodes\">[];\n topicId?: string | Id<\"topics\">;\n}\ninterface EpistemicEdgeDoc {\n _id: Id<\"epistemicEdges\">;\n edgeType: string;\n globalId: string;\n}\ninterface InsightIdCollections {\n contradictingInsightIds: Id<\"epistemicNodes\">[];\n supportingInsightIds: Id<\"epistemicNodes\">[];\n}\ninterface OperationalEpistemicEdgeInsert {\n confidence: number;\n context: string;\n createdAt: number;\n createdBy: string;\n derivationType: \"evidence_sl_scoring\";\n edgeType: \"informs\";\n fromLayer: \"L2\";\n fromNodeId: string;\n fromNodeType: \"evidence\";\n globalId: string;\n metadata: OperationalEpistemicEdgeMetadata;\n projectId?: string;\n reasoningMethod: \"testimonial\";\n sourceGlobalId: string;\n targetGlobalId: string;\n toLayer: \"L3\";\n toNodeId: string;\n toNodeType: \"belief\";\n topicId?: string;\n updatedAt: number;\n weight: number;\n}\ninterface OperationalEpistemicEdgeMetadata {\n confidence: number;\n impactScore: number;\n invariant: \"evidence.belief_impact_required\";\n relation: BeliefEvidenceRelation;\n}\ninterface SpineNodeDoc {\n _id: Id<\"epistemicNodes\">;\n globalId: string;\n nodeType: string;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction readConvexId<TableName extends string>(\n value: unknown\n): Id<TableName> | null {\n return typeof value === \"string\" && value.length > 0\n ? (value as Id<TableName>)\n : null;\n}\n\nfunction readEpistemicEdgeDoc(value: unknown): EpistemicEdgeDoc | null {\n if (!isRecord(value)) {\n return null;\n }\n const id = readConvexId<\"epistemicEdges\">(value._id);\n if (\n !id ||\n typeof value.edgeType !== \"string\" ||\n typeof value.globalId !== \"string\"\n ) {\n return null;\n }\n return {\n _id: id,\n edgeType: value.edgeType,\n globalId: value.globalId,\n };\n}\n\nfunction readInsightIdArray(value: unknown): Id<\"epistemicNodes\">[] {\n if (!Array.isArray(value)) {\n return [];\n }\n return value.flatMap((entry) => {\n const id = readConvexId<\"epistemicNodes\">(entry);\n return id ? [id] : [];\n });\n}\n\nfunction readInsightIdCollections(value: unknown): InsightIdCollections {\n if (!isRecord(value)) {\n return {\n contradictingInsightIds: [],\n supportingInsightIds: [],\n };\n }\n return {\n contradictingInsightIds: readInsightIdArray(value.contradictingInsightIds),\n supportingInsightIds: readInsightIdArray(value.supportingInsightIds),\n };\n}\n\nfunction readSpineNodeDoc(value: unknown): SpineNodeDoc | null {\n if (!isRecord(value)) {\n return null;\n }\n const id = readConvexId<\"epistemicNodes\">(value._id);\n if (\n !id ||\n typeof value.globalId !== \"string\" ||\n typeof value.nodeType !== \"string\"\n ) {\n return null;\n }\n return {\n _id: id,\n globalId: value.globalId,\n nodeType: value.nodeType,\n };\n}\n\nasync function insertOperationalEpistemicEdge(\n ctx: MutationCtx,\n doc: OperationalEpistemicEdgeInsert\n): Promise<void> {\n await insertEpistemicEdge(\n ctx,\n doc as unknown as Parameters<typeof insertEpistemicEdge>[1]\n );\n}\n\nfunction assertEvidenceImpact(args: {\n relation: BeliefEvidenceRelation;\n weight: number;\n}) {\n if (\n !Number.isFinite(args.weight) ||\n args.weight === 0 ||\n args.weight < -1 ||\n args.weight > 1\n ) {\n throw new Error(\n \"Belief evidence links require explicit nonzero weight in [-1, 1]\"\n );\n }\n if (args.relation === \"supports\" && args.weight < 0) {\n throw new Error(\"Supporting evidence links require positive weight\");\n }\n if (args.relation === \"contradicts\" && args.weight > 0) {\n throw new Error(\"Contradicting evidence links require negative weight\");\n }\n}\n\nexport async function applyOperationalLinkEffects(\n ctx: MutationCtx,\n args: {\n beliefNode: EpistemicNode;\n beliefId: Id<\"epistemicNodes\">;\n insightId: Id<\"epistemicNodes\">;\n relation: BeliefEvidenceRelation;\n weight: number;\n rationale?: string;\n createdBy: string;\n }\n): Promise<void> {\n assertEvidenceImpact({ relation: args.relation, weight: args.weight });\n const confidence = Math.abs(args.weight);\n const currentSupporting = args.beliefNode.supportingInsightIds ?? [];\n const currentContradicting = args.beliefNode.contradictingInsightIds ?? [];\n\n if (\n args.relation === \"supports\" &&\n !currentSupporting.includes(args.insightId)\n ) {\n await ctx.db.patch(args.beliefId, {\n supportingInsightIds: [...currentSupporting, args.insightId],\n contradictingInsightIds: currentContradicting.filter(\n (id: Id<\"epistemicNodes\">) => id !== args.insightId\n ),\n });\n } else if (\n args.relation === \"contradicts\" &&\n !currentContradicting.includes(args.insightId)\n ) {\n await ctx.db.patch(args.beliefId, {\n contradictingInsightIds: [...currentContradicting, args.insightId],\n supportingInsightIds: currentSupporting.filter(\n (id: Id<\"epistemicNodes\">) => id !== args.insightId\n ),\n });\n }\n\n try {\n const beliefSpineNode = readSpineNodeDoc(await ctx.db.get(args.beliefId));\n const evidenceSpineNode = readSpineNodeDoc(\n await ctx.db.get(args.insightId)\n );\n\n if (\n beliefSpineNode?.nodeType === \"belief\" &&\n evidenceSpineNode?.nodeType === \"evidence\"\n ) {\n const existingEdges = (\n await ctx.db\n .query(\"epistemicEdges\")\n .withIndex(\"by_from_to\", (q: IndexRangeBuilder) =>\n q\n .eq(\"fromNodeId\", evidenceSpineNode.globalId)\n .eq(\"toNodeId\", beliefSpineNode.globalId)\n )\n .collect()\n )\n .map(readEpistemicEdgeDoc)\n .filter((edge): edge is EpistemicEdgeDoc => edge !== null);\n\n for (const edge of existingEdges) {\n if (edge.edgeType === \"informs\") {\n await ctx.scheduler.runAfter(0, internal.neo4jEdgeAPI.deleteEdge, {\n globalId: edge.globalId,\n });\n await ctx.db.delete(edge._id);\n }\n }\n\n const globalId = generateGlobalId();\n const context = args.rationale || `Linked as ${args.relation}`;\n await insertOperationalEpistemicEdge(ctx, {\n globalId,\n // C2-RR.4 Defect E — canonical UUIDv7 endpoints, not Convex doc ids.\n fromNodeId: evidenceSpineNode.globalId,\n toNodeId: beliefSpineNode.globalId,\n sourceGlobalId: evidenceSpineNode.globalId,\n targetGlobalId: beliefSpineNode.globalId,\n edgeType: \"informs\",\n weight: args.weight,\n confidence,\n context,\n reasoningMethod: \"testimonial\",\n derivationType: \"evidence_sl_scoring\",\n metadata: {\n relation: args.relation,\n confidence,\n impactScore: args.weight,\n invariant: \"evidence.belief_impact_required\",\n },\n createdBy: args.createdBy,\n createdAt: Date.now(),\n updatedAt: Date.now(),\n projectId: args.beliefNode.projectId,\n topicId: args.beliefNode.topicId\n ? String(args.beliefNode.topicId)\n : undefined,\n fromNodeType: \"evidence\",\n toNodeType: \"belief\",\n fromLayer: \"L2\",\n toLayer: \"L3\",\n });\n\n await ctx.scheduler.runAfter(0, internal.neo4jEdgeAPI.createEdge, {\n globalId,\n fromGlobalId: evidenceSpineNode.globalId,\n toGlobalId: beliefSpineNode.globalId,\n edgeType: \"informs\",\n weight: args.weight,\n confidence,\n context,\n projectId: args.beliefNode.projectId\n ? String(args.beliefNode.projectId)\n : undefined,\n createdBy: args.createdBy,\n fromNodeType: \"evidence\",\n toNodeType: \"belief\",\n fromLayer: \"L2\",\n toLayer: \"L3\",\n });\n }\n } catch (e) {\n console.error(\"[EpistemicSpine] Failed to create informs edge:\", e);\n }\n\n if (args.beliefNode.projectId) {\n await ctx.scheduler.runAfter(0, \"verificationActions:deepVerifyEvidence\", {\n insightId: args.insightId,\n targetType: \"belief\",\n targetId: args.beliefId,\n projectId: args.beliefNode.projectId,\n userId: args.createdBy,\n });\n }\n}\n\nexport async function removeOperationalLinkEffects(\n ctx: MutationCtx,\n args: {\n beliefId: Id<\"epistemicNodes\">;\n insightId: Id<\"epistemicNodes\">;\n relation: BeliefEvidenceRelation;\n }\n): Promise<void> {\n const belief = await ctx.db.get(args.beliefId);\n if (belief) {\n const { contradictingInsightIds, supportingInsightIds } =\n readInsightIdCollections(belief);\n\n if (args.relation === \"supports\") {\n await ctx.db.patch(args.beliefId, {\n supportingInsightIds: supportingInsightIds.filter(\n (id: Id<\"epistemicNodes\">) => id !== args.insightId\n ),\n });\n } else {\n await ctx.db.patch(args.beliefId, {\n contradictingInsightIds: contradictingInsightIds.filter(\n (id: Id<\"epistemicNodes\">) => id !== args.insightId\n ),\n });\n }\n }\n\n try {\n const beliefSpineNode = readSpineNodeDoc(await ctx.db.get(args.beliefId));\n const evidenceSpineNode = readSpineNodeDoc(\n await ctx.db.get(args.insightId)\n );\n\n if (\n beliefSpineNode?.nodeType === \"belief\" &&\n evidenceSpineNode?.nodeType === \"evidence\"\n ) {\n const edges = (\n await ctx.db\n .query(\"epistemicEdges\")\n .withIndex(\"by_from_to\", (q: IndexRangeBuilder) =>\n q\n .eq(\"fromNodeId\", evidenceSpineNode._id)\n .eq(\"toNodeId\", beliefSpineNode._id)\n )\n .collect()\n )\n .map(readEpistemicEdgeDoc)\n .filter((edge): edge is EpistemicEdgeDoc => edge !== null);\n\n for (const edge of edges) {\n if (edge.edgeType === \"informs\") {\n await ctx.scheduler.runAfter(0, internal.neo4jEdgeAPI.deleteEdge, {\n globalId: edge.globalId,\n });\n await ctx.db.delete(edge._id);\n }\n }\n }\n } catch (e) {\n console.error(\"[EpistemicSpine] Failed to remove informs edge:\", e);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/beliefLifecycle.ts"],"names":[],"mappings":";AAuBA,IAAM,oBAAA,GAAyD;AAAA,EAC7D,YAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,YAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAA;AAEA,IAAM,4BAAA,GAA6D;AAAA,EACjE,WAAA;AAAA,EACA,cAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA;AAEO,SAAS,wBACd,KAAA,EACgC;AAChC,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,oBAAA,CAAqB,SAAS,KAA8B,CAAA;AAEhE;AAEA,SAAS,4BACP,KAAA,EAC8B;AAC9B,EAAA,IAAI,uBAAA,CAAwB,KAAK,CAAA,EAAG;AAClC,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,KAAA,KAAU,QAAA,IAAY,K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A,KAAW,eAAA;AAC3C;AAEO,SAAS,+BAAA,CACd,QACA,IAAA,EAKuB;AACvB,EAAA,MAAM,cAAA,GAAiB,2BAAA,CAA4B,EAAE,GAAG,MAAM,CAAA;AAC9D,EAAA,IAAI,cAAA,EAAgB;AAClB,IAAA,OAAO,cAAA;AAAA,EACT;AACA,EAAA,IAAI,2BAAA,CAA4B,MAAM,CAAA,EAAG;AACvC,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,OAAO,MAAA;AACT;AAEO,SAAS,iCACd,MAAA,EACuB;AACvB,EAAA,OAAO,2BAAA,CAA4B,MAAM,CAAA,GAAI,QAAA,GAAW,MAAA;AAC1D","file":"beliefLifecycle.js","sourcesContent":["/**\n * Belief lifecycle helpers shared across Convex modules.\n *\n * Canonical lifecycle:\n * assumption -> hypothesis -> active -> resolved_true/resolved_false\n * \\-> superseded\n */\n\nexport type BeliefLifecycleStatus =\n | \"assumption\"\n | \"hypothesis\"\n | \"active\"\n | \"superseded\"\n | \"resolved_true\"\n | \"resolved_false\";\n\ntype PredictionOutcome =\n | \"pending\"\n | \"confirmed\"\n | \"disconfirmed\"\n | \"partial\"\n | \"expired\";\n\nconst BELIEF_STATUS_VALUES: readonly BeliefLifecycleStatus[] = [\n \"assumption\",\n \"hypothesis\",\n \"active\",\n \"superseded\",\n \"resolved_true\",\n \"resolved_false\",\n];\n\nconst RESOLVED_PREDICTION_OUTCOMES: readonly PredictionOutcome[] = [\n \"confirmed\",\n \"disconfirmed\",\n \"partial\",\n \"expired\",\n];\n\nexport function isBeliefLifecycleStatus(\n value: unknown\n): value is BeliefLifecycleStatus {\n return (\n typeof value === \"string\" &&\n BELIEF_STATUS_VALUES.includes(value as BeliefLifecycleStatus)\n );\n}\n\nfunction normalizeLegacyBeliefStatus(\n value: unknown\n): BeliefLifecycleStatus | null {\n if (isBeliefLifecycleStatus(value)) {\n return value;\n }\n if (value === \"belief\" || value === \"established\" || value === \"emerging\") {\n return \"active\";\n }\n if (value === \"fact\" || value === \"confirmed\") {\n return \"resolved_true\";\n }\n if (value === \"disconfirmed\" || value === \"expired\") {\n return \"resolved_false\";\n }\n if (value === \"deprecated\") {\n return \"superseded\";\n }\n return null;\n}\n\nfunction normalizeBeliefConfidence(confidence: unknown): number | null {\n if (typeof confidence !== \"number\" || !Number.isFinite(confidence)) {\n return null;\n }\n if (confidence >= 0 && confidence <= 1) {\n return confidence;\n }\n // Backward compatibility with historical percentage-scale confidence (0-100).\n if (confidence > 1 && confidence <= 100) {\n return confidence / 100;\n }\n return null;\n}\n\nexport function isResolvedByConfidence(confidence: unknown): boolean {\n const normalized = normalizeBeliefConfidence(confidence);\n if (normalized === null) {\n return false;\n }\n return normalized <= 0 || normalized >= 1;\n}\n\nexport function hasResolvedPredictionOutcome(predictionMeta: unknown): boolean {\n if (!predictionMeta || typeof predictionMeta !== \"object\") {\n return false;\n }\n const outcome = (predictionMeta as { outcome?: unknown }).outcome;\n return (\n typeof outcome === \"string\" &&\n RESOLVED_PREDICTION_OUTCOMES.includes(outcome as PredictionOutcome)\n );\n}\n\nfunction getPredictionMetaFromMetadata(\n metadata: Record<string, unknown> | undefined\n): unknown {\n return metadata?.predictionMeta;\n}\n\nexport function shouldTreatBeliefAsFact(opts: {\n confidence?: unknown;\n predictionMeta?: unknown;\n metadata?: Record<string, unknown>;\n}): boolean {\n if (isResolvedByConfidence(opts.confidence)) {\n return true;\n }\n if (hasResolvedPredictionOutcome(opts.predictionMeta)) {\n return true;\n }\n if (\n hasResolvedPredictionOutcome(getPredictionMetaFromMetadata(opts.metadata))\n ) {\n return true;\n }\n return false;\n}\n\nfunction resolvedPredictionStatus(\n predictionMeta: unknown\n): BeliefLifecycleStatus | null {\n if (!predictionMeta || typeof predictionMeta !== \"object\") {\n return null;\n }\n const outcome = (predictionMeta as { outcome?: unknown }).outcome;\n if (outcome === \"confirmed\") {\n return \"resolved_true\";\n }\n if (outcome === \"disconfirmed\" || outcome === \"expired\") {\n return \"resolved_false\";\n }\n return null;\n}\n\nfunction shouldTreatBeliefAsResolved(opts: {\n confidence?: unknown;\n predictionMeta?: unknown;\n metadata?: Record<string, unknown>;\n}): BeliefLifecycleStatus | null {\n if (isResolvedByConfidence(opts.confidence)) {\n const normalized = normalizeBeliefConfidence(opts.confidence);\n return normalized === 0 ? \"resolved_false\" : \"resolved_true\";\n }\n const directPredictionStatus = resolvedPredictionStatus(opts.predictionMeta);\n if (directPredictionStatus) {\n return directPredictionStatus;\n }\n const metadataPredictionStatus = resolvedPredictionStatus(\n getPredictionMetaFromMetadata(opts.metadata)\n );\n if (metadataPredictionStatus) {\n return metadataPredictionStatus;\n }\n return null;\n}\n\nexport function resolveBeliefLifecycleStatus(opts: {\n beliefStatus?: unknown;\n confidence?: unknown;\n predictionMeta?: unknown;\n metadata?: Record<string, unknown>;\n}): BeliefLifecycleStatus {\n const resolvedStatus = shouldTreatBeliefAsResolved(opts);\n if (resolvedStatus) {\n return resolvedStatus;\n }\n\n const direct = opts.beliefStatus;\n const normalizedDirect = normalizeLegacyBeliefStatus(direct);\n if (normalizedDirect) {\n // If the belief has been scored (has numeric credence) but stored status\n // is still pre-validation, promote to active. Evidence, not user intent,\n // makes a hypothesis active.\n const normalized = normalizeBeliefConfidence(opts.confidence);\n if (\n normalized !== null &&\n isPreValidationBeliefStatus(normalizedDirect)\n ) {\n return \"active\";\n }\n return normalizedDirect;\n }\n\n const metaStatus = opts.metadata?.beliefStatus;\n const normalizedMetaStatus = normalizeLegacyBeliefStatus(metaStatus);\n if (normalizedMetaStatus) {\n const normalized = normalizeBeliefConfidence(opts.confidence);\n if (\n normalized !== null &&\n isPreValidationBeliefStatus(normalizedMetaStatus)\n ) {\n return \"active\";\n }\n return normalizedMetaStatus;\n }\n\n return \"assumption\";\n}\n\nexport function isPreValidationBeliefStatus(\n status: BeliefLifecycleStatus\n): boolean {\n return status === \"assumption\" || status === \"hypothesis\";\n}\n\nexport function isPropagationEligibleBeliefStatus(\n status: BeliefLifecycleStatus\n): boolean {\n return status === \"active\" || status === \"resolved_true\";\n}\n\nexport function promoteBeliefStatusAfterScoring(\n status: BeliefLifecycleStatus,\n opts?: {\n confidence?: unknown;\n predictionMeta?: unknown;\n metadata?: Record<string, unknown>;\n }\n): BeliefLifecycleStatus {\n const resolvedStatus = shouldTreatBeliefAsResolved({ ...opts });\n if (resolvedStatus) {\n return resolvedStatus;\n }\n if (isPreValidationBeliefStatus(status)) {\n return \"active\";\n }\n return status;\n}\n\nexport function promoteBeliefStatusAfterEvidence(\n status: BeliefLifecycleStatus\n): BeliefLifecycleStatus {\n return isPreValidationBeliefStatus(status) ? \"active\" : status;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/beliefLifecycle.ts"],"names":[],"mappings":";AAwBA,IAAM,oBAAA,GAAyD;AAAA,EAC7D,YAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,YAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAA;AAEA,IAAM,4BAAA,GAA6D;AAAA,EACjE,WAAA;AAAA,EACA,cAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA;AAEO,SAAS,wBACd,KAAA,EACgC;AAChC,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,oBAAA,CAAqB,SAAS,KAA8B,CAAA;AAEhE;AAEA,SAAS,4BACP,KAAA,EAC8B;AAC9B,EAAA,IAAI,uBAAA,CAAwB,KAAK,CAAA,EAAG;AAClC,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,aAAA,IAAiB,UAAU,UAAA,EAAY;AACzE,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,IAAI,KAAA,KAAU,MAAA,IAAU,KAAA,KAAU,WAAA,EAAa;AAC7C,IAAA,OAAO,eAAA;AAAA,EACT;AACA,EAAA,IAAI,KAAA,KAAU,cAAA,IAAkB,KAAA,KAAU,SAAA,EAAW;AACnD,IAAA,OAAO,gBAAA;A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,QAAA;AAAA,EACT;AACA,EAAA,OAAO,MAAA;AACT;AAEO,SAAS,iCACd,MAAA,EACuB;AACvB,EAAA,OAAO,2BAAA,CAA4B,MAAM,CAAA,GAAI,QAAA,GAAW,MAAA;AAC1D","file":"beliefLifecycle.js","sourcesContent":["// biome-ignore-all lint/style/useFilenamingConvention: Public graph-primitives wildcard-export path; rename requires an export-map migration.\n/**\n * Belief lifecycle helpers shared across Convex modules.\n *\n * Canonical lifecycle:\n * assumption -> hypothesis -> active -> resolved_true/resolved_false\n * \\-> superseded\n */\n\nexport type BeliefLifecycleStatus =\n | \"assumption\"\n | \"hypothesis\"\n | \"active\"\n | \"superseded\"\n | \"resolved_true\"\n | \"resolved_false\";\n\ntype PredictionOutcome =\n | \"pending\"\n | \"confirmed\"\n | \"disconfirmed\"\n | \"partial\"\n | \"expired\";\n\nconst BELIEF_STATUS_VALUES: readonly BeliefLifecycleStatus[] = [\n \"assumption\",\n \"hypothesis\",\n \"active\",\n \"superseded\",\n \"resolved_true\",\n \"resolved_false\",\n];\n\nconst RESOLVED_PREDICTION_OUTCOMES: readonly PredictionOutcome[] = [\n \"confirmed\",\n \"disconfirmed\",\n \"partial\",\n \"expired\",\n];\n\nexport function isBeliefLifecycleStatus(\n value: unknown\n): value is BeliefLifecycleStatus {\n return (\n typeof value === \"string\" &&\n BELIEF_STATUS_VALUES.includes(value as BeliefLifecycleStatus)\n );\n}\n\nfunction normalizeLegacyBeliefStatus(\n value: unknown\n): BeliefLifecycleStatus | null {\n if (isBeliefLifecycleStatus(value)) {\n return value;\n }\n if (value === \"belief\" || value === \"established\" || value === \"emerging\") {\n return \"active\";\n }\n if (value === \"fact\" || value === \"confirmed\") {\n return \"resolved_true\";\n }\n if (value === \"disconfirmed\" || value === \"expired\") {\n return \"resolved_false\";\n }\n if (value === \"deprecated\") {\n return \"superseded\";\n }\n return null;\n}\n\nfunction normalizeBeliefConfidence(confidence: unknown): number | null {\n if (typeof confidence !== \"number\" || !Number.isFinite(confidence)) {\n return null;\n }\n if (confidence >= 0 && confidence <= 1) {\n return confidence;\n }\n // Backward compatibility with historical percentage-scale confidence (0-100).\n if (confidence > 1 && confidence <= 100) {\n return confidence / 100;\n }\n return null;\n}\n\nexport function isResolvedByConfidence(confidence: unknown): boolean {\n const normalized = normalizeBeliefConfidence(confidence);\n if (normalized === null) {\n return false;\n }\n return normalized <= 0 || normalized >= 1;\n}\n\nexport function hasResolvedPredictionOutcome(predictionMeta: unknown): boolean {\n if (!predictionMeta || typeof predictionMeta !== \"object\") {\n return false;\n }\n const outcome = (predictionMeta as { outcome?: unknown }).outcome;\n return (\n typeof outcome === \"string\" &&\n RESOLVED_PREDICTION_OUTCOMES.includes(outcome as PredictionOutcome)\n );\n}\n\nfunction getPredictionMetaFromMetadata(\n metadata: Record<string, unknown> | undefined\n): unknown {\n return metadata?.predictionMeta;\n}\n\nexport function shouldTreatBeliefAsFact(opts: {\n confidence?: unknown;\n predictionMeta?: unknown;\n metadata?: Record<string, unknown>;\n}): boolean {\n if (isResolvedByConfidence(opts.confidence)) {\n return true;\n }\n if (hasResolvedPredictionOutcome(opts.predictionMeta)) {\n return true;\n }\n if (\n hasResolvedPredictionOutcome(getPredictionMetaFromMetadata(opts.metadata))\n ) {\n return true;\n }\n return false;\n}\n\nfunction resolvedPredictionStatus(\n predictionMeta: unknown\n): BeliefLifecycleStatus | null {\n if (!predictionMeta || typeof predictionMeta !== \"object\") {\n return null;\n }\n const outcome = (predictionMeta as { outcome?: unknown }).outcome;\n if (outcome === \"confirmed\") {\n return \"resolved_true\";\n }\n if (outcome === \"disconfirmed\" || outcome === \"expired\") {\n return \"resolved_false\";\n }\n return null;\n}\n\nfunction shouldTreatBeliefAsResolved(opts: {\n confidence?: unknown;\n predictionMeta?: unknown;\n metadata?: Record<string, unknown>;\n}): BeliefLifecycleStatus | null {\n if (isResolvedByConfidence(opts.confidence)) {\n const normalized = normalizeBeliefConfidence(opts.confidence);\n return normalized === 0 ? \"resolved_false\" : \"resolved_true\";\n }\n const directPredictionStatus = resolvedPredictionStatus(opts.predictionMeta);\n if (directPredictionStatus) {\n return directPredictionStatus;\n }\n const metadataPredictionStatus = resolvedPredictionStatus(\n getPredictionMetaFromMetadata(opts.metadata)\n );\n if (metadataPredictionStatus) {\n return metadataPredictionStatus;\n }\n return null;\n}\n\nexport function resolveBeliefLifecycleStatus(opts: {\n beliefStatus?: unknown;\n confidence?: unknown;\n predictionMeta?: unknown;\n metadata?: Record<string, unknown>;\n}): BeliefLifecycleStatus {\n const resolvedStatus = shouldTreatBeliefAsResolved(opts);\n if (resolvedStatus) {\n return resolvedStatus;\n }\n\n const direct = opts.beliefStatus;\n const normalizedDirect = normalizeLegacyBeliefStatus(direct);\n if (normalizedDirect) {\n // If the belief has been scored (has numeric credence) but stored status\n // is still pre-validation, promote to active. Evidence, not user intent,\n // makes a hypothesis active.\n const normalized = normalizeBeliefConfidence(opts.confidence);\n if (normalized !== null && isPreValidationBeliefStatus(normalizedDirect)) {\n return \"active\";\n }\n return normalizedDirect;\n }\n\n const metaStatus = opts.metadata?.beliefStatus;\n const normalizedMetaStatus = normalizeLegacyBeliefStatus(metaStatus);\n if (normalizedMetaStatus) {\n const normalized = normalizeBeliefConfidence(opts.confidence);\n if (\n normalized !== null &&\n isPreValidationBeliefStatus(normalizedMetaStatus)\n ) {\n return \"active\";\n }\n return normalizedMetaStatus;\n }\n\n return \"assumption\";\n}\n\nexport function isPreValidationBeliefStatus(\n status: BeliefLifecycleStatus\n): boolean {\n return status === \"assumption\" || status === \"hypothesis\";\n}\n\nexport function isPropagationEligibleBeliefStatus(\n status: BeliefLifecycleStatus\n): boolean {\n return status === \"active\" || status === \"resolved_true\";\n}\n\nexport function promoteBeliefStatusAfterScoring(\n status: BeliefLifecycleStatus,\n opts?: {\n confidence?: unknown;\n predictionMeta?: unknown;\n metadata?: Record<string, unknown>;\n }\n): BeliefLifecycleStatus {\n const resolvedStatus = shouldTreatBeliefAsResolved({ ...opts });\n if (resolvedStatus) {\n return resolvedStatus;\n }\n if (isPreValidationBeliefStatus(status)) {\n return \"active\";\n }\n return status;\n}\n\nexport function promoteBeliefStatusAfterEvidence(\n status: BeliefLifecycleStatus\n): BeliefLifecycleStatus {\n return isPreValidationBeliefStatus(status) ? \"active\" : status;\n}\n"]}
|
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PropagationEdgeType, PropagationTraversalDirection, PropagationEdgeRecord, EdgePropagationSpec } from './edges/
|
|
1
|
+
import { SLOperator, SLOpinion } from '@lucern/confidence';
|
|
2
|
+
import { PropagationEdgeType, PropagationTraversalDirection, PropagationEdgeRecord, EdgePropagationSpec } from './edges/propagation-types.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface PropagationDispatchScope {
|
|
5
5
|
tenantId?: string;
|
|
6
6
|
workspaceId?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
7
|
+
}
|
|
8
|
+
interface PropagationDispatchNode<TNodeId extends string = string> {
|
|
9
9
|
_id?: TNodeId;
|
|
10
|
-
nodeType?: string;
|
|
11
|
-
tenantId?: string;
|
|
12
|
-
workspaceId?: string;
|
|
13
10
|
epistemicLayer?: string;
|
|
14
|
-
publicationStatus?: string;
|
|
15
11
|
metadata?: unknown;
|
|
12
|
+
nodeType?: string;
|
|
13
|
+
opinion_a?: number;
|
|
16
14
|
opinion_b?: number;
|
|
17
15
|
opinion_d?: number;
|
|
18
16
|
opinion_u?: number;
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
publicationStatus?: string;
|
|
18
|
+
tenantId?: string;
|
|
19
|
+
workspaceId?: string;
|
|
20
|
+
}
|
|
21
21
|
type PropagationDispatchEdge<TNodeId extends string = string> = PropagationEdgeRecord<TNodeId>;
|
|
22
|
-
|
|
23
|
-
targetNodeId: TNodeId;
|
|
22
|
+
interface ConfidencePropagationDispatch<TNodeId extends string = string> {
|
|
24
23
|
edgeType: PropagationEdgeType;
|
|
25
|
-
|
|
26
|
-
weight: number;
|
|
27
|
-
opinion: SLOpinion;
|
|
24
|
+
hop: number;
|
|
28
25
|
operator: SLOperator;
|
|
26
|
+
opinion: SLOpinion;
|
|
29
27
|
rationale: string;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
targetNodeId: TNodeId;
|
|
29
|
+
traversedDirection: PropagationTraversalDirection;
|
|
30
|
+
weight: number;
|
|
31
|
+
}
|
|
32
|
+
interface CollectConfidencePropagationDispatchesArgs<TNodeId extends string = string> {
|
|
33
|
+
getNode: (nodeId: TNodeId) => Promise<PropagationDispatchNode<TNodeId> | null | undefined>;
|
|
34
|
+
queryEdges: (args: {
|
|
35
|
+
direction: PropagationTraversalDirection;
|
|
36
|
+
hop: number;
|
|
37
|
+
nodeId: TNodeId;
|
|
38
|
+
spec: EdgePropagationSpec<TNodeId>;
|
|
39
|
+
}) => Promise<readonly PropagationDispatchEdge<TNodeId>[]>;
|
|
33
40
|
sourceNodeId: TNodeId;
|
|
34
41
|
sourceOpinion: SLOpinion;
|
|
35
42
|
sourceScope?: PropagationDispatchScope;
|
|
36
43
|
traversalSpecs?: readonly EdgePropagationSpec<TNodeId>[];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
spec: EdgePropagationSpec<TNodeId>;
|
|
40
|
-
direction: PropagationTraversalDirection;
|
|
41
|
-
hop: number;
|
|
42
|
-
}) => Promise<ReadonlyArray<PropagationDispatchEdge<TNodeId>>>;
|
|
43
|
-
getNode: (nodeId: TNodeId) => Promise<PropagationDispatchNode<TNodeId> | null | undefined>;
|
|
44
|
-
}): Promise<ConfidencePropagationDispatch<TNodeId>[]>;
|
|
44
|
+
}
|
|
45
|
+
declare function collectConfidencePropagationDispatches<TNodeId extends string = string>(args: CollectConfidencePropagationDispatchesArgs<TNodeId>): Promise<ConfidencePropagationDispatch<TNodeId>[]>;
|
|
45
46
|
|
|
46
47
|
export { type ConfidencePropagationDispatch, type PropagationDispatchEdge, type PropagationDispatchNode, type PropagationDispatchScope, collectConfidencePropagationDispatches };
|