@lucern/events 1.0.15 → 1.0.17
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/index.js +233 -153
- package/dist/index.js.map +1 -1
- package/dist/outbox.js +233 -153
- package/dist/outbox.js.map +1 -1
- package/dist/proof-attestation.json +3 -3
- package/dist/types.js +233 -153
- package/dist/types.js.map +1 -1
- package/dist/webhook-delivery-machine.js +233 -153
- package/dist/webhook-delivery-machine.js.map +1 -1
- package/dist/webhooks.js +233 -153
- package/dist/webhooks.js.map +1 -1
- package/package.json +2 -2
package/dist/webhooks.js
CHANGED
|
@@ -34,7 +34,7 @@ var REASONING_METHODS = [
|
|
|
34
34
|
// ../contracts/src/tool-contracts.graph.ts
|
|
35
35
|
var QUERY_LINEAGE = {
|
|
36
36
|
name: "query_lineage",
|
|
37
|
-
description: "Trace a belief's full ancestry \u2014 every fork, score, and
|
|
37
|
+
description: "Trace a belief's full ancestry \u2014 every fork, score, and SL scoring event. Like `git log --graph`. Returns the complete evolution chain showing how understanding developed over time. Lineage is permanent and can never be erased (Invariant #3).",
|
|
38
38
|
parameters: {
|
|
39
39
|
nodeId: { type: "string", description: "Starting node to trace from" },
|
|
40
40
|
depth: {
|
|
@@ -233,7 +233,7 @@ var FIND_CONTRADICTIONS = {
|
|
|
233
233
|
};
|
|
234
234
|
var BISECT_CONFIDENCE = {
|
|
235
235
|
name: "bisect_confidence",
|
|
236
|
-
description: "Find when a belief's confidence diverged from reality. Like `git bisect` \u2014 binary search through the credence history to find the inflection point. Given a belief that is now known to be wrong (or right), traces back through
|
|
236
|
+
description: "Find when a belief's confidence diverged from reality. Like `git bisect` \u2014 binary search through the credence history to find the inflection point. Given a belief that is now known to be wrong (or right), traces back through SL scoring events to identify which evidence or event caused the divergence.",
|
|
237
237
|
parameters: {
|
|
238
238
|
nodeId: { type: "string", description: "The belief to bisect" },
|
|
239
239
|
expectedDirection: {
|
|
@@ -252,7 +252,7 @@ var BISECT_CONFIDENCE = {
|
|
|
252
252
|
fields: {
|
|
253
253
|
beliefId: "string \u2014 canonical belief ID",
|
|
254
254
|
expectedDirection: "string \u2014 overconfident | underconfident",
|
|
255
|
-
inflectionEntry: "object \u2014 the
|
|
255
|
+
inflectionEntry: "object \u2014 the scoring event where divergence began",
|
|
256
256
|
triggerEvent: "string | null \u2014 what caused the divergence",
|
|
257
257
|
confidenceBefore: "number | null",
|
|
258
258
|
confidenceAfter: "number | null",
|
|
@@ -546,18 +546,18 @@ var SEARCH_EVIDENCE = {
|
|
|
546
546
|
};
|
|
547
547
|
var CREATE_EVIDENCE = {
|
|
548
548
|
name: "create_evidence",
|
|
549
|
-
description: "Commit evidence to the reasoning graph. Like `git commit` \u2014 creates a traceable evidence record with canonical public IDs.
|
|
549
|
+
description: "Commit evidence to the reasoning graph. Like `git commit` \u2014 creates a traceable evidence record with canonical public IDs. Evidence creation must link to at least one belief and must include a signed impact score. Positive scores support the belief; negative scores contradict it. SL confidence is derived from these weighted evidence relations.",
|
|
550
550
|
parameters: {
|
|
551
551
|
topicId: { type: "string", description: "Topic scope" },
|
|
552
552
|
text: { type: "string", description: "Canonical evidence text" },
|
|
553
553
|
source: { type: "string", description: "Source URL or source label" },
|
|
554
554
|
targetId: {
|
|
555
555
|
type: "string",
|
|
556
|
-
description: "
|
|
556
|
+
description: "Belief identifier to link immediately"
|
|
557
557
|
},
|
|
558
558
|
weight: {
|
|
559
559
|
type: "number",
|
|
560
|
-
description: "
|
|
560
|
+
description: "Required nonzero signed impact score: -1.0 (contradicts) to +1.0 (supports)."
|
|
561
561
|
},
|
|
562
562
|
evidenceRelation: {
|
|
563
563
|
type: "string",
|
|
@@ -566,7 +566,7 @@ var CREATE_EVIDENCE = {
|
|
|
566
566
|
},
|
|
567
567
|
confidence: {
|
|
568
568
|
type: "number",
|
|
569
|
-
description: "
|
|
569
|
+
description: "Deprecated hint. Runtime confidence is derived from the signed impact score."
|
|
570
570
|
},
|
|
571
571
|
beliefRelations: {
|
|
572
572
|
type: "array",
|
|
@@ -588,7 +588,7 @@ var CREATE_EVIDENCE = {
|
|
|
588
588
|
},
|
|
589
589
|
kind: { type: "string", description: "Optional evidence kind" }
|
|
590
590
|
},
|
|
591
|
-
required: ["text", "rationale"],
|
|
591
|
+
required: ["text", "rationale", "weight"],
|
|
592
592
|
response: {
|
|
593
593
|
description: "The created canonical evidence record",
|
|
594
594
|
fields: {
|
|
@@ -663,7 +663,7 @@ var LINK_EVIDENCE = {
|
|
|
663
663
|
},
|
|
664
664
|
rationale: { type: "string", description: "Why this link exists" }
|
|
665
665
|
},
|
|
666
|
-
required: ["evidenceId", "targetId"],
|
|
666
|
+
required: ["evidenceId", "targetId", "weight"],
|
|
667
667
|
response: {
|
|
668
668
|
description: "The created canonical evidence edge summary",
|
|
669
669
|
fields: {
|
|
@@ -699,7 +699,7 @@ var LINK_EVIDENCE_TO_BELIEF = {
|
|
|
699
699
|
},
|
|
700
700
|
rationale: { type: "string", description: "Why this evidence is relevant" }
|
|
701
701
|
},
|
|
702
|
-
required: ["evidenceId", "beliefId"],
|
|
702
|
+
required: ["evidenceId", "beliefId", "weight"],
|
|
703
703
|
response: {
|
|
704
704
|
description: "The created edge linking evidence to belief",
|
|
705
705
|
fields: {
|
|
@@ -717,15 +717,23 @@ var LINK_EVIDENCE_TO_BELIEF = {
|
|
|
717
717
|
// ../contracts/src/tool-contracts.lifecycle.ts
|
|
718
718
|
var CREATE_BELIEF = {
|
|
719
719
|
name: "create_belief",
|
|
720
|
-
description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object with a prior. Creation stores the vacuous opinion `(0, 0, 1, a)`; attach supporting or contradicting evidence with create_evidence or link_evidence_to_belief to record evidential updates.",
|
|
720
|
+
description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object with a prior. Creation requires a topic epistemic-node anchor and writes a `scoped_by` edge directly from belief node to topic node; orphan beliefs are invalid. Creation stores the vacuous opinion `(0, 0, 1, a)`; attach supporting or contradicting evidence with create_evidence or link_evidence_to_belief to record evidential updates.",
|
|
721
721
|
parameters: {
|
|
722
722
|
canonicalText: {
|
|
723
723
|
type: "string",
|
|
724
724
|
description: "The belief statement \u2014 what the agent holds to be true"
|
|
725
725
|
},
|
|
726
|
+
topicGlobalId: {
|
|
727
|
+
type: "string",
|
|
728
|
+
description: "Required globalId (UUID) of the topic node in epistemicNodes that anchors the belief"
|
|
729
|
+
},
|
|
730
|
+
topicNodeId: {
|
|
731
|
+
type: "string",
|
|
732
|
+
description: "Optional internal epistemicNodes _id for the topic anchor. Prefer topicGlobalId for public callers."
|
|
733
|
+
},
|
|
726
734
|
topicId: {
|
|
727
735
|
type: "string",
|
|
728
|
-
description: "
|
|
736
|
+
description: "Deprecated compatibility alias for topicGlobalId. Must identify a topic epistemicNode, not a legacy topics-table row."
|
|
729
737
|
},
|
|
730
738
|
baseRate: {
|
|
731
739
|
type: "number",
|
|
@@ -740,7 +748,7 @@ var CREATE_BELIEF = {
|
|
|
740
748
|
description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
|
|
741
749
|
}
|
|
742
750
|
},
|
|
743
|
-
required: ["canonicalText"],
|
|
751
|
+
required: ["canonicalText", "topicGlobalId"],
|
|
744
752
|
response: {
|
|
745
753
|
description: "The created canonical belief record",
|
|
746
754
|
fields: {
|
|
@@ -749,7 +757,7 @@ var CREATE_BELIEF = {
|
|
|
749
757
|
beliefId: "string \u2014 canonical belief ID",
|
|
750
758
|
text: "string \u2014 canonical belief formulation",
|
|
751
759
|
topicId: "string",
|
|
752
|
-
|
|
760
|
+
beliefStatus: "string \u2014 assumption | hypothesis | active | superseded | resolved_true | resolved_false",
|
|
753
761
|
scoringState: "string \u2014 unscored | scored"
|
|
754
762
|
}
|
|
755
763
|
},
|
|
@@ -772,7 +780,7 @@ var GET_BELIEF = {
|
|
|
772
780
|
beliefId: "string \u2014 canonical belief ID",
|
|
773
781
|
text: "string \u2014 canonical belief formulation",
|
|
774
782
|
topicId: "string",
|
|
775
|
-
|
|
783
|
+
beliefStatus: "string \u2014 assumption | hypothesis | active | superseded | resolved_true | resolved_false",
|
|
776
784
|
scoringState: "string \u2014 unscored | scored"
|
|
777
785
|
}
|
|
778
786
|
},
|
|
@@ -801,34 +809,24 @@ var REFINE_BELIEF = {
|
|
|
801
809
|
ontologyPrimitive: "belief",
|
|
802
810
|
tier: "showcase"
|
|
803
811
|
};
|
|
804
|
-
var
|
|
805
|
-
name: "
|
|
806
|
-
description: "Internal
|
|
812
|
+
var APPEND_SL_SCORING = {
|
|
813
|
+
name: "append_sl_scoring",
|
|
814
|
+
description: "Internal evidence-backed Subjective Logic scoring append. This is not a public MCP tool: callers should attach supporting or contradicting evidence, and governed system paths append the derived SL tuple.",
|
|
807
815
|
parameters: {
|
|
808
|
-
nodeId: { type: "string", description: "The belief
|
|
809
|
-
belief: {
|
|
810
|
-
type: "number",
|
|
811
|
-
description: "Subjective-logic belief mass `b` in [0, 1]"
|
|
812
|
-
},
|
|
816
|
+
nodeId: { type: "string", description: "The belief receiving the SL score" },
|
|
817
|
+
belief: { type: "number", description: "Subjective Logic belief mass b" },
|
|
813
818
|
disbelief: {
|
|
814
819
|
type: "number",
|
|
815
|
-
description: "Subjective
|
|
820
|
+
description: "Subjective Logic disbelief mass d"
|
|
816
821
|
},
|
|
817
822
|
uncertainty: {
|
|
818
823
|
type: "number",
|
|
819
|
-
description: "Subjective
|
|
820
|
-
},
|
|
821
|
-
baseRate: {
|
|
822
|
-
type: "number",
|
|
823
|
-
description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
|
|
824
|
-
},
|
|
825
|
-
worktreeId: {
|
|
826
|
-
type: "string",
|
|
827
|
-
description: "Completed worktree that tested this belief when confidence policy requires merge-backed scoring."
|
|
824
|
+
description: "Subjective Logic uncertainty mass u"
|
|
828
825
|
},
|
|
826
|
+
baseRate: { type: "number", description: "Subjective Logic base rate a" },
|
|
829
827
|
trigger: {
|
|
830
828
|
type: "string",
|
|
831
|
-
description: "
|
|
829
|
+
description: "Evidence-bearing cause of the scoring event",
|
|
832
830
|
enum: [
|
|
833
831
|
"evidence_added",
|
|
834
832
|
"evidence_removed",
|
|
@@ -839,64 +837,39 @@ var MODULATE_CONFIDENCE = {
|
|
|
839
837
|
"worktree_completed",
|
|
840
838
|
"fusion",
|
|
841
839
|
"discount",
|
|
842
|
-
"deduction"
|
|
840
|
+
"deduction",
|
|
841
|
+
"backfill_synthetic"
|
|
843
842
|
]
|
|
844
843
|
},
|
|
845
|
-
|
|
846
|
-
type: "
|
|
847
|
-
description: "
|
|
848
|
-
},
|
|
849
|
-
triggeringQuestionId: {
|
|
850
|
-
type: "string",
|
|
851
|
-
description: "Answered question whose resolution supports this modulation"
|
|
852
|
-
},
|
|
853
|
-
triggeringAnswerId: {
|
|
854
|
-
type: "string",
|
|
855
|
-
description: "Answer node whose content supports this modulation"
|
|
856
|
-
},
|
|
857
|
-
triggeringContradictionId: {
|
|
858
|
-
type: "string",
|
|
859
|
-
description: "Contradiction record that caused a contradiction-triggered modulation"
|
|
860
|
-
},
|
|
861
|
-
triggeringWorktreeId: {
|
|
862
|
-
type: "string",
|
|
863
|
-
description: "Completed worktree whose outcome caused a worktree-triggered modulation"
|
|
844
|
+
provenance: {
|
|
845
|
+
type: "object",
|
|
846
|
+
description: "At least one of evidence, question, answer, contradiction, or worktree."
|
|
864
847
|
},
|
|
865
848
|
rationale: {
|
|
866
849
|
type: "string",
|
|
867
|
-
description: "
|
|
850
|
+
description: "Why this evidence-bearing event moved the SL tuple"
|
|
868
851
|
}
|
|
869
852
|
},
|
|
870
|
-
required: [
|
|
871
|
-
"nodeId",
|
|
872
|
-
"belief",
|
|
873
|
-
"disbelief",
|
|
874
|
-
"uncertainty",
|
|
875
|
-
"baseRate",
|
|
876
|
-
"trigger",
|
|
877
|
-
"rationale"
|
|
878
|
-
],
|
|
853
|
+
required: ["nodeId", "belief", "disbelief", "uncertainty", "baseRate", "trigger", "rationale"],
|
|
879
854
|
response: {
|
|
880
|
-
description: "
|
|
855
|
+
description: "Internal SL scoring append receipt",
|
|
881
856
|
fields: {
|
|
882
|
-
|
|
883
|
-
nodeId: "string \u2014 canonical belief ID",
|
|
884
|
-
newConfidence: "number",
|
|
857
|
+
nodeId: "string",
|
|
885
858
|
previousConfidence: "number",
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
propagationSummary: "object \u2014 bounded inline cascade summary with totalCandidateTargets, inlineTargets, and remainingTargetCount"
|
|
859
|
+
newConfidence: "number",
|
|
860
|
+
beliefConfidenceId: "string"
|
|
889
861
|
}
|
|
890
862
|
},
|
|
891
863
|
ownerModule: "graph-primitives",
|
|
892
864
|
ontologyPrimitive: "belief",
|
|
893
|
-
tier: "
|
|
865
|
+
tier: "workhorse",
|
|
866
|
+
internal: true
|
|
894
867
|
};
|
|
895
868
|
var FORK_BELIEF = {
|
|
896
869
|
name: "fork_belief",
|
|
897
|
-
description: "Branch off
|
|
870
|
+
description: "Branch off an evidence-bearing belief to create a new formulation. Like `git fork` \u2014 the parent remains immutable with full history, and every fork must cite evidence already attached to the parent through SL scoring. `forkMode=supersede` marks the parent superseded and requires contradicting evidence; `forkMode=branch` preserves the parent and creates a derived child.",
|
|
898
871
|
parameters: {
|
|
899
|
-
nodeId: { type: "string", description: "The
|
|
872
|
+
nodeId: { type: "string", description: "The belief to fork from" },
|
|
900
873
|
newFormulation: {
|
|
901
874
|
type: "string",
|
|
902
875
|
description: "The evolved belief statement"
|
|
@@ -908,12 +881,20 @@ var FORK_BELIEF = {
|
|
|
908
881
|
"refinement",
|
|
909
882
|
"contradiction_response",
|
|
910
883
|
"scope_change",
|
|
911
|
-
"confidence_collapse"
|
|
912
|
-
"manual"
|
|
884
|
+
"confidence_collapse"
|
|
913
885
|
]
|
|
886
|
+
},
|
|
887
|
+
forkMode: {
|
|
888
|
+
type: "string",
|
|
889
|
+
description: "supersede replaces the parent; branch creates a child while preserving the parent.",
|
|
890
|
+
enum: ["supersede", "branch"]
|
|
891
|
+
},
|
|
892
|
+
triggeringEvidenceId: {
|
|
893
|
+
type: "string",
|
|
894
|
+
description: "Evidence already attached to the parent belief that caused the fork."
|
|
914
895
|
}
|
|
915
896
|
},
|
|
916
|
-
required: ["nodeId", "newFormulation", "forkReason"],
|
|
897
|
+
required: ["nodeId", "newFormulation", "forkReason", "triggeringEvidenceId"],
|
|
917
898
|
response: {
|
|
918
899
|
description: "The forked canonical belief record",
|
|
919
900
|
fields: {
|
|
@@ -2178,7 +2159,7 @@ var TRIGGER_BELIEF_REVIEW = {
|
|
|
2178
2159
|
};
|
|
2179
2160
|
var EVALUATE_CONTRACT = {
|
|
2180
2161
|
name: "evaluate_contract",
|
|
2181
|
-
description: "Run a contract evaluation and record the append-only result. Like `git test` for a belief binding \u2014 executes the evaluator, logs the result, and applies any allowed
|
|
2162
|
+
description: "Run a contract evaluation and record the append-only result. Like `git test` for a belief binding \u2014 executes the evaluator, logs the result, and applies any allowed SL scoring action.",
|
|
2182
2163
|
parameters: {
|
|
2183
2164
|
contractId: { type: "string", description: "Which contract to evaluate" },
|
|
2184
2165
|
trigger: {
|
|
@@ -4052,6 +4033,10 @@ var COMPILE_CONTEXT = {
|
|
|
4052
4033
|
type: "number",
|
|
4053
4034
|
description: "Optional per-section item limit"
|
|
4054
4035
|
},
|
|
4036
|
+
contentTopicLimit: {
|
|
4037
|
+
type: "number",
|
|
4038
|
+
description: "Dimension-seeded compiles synthesize every matching worktree but bound raw belief/question/evidence enrichment to this many carrier topics (max 16) so hosted Convex queries remain fast. Receipts report any omitted raw topic enrichment."
|
|
4039
|
+
},
|
|
4055
4040
|
maxDepth: {
|
|
4056
4041
|
type: "number",
|
|
4057
4042
|
description: "Optional descendant topic depth for neighborhood expansion"
|
|
@@ -4065,6 +4050,11 @@ var COMPILE_CONTEXT = {
|
|
|
4065
4050
|
response: {
|
|
4066
4051
|
description: "Compiled context pack for the requested topic",
|
|
4067
4052
|
fields: {
|
|
4053
|
+
contextNarrative: "array \u2014 first field; ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
|
|
4054
|
+
narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, topicsSynthesized, topicsEnriched, topicContentOmitted, enrichmentMode, and blocksEmitted for the narrative",
|
|
4055
|
+
synthesisLints: "array \u2014 inline quality warnings for degenerate synthesis blocks or weak narrative coverage",
|
|
4056
|
+
retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
|
|
4057
|
+
supportingObjects: "object \u2014 raw graph records grouped behind the synthesis: invariants, activeBeliefs, openQuestions, recentEvidence, worktrees, lanes, entities, and contradictions",
|
|
4068
4058
|
schemaVersion: "string",
|
|
4069
4059
|
topicId: "string",
|
|
4070
4060
|
topicName: "string",
|
|
@@ -4072,15 +4062,6 @@ var COMPILE_CONTEXT = {
|
|
|
4072
4062
|
generatedAt: "number \u2014 deterministic graph-backed reference timestamp for this compilation",
|
|
4073
4063
|
ranking: "string \u2014 baseline_v1 | weighted_v1",
|
|
4074
4064
|
summary: "object \u2014 counts and scoped health signals",
|
|
4075
|
-
invariants: "array \u2014 high-confidence invariant beliefs",
|
|
4076
|
-
activeBeliefs: "array \u2014 current high-signal beliefs",
|
|
4077
|
-
openQuestions: "array \u2014 unresolved questions ranked for this query",
|
|
4078
|
-
recentEvidence: "array \u2014 recent evidence ranked for this query",
|
|
4079
|
-
contradictions: "array \u2014 unresolved contradiction records",
|
|
4080
|
-
relatedEntities: "array | undefined \u2014 ranked ontological entities in scope",
|
|
4081
|
-
contextNarrative: "array \u2014 ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
|
|
4082
|
-
retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
|
|
4083
|
-
narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, and blocksEmitted for the narrative",
|
|
4084
4065
|
injectionPolicy: "object \u2014 token-budgeted section selections",
|
|
4085
4066
|
diagnostics: "object \u2014 scoring and utilization telemetry"
|
|
4086
4067
|
}
|
|
@@ -4639,7 +4620,7 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
4639
4620
|
create_belief: CREATE_BELIEF,
|
|
4640
4621
|
get_belief: GET_BELIEF,
|
|
4641
4622
|
refine_belief: REFINE_BELIEF,
|
|
4642
|
-
|
|
4623
|
+
append_sl_scoring: APPEND_SL_SCORING,
|
|
4643
4624
|
fork_belief: FORK_BELIEF,
|
|
4644
4625
|
archive_belief: ARCHIVE_BELIEF,
|
|
4645
4626
|
create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
|
|
@@ -6437,8 +6418,10 @@ defineTable({
|
|
|
6437
6418
|
"beliefStatus": z.object({
|
|
6438
6419
|
"assumption": z.number(),
|
|
6439
6420
|
"hypothesis": z.number(),
|
|
6440
|
-
"
|
|
6441
|
-
"
|
|
6421
|
+
"active": z.number(),
|
|
6422
|
+
"superseded": z.number(),
|
|
6423
|
+
"resolved_true": z.number(),
|
|
6424
|
+
"resolved_false": z.number()
|
|
6442
6425
|
}).optional(),
|
|
6443
6426
|
"evidenceTemporalNature": z.object({
|
|
6444
6427
|
"factual": z.number(),
|
|
@@ -6660,8 +6643,8 @@ defineTable({
|
|
|
6660
6643
|
"exportClass": z.enum(["internal_only", "client_safe", "public_safe", "restricted"]).optional(),
|
|
6661
6644
|
"anonymizationClass": z.enum(["none", "standard", "strict"]).optional(),
|
|
6662
6645
|
"beliefType": z.string().optional(),
|
|
6663
|
-
"beliefStatus": z.enum(["assumption", "hypothesis", "
|
|
6664
|
-
"epistemicStatus": z.enum(["
|
|
6646
|
+
"beliefStatus": z.enum(["assumption", "hypothesis", "active", "superseded", "resolved_true", "resolved_false"]).optional(),
|
|
6647
|
+
"epistemicStatus": z.enum(["assumption", "hypothesis", "active", "superseded", "resolved_true", "resolved_false"]).optional(),
|
|
6665
6648
|
"reversibility": z.enum(["irreversible", "hard_to_reverse", "reversible", "trivial"]).optional(),
|
|
6666
6649
|
"predictionMeta": z.object({
|
|
6667
6650
|
"isPrediction": z.boolean(),
|
|
@@ -11627,11 +11610,39 @@ var createEvidenceInputSchemaBase = z.object({
|
|
|
11627
11610
|
metadata: jsonRecordSchema.optional(),
|
|
11628
11611
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
11629
11612
|
}).passthrough();
|
|
11630
|
-
function
|
|
11631
|
-
return typeof value === "number" && Number.isFinite(value) && value !== 0;
|
|
11613
|
+
function isSignedImpactScore(value) {
|
|
11614
|
+
return typeof value === "number" && Number.isFinite(value) && value >= -1 && value <= 1 && value !== 0;
|
|
11632
11615
|
}
|
|
11633
|
-
function
|
|
11634
|
-
|
|
11616
|
+
function validateSignedImpactScore(value, ctx, path) {
|
|
11617
|
+
if (!isSignedImpactScore(value)) {
|
|
11618
|
+
ctx.addIssue({
|
|
11619
|
+
code: z.ZodIssueCode.custom,
|
|
11620
|
+
message: "evidence-to-belief links require an explicit nonzero signed impact score in [-1, 1]",
|
|
11621
|
+
path
|
|
11622
|
+
});
|
|
11623
|
+
return false;
|
|
11624
|
+
}
|
|
11625
|
+
return true;
|
|
11626
|
+
}
|
|
11627
|
+
function validateRelationImpactConsistency(relation, weight, ctx, path) {
|
|
11628
|
+
const normalized = normalizeRelationAlias(relation);
|
|
11629
|
+
if (!normalized || !isSignedImpactScore(weight)) {
|
|
11630
|
+
return;
|
|
11631
|
+
}
|
|
11632
|
+
if (normalized === "supports" && weight < 0) {
|
|
11633
|
+
ctx.addIssue({
|
|
11634
|
+
code: z.ZodIssueCode.custom,
|
|
11635
|
+
message: "supporting evidence requires a positive impact score",
|
|
11636
|
+
path
|
|
11637
|
+
});
|
|
11638
|
+
}
|
|
11639
|
+
if (normalized === "contradicts" && weight > 0) {
|
|
11640
|
+
ctx.addIssue({
|
|
11641
|
+
code: z.ZodIssueCode.custom,
|
|
11642
|
+
message: "contradicting evidence requires a negative impact score",
|
|
11643
|
+
path
|
|
11644
|
+
});
|
|
11645
|
+
}
|
|
11635
11646
|
}
|
|
11636
11647
|
var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
11637
11648
|
(input, ctx) => {
|
|
@@ -11648,13 +11659,27 @@ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
|
11648
11659
|
input.linkedBeliefNodeId || kind === "belief" || kind === "unknown" && target
|
|
11649
11660
|
);
|
|
11650
11661
|
const weight = typeof input.weight === "number" ? input.weight : void 0;
|
|
11651
|
-
|
|
11662
|
+
const hasBeliefRelations = (input.beliefRelations?.length ?? 0) > 0;
|
|
11663
|
+
if (!linksPrimaryBelief && !hasBeliefRelations) {
|
|
11664
|
+
ctx.addIssue({
|
|
11665
|
+
code: z.ZodIssueCode.custom,
|
|
11666
|
+
message: "create_evidence requires at least one linked belief; evidence cannot be created as an orphan or linked only to a question/worktree",
|
|
11667
|
+
path: ["linkedBeliefNodeId"]
|
|
11668
|
+
});
|
|
11669
|
+
}
|
|
11670
|
+
if (kind === "question" || kind === "worktree") {
|
|
11652
11671
|
ctx.addIssue({
|
|
11653
11672
|
code: z.ZodIssueCode.custom,
|
|
11654
|
-
message: "belief
|
|
11655
|
-
path: ["
|
|
11673
|
+
message: "create_evidence targetId must be a belief. Link evidence to questions/worktrees only after the evidence has a belief impact edge.",
|
|
11674
|
+
path: ["targetId"]
|
|
11656
11675
|
});
|
|
11657
11676
|
}
|
|
11677
|
+
if (linksPrimaryBelief) {
|
|
11678
|
+
validateSignedImpactScore(weight, ctx, ["weight"]);
|
|
11679
|
+
validateRelationImpactConsistency(input.evidenceRelation, weight, ctx, [
|
|
11680
|
+
"weight"
|
|
11681
|
+
]);
|
|
11682
|
+
}
|
|
11658
11683
|
input.beliefRelations?.forEach((relation, index) => {
|
|
11659
11684
|
const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
|
|
11660
11685
|
if (!beliefNodeId) {
|
|
@@ -11665,15 +11690,18 @@ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
|
11665
11690
|
});
|
|
11666
11691
|
}
|
|
11667
11692
|
const relationWeight2 = typeof relation.weight === "number" ? relation.weight : void 0;
|
|
11668
|
-
if (beliefNodeId
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11693
|
+
if (beliefNodeId) {
|
|
11694
|
+
validateSignedImpactScore(relationWeight2, ctx, [
|
|
11695
|
+
"beliefRelations",
|
|
11696
|
+
index,
|
|
11697
|
+
"weight"
|
|
11698
|
+
]);
|
|
11699
|
+
validateRelationImpactConsistency(
|
|
11700
|
+
relation.evidenceRelation ?? relation.relation,
|
|
11701
|
+
relationWeight2,
|
|
11702
|
+
ctx,
|
|
11703
|
+
["beliefRelations", index, "weight"]
|
|
11704
|
+
);
|
|
11677
11705
|
}
|
|
11678
11706
|
});
|
|
11679
11707
|
}
|
|
@@ -11727,18 +11755,28 @@ function targetKind(targetId) {
|
|
|
11727
11755
|
}
|
|
11728
11756
|
return "unknown";
|
|
11729
11757
|
}
|
|
11730
|
-
function
|
|
11758
|
+
function normalizeRelationAlias(value) {
|
|
11731
11759
|
if (value === "supports" || value === "supporting") {
|
|
11732
11760
|
return "supports";
|
|
11733
11761
|
}
|
|
11734
11762
|
if (value === "contradicts" || value === "contradicting") {
|
|
11735
11763
|
return "contradicts";
|
|
11736
11764
|
}
|
|
11765
|
+
return void 0;
|
|
11766
|
+
}
|
|
11767
|
+
function normalizeRelation(value, weight) {
|
|
11768
|
+
const alias = normalizeRelationAlias(value);
|
|
11769
|
+
if (alias) {
|
|
11770
|
+
return alias;
|
|
11771
|
+
}
|
|
11737
11772
|
if (weight === void 0 || !hasNonzeroWeight(weight)) {
|
|
11738
11773
|
return void 0;
|
|
11739
11774
|
}
|
|
11740
11775
|
return weight < 0 ? "contradicts" : "supports";
|
|
11741
11776
|
}
|
|
11777
|
+
function hasNonzeroWeight(value) {
|
|
11778
|
+
return typeof value === "number" && Number.isFinite(value) && value !== 0;
|
|
11779
|
+
}
|
|
11742
11780
|
function normalizeConfidence(confidence, weight) {
|
|
11743
11781
|
if (confidence !== void 0) {
|
|
11744
11782
|
return Math.min(1, Math.max(0, confidence));
|
|
@@ -11765,6 +11803,7 @@ function normalizeBeliefRelation(relation) {
|
|
|
11765
11803
|
beliefNodeId,
|
|
11766
11804
|
relation: evidenceRelation,
|
|
11767
11805
|
confidence: normalizeConfidence(relation.confidence, weight),
|
|
11806
|
+
weight,
|
|
11768
11807
|
rationale: relation.rationale
|
|
11769
11808
|
});
|
|
11770
11809
|
}
|
|
@@ -11813,6 +11852,7 @@ var createEvidenceProjection = defineProjection({
|
|
|
11813
11852
|
linkedBeliefNodeId,
|
|
11814
11853
|
evidenceRelation,
|
|
11815
11854
|
confidence,
|
|
11855
|
+
weight,
|
|
11816
11856
|
beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
|
|
11817
11857
|
rationale: input.rationale,
|
|
11818
11858
|
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
@@ -11842,12 +11882,14 @@ var createEvidenceProjection = defineProjection({
|
|
|
11842
11882
|
v.literal("contradicts")
|
|
11843
11883
|
)
|
|
11844
11884
|
),
|
|
11885
|
+
weight: v.optional(v.number()),
|
|
11845
11886
|
beliefRelations: v.optional(
|
|
11846
11887
|
v.array(
|
|
11847
11888
|
v.object({
|
|
11848
11889
|
beliefNodeId: v.string(),
|
|
11849
11890
|
relation: v.union(v.literal("supports"), v.literal("contradicts")),
|
|
11850
11891
|
confidence: v.optional(v.number()),
|
|
11892
|
+
weight: v.number(),
|
|
11851
11893
|
rationale: v.optional(v.string())
|
|
11852
11894
|
})
|
|
11853
11895
|
)
|
|
@@ -11965,7 +12007,7 @@ var slOpinionProjectionSchema = z.object({
|
|
|
11965
12007
|
uncertainty: z.number(),
|
|
11966
12008
|
baseRate: z.number()
|
|
11967
12009
|
});
|
|
11968
|
-
var
|
|
12010
|
+
var appendSlScoringInputObjectSchema = z.object({
|
|
11969
12011
|
nodeId: z.string().optional(),
|
|
11970
12012
|
beliefNodeId: z.string().optional(),
|
|
11971
12013
|
worktreeId: z.string().optional(),
|
|
@@ -11984,23 +12026,23 @@ var modulateConfidenceInputObjectSchema = z.object({
|
|
|
11984
12026
|
rationale: z.string(),
|
|
11985
12027
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
11986
12028
|
});
|
|
11987
|
-
var
|
|
12029
|
+
var appendSlScoringInputSchema = appendSlScoringInputObjectSchema.superRefine((input, ctx) => {
|
|
11988
12030
|
if (hasProvenance(input)) {
|
|
11989
12031
|
return;
|
|
11990
12032
|
}
|
|
11991
12033
|
ctx.addIssue({
|
|
11992
12034
|
code: z.ZodIssueCode.custom,
|
|
11993
|
-
message: "
|
|
12035
|
+
message: "append_sl_scoring requires evidence, question, answer, contradiction, or worktree provenance",
|
|
11994
12036
|
path: ["provenance"]
|
|
11995
12037
|
});
|
|
11996
12038
|
});
|
|
11997
|
-
var
|
|
11998
|
-
contractName: "
|
|
11999
|
-
inputSchema:
|
|
12039
|
+
var appendSlScoringProjection = defineProjection({
|
|
12040
|
+
contractName: "append_sl_scoring",
|
|
12041
|
+
inputSchema: appendSlScoringInputSchema,
|
|
12000
12042
|
project: (input) => {
|
|
12001
12043
|
const nodeId = input.beliefNodeId ?? input.nodeId;
|
|
12002
12044
|
if (!nodeId) {
|
|
12003
|
-
throw new Error("
|
|
12045
|
+
throw new Error("append_sl_scoring requires beliefNodeId or nodeId");
|
|
12004
12046
|
}
|
|
12005
12047
|
const opinion = input.opinion ?? {
|
|
12006
12048
|
belief: requireNumber(input.belief, "belief"),
|
|
@@ -12057,14 +12099,14 @@ var modulateConfidenceProjection = defineProjection({
|
|
|
12057
12099
|
});
|
|
12058
12100
|
function requireNumber(value, field) {
|
|
12059
12101
|
if (value === void 0) {
|
|
12060
|
-
throw new Error(`
|
|
12102
|
+
throw new Error(`append_sl_scoring requires ${field}`);
|
|
12061
12103
|
}
|
|
12062
12104
|
return value;
|
|
12063
12105
|
}
|
|
12064
12106
|
function assertProvenance(input) {
|
|
12065
12107
|
if (!hasProvenance(input)) {
|
|
12066
12108
|
throw new Error(
|
|
12067
|
-
"
|
|
12109
|
+
"append_sl_scoring requires evidence, question, answer, contradiction, or worktree provenance"
|
|
12068
12110
|
);
|
|
12069
12111
|
}
|
|
12070
12112
|
}
|
|
@@ -12407,12 +12449,12 @@ var LUCERN_OPERATION_MANIFEST = {
|
|
|
12407
12449
|
internalSystem,
|
|
12408
12450
|
"Lucern system/background operation. Available to platform code paths, hidden from public MCP discovery."
|
|
12409
12451
|
),
|
|
12410
|
-
|
|
12411
|
-
name: "
|
|
12452
|
+
append_sl_scoring: {
|
|
12453
|
+
name: "append_sl_scoring",
|
|
12412
12454
|
surfaceClass: "platform_internal",
|
|
12413
12455
|
surfaceIntent: "system",
|
|
12414
12456
|
surfaces: internalSdkRestOnly,
|
|
12415
|
-
rationale: "Internal SL
|
|
12457
|
+
rationale: "Internal SL scoring append primitive. Public callers attach evidence or contradiction relations; confidence is derived algorithmically."
|
|
12416
12458
|
},
|
|
12417
12459
|
...entries(
|
|
12418
12460
|
LEGACY_COMPAT_OPERATION_NAMES,
|
|
@@ -12966,7 +13008,15 @@ var predictionMetaSchema = z.object({
|
|
|
12966
13008
|
});
|
|
12967
13009
|
var createBeliefArgs = z.object({
|
|
12968
13010
|
canonicalText: z.string().describe("The belief statement the agent holds to be true."),
|
|
12969
|
-
|
|
13011
|
+
topicGlobalId: z.string().describe(
|
|
13012
|
+
"Required globalId of the topic epistemicNode that anchors this belief. Belief creation creates a scoped_by edge directly to that topic node."
|
|
13013
|
+
),
|
|
13014
|
+
topicNodeId: z.string().optional().describe(
|
|
13015
|
+
"Optional internal epistemicNodes _id for the topic anchor. Prefer topicGlobalId for public callers."
|
|
13016
|
+
),
|
|
13017
|
+
topicId: z.string().optional().describe(
|
|
13018
|
+
"Deprecated compatibility alias for topicGlobalId. Must identify a topic epistemicNode, not a legacy topics-table row."
|
|
13019
|
+
),
|
|
12970
13020
|
baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
|
|
12971
13021
|
beliefType: z.string().optional().describe("Schema belief type."),
|
|
12972
13022
|
metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
|
|
@@ -12985,9 +13035,14 @@ var forkBeliefArgs = z.object({
|
|
|
12985
13035
|
"refinement",
|
|
12986
13036
|
"contradiction_response",
|
|
12987
13037
|
"scope_change",
|
|
12988
|
-
"confidence_collapse"
|
|
12989
|
-
"manual"
|
|
13038
|
+
"confidence_collapse"
|
|
12990
13039
|
]).describe("Why this fork was created."),
|
|
13040
|
+
forkMode: z.enum(["supersede", "branch"]).optional().describe(
|
|
13041
|
+
"supersede marks the parent belief superseded; branch preserves the parent and creates a derived child."
|
|
13042
|
+
),
|
|
13043
|
+
triggeringEvidenceId: z.string().describe(
|
|
13044
|
+
"Evidence already attached to the parent belief through SL scoring; required for every fork."
|
|
13045
|
+
),
|
|
12991
13046
|
rationale: z.string().optional().describe("Why the fork is warranted.")
|
|
12992
13047
|
});
|
|
12993
13048
|
var beliefLookupInput = (input) => compactRecord4({
|
|
@@ -13001,7 +13056,9 @@ var createBeliefInput = (input, context) => {
|
|
|
13001
13056
|
return withUserId(
|
|
13002
13057
|
compactRecord4({
|
|
13003
13058
|
projectId: input.projectId,
|
|
13004
|
-
topicId: input.topicId,
|
|
13059
|
+
topicId: input.topicGlobalId ?? input.topicNodeId ?? input.topicId,
|
|
13060
|
+
topicGlobalId: input.topicGlobalId,
|
|
13061
|
+
topicNodeId: input.topicNodeId,
|
|
13005
13062
|
formulation: input.formulation ?? input.canonicalText,
|
|
13006
13063
|
beliefType: input.beliefType,
|
|
13007
13064
|
rationale: input.rationale,
|
|
@@ -13023,20 +13080,22 @@ var forkBeliefInput = (input, context) => withUserId(
|
|
|
13023
13080
|
parentNodeId: input.parentNodeId ?? input.nodeId ?? input.id,
|
|
13024
13081
|
newFormulation: input.newFormulation,
|
|
13025
13082
|
forkReason: input.forkReason,
|
|
13083
|
+
forkMode: input.forkMode,
|
|
13084
|
+
triggeringEvidenceId: input.triggeringEvidenceId,
|
|
13026
13085
|
rationale: input.rationale,
|
|
13027
13086
|
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
13028
13087
|
}),
|
|
13029
13088
|
context
|
|
13030
13089
|
);
|
|
13031
|
-
var
|
|
13032
|
-
const parsed =
|
|
13090
|
+
var appendSlScoringInput = (input, context) => {
|
|
13091
|
+
const parsed = appendSlScoringProjection.inputSchema.safeParse(input);
|
|
13033
13092
|
if (!parsed.success) {
|
|
13034
13093
|
throw new Error(
|
|
13035
|
-
`
|
|
13094
|
+
`append_sl_scoring projection input rejected: ${parsed.error.message}`
|
|
13036
13095
|
);
|
|
13037
13096
|
}
|
|
13038
13097
|
return withUserId(
|
|
13039
|
-
compactRecord4(
|
|
13098
|
+
compactRecord4(appendSlScoringProjection.project(parsed.data)),
|
|
13040
13099
|
context
|
|
13041
13100
|
);
|
|
13042
13101
|
};
|
|
@@ -13114,21 +13173,21 @@ var beliefsContracts = [
|
|
|
13114
13173
|
}
|
|
13115
13174
|
}),
|
|
13116
13175
|
surfaceContract({
|
|
13117
|
-
name: "
|
|
13176
|
+
name: "append_sl_scoring",
|
|
13118
13177
|
kind: "mutation",
|
|
13119
13178
|
domain: "beliefs",
|
|
13120
13179
|
surfaceClass: "platform_internal",
|
|
13121
|
-
path: "/beliefs/
|
|
13180
|
+
path: "/beliefs/sl-scoring",
|
|
13122
13181
|
sdkNamespace: "beliefs",
|
|
13123
|
-
sdkMethod: "
|
|
13124
|
-
summary: "Internal SL
|
|
13182
|
+
sdkMethod: "appendSlScoring",
|
|
13183
|
+
summary: "Internal SL scoring append. Public callers attach evidence or contradiction relations instead.",
|
|
13125
13184
|
convex: {
|
|
13126
13185
|
module: "beliefs",
|
|
13127
|
-
functionName: "
|
|
13186
|
+
functionName: "appendSlScoring",
|
|
13128
13187
|
kind: "mutation",
|
|
13129
|
-
inputProjection:
|
|
13188
|
+
inputProjection: appendSlScoringInput
|
|
13130
13189
|
},
|
|
13131
|
-
args:
|
|
13190
|
+
args: appendSlScoringInputSchema
|
|
13132
13191
|
}),
|
|
13133
13192
|
surfaceContract({
|
|
13134
13193
|
name: "fork_belief",
|
|
@@ -13234,8 +13293,12 @@ var beliefRelationSchema2 = z.object({
|
|
|
13234
13293
|
targetId: z.string().optional().describe("Belief target ID alias for beliefId/beliefNodeId."),
|
|
13235
13294
|
relation: z.enum(["supports", "contradicts", "supporting", "contradicting"]).optional().describe("Relation alias for how the evidence bears on the belief."),
|
|
13236
13295
|
evidenceRelation: evidenceRelationSchema2.optional().describe("Canonical relation: supports or contradicts."),
|
|
13237
|
-
confidence: z.number().optional().describe(
|
|
13238
|
-
|
|
13296
|
+
confidence: z.number().optional().describe(
|
|
13297
|
+
"Deprecated read-only hint. Runtime SL confidence is derived from signed weight."
|
|
13298
|
+
),
|
|
13299
|
+
weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
|
|
13300
|
+
message: "Evidence impact weight must be nonzero."
|
|
13301
|
+
}).describe("Required signed impact score from -1.0 to +1.0 for this belief."),
|
|
13239
13302
|
rationale: z.string().optional().describe("Why this relation exists.")
|
|
13240
13303
|
});
|
|
13241
13304
|
var createEvidenceArgs = z.object({
|
|
@@ -13244,7 +13307,7 @@ var createEvidenceArgs = z.object({
|
|
|
13244
13307
|
source: z.string().optional().describe("Source URL or source label."),
|
|
13245
13308
|
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
13246
13309
|
targetId: z.string().optional().describe(
|
|
13247
|
-
"Belief
|
|
13310
|
+
"Belief identifier to link immediately. Evidence creation cannot target only a question or worktree."
|
|
13248
13311
|
),
|
|
13249
13312
|
linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
|
|
13250
13313
|
evidenceRelation: evidenceRelationSchema2.optional().describe(
|
|
@@ -13253,8 +13316,14 @@ var createEvidenceArgs = z.object({
|
|
|
13253
13316
|
beliefRelations: z.array(beliefRelationSchema2).optional().describe(
|
|
13254
13317
|
"Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
|
|
13255
13318
|
),
|
|
13256
|
-
confidence: z.number().optional().describe(
|
|
13257
|
-
|
|
13319
|
+
confidence: z.number().optional().describe(
|
|
13320
|
+
"Deprecated hint. Runtime confidence is derived from signed weight."
|
|
13321
|
+
),
|
|
13322
|
+
weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
|
|
13323
|
+
message: "Evidence impact weight must be nonzero."
|
|
13324
|
+
}).describe(
|
|
13325
|
+
"Required signed impact score from -1.0 to +1.0 for targetId/linkedBeliefNodeId."
|
|
13326
|
+
),
|
|
13258
13327
|
metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
|
|
13259
13328
|
rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
|
|
13260
13329
|
reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
|
|
@@ -13276,7 +13345,9 @@ var addEvidenceArgs = z.object({
|
|
|
13276
13345
|
topicId: z.string().optional().describe("Topic scope hint."),
|
|
13277
13346
|
sourceUrl: z.string().optional().describe("URL of the source material."),
|
|
13278
13347
|
targetNodeId: z.string().describe("The belief this evidence bears on."),
|
|
13279
|
-
weight: z.number().
|
|
13348
|
+
weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
|
|
13349
|
+
message: "Evidence impact weight must be nonzero."
|
|
13350
|
+
}).describe("Required signed impact score from -1.0 to +1.0."),
|
|
13280
13351
|
reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
|
|
13281
13352
|
title: z.string().optional().describe("Optional short title."),
|
|
13282
13353
|
content: z.string().optional().describe("Optional long-form evidence content."),
|
|
@@ -13296,19 +13367,21 @@ var createEvidenceInput = (input, context) => {
|
|
|
13296
13367
|
);
|
|
13297
13368
|
};
|
|
13298
13369
|
function relationWeight(input) {
|
|
13299
|
-
if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
|
|
13370
|
+
if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0 && input.weight >= -1 && input.weight <= 1) {
|
|
13371
|
+
const relation = String(
|
|
13372
|
+
input.evidenceRelation ?? input.relation ?? input.type ?? ""
|
|
13373
|
+
);
|
|
13374
|
+
if ((relation === "supports" || relation === "supporting") && input.weight < 0) {
|
|
13375
|
+
throw new Error("Supporting evidence links require positive weight.");
|
|
13376
|
+
}
|
|
13377
|
+
if ((relation === "contradicts" || relation === "contradicting") && input.weight > 0) {
|
|
13378
|
+
throw new Error("Contradicting evidence links require negative weight.");
|
|
13379
|
+
}
|
|
13300
13380
|
return input.weight;
|
|
13301
13381
|
}
|
|
13302
|
-
|
|
13303
|
-
|
|
13382
|
+
throw new Error(
|
|
13383
|
+
"Belief evidence links require explicit nonzero weight in [-1, 1]."
|
|
13304
13384
|
);
|
|
13305
|
-
if (relation !== "supports" && relation !== "supporting" && relation !== "contradicts" && relation !== "contradicting") {
|
|
13306
|
-
throw new Error(
|
|
13307
|
-
"Belief evidence links require evidenceRelation='supports'|'contradicts' or a nonzero signed weight."
|
|
13308
|
-
);
|
|
13309
|
-
}
|
|
13310
|
-
const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
|
|
13311
|
-
return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
|
|
13312
13385
|
}
|
|
13313
13386
|
var linkEvidenceToBeliefInput = (input, context) => {
|
|
13314
13387
|
const weight = relationWeight(input);
|
|
@@ -13317,6 +13390,7 @@ var linkEvidenceToBeliefInput = (input, context) => {
|
|
|
13317
13390
|
beliefNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
|
|
13318
13391
|
insightId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
|
|
13319
13392
|
type: weight < 0 ? "contradicting" : "supporting",
|
|
13393
|
+
weight,
|
|
13320
13394
|
confidence: Math.min(1, Math.abs(weight)),
|
|
13321
13395
|
rationale: input.rationale ?? input.context,
|
|
13322
13396
|
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
@@ -13393,7 +13467,12 @@ var evidenceContracts = [
|
|
|
13393
13467
|
functionName: "create",
|
|
13394
13468
|
kind: "mutation",
|
|
13395
13469
|
inputProjection: (input, context) => {
|
|
13396
|
-
|
|
13470
|
+
if (typeof input.weight !== "number" || !Number.isFinite(input.weight) || input.weight === 0 || input.weight < -1 || input.weight > 1) {
|
|
13471
|
+
throw new Error(
|
|
13472
|
+
"add_evidence requires explicit nonzero weight in [-1, 1]."
|
|
13473
|
+
);
|
|
13474
|
+
}
|
|
13475
|
+
const weight = input.weight;
|
|
13397
13476
|
return createEvidenceInput(
|
|
13398
13477
|
{
|
|
13399
13478
|
...input,
|
|
@@ -13402,6 +13481,7 @@ var evidenceContracts = [
|
|
|
13402
13481
|
linkedBeliefNodeId: input.linkedBeliefNodeId ?? input.targetNodeId ?? input.targetId,
|
|
13403
13482
|
evidenceRelation: weight < 0 ? "contradicts" : "supports",
|
|
13404
13483
|
confidence: Math.min(1, Math.max(0, Math.abs(weight))),
|
|
13484
|
+
weight,
|
|
13405
13485
|
rationale: input.reasoning,
|
|
13406
13486
|
metadata: {
|
|
13407
13487
|
...recordValue2(input.metadata),
|