@lucern/graph-primitives 1.0.29 → 1.0.31
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 +395 -225
- 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 +854 -480
- 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 +365 -166
- package/dist/epistemicBeliefs.admin.js.map +1 -1
- package/dist/epistemicBeliefs.backfills.d.ts +8 -8
- package/dist/epistemicBeliefs.backfills.js +655 -289
- package/dist/epistemicBeliefs.backfills.js.map +1 -1
- package/dist/epistemicBeliefs.confidence.d.ts +19 -15
- package/dist/epistemicBeliefs.confidence.js +633 -386
- package/dist/epistemicBeliefs.confidence.js.map +1 -1
- package/dist/epistemicBeliefs.core.d.ts +6 -6
- package/dist/epistemicBeliefs.core.js +717 -371
- package/dist/epistemicBeliefs.core.js.map +1 -1
- package/dist/epistemicBeliefs.d.ts +11 -9
- package/dist/epistemicBeliefs.forkEvidence.d.ts +2 -0
- package/dist/epistemicBeliefs.forkEvidence.js +8 -8
- package/dist/epistemicBeliefs.forkEvidence.js.map +1 -1
- package/dist/epistemicBeliefs.helpers.d.ts +68 -49
- package/dist/epistemicBeliefs.helpers.js +358 -211
- package/dist/epistemicBeliefs.helpers.js.map +1 -1
- package/dist/epistemicBeliefs.internal.d.ts +5 -5
- package/dist/epistemicBeliefs.internal.js +1248 -1026
- package/dist/epistemicBeliefs.internal.js.map +1 -1
- package/dist/epistemicBeliefs.js +4942 -3590
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicBeliefs.lifecycle.d.ts +5 -5
- package/dist/epistemicBeliefs.lifecycle.js +1138 -781
- package/dist/epistemicBeliefs.lifecycle.js.map +1 -1
- package/dist/epistemicBeliefs.links.d.ts +7 -7
- package/dist/epistemicBeliefs.links.js +404 -267
- 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 +1062 -576
- package/dist/epistemicContracts.evaluators.js.map +1 -1
- package/dist/epistemicContracts.handlers.d.ts +15 -32
- package/dist/epistemicContracts.handlers.js +1829 -1351
- package/dist/epistemicContracts.handlers.js.map +1 -1
- package/dist/epistemicContracts.js +1131 -636
- 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 +1966 -1202
- package/dist/epistemicEdges.js.map +1 -1
- package/dist/epistemicEdges.mutations.d.ts +7 -7
- package/dist/epistemicEdges.mutations.js +956 -579
- 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 +933 -532
- 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 +840 -692
- 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 +700 -504
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/epistemicNodes.mutations.d.ts +6 -6
- package/dist/epistemicNodes.mutations.js +560 -463
- 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 +351 -311
- 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 +86 -83
- package/dist/index.js +16914 -11760
- 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
package/dist/epistemicHelpers.js
CHANGED
|
@@ -1,89 +1,14 @@
|
|
|
1
|
+
import { unsafeConvexAnyApi } from '@lucern/contracts/convex/unsafeAnyApi';
|
|
2
|
+
import { componentsGeneric } from 'convex/server';
|
|
1
3
|
import { generateGlobalId, assertUuidV7Identity } from '@lucern/contracts/ids';
|
|
2
|
-
import { componentsGeneric, anyApi } from 'convex/server';
|
|
3
4
|
import '@lucern/contracts';
|
|
4
5
|
|
|
5
|
-
// src/
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
question: "Question",
|
|
12
|
-
theme: "Theme",
|
|
13
|
-
deal: "Deal",
|
|
14
|
-
topic: "Topic",
|
|
15
|
-
// L2: Compression Boundary
|
|
16
|
-
claim: "Claim",
|
|
17
|
-
evidence: "Evidence",
|
|
18
|
-
synthesis: "Synthesis",
|
|
19
|
-
answer: "Answer",
|
|
20
|
-
// L1: Terminal Leaves
|
|
21
|
-
atomic_fact: "AtomicFact",
|
|
22
|
-
excerpt: "Excerpt",
|
|
23
|
-
source: "Source",
|
|
24
|
-
// Ontological (Neo4j is SOT)
|
|
25
|
-
company: "Company",
|
|
26
|
-
person: "Person",
|
|
27
|
-
investor: "Investor",
|
|
28
|
-
function: "Function",
|
|
29
|
-
value_chain: "ValueChain"
|
|
30
|
-
};
|
|
31
|
-
var EDGE_TYPE_TO_REL = {
|
|
32
|
-
// === THE SIX CANONICAL EPISTEMIC EDGE TYPES ===
|
|
33
|
-
supports: "SUPPORTS",
|
|
34
|
-
// L3↔L3: belief bears on belief (weight -1 to +1)
|
|
35
|
-
informs: "INFORMS",
|
|
36
|
-
// L2→L3: evidence bears on belief
|
|
37
|
-
depends_on: "DEPENDS_ON",
|
|
38
|
-
// L3→L3, Q→Q: structural gate
|
|
39
|
-
derived_from: "DERIVED_FROM",
|
|
40
|
-
// Any→Any: provenance chain (fork, synthesis, extraction, answer)
|
|
41
|
-
contains: "CONTAINS",
|
|
42
|
-
// Any→Any: hierarchy, scoping, membership
|
|
43
|
-
tests: "TESTS",
|
|
44
|
-
// Q→L3: question interrogates belief
|
|
45
|
-
// === L4 DECISION EDGES (derived_from with derivationType=decision) ===
|
|
46
|
-
// Kept as separate Neo4j relationship types for backward compat with L4 queries.
|
|
47
|
-
// New code should use derived_from + metadata.
|
|
48
|
-
based_on_belief: "BASED_ON_BELIEF",
|
|
49
|
-
based_on_question: "BASED_ON_QUESTION",
|
|
50
|
-
blocked_by_contradiction: "BLOCKED_BY_CONTRADICTION",
|
|
51
|
-
informed_by_theme: "INFORMED_BY_THEME",
|
|
52
|
-
// === ONTOLOGICAL EDGES (tenant-extensible, managed by ontology system) ===
|
|
53
|
-
works_at: "WORKS_AT",
|
|
54
|
-
invested_in: "INVESTED_IN",
|
|
55
|
-
competes_with: "COMPETES_WITH",
|
|
56
|
-
participates_in: "PARTICIPATES_IN",
|
|
57
|
-
founded_by: "FOUNDED_BY",
|
|
58
|
-
evaluates: "EVALUATES",
|
|
59
|
-
performs: "PERFORMS",
|
|
60
|
-
function_in: "FUNCTION_IN",
|
|
61
|
-
impacts: "IMPACTS",
|
|
62
|
-
raised_from: "RAISED_FROM",
|
|
63
|
-
mentioned_in: "MENTIONED_IN",
|
|
64
|
-
perspective_on: "PERSPECTIVE_ON",
|
|
65
|
-
about_entity: "ABOUT_ENTITY",
|
|
66
|
-
entity_referenced_in: "ENTITY_REFERENCED_IN"
|
|
67
|
-
};
|
|
68
|
-
function getNeo4jLabel(nodeType) {
|
|
69
|
-
return NODE_TYPE_TO_LABEL[nodeType] || nodeType.charAt(0).toUpperCase() + nodeType.slice(1);
|
|
70
|
-
}
|
|
71
|
-
function getNeo4jRelType(edgeType) {
|
|
72
|
-
return EDGE_TYPE_TO_REL[edgeType] || edgeType.toUpperCase();
|
|
73
|
-
}
|
|
74
|
-
var CANONICAL_EPISTEMIC_TYPES = /* @__PURE__ */ new Set([
|
|
75
|
-
"supports",
|
|
76
|
-
"informs",
|
|
77
|
-
"depends_on",
|
|
78
|
-
"derived_from",
|
|
79
|
-
"contains",
|
|
80
|
-
"tests"
|
|
81
|
-
]);
|
|
82
|
-
function isDeprecatedEdgeType(edgeType) {
|
|
83
|
-
if (CANONICAL_EPISTEMIC_TYPES.has(edgeType)) return false;
|
|
84
|
-
if (edgeType in EDGE_TYPE_TO_REL) return false;
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
6
|
+
// src/convex.ts
|
|
7
|
+
var unsafeApi = unsafeConvexAnyApi(
|
|
8
|
+
"graph-primitives top-level module bundle lacks a committed Convex _generated/api surface"
|
|
9
|
+
);
|
|
10
|
+
componentsGeneric();
|
|
11
|
+
var internal = unsafeApi;
|
|
87
12
|
|
|
88
13
|
// src/epistemicLayerRules.ts
|
|
89
14
|
function getNodeLayer(nodeType) {
|
|
@@ -265,11 +190,7 @@ function getDefaultEdgeTypesForMode(mode) {
|
|
|
265
190
|
"same_theme_as"
|
|
266
191
|
];
|
|
267
192
|
case "decision_trace":
|
|
268
|
-
return [
|
|
269
|
-
"derived_from",
|
|
270
|
-
"depends_on",
|
|
271
|
-
"contains"
|
|
272
|
-
];
|
|
193
|
+
return ["derived_from", "depends_on", "contains"];
|
|
273
194
|
default:
|
|
274
195
|
return [];
|
|
275
196
|
}
|
|
@@ -562,10 +483,63 @@ function validateEdgeLayers(edgeType, fromLayer, toLayer) {
|
|
|
562
483
|
}
|
|
563
484
|
return { valid: true };
|
|
564
485
|
}
|
|
565
|
-
componentsGeneric();
|
|
566
|
-
var internal = anyApi;
|
|
567
486
|
|
|
568
487
|
// src/epistemicEdgeCreation.ts
|
|
488
|
+
var EPISTEMIC_LAYERS = /* @__PURE__ */ new Set([
|
|
489
|
+
"L4",
|
|
490
|
+
"L3",
|
|
491
|
+
"L2",
|
|
492
|
+
"L1",
|
|
493
|
+
"ontological",
|
|
494
|
+
"organizational"
|
|
495
|
+
]);
|
|
496
|
+
function readOptionalString(value) {
|
|
497
|
+
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
498
|
+
}
|
|
499
|
+
function readConvexId(value) {
|
|
500
|
+
const normalized = readOptionalString(value);
|
|
501
|
+
return normalized;
|
|
502
|
+
}
|
|
503
|
+
function readEpistemicLayer(value) {
|
|
504
|
+
const layer = readOptionalString(value);
|
|
505
|
+
return layer && EPISTEMIC_LAYERS.has(layer) ? layer : void 0;
|
|
506
|
+
}
|
|
507
|
+
function readRecord(value) {
|
|
508
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
509
|
+
}
|
|
510
|
+
function readEdgeNodeRow(value) {
|
|
511
|
+
const record = readRecord(value);
|
|
512
|
+
if (!record) {
|
|
513
|
+
return null;
|
|
514
|
+
}
|
|
515
|
+
const id = readConvexId(record._id);
|
|
516
|
+
const globalId = readOptionalString(record.globalId);
|
|
517
|
+
const nodeType = readOptionalString(record.nodeType);
|
|
518
|
+
if (!(id && globalId && nodeType)) {
|
|
519
|
+
return null;
|
|
520
|
+
}
|
|
521
|
+
const node = { _id: id, globalId, nodeType };
|
|
522
|
+
const epistemicLayer = readEpistemicLayer(record.epistemicLayer);
|
|
523
|
+
if (epistemicLayer !== void 0) {
|
|
524
|
+
node.epistemicLayer = epistemicLayer;
|
|
525
|
+
}
|
|
526
|
+
const metadata = readRecord(record.metadata);
|
|
527
|
+
if (metadata !== void 0) {
|
|
528
|
+
node.metadata = metadata;
|
|
529
|
+
}
|
|
530
|
+
const projectId = readOptionalString(record.projectId);
|
|
531
|
+
if (projectId !== void 0) {
|
|
532
|
+
node.projectId = projectId;
|
|
533
|
+
}
|
|
534
|
+
return node;
|
|
535
|
+
}
|
|
536
|
+
function requireEdgeNodeRow(value, context) {
|
|
537
|
+
const node = readEdgeNodeRow(value);
|
|
538
|
+
if (!node) {
|
|
539
|
+
throw new Error(`${context} requires a canonical epistemic node row.`);
|
|
540
|
+
}
|
|
541
|
+
return node;
|
|
542
|
+
}
|
|
569
543
|
function normalizeConfidence(confidence) {
|
|
570
544
|
if (typeof confidence === "number") {
|
|
571
545
|
return confidence > 1 ? confidence / 100 : confidence;
|
|
@@ -586,13 +560,16 @@ function normalizeConfidence(confidence) {
|
|
|
586
560
|
}
|
|
587
561
|
async function createEpistemicEdge(ctx, params) {
|
|
588
562
|
const globalId = generateGlobalId();
|
|
589
|
-
const fromNode =
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
563
|
+
const fromNode = requireEdgeNodeRow(
|
|
564
|
+
await ctx.db.get(params.fromNodeId),
|
|
565
|
+
"Create epistemic edge source"
|
|
566
|
+
);
|
|
567
|
+
const toNode = requireEdgeNodeRow(
|
|
568
|
+
await ctx.db.get(params.toNodeId),
|
|
569
|
+
"Create epistemic edge target"
|
|
570
|
+
);
|
|
571
|
+
const fromLayer = fromNode.epistemicLayer ?? getNodeLayer(fromNode.nodeType);
|
|
572
|
+
const toLayer = toNode.epistemicLayer ?? getNodeLayer(toNode.nodeType);
|
|
596
573
|
if (!params.skipLayerValidation) {
|
|
597
574
|
const validation = validateEdgeLayers(params.edgeType, fromLayer, toLayer);
|
|
598
575
|
if (!validation.valid) {
|
|
@@ -629,11 +606,11 @@ async function createEdgeForInsightQuestionLink(ctx, questionId, insightId, crea
|
|
|
629
606
|
questionNode: questionNode ? String(questionNode) : null,
|
|
630
607
|
insightNode: insightNode ? String(insightNode) : null
|
|
631
608
|
});
|
|
632
|
-
if (!questionNode
|
|
609
|
+
if (!(questionNode && insightNode)) {
|
|
633
610
|
console.log("[EpistemicSpine] Missing nodes, skipping edge creation");
|
|
634
611
|
return null;
|
|
635
612
|
}
|
|
636
|
-
const question = await ctx.db.get(questionId);
|
|
613
|
+
const question = readEdgeNodeRow(await ctx.db.get(questionId));
|
|
637
614
|
const projectId = question?.projectId;
|
|
638
615
|
return await createEpistemicEdge(ctx, {
|
|
639
616
|
fromNodeId: insightNode,
|
|
@@ -645,16 +622,16 @@ async function createEdgeForInsightQuestionLink(ctx, questionId, insightId, crea
|
|
|
645
622
|
});
|
|
646
623
|
}
|
|
647
624
|
async function findNodeByLegacyId(ctx, legacyType, legacyId) {
|
|
648
|
-
const nodeType = legacyType
|
|
625
|
+
const nodeType = normalizeLegacyNodeType(legacyType);
|
|
649
626
|
const nodes = await ctx.db.query("epistemicNodes").withIndex(
|
|
650
627
|
"by_nodeType",
|
|
651
628
|
(q) => q.eq("nodeType", nodeType)
|
|
652
629
|
).collect();
|
|
653
630
|
const legacyKey = `legacy${legacyType.charAt(0).toUpperCase() + legacyType.slice(1)}Id`;
|
|
654
631
|
const legacyIdStr = String(legacyId);
|
|
655
|
-
const found = nodes.find((
|
|
656
|
-
const
|
|
657
|
-
const storedId = metadata?.[legacyKey];
|
|
632
|
+
const found = nodes.find((candidate) => {
|
|
633
|
+
const node = readEdgeNodeRow(candidate);
|
|
634
|
+
const storedId = node?.metadata?.[legacyKey];
|
|
658
635
|
return storedId && String(storedId) === legacyIdStr;
|
|
659
636
|
});
|
|
660
637
|
if (!found) {
|
|
@@ -662,9 +639,18 @@ async function findNodeByLegacyId(ctx, legacyType, legacyId) {
|
|
|
662
639
|
`[EpistemicSpine] Node not found for ${legacyType}:${legacyIdStr}, searched ${nodes.length} ${nodeType} nodes`
|
|
663
640
|
);
|
|
664
641
|
}
|
|
665
|
-
return found?._id ?? null;
|
|
642
|
+
return readEdgeNodeRow(found)?._id ?? null;
|
|
643
|
+
}
|
|
644
|
+
function normalizeLegacyNodeType(legacyType) {
|
|
645
|
+
if (legacyType === "insight") {
|
|
646
|
+
return "evidence";
|
|
647
|
+
}
|
|
648
|
+
if (legacyType === "artifact") {
|
|
649
|
+
return "source";
|
|
650
|
+
}
|
|
651
|
+
return legacyType;
|
|
666
652
|
}
|
|
667
|
-
|
|
653
|
+
function insertEpistemicNode(ctx, doc) {
|
|
668
654
|
assertUuidV7Identity("epistemicNodes", doc.globalId);
|
|
669
655
|
return ctx.db.insert("epistemicNodes", doc);
|
|
670
656
|
}
|
|
@@ -674,8 +660,11 @@ function generateContentHash(nodeType, text) {
|
|
|
674
660
|
const content = `${nodeType}:${normalizeText(text)}`;
|
|
675
661
|
let hash = 5381;
|
|
676
662
|
for (let i = 0; i < content.length; i++) {
|
|
677
|
-
|
|
678
|
-
hash
|
|
663
|
+
const nextHash = hash * 33 + content.charCodeAt(i);
|
|
664
|
+
hash = nextHash - Math.floor(nextHash / 4294967296) * 4294967296;
|
|
665
|
+
if (hash >= 2147483648) {
|
|
666
|
+
hash -= 4294967296;
|
|
667
|
+
}
|
|
679
668
|
}
|
|
680
669
|
const hashHex = Math.abs(hash).toString(16).padStart(8, "0");
|
|
681
670
|
const lengthHex = content.length.toString(16).padStart(4, "0");
|
|
@@ -685,6 +674,71 @@ function generateContentHash(nodeType, text) {
|
|
|
685
674
|
function normalizeText(text) {
|
|
686
675
|
return text.trim().toLowerCase().replace(/\s+/g, " ");
|
|
687
676
|
}
|
|
677
|
+
function readOptionalString2(value) {
|
|
678
|
+
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
679
|
+
}
|
|
680
|
+
function readOptionalBoolean(value) {
|
|
681
|
+
return typeof value === "boolean" ? value : void 0;
|
|
682
|
+
}
|
|
683
|
+
function readRecord2(value) {
|
|
684
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
685
|
+
}
|
|
686
|
+
function readConvexId2(value) {
|
|
687
|
+
const normalized = readOptionalString2(value);
|
|
688
|
+
return normalized ? normalized : null;
|
|
689
|
+
}
|
|
690
|
+
function readExistingEpistemicNodeRow(value) {
|
|
691
|
+
const record = readRecord2(value);
|
|
692
|
+
if (!record) {
|
|
693
|
+
return null;
|
|
694
|
+
}
|
|
695
|
+
const id = readConvexId2(record._id);
|
|
696
|
+
if (!id) {
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
const node = { _id: id };
|
|
700
|
+
const metadata = readRecord2(record.metadata);
|
|
701
|
+
if (metadata) {
|
|
702
|
+
node.metadata = metadata;
|
|
703
|
+
}
|
|
704
|
+
const projectId = readOptionalString2(record.projectId);
|
|
705
|
+
if (projectId !== void 0) {
|
|
706
|
+
node.projectId = projectId;
|
|
707
|
+
}
|
|
708
|
+
const status = readOptionalString2(record.status);
|
|
709
|
+
if (status !== void 0) {
|
|
710
|
+
node.status = status;
|
|
711
|
+
}
|
|
712
|
+
return node;
|
|
713
|
+
}
|
|
714
|
+
function readSourceArtifactRow(value) {
|
|
715
|
+
const record = readRecord2(value);
|
|
716
|
+
if (!record) {
|
|
717
|
+
return null;
|
|
718
|
+
}
|
|
719
|
+
const artifact = {};
|
|
720
|
+
const content = readOptionalString2(record.content);
|
|
721
|
+
if (content !== void 0) {
|
|
722
|
+
artifact.content = content;
|
|
723
|
+
}
|
|
724
|
+
const metadata = readRecord2(record.metadata);
|
|
725
|
+
if (metadata) {
|
|
726
|
+
artifact.metadata = metadata;
|
|
727
|
+
}
|
|
728
|
+
const projectId = readOptionalString2(record.projectId);
|
|
729
|
+
if (projectId !== void 0) {
|
|
730
|
+
artifact.projectId = projectId;
|
|
731
|
+
}
|
|
732
|
+
const stage = readOptionalString2(record.stage);
|
|
733
|
+
if (stage !== void 0) {
|
|
734
|
+
artifact.stage = stage;
|
|
735
|
+
}
|
|
736
|
+
const topicId = readOptionalString2(record.topicId);
|
|
737
|
+
if (topicId !== void 0) {
|
|
738
|
+
artifact.topicId = topicId;
|
|
739
|
+
}
|
|
740
|
+
return artifact;
|
|
741
|
+
}
|
|
688
742
|
function mapInsightSourceType(sourceType) {
|
|
689
743
|
switch (sourceType) {
|
|
690
744
|
case "verified":
|
|
@@ -707,16 +761,38 @@ function mapVerificationStatus(status) {
|
|
|
707
761
|
return "unverified";
|
|
708
762
|
}
|
|
709
763
|
}
|
|
764
|
+
function inferInsightConfidence(verificationStatus) {
|
|
765
|
+
if (verificationStatus === "manually_verified") {
|
|
766
|
+
return 0.9;
|
|
767
|
+
}
|
|
768
|
+
if (verificationStatus === "deep_verified") {
|
|
769
|
+
return 0.7;
|
|
770
|
+
}
|
|
771
|
+
if (verificationStatus === "pre_screened") {
|
|
772
|
+
return 0.5;
|
|
773
|
+
}
|
|
774
|
+
return 0.3;
|
|
775
|
+
}
|
|
776
|
+
function mapQuestionSourceType(source) {
|
|
777
|
+
if (source === "manual") {
|
|
778
|
+
return "human";
|
|
779
|
+
}
|
|
780
|
+
if (source === "ai_suggested") {
|
|
781
|
+
return "ai_generated";
|
|
782
|
+
}
|
|
783
|
+
return "ai_extracted";
|
|
784
|
+
}
|
|
710
785
|
async function createEpistemicNodeForInsight(ctx, _insightId, insight) {
|
|
711
786
|
const now = Date.now();
|
|
712
787
|
const globalId = generateGlobalId();
|
|
713
788
|
const contentHash = generateContentHash("evidence", insight.text);
|
|
714
789
|
const existing = await ctx.db.query("epistemicNodes").withIndex("by_contentHash", (q) => q.eq("contentHash", contentHash)).first();
|
|
715
|
-
|
|
716
|
-
|
|
790
|
+
const existingInsightNode = readExistingEpistemicNodeRow(existing);
|
|
791
|
+
if (existingInsightNode?.status === "active") {
|
|
792
|
+
await ctx.db.patch(existingInsightNode._id, {
|
|
717
793
|
updatedAt: now
|
|
718
794
|
});
|
|
719
|
-
return
|
|
795
|
+
return existingInsightNode._id;
|
|
720
796
|
}
|
|
721
797
|
const nodeId = await insertEpistemicNode(ctx, {
|
|
722
798
|
globalId,
|
|
@@ -752,7 +828,7 @@ async function createEpistemicNodeForInsight(ctx, _insightId, insight) {
|
|
|
752
828
|
},
|
|
753
829
|
sourceType: mapInsightSourceType(insight.sourceType),
|
|
754
830
|
aiProvider: insight.aiProvider,
|
|
755
|
-
confidence: insight.verificationStatus
|
|
831
|
+
confidence: inferInsightConfidence(insight.verificationStatus),
|
|
756
832
|
verificationStatus: mapVerificationStatus(insight.verificationStatus),
|
|
757
833
|
status: "active",
|
|
758
834
|
topicId: insight.projectId,
|
|
@@ -784,15 +860,16 @@ async function createEpistemicNodeForBelief(ctx, beliefId, belief) {
|
|
|
784
860
|
const globalId = generateGlobalId();
|
|
785
861
|
const contentHash = generateContentHash("belief", belief.belief);
|
|
786
862
|
const existing = await ctx.db.query("epistemicNodes").withIndex("by_contentHash", (q) => q.eq("contentHash", contentHash)).first();
|
|
787
|
-
|
|
788
|
-
|
|
863
|
+
const existingBeliefNode = readExistingEpistemicNodeRow(existing);
|
|
864
|
+
if (existingBeliefNode?.status === "active") {
|
|
865
|
+
await ctx.db.patch(existingBeliefNode._id, {
|
|
789
866
|
metadata: {
|
|
790
|
-
...
|
|
867
|
+
...existingBeliefNode.metadata ?? {},
|
|
791
868
|
sourceBeliefId: beliefId
|
|
792
869
|
},
|
|
793
870
|
updatedAt: now
|
|
794
871
|
});
|
|
795
|
-
return
|
|
872
|
+
return existingBeliefNode._id;
|
|
796
873
|
}
|
|
797
874
|
const nodeId = await insertEpistemicNode(ctx, {
|
|
798
875
|
globalId,
|
|
@@ -835,13 +912,14 @@ async function createEpistemicNodeForQuestion(ctx, _questionId, question) {
|
|
|
835
912
|
const globalId = generateGlobalId();
|
|
836
913
|
const contentHash = generateContentHash("question", question.question);
|
|
837
914
|
const existing = await ctx.db.query("epistemicNodes").withIndex("by_contentHash", (q) => q.eq("contentHash", contentHash)).first();
|
|
838
|
-
|
|
839
|
-
|
|
915
|
+
const existingQuestionNode = readExistingEpistemicNodeRow(existing);
|
|
916
|
+
if (existingQuestionNode?.status === "active") {
|
|
917
|
+
await ctx.db.patch(existingQuestionNode._id, {
|
|
840
918
|
updatedAt: now
|
|
841
919
|
});
|
|
842
|
-
return
|
|
920
|
+
return existingQuestionNode._id;
|
|
843
921
|
}
|
|
844
|
-
const sourceType = question.source
|
|
922
|
+
const sourceType = mapQuestionSourceType(question.source);
|
|
845
923
|
const nodeId = await insertEpistemicNode(ctx, {
|
|
846
924
|
globalId,
|
|
847
925
|
nodeType: "question",
|
|
@@ -882,8 +960,9 @@ async function createEpistemicNodeForArtifact(ctx, artifactId, artifact) {
|
|
|
882
960
|
artifact.title + artifact.content.slice(0, 500)
|
|
883
961
|
);
|
|
884
962
|
const existing2 = await ctx.db.query("epistemicNodes").withIndex("by_contentHash", (q) => q.eq("contentHash", contentHash2)).first();
|
|
885
|
-
|
|
886
|
-
|
|
963
|
+
const existingSynthesisNode = readExistingEpistemicNodeRow(existing2);
|
|
964
|
+
if (existingSynthesisNode?.status === "active") {
|
|
965
|
+
return existingSynthesisNode._id;
|
|
887
966
|
}
|
|
888
967
|
throw new Error("SKIP_SYNTHESIS_NODE_CREATION");
|
|
889
968
|
}
|
|
@@ -892,15 +971,16 @@ async function createEpistemicNodeForArtifact(ctx, artifactId, artifact) {
|
|
|
892
971
|
artifact.title + artifact.content.slice(0, 500)
|
|
893
972
|
);
|
|
894
973
|
const existing = await ctx.db.query("epistemicNodes").withIndex("by_contentHash", (q) => q.eq("contentHash", contentHash)).first();
|
|
895
|
-
|
|
896
|
-
|
|
974
|
+
const existingArtifactNode = readExistingEpistemicNodeRow(existing);
|
|
975
|
+
if (existingArtifactNode?.status === "active") {
|
|
976
|
+
await ctx.db.patch(existingArtifactNode._id, {
|
|
897
977
|
metadata: {
|
|
898
|
-
...
|
|
978
|
+
...existingArtifactNode.metadata ?? {},
|
|
899
979
|
legacyArtifactId: artifactId
|
|
900
980
|
},
|
|
901
981
|
updatedAt: now
|
|
902
982
|
});
|
|
903
|
-
return
|
|
983
|
+
return existingArtifactNode._id;
|
|
904
984
|
}
|
|
905
985
|
const epistemicLayer = "L1";
|
|
906
986
|
const nodeId = await insertEpistemicNode(ctx, {
|
|
@@ -929,21 +1009,28 @@ async function createEpistemicNodeForArtifact(ctx, artifactId, artifact) {
|
|
|
929
1009
|
return nodeId;
|
|
930
1010
|
}
|
|
931
1011
|
async function findOrCreateSourceNode(ctx, artifactId, createdBy, scopeProjectId) {
|
|
932
|
-
const artifact = await ctx.db.get(artifactId);
|
|
1012
|
+
const artifact = readSourceArtifactRow(await ctx.db.get(artifactId));
|
|
933
1013
|
const effectiveProjectId = scopeProjectId || artifact?.projectId;
|
|
934
1014
|
const effectiveTopicId = artifact?.topicId;
|
|
935
1015
|
let existingNodes;
|
|
936
1016
|
if (effectiveTopicId) {
|
|
937
|
-
|
|
1017
|
+
const collectedNodes = await ctx.db.query("epistemicNodes").withIndex("by_topic", (q) => q.eq("topicId", effectiveTopicId)).collect();
|
|
1018
|
+
existingNodes = collectedNodes.flatMap((node) => {
|
|
1019
|
+
const row = readExistingEpistemicNodeRow(node);
|
|
1020
|
+
return row ? [row] : [];
|
|
1021
|
+
});
|
|
938
1022
|
} else {
|
|
939
|
-
|
|
1023
|
+
const collectedNodes = await ctx.db.query("epistemicNodes").withIndex("by_nodeType", (q) => q.eq("nodeType", "source")).collect();
|
|
1024
|
+
existingNodes = collectedNodes.flatMap((node) => {
|
|
1025
|
+
const row = readExistingEpistemicNodeRow(node);
|
|
1026
|
+
return row ? [row] : [];
|
|
1027
|
+
});
|
|
940
1028
|
}
|
|
941
1029
|
const existing = existingNodes.find((n) => {
|
|
942
1030
|
if (effectiveProjectId && n.projectId && n.projectId !== effectiveProjectId) {
|
|
943
1031
|
return false;
|
|
944
1032
|
}
|
|
945
|
-
|
|
946
|
-
return metadata?.legacyArtifactId === artifactId;
|
|
1033
|
+
return n.metadata?.legacyArtifactId === artifactId;
|
|
947
1034
|
});
|
|
948
1035
|
if (existing) {
|
|
949
1036
|
return existing._id;
|
|
@@ -953,18 +1040,18 @@ async function findOrCreateSourceNode(ctx, artifactId, createdBy, scopeProjectId
|
|
|
953
1040
|
}
|
|
954
1041
|
const now = Date.now();
|
|
955
1042
|
const globalId = generateGlobalId();
|
|
956
|
-
const artifactType = artifact.metadata?.type
|
|
957
|
-
const isDeepResearch = artifact.metadata?.isDeepResearch;
|
|
1043
|
+
const artifactType = readOptionalString2(artifact.metadata?.type) ?? "";
|
|
1044
|
+
const isDeepResearch = readOptionalBoolean(artifact.metadata?.isDeepResearch) ?? false;
|
|
958
1045
|
let nodeType = "source";
|
|
959
1046
|
if (isDeepResearch || artifactType.includes("deep") || artifactType.includes("research")) {
|
|
960
1047
|
nodeType = "synthesis";
|
|
961
1048
|
} else if (artifactType.includes("primer")) {
|
|
962
1049
|
nodeType = "synthesis";
|
|
963
1050
|
}
|
|
964
|
-
const title = artifact.metadata?.title || artifact.metadata?.theme || "Untitled";
|
|
1051
|
+
const title = readOptionalString2(artifact.metadata?.title) || readOptionalString2(artifact.metadata?.theme) || "Untitled";
|
|
965
1052
|
const contentHash = generateContentHash(
|
|
966
1053
|
nodeType,
|
|
967
|
-
title + (artifact.content?.slice(0, 500)
|
|
1054
|
+
title + (artifact.content?.slice(0, 500) ?? "")
|
|
968
1055
|
);
|
|
969
1056
|
const epistemicLayer = nodeType === "synthesis" ? "L2" : "L1";
|
|
970
1057
|
const nodeId = await insertEpistemicNode(ctx, {
|
|
@@ -994,6 +1081,93 @@ async function findOrCreateSourceNode(ctx, artifactId, createdBy, scopeProjectId
|
|
|
994
1081
|
return nodeId;
|
|
995
1082
|
}
|
|
996
1083
|
|
|
1084
|
+
// src/graphTypes.ts
|
|
1085
|
+
var NODE_TYPE_TO_LABEL = {
|
|
1086
|
+
// L4: Audit Targets
|
|
1087
|
+
decision: "Decision",
|
|
1088
|
+
// L3: Traversal Anchors
|
|
1089
|
+
belief: "Belief",
|
|
1090
|
+
question: "Question",
|
|
1091
|
+
theme: "Theme",
|
|
1092
|
+
deal: "Deal",
|
|
1093
|
+
topic: "Topic",
|
|
1094
|
+
// L2: Compression Boundary
|
|
1095
|
+
claim: "Claim",
|
|
1096
|
+
evidence: "Evidence",
|
|
1097
|
+
synthesis: "Synthesis",
|
|
1098
|
+
answer: "Answer",
|
|
1099
|
+
// L1: Terminal Leaves
|
|
1100
|
+
atomic_fact: "AtomicFact",
|
|
1101
|
+
excerpt: "Excerpt",
|
|
1102
|
+
source: "Source",
|
|
1103
|
+
// Ontological (Neo4j is SOT)
|
|
1104
|
+
company: "Company",
|
|
1105
|
+
person: "Person",
|
|
1106
|
+
investor: "Investor",
|
|
1107
|
+
function: "Function",
|
|
1108
|
+
value_chain: "ValueChain"
|
|
1109
|
+
};
|
|
1110
|
+
var EDGE_TYPE_TO_REL = {
|
|
1111
|
+
// === THE SIX CANONICAL EPISTEMIC EDGE TYPES ===
|
|
1112
|
+
supports: "SUPPORTS",
|
|
1113
|
+
// L3↔L3: belief bears on belief (weight -1 to +1)
|
|
1114
|
+
informs: "INFORMS",
|
|
1115
|
+
// L2→L3: evidence bears on belief
|
|
1116
|
+
depends_on: "DEPENDS_ON",
|
|
1117
|
+
// L3→L3, Q→Q: structural gate
|
|
1118
|
+
derived_from: "DERIVED_FROM",
|
|
1119
|
+
// Any→Any: provenance chain (fork, synthesis, extraction, answer)
|
|
1120
|
+
contains: "CONTAINS",
|
|
1121
|
+
// Any→Any: hierarchy, scoping, membership
|
|
1122
|
+
tests: "TESTS",
|
|
1123
|
+
// Q→L3: question interrogates belief
|
|
1124
|
+
// === L4 DECISION EDGES (derived_from with derivationType=decision) ===
|
|
1125
|
+
// Kept as separate Neo4j relationship types for backward compat with L4 queries.
|
|
1126
|
+
// New code should use derived_from + metadata.
|
|
1127
|
+
based_on_belief: "BASED_ON_BELIEF",
|
|
1128
|
+
based_on_question: "BASED_ON_QUESTION",
|
|
1129
|
+
blocked_by_contradiction: "BLOCKED_BY_CONTRADICTION",
|
|
1130
|
+
informed_by_theme: "INFORMED_BY_THEME",
|
|
1131
|
+
// === ONTOLOGICAL EDGES (tenant-extensible, managed by ontology system) ===
|
|
1132
|
+
works_at: "WORKS_AT",
|
|
1133
|
+
invested_in: "INVESTED_IN",
|
|
1134
|
+
competes_with: "COMPETES_WITH",
|
|
1135
|
+
participates_in: "PARTICIPATES_IN",
|
|
1136
|
+
founded_by: "FOUNDED_BY",
|
|
1137
|
+
evaluates: "EVALUATES",
|
|
1138
|
+
performs: "PERFORMS",
|
|
1139
|
+
function_in: "FUNCTION_IN",
|
|
1140
|
+
impacts: "IMPACTS",
|
|
1141
|
+
raised_from: "RAISED_FROM",
|
|
1142
|
+
mentioned_in: "MENTIONED_IN",
|
|
1143
|
+
perspective_on: "PERSPECTIVE_ON",
|
|
1144
|
+
about_entity: "ABOUT_ENTITY",
|
|
1145
|
+
entity_referenced_in: "ENTITY_REFERENCED_IN"
|
|
1146
|
+
};
|
|
1147
|
+
function getNeo4jLabel(nodeType) {
|
|
1148
|
+
return NODE_TYPE_TO_LABEL[nodeType] || nodeType.charAt(0).toUpperCase() + nodeType.slice(1);
|
|
1149
|
+
}
|
|
1150
|
+
function getNeo4jRelType(edgeType) {
|
|
1151
|
+
return EDGE_TYPE_TO_REL[edgeType] || edgeType.toUpperCase();
|
|
1152
|
+
}
|
|
1153
|
+
var CANONICAL_EPISTEMIC_TYPES = /* @__PURE__ */ new Set([
|
|
1154
|
+
"supports",
|
|
1155
|
+
"informs",
|
|
1156
|
+
"depends_on",
|
|
1157
|
+
"derived_from",
|
|
1158
|
+
"contains",
|
|
1159
|
+
"tests"
|
|
1160
|
+
]);
|
|
1161
|
+
function isDeprecatedEdgeType(edgeType) {
|
|
1162
|
+
if (CANONICAL_EPISTEMIC_TYPES.has(edgeType)) {
|
|
1163
|
+
return false;
|
|
1164
|
+
}
|
|
1165
|
+
if (edgeType in EDGE_TYPE_TO_REL) {
|
|
1166
|
+
return false;
|
|
1167
|
+
}
|
|
1168
|
+
return true;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
997
1171
|
export { EDGE_LAYER_RULES, LAYER_TRAVERSAL_RULES, canTraverseToLayer, createEdgeForInsightQuestionLink, createEpistemicEdge, createEpistemicNodeForArtifact, createEpistemicNodeForBelief, createEpistemicNodeForInsight, createEpistemicNodeForQuestion, getDefaultEdgeTypesForMode, getDefaultMinLayer, getLayerDepth, getNeo4jLabel, getNeo4jRelType, getNodeLayer, isDeprecatedEdgeType, isValidLayerConnection, normalizeConfidence, shouldContinueTraversal, validateEdgeLayers };
|
|
998
1172
|
//# sourceMappingURL=epistemicHelpers.js.map
|
|
999
1173
|
//# sourceMappingURL=epistemicHelpers.js.map
|