@lucern/events 1.0.16 → 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 +229 -153
- package/dist/index.js.map +1 -1
- package/dist/outbox.js +229 -153
- package/dist/outbox.js.map +1 -1
- package/dist/proof-attestation.json +3 -3
- package/dist/types.js +229 -153
- package/dist/types.js.map +1 -1
- package/dist/webhook-delivery-machine.js +229 -153
- package/dist/webhook-delivery-machine.js.map +1 -1
- package/dist/webhooks.js +229 -153
- package/dist/webhooks.js.map +1 -1
- package/package.json +2 -2
|
@@ -35,7 +35,7 @@ var REASONING_METHODS = [
|
|
|
35
35
|
// ../contracts/src/tool-contracts.graph.ts
|
|
36
36
|
var QUERY_LINEAGE = {
|
|
37
37
|
name: "query_lineage",
|
|
38
|
-
description: "Trace a belief's full ancestry \u2014 every fork, score, and
|
|
38
|
+
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).",
|
|
39
39
|
parameters: {
|
|
40
40
|
nodeId: { type: "string", description: "Starting node to trace from" },
|
|
41
41
|
depth: {
|
|
@@ -234,7 +234,7 @@ var FIND_CONTRADICTIONS = {
|
|
|
234
234
|
};
|
|
235
235
|
var BISECT_CONFIDENCE = {
|
|
236
236
|
name: "bisect_confidence",
|
|
237
|
-
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
|
|
237
|
+
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.",
|
|
238
238
|
parameters: {
|
|
239
239
|
nodeId: { type: "string", description: "The belief to bisect" },
|
|
240
240
|
expectedDirection: {
|
|
@@ -253,7 +253,7 @@ var BISECT_CONFIDENCE = {
|
|
|
253
253
|
fields: {
|
|
254
254
|
beliefId: "string \u2014 canonical belief ID",
|
|
255
255
|
expectedDirection: "string \u2014 overconfident | underconfident",
|
|
256
|
-
inflectionEntry: "object \u2014 the
|
|
256
|
+
inflectionEntry: "object \u2014 the scoring event where divergence began",
|
|
257
257
|
triggerEvent: "string | null \u2014 what caused the divergence",
|
|
258
258
|
confidenceBefore: "number | null",
|
|
259
259
|
confidenceAfter: "number | null",
|
|
@@ -547,18 +547,18 @@ var SEARCH_EVIDENCE = {
|
|
|
547
547
|
};
|
|
548
548
|
var CREATE_EVIDENCE = {
|
|
549
549
|
name: "create_evidence",
|
|
550
|
-
description: "Commit evidence to the reasoning graph. Like `git commit` \u2014 creates a traceable evidence record with canonical public IDs.
|
|
550
|
+
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.",
|
|
551
551
|
parameters: {
|
|
552
552
|
topicId: { type: "string", description: "Topic scope" },
|
|
553
553
|
text: { type: "string", description: "Canonical evidence text" },
|
|
554
554
|
source: { type: "string", description: "Source URL or source label" },
|
|
555
555
|
targetId: {
|
|
556
556
|
type: "string",
|
|
557
|
-
description: "
|
|
557
|
+
description: "Belief identifier to link immediately"
|
|
558
558
|
},
|
|
559
559
|
weight: {
|
|
560
560
|
type: "number",
|
|
561
|
-
description: "
|
|
561
|
+
description: "Required nonzero signed impact score: -1.0 (contradicts) to +1.0 (supports)."
|
|
562
562
|
},
|
|
563
563
|
evidenceRelation: {
|
|
564
564
|
type: "string",
|
|
@@ -567,7 +567,7 @@ var CREATE_EVIDENCE = {
|
|
|
567
567
|
},
|
|
568
568
|
confidence: {
|
|
569
569
|
type: "number",
|
|
570
|
-
description: "
|
|
570
|
+
description: "Deprecated hint. Runtime confidence is derived from the signed impact score."
|
|
571
571
|
},
|
|
572
572
|
beliefRelations: {
|
|
573
573
|
type: "array",
|
|
@@ -589,7 +589,7 @@ var CREATE_EVIDENCE = {
|
|
|
589
589
|
},
|
|
590
590
|
kind: { type: "string", description: "Optional evidence kind" }
|
|
591
591
|
},
|
|
592
|
-
required: ["text", "rationale"],
|
|
592
|
+
required: ["text", "rationale", "weight"],
|
|
593
593
|
response: {
|
|
594
594
|
description: "The created canonical evidence record",
|
|
595
595
|
fields: {
|
|
@@ -664,7 +664,7 @@ var LINK_EVIDENCE = {
|
|
|
664
664
|
},
|
|
665
665
|
rationale: { type: "string", description: "Why this link exists" }
|
|
666
666
|
},
|
|
667
|
-
required: ["evidenceId", "targetId"],
|
|
667
|
+
required: ["evidenceId", "targetId", "weight"],
|
|
668
668
|
response: {
|
|
669
669
|
description: "The created canonical evidence edge summary",
|
|
670
670
|
fields: {
|
|
@@ -700,7 +700,7 @@ var LINK_EVIDENCE_TO_BELIEF = {
|
|
|
700
700
|
},
|
|
701
701
|
rationale: { type: "string", description: "Why this evidence is relevant" }
|
|
702
702
|
},
|
|
703
|
-
required: ["evidenceId", "beliefId"],
|
|
703
|
+
required: ["evidenceId", "beliefId", "weight"],
|
|
704
704
|
response: {
|
|
705
705
|
description: "The created edge linking evidence to belief",
|
|
706
706
|
fields: {
|
|
@@ -718,15 +718,23 @@ var LINK_EVIDENCE_TO_BELIEF = {
|
|
|
718
718
|
// ../contracts/src/tool-contracts.lifecycle.ts
|
|
719
719
|
var CREATE_BELIEF = {
|
|
720
720
|
name: "create_belief",
|
|
721
|
-
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.",
|
|
721
|
+
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.",
|
|
722
722
|
parameters: {
|
|
723
723
|
canonicalText: {
|
|
724
724
|
type: "string",
|
|
725
725
|
description: "The belief statement \u2014 what the agent holds to be true"
|
|
726
726
|
},
|
|
727
|
+
topicGlobalId: {
|
|
728
|
+
type: "string",
|
|
729
|
+
description: "Required globalId (UUID) of the topic node in epistemicNodes that anchors the belief"
|
|
730
|
+
},
|
|
731
|
+
topicNodeId: {
|
|
732
|
+
type: "string",
|
|
733
|
+
description: "Optional internal epistemicNodes _id for the topic anchor. Prefer topicGlobalId for public callers."
|
|
734
|
+
},
|
|
727
735
|
topicId: {
|
|
728
736
|
type: "string",
|
|
729
|
-
description: "
|
|
737
|
+
description: "Deprecated compatibility alias for topicGlobalId. Must identify a topic epistemicNode, not a legacy topics-table row."
|
|
730
738
|
},
|
|
731
739
|
baseRate: {
|
|
732
740
|
type: "number",
|
|
@@ -741,7 +749,7 @@ var CREATE_BELIEF = {
|
|
|
741
749
|
description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
|
|
742
750
|
}
|
|
743
751
|
},
|
|
744
|
-
required: ["canonicalText"],
|
|
752
|
+
required: ["canonicalText", "topicGlobalId"],
|
|
745
753
|
response: {
|
|
746
754
|
description: "The created canonical belief record",
|
|
747
755
|
fields: {
|
|
@@ -750,7 +758,7 @@ var CREATE_BELIEF = {
|
|
|
750
758
|
beliefId: "string \u2014 canonical belief ID",
|
|
751
759
|
text: "string \u2014 canonical belief formulation",
|
|
752
760
|
topicId: "string",
|
|
753
|
-
|
|
761
|
+
beliefStatus: "string \u2014 assumption | hypothesis | active | superseded | resolved_true | resolved_false",
|
|
754
762
|
scoringState: "string \u2014 unscored | scored"
|
|
755
763
|
}
|
|
756
764
|
},
|
|
@@ -773,7 +781,7 @@ var GET_BELIEF = {
|
|
|
773
781
|
beliefId: "string \u2014 canonical belief ID",
|
|
774
782
|
text: "string \u2014 canonical belief formulation",
|
|
775
783
|
topicId: "string",
|
|
776
|
-
|
|
784
|
+
beliefStatus: "string \u2014 assumption | hypothesis | active | superseded | resolved_true | resolved_false",
|
|
777
785
|
scoringState: "string \u2014 unscored | scored"
|
|
778
786
|
}
|
|
779
787
|
},
|
|
@@ -802,34 +810,24 @@ var REFINE_BELIEF = {
|
|
|
802
810
|
ontologyPrimitive: "belief",
|
|
803
811
|
tier: "showcase"
|
|
804
812
|
};
|
|
805
|
-
var
|
|
806
|
-
name: "
|
|
807
|
-
description: "Internal
|
|
813
|
+
var APPEND_SL_SCORING = {
|
|
814
|
+
name: "append_sl_scoring",
|
|
815
|
+
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.",
|
|
808
816
|
parameters: {
|
|
809
|
-
nodeId: { type: "string", description: "The belief
|
|
810
|
-
belief: {
|
|
811
|
-
type: "number",
|
|
812
|
-
description: "Subjective-logic belief mass `b` in [0, 1]"
|
|
813
|
-
},
|
|
817
|
+
nodeId: { type: "string", description: "The belief receiving the SL score" },
|
|
818
|
+
belief: { type: "number", description: "Subjective Logic belief mass b" },
|
|
814
819
|
disbelief: {
|
|
815
820
|
type: "number",
|
|
816
|
-
description: "Subjective
|
|
821
|
+
description: "Subjective Logic disbelief mass d"
|
|
817
822
|
},
|
|
818
823
|
uncertainty: {
|
|
819
824
|
type: "number",
|
|
820
|
-
description: "Subjective
|
|
821
|
-
},
|
|
822
|
-
baseRate: {
|
|
823
|
-
type: "number",
|
|
824
|
-
description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
|
|
825
|
-
},
|
|
826
|
-
worktreeId: {
|
|
827
|
-
type: "string",
|
|
828
|
-
description: "Completed worktree that tested this belief when confidence policy requires merge-backed scoring."
|
|
825
|
+
description: "Subjective Logic uncertainty mass u"
|
|
829
826
|
},
|
|
827
|
+
baseRate: { type: "number", description: "Subjective Logic base rate a" },
|
|
830
828
|
trigger: {
|
|
831
829
|
type: "string",
|
|
832
|
-
description: "
|
|
830
|
+
description: "Evidence-bearing cause of the scoring event",
|
|
833
831
|
enum: [
|
|
834
832
|
"evidence_added",
|
|
835
833
|
"evidence_removed",
|
|
@@ -840,64 +838,39 @@ var MODULATE_CONFIDENCE = {
|
|
|
840
838
|
"worktree_completed",
|
|
841
839
|
"fusion",
|
|
842
840
|
"discount",
|
|
843
|
-
"deduction"
|
|
841
|
+
"deduction",
|
|
842
|
+
"backfill_synthetic"
|
|
844
843
|
]
|
|
845
844
|
},
|
|
846
|
-
|
|
847
|
-
type: "
|
|
848
|
-
description: "
|
|
849
|
-
},
|
|
850
|
-
triggeringQuestionId: {
|
|
851
|
-
type: "string",
|
|
852
|
-
description: "Answered question whose resolution supports this modulation"
|
|
853
|
-
},
|
|
854
|
-
triggeringAnswerId: {
|
|
855
|
-
type: "string",
|
|
856
|
-
description: "Answer node whose content supports this modulation"
|
|
857
|
-
},
|
|
858
|
-
triggeringContradictionId: {
|
|
859
|
-
type: "string",
|
|
860
|
-
description: "Contradiction record that caused a contradiction-triggered modulation"
|
|
861
|
-
},
|
|
862
|
-
triggeringWorktreeId: {
|
|
863
|
-
type: "string",
|
|
864
|
-
description: "Completed worktree whose outcome caused a worktree-triggered modulation"
|
|
845
|
+
provenance: {
|
|
846
|
+
type: "object",
|
|
847
|
+
description: "At least one of evidence, question, answer, contradiction, or worktree."
|
|
865
848
|
},
|
|
866
849
|
rationale: {
|
|
867
850
|
type: "string",
|
|
868
|
-
description: "
|
|
851
|
+
description: "Why this evidence-bearing event moved the SL tuple"
|
|
869
852
|
}
|
|
870
853
|
},
|
|
871
|
-
required: [
|
|
872
|
-
"nodeId",
|
|
873
|
-
"belief",
|
|
874
|
-
"disbelief",
|
|
875
|
-
"uncertainty",
|
|
876
|
-
"baseRate",
|
|
877
|
-
"trigger",
|
|
878
|
-
"rationale"
|
|
879
|
-
],
|
|
854
|
+
required: ["nodeId", "belief", "disbelief", "uncertainty", "baseRate", "trigger", "rationale"],
|
|
880
855
|
response: {
|
|
881
|
-
description: "
|
|
856
|
+
description: "Internal SL scoring append receipt",
|
|
882
857
|
fields: {
|
|
883
|
-
|
|
884
|
-
nodeId: "string \u2014 canonical belief ID",
|
|
885
|
-
newConfidence: "number",
|
|
858
|
+
nodeId: "string",
|
|
886
859
|
previousConfidence: "number",
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
propagationSummary: "object \u2014 bounded inline cascade summary with totalCandidateTargets, inlineTargets, and remainingTargetCount"
|
|
860
|
+
newConfidence: "number",
|
|
861
|
+
beliefConfidenceId: "string"
|
|
890
862
|
}
|
|
891
863
|
},
|
|
892
864
|
ownerModule: "graph-primitives",
|
|
893
865
|
ontologyPrimitive: "belief",
|
|
894
|
-
tier: "
|
|
866
|
+
tier: "workhorse",
|
|
867
|
+
internal: true
|
|
895
868
|
};
|
|
896
869
|
var FORK_BELIEF = {
|
|
897
870
|
name: "fork_belief",
|
|
898
|
-
description: "Branch off
|
|
871
|
+
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.",
|
|
899
872
|
parameters: {
|
|
900
|
-
nodeId: { type: "string", description: "The
|
|
873
|
+
nodeId: { type: "string", description: "The belief to fork from" },
|
|
901
874
|
newFormulation: {
|
|
902
875
|
type: "string",
|
|
903
876
|
description: "The evolved belief statement"
|
|
@@ -909,12 +882,20 @@ var FORK_BELIEF = {
|
|
|
909
882
|
"refinement",
|
|
910
883
|
"contradiction_response",
|
|
911
884
|
"scope_change",
|
|
912
|
-
"confidence_collapse"
|
|
913
|
-
"manual"
|
|
885
|
+
"confidence_collapse"
|
|
914
886
|
]
|
|
887
|
+
},
|
|
888
|
+
forkMode: {
|
|
889
|
+
type: "string",
|
|
890
|
+
description: "supersede replaces the parent; branch creates a child while preserving the parent.",
|
|
891
|
+
enum: ["supersede", "branch"]
|
|
892
|
+
},
|
|
893
|
+
triggeringEvidenceId: {
|
|
894
|
+
type: "string",
|
|
895
|
+
description: "Evidence already attached to the parent belief that caused the fork."
|
|
915
896
|
}
|
|
916
897
|
},
|
|
917
|
-
required: ["nodeId", "newFormulation", "forkReason"],
|
|
898
|
+
required: ["nodeId", "newFormulation", "forkReason", "triggeringEvidenceId"],
|
|
918
899
|
response: {
|
|
919
900
|
description: "The forked canonical belief record",
|
|
920
901
|
fields: {
|
|
@@ -2179,7 +2160,7 @@ var TRIGGER_BELIEF_REVIEW = {
|
|
|
2179
2160
|
};
|
|
2180
2161
|
var EVALUATE_CONTRACT = {
|
|
2181
2162
|
name: "evaluate_contract",
|
|
2182
|
-
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
|
|
2163
|
+
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.",
|
|
2183
2164
|
parameters: {
|
|
2184
2165
|
contractId: { type: "string", description: "Which contract to evaluate" },
|
|
2185
2166
|
trigger: {
|
|
@@ -4070,6 +4051,11 @@ var COMPILE_CONTEXT = {
|
|
|
4070
4051
|
response: {
|
|
4071
4052
|
description: "Compiled context pack for the requested topic",
|
|
4072
4053
|
fields: {
|
|
4054
|
+
contextNarrative: "array \u2014 first field; ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
|
|
4055
|
+
narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, topicsSynthesized, topicsEnriched, topicContentOmitted, enrichmentMode, and blocksEmitted for the narrative",
|
|
4056
|
+
synthesisLints: "array \u2014 inline quality warnings for degenerate synthesis blocks or weak narrative coverage",
|
|
4057
|
+
retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
|
|
4058
|
+
supportingObjects: "object \u2014 raw graph records grouped behind the synthesis: invariants, activeBeliefs, openQuestions, recentEvidence, worktrees, lanes, entities, and contradictions",
|
|
4073
4059
|
schemaVersion: "string",
|
|
4074
4060
|
topicId: "string",
|
|
4075
4061
|
topicName: "string",
|
|
@@ -4077,15 +4063,6 @@ var COMPILE_CONTEXT = {
|
|
|
4077
4063
|
generatedAt: "number \u2014 deterministic graph-backed reference timestamp for this compilation",
|
|
4078
4064
|
ranking: "string \u2014 baseline_v1 | weighted_v1",
|
|
4079
4065
|
summary: "object \u2014 counts and scoped health signals",
|
|
4080
|
-
invariants: "array \u2014 high-confidence invariant beliefs",
|
|
4081
|
-
activeBeliefs: "array \u2014 current high-signal beliefs",
|
|
4082
|
-
openQuestions: "array \u2014 unresolved questions ranked for this query",
|
|
4083
|
-
recentEvidence: "array \u2014 recent evidence ranked for this query",
|
|
4084
|
-
contradictions: "array \u2014 unresolved contradiction records",
|
|
4085
|
-
relatedEntities: "array | undefined \u2014 ranked ontological entities in scope",
|
|
4086
|
-
contextNarrative: "array \u2014 ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
|
|
4087
|
-
retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
|
|
4088
|
-
narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, topicsSynthesized, topicsEnriched, topicContentOmitted, enrichmentMode, and blocksEmitted for the narrative",
|
|
4089
4066
|
injectionPolicy: "object \u2014 token-budgeted section selections",
|
|
4090
4067
|
diagnostics: "object \u2014 scoring and utilization telemetry"
|
|
4091
4068
|
}
|
|
@@ -4644,7 +4621,7 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
4644
4621
|
create_belief: CREATE_BELIEF,
|
|
4645
4622
|
get_belief: GET_BELIEF,
|
|
4646
4623
|
refine_belief: REFINE_BELIEF,
|
|
4647
|
-
|
|
4624
|
+
append_sl_scoring: APPEND_SL_SCORING,
|
|
4648
4625
|
fork_belief: FORK_BELIEF,
|
|
4649
4626
|
archive_belief: ARCHIVE_BELIEF,
|
|
4650
4627
|
create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
|
|
@@ -6442,8 +6419,10 @@ defineTable({
|
|
|
6442
6419
|
"beliefStatus": z.object({
|
|
6443
6420
|
"assumption": z.number(),
|
|
6444
6421
|
"hypothesis": z.number(),
|
|
6445
|
-
"
|
|
6446
|
-
"
|
|
6422
|
+
"active": z.number(),
|
|
6423
|
+
"superseded": z.number(),
|
|
6424
|
+
"resolved_true": z.number(),
|
|
6425
|
+
"resolved_false": z.number()
|
|
6447
6426
|
}).optional(),
|
|
6448
6427
|
"evidenceTemporalNature": z.object({
|
|
6449
6428
|
"factual": z.number(),
|
|
@@ -6665,8 +6644,8 @@ defineTable({
|
|
|
6665
6644
|
"exportClass": z.enum(["internal_only", "client_safe", "public_safe", "restricted"]).optional(),
|
|
6666
6645
|
"anonymizationClass": z.enum(["none", "standard", "strict"]).optional(),
|
|
6667
6646
|
"beliefType": z.string().optional(),
|
|
6668
|
-
"beliefStatus": z.enum(["assumption", "hypothesis", "
|
|
6669
|
-
"epistemicStatus": z.enum(["
|
|
6647
|
+
"beliefStatus": z.enum(["assumption", "hypothesis", "active", "superseded", "resolved_true", "resolved_false"]).optional(),
|
|
6648
|
+
"epistemicStatus": z.enum(["assumption", "hypothesis", "active", "superseded", "resolved_true", "resolved_false"]).optional(),
|
|
6670
6649
|
"reversibility": z.enum(["irreversible", "hard_to_reverse", "reversible", "trivial"]).optional(),
|
|
6671
6650
|
"predictionMeta": z.object({
|
|
6672
6651
|
"isPrediction": z.boolean(),
|
|
@@ -11632,11 +11611,39 @@ var createEvidenceInputSchemaBase = z.object({
|
|
|
11632
11611
|
metadata: jsonRecordSchema.optional(),
|
|
11633
11612
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
11634
11613
|
}).passthrough();
|
|
11635
|
-
function
|
|
11636
|
-
return typeof value === "number" && Number.isFinite(value) && value !== 0;
|
|
11614
|
+
function isSignedImpactScore(value) {
|
|
11615
|
+
return typeof value === "number" && Number.isFinite(value) && value >= -1 && value <= 1 && value !== 0;
|
|
11637
11616
|
}
|
|
11638
|
-
function
|
|
11639
|
-
|
|
11617
|
+
function validateSignedImpactScore(value, ctx, path) {
|
|
11618
|
+
if (!isSignedImpactScore(value)) {
|
|
11619
|
+
ctx.addIssue({
|
|
11620
|
+
code: z.ZodIssueCode.custom,
|
|
11621
|
+
message: "evidence-to-belief links require an explicit nonzero signed impact score in [-1, 1]",
|
|
11622
|
+
path
|
|
11623
|
+
});
|
|
11624
|
+
return false;
|
|
11625
|
+
}
|
|
11626
|
+
return true;
|
|
11627
|
+
}
|
|
11628
|
+
function validateRelationImpactConsistency(relation, weight, ctx, path) {
|
|
11629
|
+
const normalized = normalizeRelationAlias(relation);
|
|
11630
|
+
if (!normalized || !isSignedImpactScore(weight)) {
|
|
11631
|
+
return;
|
|
11632
|
+
}
|
|
11633
|
+
if (normalized === "supports" && weight < 0) {
|
|
11634
|
+
ctx.addIssue({
|
|
11635
|
+
code: z.ZodIssueCode.custom,
|
|
11636
|
+
message: "supporting evidence requires a positive impact score",
|
|
11637
|
+
path
|
|
11638
|
+
});
|
|
11639
|
+
}
|
|
11640
|
+
if (normalized === "contradicts" && weight > 0) {
|
|
11641
|
+
ctx.addIssue({
|
|
11642
|
+
code: z.ZodIssueCode.custom,
|
|
11643
|
+
message: "contradicting evidence requires a negative impact score",
|
|
11644
|
+
path
|
|
11645
|
+
});
|
|
11646
|
+
}
|
|
11640
11647
|
}
|
|
11641
11648
|
var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
11642
11649
|
(input, ctx) => {
|
|
@@ -11653,13 +11660,27 @@ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
|
11653
11660
|
input.linkedBeliefNodeId || kind === "belief" || kind === "unknown" && target
|
|
11654
11661
|
);
|
|
11655
11662
|
const weight = typeof input.weight === "number" ? input.weight : void 0;
|
|
11656
|
-
|
|
11663
|
+
const hasBeliefRelations = (input.beliefRelations?.length ?? 0) > 0;
|
|
11664
|
+
if (!linksPrimaryBelief && !hasBeliefRelations) {
|
|
11665
|
+
ctx.addIssue({
|
|
11666
|
+
code: z.ZodIssueCode.custom,
|
|
11667
|
+
message: "create_evidence requires at least one linked belief; evidence cannot be created as an orphan or linked only to a question/worktree",
|
|
11668
|
+
path: ["linkedBeliefNodeId"]
|
|
11669
|
+
});
|
|
11670
|
+
}
|
|
11671
|
+
if (kind === "question" || kind === "worktree") {
|
|
11657
11672
|
ctx.addIssue({
|
|
11658
11673
|
code: z.ZodIssueCode.custom,
|
|
11659
|
-
message: "belief
|
|
11660
|
-
path: ["
|
|
11674
|
+
message: "create_evidence targetId must be a belief. Link evidence to questions/worktrees only after the evidence has a belief impact edge.",
|
|
11675
|
+
path: ["targetId"]
|
|
11661
11676
|
});
|
|
11662
11677
|
}
|
|
11678
|
+
if (linksPrimaryBelief) {
|
|
11679
|
+
validateSignedImpactScore(weight, ctx, ["weight"]);
|
|
11680
|
+
validateRelationImpactConsistency(input.evidenceRelation, weight, ctx, [
|
|
11681
|
+
"weight"
|
|
11682
|
+
]);
|
|
11683
|
+
}
|
|
11663
11684
|
input.beliefRelations?.forEach((relation, index) => {
|
|
11664
11685
|
const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
|
|
11665
11686
|
if (!beliefNodeId) {
|
|
@@ -11670,15 +11691,18 @@ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
|
11670
11691
|
});
|
|
11671
11692
|
}
|
|
11672
11693
|
const relationWeight2 = typeof relation.weight === "number" ? relation.weight : void 0;
|
|
11673
|
-
if (beliefNodeId
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11694
|
+
if (beliefNodeId) {
|
|
11695
|
+
validateSignedImpactScore(relationWeight2, ctx, [
|
|
11696
|
+
"beliefRelations",
|
|
11697
|
+
index,
|
|
11698
|
+
"weight"
|
|
11699
|
+
]);
|
|
11700
|
+
validateRelationImpactConsistency(
|
|
11701
|
+
relation.evidenceRelation ?? relation.relation,
|
|
11702
|
+
relationWeight2,
|
|
11703
|
+
ctx,
|
|
11704
|
+
["beliefRelations", index, "weight"]
|
|
11705
|
+
);
|
|
11682
11706
|
}
|
|
11683
11707
|
});
|
|
11684
11708
|
}
|
|
@@ -11732,18 +11756,28 @@ function targetKind(targetId) {
|
|
|
11732
11756
|
}
|
|
11733
11757
|
return "unknown";
|
|
11734
11758
|
}
|
|
11735
|
-
function
|
|
11759
|
+
function normalizeRelationAlias(value) {
|
|
11736
11760
|
if (value === "supports" || value === "supporting") {
|
|
11737
11761
|
return "supports";
|
|
11738
11762
|
}
|
|
11739
11763
|
if (value === "contradicts" || value === "contradicting") {
|
|
11740
11764
|
return "contradicts";
|
|
11741
11765
|
}
|
|
11766
|
+
return void 0;
|
|
11767
|
+
}
|
|
11768
|
+
function normalizeRelation(value, weight) {
|
|
11769
|
+
const alias = normalizeRelationAlias(value);
|
|
11770
|
+
if (alias) {
|
|
11771
|
+
return alias;
|
|
11772
|
+
}
|
|
11742
11773
|
if (weight === void 0 || !hasNonzeroWeight(weight)) {
|
|
11743
11774
|
return void 0;
|
|
11744
11775
|
}
|
|
11745
11776
|
return weight < 0 ? "contradicts" : "supports";
|
|
11746
11777
|
}
|
|
11778
|
+
function hasNonzeroWeight(value) {
|
|
11779
|
+
return typeof value === "number" && Number.isFinite(value) && value !== 0;
|
|
11780
|
+
}
|
|
11747
11781
|
function normalizeConfidence(confidence, weight) {
|
|
11748
11782
|
if (confidence !== void 0) {
|
|
11749
11783
|
return Math.min(1, Math.max(0, confidence));
|
|
@@ -11770,6 +11804,7 @@ function normalizeBeliefRelation(relation) {
|
|
|
11770
11804
|
beliefNodeId,
|
|
11771
11805
|
relation: evidenceRelation,
|
|
11772
11806
|
confidence: normalizeConfidence(relation.confidence, weight),
|
|
11807
|
+
weight,
|
|
11773
11808
|
rationale: relation.rationale
|
|
11774
11809
|
});
|
|
11775
11810
|
}
|
|
@@ -11818,6 +11853,7 @@ var createEvidenceProjection = defineProjection({
|
|
|
11818
11853
|
linkedBeliefNodeId,
|
|
11819
11854
|
evidenceRelation,
|
|
11820
11855
|
confidence,
|
|
11856
|
+
weight,
|
|
11821
11857
|
beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
|
|
11822
11858
|
rationale: input.rationale,
|
|
11823
11859
|
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
@@ -11847,12 +11883,14 @@ var createEvidenceProjection = defineProjection({
|
|
|
11847
11883
|
v.literal("contradicts")
|
|
11848
11884
|
)
|
|
11849
11885
|
),
|
|
11886
|
+
weight: v.optional(v.number()),
|
|
11850
11887
|
beliefRelations: v.optional(
|
|
11851
11888
|
v.array(
|
|
11852
11889
|
v.object({
|
|
11853
11890
|
beliefNodeId: v.string(),
|
|
11854
11891
|
relation: v.union(v.literal("supports"), v.literal("contradicts")),
|
|
11855
11892
|
confidence: v.optional(v.number()),
|
|
11893
|
+
weight: v.number(),
|
|
11856
11894
|
rationale: v.optional(v.string())
|
|
11857
11895
|
})
|
|
11858
11896
|
)
|
|
@@ -11970,7 +12008,7 @@ var slOpinionProjectionSchema = z.object({
|
|
|
11970
12008
|
uncertainty: z.number(),
|
|
11971
12009
|
baseRate: z.number()
|
|
11972
12010
|
});
|
|
11973
|
-
var
|
|
12011
|
+
var appendSlScoringInputObjectSchema = z.object({
|
|
11974
12012
|
nodeId: z.string().optional(),
|
|
11975
12013
|
beliefNodeId: z.string().optional(),
|
|
11976
12014
|
worktreeId: z.string().optional(),
|
|
@@ -11989,23 +12027,23 @@ var modulateConfidenceInputObjectSchema = z.object({
|
|
|
11989
12027
|
rationale: z.string(),
|
|
11990
12028
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
11991
12029
|
});
|
|
11992
|
-
var
|
|
12030
|
+
var appendSlScoringInputSchema = appendSlScoringInputObjectSchema.superRefine((input, ctx) => {
|
|
11993
12031
|
if (hasProvenance(input)) {
|
|
11994
12032
|
return;
|
|
11995
12033
|
}
|
|
11996
12034
|
ctx.addIssue({
|
|
11997
12035
|
code: z.ZodIssueCode.custom,
|
|
11998
|
-
message: "
|
|
12036
|
+
message: "append_sl_scoring requires evidence, question, answer, contradiction, or worktree provenance",
|
|
11999
12037
|
path: ["provenance"]
|
|
12000
12038
|
});
|
|
12001
12039
|
});
|
|
12002
|
-
var
|
|
12003
|
-
contractName: "
|
|
12004
|
-
inputSchema:
|
|
12040
|
+
var appendSlScoringProjection = defineProjection({
|
|
12041
|
+
contractName: "append_sl_scoring",
|
|
12042
|
+
inputSchema: appendSlScoringInputSchema,
|
|
12005
12043
|
project: (input) => {
|
|
12006
12044
|
const nodeId = input.beliefNodeId ?? input.nodeId;
|
|
12007
12045
|
if (!nodeId) {
|
|
12008
|
-
throw new Error("
|
|
12046
|
+
throw new Error("append_sl_scoring requires beliefNodeId or nodeId");
|
|
12009
12047
|
}
|
|
12010
12048
|
const opinion = input.opinion ?? {
|
|
12011
12049
|
belief: requireNumber(input.belief, "belief"),
|
|
@@ -12062,14 +12100,14 @@ var modulateConfidenceProjection = defineProjection({
|
|
|
12062
12100
|
});
|
|
12063
12101
|
function requireNumber(value, field) {
|
|
12064
12102
|
if (value === void 0) {
|
|
12065
|
-
throw new Error(`
|
|
12103
|
+
throw new Error(`append_sl_scoring requires ${field}`);
|
|
12066
12104
|
}
|
|
12067
12105
|
return value;
|
|
12068
12106
|
}
|
|
12069
12107
|
function assertProvenance(input) {
|
|
12070
12108
|
if (!hasProvenance(input)) {
|
|
12071
12109
|
throw new Error(
|
|
12072
|
-
"
|
|
12110
|
+
"append_sl_scoring requires evidence, question, answer, contradiction, or worktree provenance"
|
|
12073
12111
|
);
|
|
12074
12112
|
}
|
|
12075
12113
|
}
|
|
@@ -12412,12 +12450,12 @@ var LUCERN_OPERATION_MANIFEST = {
|
|
|
12412
12450
|
internalSystem,
|
|
12413
12451
|
"Lucern system/background operation. Available to platform code paths, hidden from public MCP discovery."
|
|
12414
12452
|
),
|
|
12415
|
-
|
|
12416
|
-
name: "
|
|
12453
|
+
append_sl_scoring: {
|
|
12454
|
+
name: "append_sl_scoring",
|
|
12417
12455
|
surfaceClass: "platform_internal",
|
|
12418
12456
|
surfaceIntent: "system",
|
|
12419
12457
|
surfaces: internalSdkRestOnly,
|
|
12420
|
-
rationale: "Internal SL
|
|
12458
|
+
rationale: "Internal SL scoring append primitive. Public callers attach evidence or contradiction relations; confidence is derived algorithmically."
|
|
12421
12459
|
},
|
|
12422
12460
|
...entries(
|
|
12423
12461
|
LEGACY_COMPAT_OPERATION_NAMES,
|
|
@@ -12971,7 +13009,15 @@ var predictionMetaSchema = z.object({
|
|
|
12971
13009
|
});
|
|
12972
13010
|
var createBeliefArgs = z.object({
|
|
12973
13011
|
canonicalText: z.string().describe("The belief statement the agent holds to be true."),
|
|
12974
|
-
|
|
13012
|
+
topicGlobalId: z.string().describe(
|
|
13013
|
+
"Required globalId of the topic epistemicNode that anchors this belief. Belief creation creates a scoped_by edge directly to that topic node."
|
|
13014
|
+
),
|
|
13015
|
+
topicNodeId: z.string().optional().describe(
|
|
13016
|
+
"Optional internal epistemicNodes _id for the topic anchor. Prefer topicGlobalId for public callers."
|
|
13017
|
+
),
|
|
13018
|
+
topicId: z.string().optional().describe(
|
|
13019
|
+
"Deprecated compatibility alias for topicGlobalId. Must identify a topic epistemicNode, not a legacy topics-table row."
|
|
13020
|
+
),
|
|
12975
13021
|
baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
|
|
12976
13022
|
beliefType: z.string().optional().describe("Schema belief type."),
|
|
12977
13023
|
metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
|
|
@@ -12990,9 +13036,14 @@ var forkBeliefArgs = z.object({
|
|
|
12990
13036
|
"refinement",
|
|
12991
13037
|
"contradiction_response",
|
|
12992
13038
|
"scope_change",
|
|
12993
|
-
"confidence_collapse"
|
|
12994
|
-
"manual"
|
|
13039
|
+
"confidence_collapse"
|
|
12995
13040
|
]).describe("Why this fork was created."),
|
|
13041
|
+
forkMode: z.enum(["supersede", "branch"]).optional().describe(
|
|
13042
|
+
"supersede marks the parent belief superseded; branch preserves the parent and creates a derived child."
|
|
13043
|
+
),
|
|
13044
|
+
triggeringEvidenceId: z.string().describe(
|
|
13045
|
+
"Evidence already attached to the parent belief through SL scoring; required for every fork."
|
|
13046
|
+
),
|
|
12996
13047
|
rationale: z.string().optional().describe("Why the fork is warranted.")
|
|
12997
13048
|
});
|
|
12998
13049
|
var beliefLookupInput = (input) => compactRecord4({
|
|
@@ -13006,7 +13057,9 @@ var createBeliefInput = (input, context) => {
|
|
|
13006
13057
|
return withUserId(
|
|
13007
13058
|
compactRecord4({
|
|
13008
13059
|
projectId: input.projectId,
|
|
13009
|
-
topicId: input.topicId,
|
|
13060
|
+
topicId: input.topicGlobalId ?? input.topicNodeId ?? input.topicId,
|
|
13061
|
+
topicGlobalId: input.topicGlobalId,
|
|
13062
|
+
topicNodeId: input.topicNodeId,
|
|
13010
13063
|
formulation: input.formulation ?? input.canonicalText,
|
|
13011
13064
|
beliefType: input.beliefType,
|
|
13012
13065
|
rationale: input.rationale,
|
|
@@ -13028,20 +13081,22 @@ var forkBeliefInput = (input, context) => withUserId(
|
|
|
13028
13081
|
parentNodeId: input.parentNodeId ?? input.nodeId ?? input.id,
|
|
13029
13082
|
newFormulation: input.newFormulation,
|
|
13030
13083
|
forkReason: input.forkReason,
|
|
13084
|
+
forkMode: input.forkMode,
|
|
13085
|
+
triggeringEvidenceId: input.triggeringEvidenceId,
|
|
13031
13086
|
rationale: input.rationale,
|
|
13032
13087
|
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
13033
13088
|
}),
|
|
13034
13089
|
context
|
|
13035
13090
|
);
|
|
13036
|
-
var
|
|
13037
|
-
const parsed =
|
|
13091
|
+
var appendSlScoringInput = (input, context) => {
|
|
13092
|
+
const parsed = appendSlScoringProjection.inputSchema.safeParse(input);
|
|
13038
13093
|
if (!parsed.success) {
|
|
13039
13094
|
throw new Error(
|
|
13040
|
-
`
|
|
13095
|
+
`append_sl_scoring projection input rejected: ${parsed.error.message}`
|
|
13041
13096
|
);
|
|
13042
13097
|
}
|
|
13043
13098
|
return withUserId(
|
|
13044
|
-
compactRecord4(
|
|
13099
|
+
compactRecord4(appendSlScoringProjection.project(parsed.data)),
|
|
13045
13100
|
context
|
|
13046
13101
|
);
|
|
13047
13102
|
};
|
|
@@ -13119,21 +13174,21 @@ var beliefsContracts = [
|
|
|
13119
13174
|
}
|
|
13120
13175
|
}),
|
|
13121
13176
|
surfaceContract({
|
|
13122
|
-
name: "
|
|
13177
|
+
name: "append_sl_scoring",
|
|
13123
13178
|
kind: "mutation",
|
|
13124
13179
|
domain: "beliefs",
|
|
13125
13180
|
surfaceClass: "platform_internal",
|
|
13126
|
-
path: "/beliefs/
|
|
13181
|
+
path: "/beliefs/sl-scoring",
|
|
13127
13182
|
sdkNamespace: "beliefs",
|
|
13128
|
-
sdkMethod: "
|
|
13129
|
-
summary: "Internal SL
|
|
13183
|
+
sdkMethod: "appendSlScoring",
|
|
13184
|
+
summary: "Internal SL scoring append. Public callers attach evidence or contradiction relations instead.",
|
|
13130
13185
|
convex: {
|
|
13131
13186
|
module: "beliefs",
|
|
13132
|
-
functionName: "
|
|
13187
|
+
functionName: "appendSlScoring",
|
|
13133
13188
|
kind: "mutation",
|
|
13134
|
-
inputProjection:
|
|
13189
|
+
inputProjection: appendSlScoringInput
|
|
13135
13190
|
},
|
|
13136
|
-
args:
|
|
13191
|
+
args: appendSlScoringInputSchema
|
|
13137
13192
|
}),
|
|
13138
13193
|
surfaceContract({
|
|
13139
13194
|
name: "fork_belief",
|
|
@@ -13239,8 +13294,12 @@ var beliefRelationSchema2 = z.object({
|
|
|
13239
13294
|
targetId: z.string().optional().describe("Belief target ID alias for beliefId/beliefNodeId."),
|
|
13240
13295
|
relation: z.enum(["supports", "contradicts", "supporting", "contradicting"]).optional().describe("Relation alias for how the evidence bears on the belief."),
|
|
13241
13296
|
evidenceRelation: evidenceRelationSchema2.optional().describe("Canonical relation: supports or contradicts."),
|
|
13242
|
-
confidence: z.number().optional().describe(
|
|
13243
|
-
|
|
13297
|
+
confidence: z.number().optional().describe(
|
|
13298
|
+
"Deprecated read-only hint. Runtime SL confidence is derived from signed weight."
|
|
13299
|
+
),
|
|
13300
|
+
weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
|
|
13301
|
+
message: "Evidence impact weight must be nonzero."
|
|
13302
|
+
}).describe("Required signed impact score from -1.0 to +1.0 for this belief."),
|
|
13244
13303
|
rationale: z.string().optional().describe("Why this relation exists.")
|
|
13245
13304
|
});
|
|
13246
13305
|
var createEvidenceArgs = z.object({
|
|
@@ -13249,7 +13308,7 @@ var createEvidenceArgs = z.object({
|
|
|
13249
13308
|
source: z.string().optional().describe("Source URL or source label."),
|
|
13250
13309
|
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
13251
13310
|
targetId: z.string().optional().describe(
|
|
13252
|
-
"Belief
|
|
13311
|
+
"Belief identifier to link immediately. Evidence creation cannot target only a question or worktree."
|
|
13253
13312
|
),
|
|
13254
13313
|
linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
|
|
13255
13314
|
evidenceRelation: evidenceRelationSchema2.optional().describe(
|
|
@@ -13258,8 +13317,14 @@ var createEvidenceArgs = z.object({
|
|
|
13258
13317
|
beliefRelations: z.array(beliefRelationSchema2).optional().describe(
|
|
13259
13318
|
"Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
|
|
13260
13319
|
),
|
|
13261
|
-
confidence: z.number().optional().describe(
|
|
13262
|
-
|
|
13320
|
+
confidence: z.number().optional().describe(
|
|
13321
|
+
"Deprecated hint. Runtime confidence is derived from signed weight."
|
|
13322
|
+
),
|
|
13323
|
+
weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
|
|
13324
|
+
message: "Evidence impact weight must be nonzero."
|
|
13325
|
+
}).describe(
|
|
13326
|
+
"Required signed impact score from -1.0 to +1.0 for targetId/linkedBeliefNodeId."
|
|
13327
|
+
),
|
|
13263
13328
|
metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
|
|
13264
13329
|
rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
|
|
13265
13330
|
reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
|
|
@@ -13281,7 +13346,9 @@ var addEvidenceArgs = z.object({
|
|
|
13281
13346
|
topicId: z.string().optional().describe("Topic scope hint."),
|
|
13282
13347
|
sourceUrl: z.string().optional().describe("URL of the source material."),
|
|
13283
13348
|
targetNodeId: z.string().describe("The belief this evidence bears on."),
|
|
13284
|
-
weight: z.number().
|
|
13349
|
+
weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
|
|
13350
|
+
message: "Evidence impact weight must be nonzero."
|
|
13351
|
+
}).describe("Required signed impact score from -1.0 to +1.0."),
|
|
13285
13352
|
reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
|
|
13286
13353
|
title: z.string().optional().describe("Optional short title."),
|
|
13287
13354
|
content: z.string().optional().describe("Optional long-form evidence content."),
|
|
@@ -13301,19 +13368,21 @@ var createEvidenceInput = (input, context) => {
|
|
|
13301
13368
|
);
|
|
13302
13369
|
};
|
|
13303
13370
|
function relationWeight(input) {
|
|
13304
|
-
if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
|
|
13371
|
+
if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0 && input.weight >= -1 && input.weight <= 1) {
|
|
13372
|
+
const relation = String(
|
|
13373
|
+
input.evidenceRelation ?? input.relation ?? input.type ?? ""
|
|
13374
|
+
);
|
|
13375
|
+
if ((relation === "supports" || relation === "supporting") && input.weight < 0) {
|
|
13376
|
+
throw new Error("Supporting evidence links require positive weight.");
|
|
13377
|
+
}
|
|
13378
|
+
if ((relation === "contradicts" || relation === "contradicting") && input.weight > 0) {
|
|
13379
|
+
throw new Error("Contradicting evidence links require negative weight.");
|
|
13380
|
+
}
|
|
13305
13381
|
return input.weight;
|
|
13306
13382
|
}
|
|
13307
|
-
|
|
13308
|
-
|
|
13383
|
+
throw new Error(
|
|
13384
|
+
"Belief evidence links require explicit nonzero weight in [-1, 1]."
|
|
13309
13385
|
);
|
|
13310
|
-
if (relation !== "supports" && relation !== "supporting" && relation !== "contradicts" && relation !== "contradicting") {
|
|
13311
|
-
throw new Error(
|
|
13312
|
-
"Belief evidence links require evidenceRelation='supports'|'contradicts' or a nonzero signed weight."
|
|
13313
|
-
);
|
|
13314
|
-
}
|
|
13315
|
-
const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
|
|
13316
|
-
return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
|
|
13317
13386
|
}
|
|
13318
13387
|
var linkEvidenceToBeliefInput = (input, context) => {
|
|
13319
13388
|
const weight = relationWeight(input);
|
|
@@ -13322,6 +13391,7 @@ var linkEvidenceToBeliefInput = (input, context) => {
|
|
|
13322
13391
|
beliefNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
|
|
13323
13392
|
insightId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
|
|
13324
13393
|
type: weight < 0 ? "contradicting" : "supporting",
|
|
13394
|
+
weight,
|
|
13325
13395
|
confidence: Math.min(1, Math.abs(weight)),
|
|
13326
13396
|
rationale: input.rationale ?? input.context,
|
|
13327
13397
|
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
@@ -13398,7 +13468,12 @@ var evidenceContracts = [
|
|
|
13398
13468
|
functionName: "create",
|
|
13399
13469
|
kind: "mutation",
|
|
13400
13470
|
inputProjection: (input, context) => {
|
|
13401
|
-
|
|
13471
|
+
if (typeof input.weight !== "number" || !Number.isFinite(input.weight) || input.weight === 0 || input.weight < -1 || input.weight > 1) {
|
|
13472
|
+
throw new Error(
|
|
13473
|
+
"add_evidence requires explicit nonzero weight in [-1, 1]."
|
|
13474
|
+
);
|
|
13475
|
+
}
|
|
13476
|
+
const weight = input.weight;
|
|
13402
13477
|
return createEvidenceInput(
|
|
13403
13478
|
{
|
|
13404
13479
|
...input,
|
|
@@ -13407,6 +13482,7 @@ var evidenceContracts = [
|
|
|
13407
13482
|
linkedBeliefNodeId: input.linkedBeliefNodeId ?? input.targetNodeId ?? input.targetId,
|
|
13408
13483
|
evidenceRelation: weight < 0 ? "contradicts" : "supports",
|
|
13409
13484
|
confidence: Math.min(1, Math.max(0, Math.abs(weight))),
|
|
13485
|
+
weight,
|
|
13410
13486
|
rationale: input.reasoning,
|
|
13411
13487
|
metadata: {
|
|
13412
13488
|
...recordValue2(input.metadata),
|