@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/index.js
CHANGED
|
@@ -60,7 +60,7 @@ var REASONING_METHODS = [
|
|
|
60
60
|
// ../contracts/src/tool-contracts.graph.ts
|
|
61
61
|
var QUERY_LINEAGE = {
|
|
62
62
|
name: "query_lineage",
|
|
63
|
-
description: "Trace a belief's full ancestry \u2014 every fork, score, and
|
|
63
|
+
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).",
|
|
64
64
|
parameters: {
|
|
65
65
|
nodeId: { type: "string", description: "Starting node to trace from" },
|
|
66
66
|
depth: {
|
|
@@ -259,7 +259,7 @@ var FIND_CONTRADICTIONS = {
|
|
|
259
259
|
};
|
|
260
260
|
var BISECT_CONFIDENCE = {
|
|
261
261
|
name: "bisect_confidence",
|
|
262
|
-
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
|
|
262
|
+
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.",
|
|
263
263
|
parameters: {
|
|
264
264
|
nodeId: { type: "string", description: "The belief to bisect" },
|
|
265
265
|
expectedDirection: {
|
|
@@ -278,7 +278,7 @@ var BISECT_CONFIDENCE = {
|
|
|
278
278
|
fields: {
|
|
279
279
|
beliefId: "string \u2014 canonical belief ID",
|
|
280
280
|
expectedDirection: "string \u2014 overconfident | underconfident",
|
|
281
|
-
inflectionEntry: "object \u2014 the
|
|
281
|
+
inflectionEntry: "object \u2014 the scoring event where divergence began",
|
|
282
282
|
triggerEvent: "string | null \u2014 what caused the divergence",
|
|
283
283
|
confidenceBefore: "number | null",
|
|
284
284
|
confidenceAfter: "number | null",
|
|
@@ -572,18 +572,18 @@ var SEARCH_EVIDENCE = {
|
|
|
572
572
|
};
|
|
573
573
|
var CREATE_EVIDENCE = {
|
|
574
574
|
name: "create_evidence",
|
|
575
|
-
description: "Commit evidence to the reasoning graph. Like `git commit` \u2014 creates a traceable evidence record with canonical public IDs.
|
|
575
|
+
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.",
|
|
576
576
|
parameters: {
|
|
577
577
|
topicId: { type: "string", description: "Topic scope" },
|
|
578
578
|
text: { type: "string", description: "Canonical evidence text" },
|
|
579
579
|
source: { type: "string", description: "Source URL or source label" },
|
|
580
580
|
targetId: {
|
|
581
581
|
type: "string",
|
|
582
|
-
description: "
|
|
582
|
+
description: "Belief identifier to link immediately"
|
|
583
583
|
},
|
|
584
584
|
weight: {
|
|
585
585
|
type: "number",
|
|
586
|
-
description: "
|
|
586
|
+
description: "Required nonzero signed impact score: -1.0 (contradicts) to +1.0 (supports)."
|
|
587
587
|
},
|
|
588
588
|
evidenceRelation: {
|
|
589
589
|
type: "string",
|
|
@@ -592,7 +592,7 @@ var CREATE_EVIDENCE = {
|
|
|
592
592
|
},
|
|
593
593
|
confidence: {
|
|
594
594
|
type: "number",
|
|
595
|
-
description: "
|
|
595
|
+
description: "Deprecated hint. Runtime confidence is derived from the signed impact score."
|
|
596
596
|
},
|
|
597
597
|
beliefRelations: {
|
|
598
598
|
type: "array",
|
|
@@ -614,7 +614,7 @@ var CREATE_EVIDENCE = {
|
|
|
614
614
|
},
|
|
615
615
|
kind: { type: "string", description: "Optional evidence kind" }
|
|
616
616
|
},
|
|
617
|
-
required: ["text", "rationale"],
|
|
617
|
+
required: ["text", "rationale", "weight"],
|
|
618
618
|
response: {
|
|
619
619
|
description: "The created canonical evidence record",
|
|
620
620
|
fields: {
|
|
@@ -689,7 +689,7 @@ var LINK_EVIDENCE = {
|
|
|
689
689
|
},
|
|
690
690
|
rationale: { type: "string", description: "Why this link exists" }
|
|
691
691
|
},
|
|
692
|
-
required: ["evidenceId", "targetId"],
|
|
692
|
+
required: ["evidenceId", "targetId", "weight"],
|
|
693
693
|
response: {
|
|
694
694
|
description: "The created canonical evidence edge summary",
|
|
695
695
|
fields: {
|
|
@@ -725,7 +725,7 @@ var LINK_EVIDENCE_TO_BELIEF = {
|
|
|
725
725
|
},
|
|
726
726
|
rationale: { type: "string", description: "Why this evidence is relevant" }
|
|
727
727
|
},
|
|
728
|
-
required: ["evidenceId", "beliefId"],
|
|
728
|
+
required: ["evidenceId", "beliefId", "weight"],
|
|
729
729
|
response: {
|
|
730
730
|
description: "The created edge linking evidence to belief",
|
|
731
731
|
fields: {
|
|
@@ -743,15 +743,23 @@ var LINK_EVIDENCE_TO_BELIEF = {
|
|
|
743
743
|
// ../contracts/src/tool-contracts.lifecycle.ts
|
|
744
744
|
var CREATE_BELIEF = {
|
|
745
745
|
name: "create_belief",
|
|
746
|
-
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.",
|
|
746
|
+
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.",
|
|
747
747
|
parameters: {
|
|
748
748
|
canonicalText: {
|
|
749
749
|
type: "string",
|
|
750
750
|
description: "The belief statement \u2014 what the agent holds to be true"
|
|
751
751
|
},
|
|
752
|
+
topicGlobalId: {
|
|
753
|
+
type: "string",
|
|
754
|
+
description: "Required globalId (UUID) of the topic node in epistemicNodes that anchors the belief"
|
|
755
|
+
},
|
|
756
|
+
topicNodeId: {
|
|
757
|
+
type: "string",
|
|
758
|
+
description: "Optional internal epistemicNodes _id for the topic anchor. Prefer topicGlobalId for public callers."
|
|
759
|
+
},
|
|
752
760
|
topicId: {
|
|
753
761
|
type: "string",
|
|
754
|
-
description: "
|
|
762
|
+
description: "Deprecated compatibility alias for topicGlobalId. Must identify a topic epistemicNode, not a legacy topics-table row."
|
|
755
763
|
},
|
|
756
764
|
baseRate: {
|
|
757
765
|
type: "number",
|
|
@@ -766,7 +774,7 @@ var CREATE_BELIEF = {
|
|
|
766
774
|
description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
|
|
767
775
|
}
|
|
768
776
|
},
|
|
769
|
-
required: ["canonicalText"],
|
|
777
|
+
required: ["canonicalText", "topicGlobalId"],
|
|
770
778
|
response: {
|
|
771
779
|
description: "The created canonical belief record",
|
|
772
780
|
fields: {
|
|
@@ -775,7 +783,7 @@ var CREATE_BELIEF = {
|
|
|
775
783
|
beliefId: "string \u2014 canonical belief ID",
|
|
776
784
|
text: "string \u2014 canonical belief formulation",
|
|
777
785
|
topicId: "string",
|
|
778
|
-
|
|
786
|
+
beliefStatus: "string \u2014 assumption | hypothesis | active | superseded | resolved_true | resolved_false",
|
|
779
787
|
scoringState: "string \u2014 unscored | scored"
|
|
780
788
|
}
|
|
781
789
|
},
|
|
@@ -798,7 +806,7 @@ var GET_BELIEF = {
|
|
|
798
806
|
beliefId: "string \u2014 canonical belief ID",
|
|
799
807
|
text: "string \u2014 canonical belief formulation",
|
|
800
808
|
topicId: "string",
|
|
801
|
-
|
|
809
|
+
beliefStatus: "string \u2014 assumption | hypothesis | active | superseded | resolved_true | resolved_false",
|
|
802
810
|
scoringState: "string \u2014 unscored | scored"
|
|
803
811
|
}
|
|
804
812
|
},
|
|
@@ -827,34 +835,24 @@ var REFINE_BELIEF = {
|
|
|
827
835
|
ontologyPrimitive: "belief",
|
|
828
836
|
tier: "showcase"
|
|
829
837
|
};
|
|
830
|
-
var
|
|
831
|
-
name: "
|
|
832
|
-
description: "Internal
|
|
838
|
+
var APPEND_SL_SCORING = {
|
|
839
|
+
name: "append_sl_scoring",
|
|
840
|
+
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.",
|
|
833
841
|
parameters: {
|
|
834
|
-
nodeId: { type: "string", description: "The belief
|
|
835
|
-
belief: {
|
|
836
|
-
type: "number",
|
|
837
|
-
description: "Subjective-logic belief mass `b` in [0, 1]"
|
|
838
|
-
},
|
|
842
|
+
nodeId: { type: "string", description: "The belief receiving the SL score" },
|
|
843
|
+
belief: { type: "number", description: "Subjective Logic belief mass b" },
|
|
839
844
|
disbelief: {
|
|
840
845
|
type: "number",
|
|
841
|
-
description: "Subjective
|
|
846
|
+
description: "Subjective Logic disbelief mass d"
|
|
842
847
|
},
|
|
843
848
|
uncertainty: {
|
|
844
849
|
type: "number",
|
|
845
|
-
description: "Subjective
|
|
846
|
-
},
|
|
847
|
-
baseRate: {
|
|
848
|
-
type: "number",
|
|
849
|
-
description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
|
|
850
|
-
},
|
|
851
|
-
worktreeId: {
|
|
852
|
-
type: "string",
|
|
853
|
-
description: "Completed worktree that tested this belief when confidence policy requires merge-backed scoring."
|
|
850
|
+
description: "Subjective Logic uncertainty mass u"
|
|
854
851
|
},
|
|
852
|
+
baseRate: { type: "number", description: "Subjective Logic base rate a" },
|
|
855
853
|
trigger: {
|
|
856
854
|
type: "string",
|
|
857
|
-
description: "
|
|
855
|
+
description: "Evidence-bearing cause of the scoring event",
|
|
858
856
|
enum: [
|
|
859
857
|
"evidence_added",
|
|
860
858
|
"evidence_removed",
|
|
@@ -865,64 +863,39 @@ var MODULATE_CONFIDENCE = {
|
|
|
865
863
|
"worktree_completed",
|
|
866
864
|
"fusion",
|
|
867
865
|
"discount",
|
|
868
|
-
"deduction"
|
|
866
|
+
"deduction",
|
|
867
|
+
"backfill_synthetic"
|
|
869
868
|
]
|
|
870
869
|
},
|
|
871
|
-
|
|
872
|
-
type: "
|
|
873
|
-
description: "
|
|
874
|
-
},
|
|
875
|
-
triggeringQuestionId: {
|
|
876
|
-
type: "string",
|
|
877
|
-
description: "Answered question whose resolution supports this modulation"
|
|
878
|
-
},
|
|
879
|
-
triggeringAnswerId: {
|
|
880
|
-
type: "string",
|
|
881
|
-
description: "Answer node whose content supports this modulation"
|
|
882
|
-
},
|
|
883
|
-
triggeringContradictionId: {
|
|
884
|
-
type: "string",
|
|
885
|
-
description: "Contradiction record that caused a contradiction-triggered modulation"
|
|
886
|
-
},
|
|
887
|
-
triggeringWorktreeId: {
|
|
888
|
-
type: "string",
|
|
889
|
-
description: "Completed worktree whose outcome caused a worktree-triggered modulation"
|
|
870
|
+
provenance: {
|
|
871
|
+
type: "object",
|
|
872
|
+
description: "At least one of evidence, question, answer, contradiction, or worktree."
|
|
890
873
|
},
|
|
891
874
|
rationale: {
|
|
892
875
|
type: "string",
|
|
893
|
-
description: "
|
|
876
|
+
description: "Why this evidence-bearing event moved the SL tuple"
|
|
894
877
|
}
|
|
895
878
|
},
|
|
896
|
-
required: [
|
|
897
|
-
"nodeId",
|
|
898
|
-
"belief",
|
|
899
|
-
"disbelief",
|
|
900
|
-
"uncertainty",
|
|
901
|
-
"baseRate",
|
|
902
|
-
"trigger",
|
|
903
|
-
"rationale"
|
|
904
|
-
],
|
|
879
|
+
required: ["nodeId", "belief", "disbelief", "uncertainty", "baseRate", "trigger", "rationale"],
|
|
905
880
|
response: {
|
|
906
|
-
description: "
|
|
881
|
+
description: "Internal SL scoring append receipt",
|
|
907
882
|
fields: {
|
|
908
|
-
|
|
909
|
-
nodeId: "string \u2014 canonical belief ID",
|
|
910
|
-
newConfidence: "number",
|
|
883
|
+
nodeId: "string",
|
|
911
884
|
previousConfidence: "number",
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
propagationSummary: "object \u2014 bounded inline cascade summary with totalCandidateTargets, inlineTargets, and remainingTargetCount"
|
|
885
|
+
newConfidence: "number",
|
|
886
|
+
beliefConfidenceId: "string"
|
|
915
887
|
}
|
|
916
888
|
},
|
|
917
889
|
ownerModule: "graph-primitives",
|
|
918
890
|
ontologyPrimitive: "belief",
|
|
919
|
-
tier: "
|
|
891
|
+
tier: "workhorse",
|
|
892
|
+
internal: true
|
|
920
893
|
};
|
|
921
894
|
var FORK_BELIEF = {
|
|
922
895
|
name: "fork_belief",
|
|
923
|
-
description: "Branch off
|
|
896
|
+
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.",
|
|
924
897
|
parameters: {
|
|
925
|
-
nodeId: { type: "string", description: "The
|
|
898
|
+
nodeId: { type: "string", description: "The belief to fork from" },
|
|
926
899
|
newFormulation: {
|
|
927
900
|
type: "string",
|
|
928
901
|
description: "The evolved belief statement"
|
|
@@ -934,12 +907,20 @@ var FORK_BELIEF = {
|
|
|
934
907
|
"refinement",
|
|
935
908
|
"contradiction_response",
|
|
936
909
|
"scope_change",
|
|
937
|
-
"confidence_collapse"
|
|
938
|
-
"manual"
|
|
910
|
+
"confidence_collapse"
|
|
939
911
|
]
|
|
912
|
+
},
|
|
913
|
+
forkMode: {
|
|
914
|
+
type: "string",
|
|
915
|
+
description: "supersede replaces the parent; branch creates a child while preserving the parent.",
|
|
916
|
+
enum: ["supersede", "branch"]
|
|
917
|
+
},
|
|
918
|
+
triggeringEvidenceId: {
|
|
919
|
+
type: "string",
|
|
920
|
+
description: "Evidence already attached to the parent belief that caused the fork."
|
|
940
921
|
}
|
|
941
922
|
},
|
|
942
|
-
required: ["nodeId", "newFormulation", "forkReason"],
|
|
923
|
+
required: ["nodeId", "newFormulation", "forkReason", "triggeringEvidenceId"],
|
|
943
924
|
response: {
|
|
944
925
|
description: "The forked canonical belief record",
|
|
945
926
|
fields: {
|
|
@@ -2204,7 +2185,7 @@ var TRIGGER_BELIEF_REVIEW = {
|
|
|
2204
2185
|
};
|
|
2205
2186
|
var EVALUATE_CONTRACT = {
|
|
2206
2187
|
name: "evaluate_contract",
|
|
2207
|
-
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
|
|
2188
|
+
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.",
|
|
2208
2189
|
parameters: {
|
|
2209
2190
|
contractId: { type: "string", description: "Which contract to evaluate" },
|
|
2210
2191
|
trigger: {
|
|
@@ -4078,6 +4059,10 @@ var COMPILE_CONTEXT = {
|
|
|
4078
4059
|
type: "number",
|
|
4079
4060
|
description: "Optional per-section item limit"
|
|
4080
4061
|
},
|
|
4062
|
+
contentTopicLimit: {
|
|
4063
|
+
type: "number",
|
|
4064
|
+
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."
|
|
4065
|
+
},
|
|
4081
4066
|
maxDepth: {
|
|
4082
4067
|
type: "number",
|
|
4083
4068
|
description: "Optional descendant topic depth for neighborhood expansion"
|
|
@@ -4091,6 +4076,11 @@ var COMPILE_CONTEXT = {
|
|
|
4091
4076
|
response: {
|
|
4092
4077
|
description: "Compiled context pack for the requested topic",
|
|
4093
4078
|
fields: {
|
|
4079
|
+
contextNarrative: "array \u2014 first field; ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
|
|
4080
|
+
narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, topicsSynthesized, topicsEnriched, topicContentOmitted, enrichmentMode, and blocksEmitted for the narrative",
|
|
4081
|
+
synthesisLints: "array \u2014 inline quality warnings for degenerate synthesis blocks or weak narrative coverage",
|
|
4082
|
+
retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
|
|
4083
|
+
supportingObjects: "object \u2014 raw graph records grouped behind the synthesis: invariants, activeBeliefs, openQuestions, recentEvidence, worktrees, lanes, entities, and contradictions",
|
|
4094
4084
|
schemaVersion: "string",
|
|
4095
4085
|
topicId: "string",
|
|
4096
4086
|
topicName: "string",
|
|
@@ -4098,15 +4088,6 @@ var COMPILE_CONTEXT = {
|
|
|
4098
4088
|
generatedAt: "number \u2014 deterministic graph-backed reference timestamp for this compilation",
|
|
4099
4089
|
ranking: "string \u2014 baseline_v1 | weighted_v1",
|
|
4100
4090
|
summary: "object \u2014 counts and scoped health signals",
|
|
4101
|
-
invariants: "array \u2014 high-confidence invariant beliefs",
|
|
4102
|
-
activeBeliefs: "array \u2014 current high-signal beliefs",
|
|
4103
|
-
openQuestions: "array \u2014 unresolved questions ranked for this query",
|
|
4104
|
-
recentEvidence: "array \u2014 recent evidence ranked for this query",
|
|
4105
|
-
contradictions: "array \u2014 unresolved contradiction records",
|
|
4106
|
-
relatedEntities: "array | undefined \u2014 ranked ontological entities in scope",
|
|
4107
|
-
contextNarrative: "array \u2014 ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
|
|
4108
|
-
retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
|
|
4109
|
-
narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, and blocksEmitted for the narrative",
|
|
4110
4091
|
injectionPolicy: "object \u2014 token-budgeted section selections",
|
|
4111
4092
|
diagnostics: "object \u2014 scoring and utilization telemetry"
|
|
4112
4093
|
}
|
|
@@ -4665,7 +4646,7 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
4665
4646
|
create_belief: CREATE_BELIEF,
|
|
4666
4647
|
get_belief: GET_BELIEF,
|
|
4667
4648
|
refine_belief: REFINE_BELIEF,
|
|
4668
|
-
|
|
4649
|
+
append_sl_scoring: APPEND_SL_SCORING,
|
|
4669
4650
|
fork_belief: FORK_BELIEF,
|
|
4670
4651
|
archive_belief: ARCHIVE_BELIEF,
|
|
4671
4652
|
create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
|
|
@@ -6463,8 +6444,10 @@ defineTable({
|
|
|
6463
6444
|
"beliefStatus": z.object({
|
|
6464
6445
|
"assumption": z.number(),
|
|
6465
6446
|
"hypothesis": z.number(),
|
|
6466
|
-
"
|
|
6467
|
-
"
|
|
6447
|
+
"active": z.number(),
|
|
6448
|
+
"superseded": z.number(),
|
|
6449
|
+
"resolved_true": z.number(),
|
|
6450
|
+
"resolved_false": z.number()
|
|
6468
6451
|
}).optional(),
|
|
6469
6452
|
"evidenceTemporalNature": z.object({
|
|
6470
6453
|
"factual": z.number(),
|
|
@@ -6686,8 +6669,8 @@ defineTable({
|
|
|
6686
6669
|
"exportClass": z.enum(["internal_only", "client_safe", "public_safe", "restricted"]).optional(),
|
|
6687
6670
|
"anonymizationClass": z.enum(["none", "standard", "strict"]).optional(),
|
|
6688
6671
|
"beliefType": z.string().optional(),
|
|
6689
|
-
"beliefStatus": z.enum(["assumption", "hypothesis", "
|
|
6690
|
-
"epistemicStatus": z.enum(["
|
|
6672
|
+
"beliefStatus": z.enum(["assumption", "hypothesis", "active", "superseded", "resolved_true", "resolved_false"]).optional(),
|
|
6673
|
+
"epistemicStatus": z.enum(["assumption", "hypothesis", "active", "superseded", "resolved_true", "resolved_false"]).optional(),
|
|
6691
6674
|
"reversibility": z.enum(["irreversible", "hard_to_reverse", "reversible", "trivial"]).optional(),
|
|
6692
6675
|
"predictionMeta": z.object({
|
|
6693
6676
|
"isPrediction": z.boolean(),
|
|
@@ -11783,11 +11766,39 @@ var createEvidenceInputSchemaBase = z.object({
|
|
|
11783
11766
|
metadata: jsonRecordSchema.optional(),
|
|
11784
11767
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
11785
11768
|
}).passthrough();
|
|
11786
|
-
function
|
|
11787
|
-
return typeof value === "number" && Number.isFinite(value) && value !== 0;
|
|
11769
|
+
function isSignedImpactScore(value) {
|
|
11770
|
+
return typeof value === "number" && Number.isFinite(value) && value >= -1 && value <= 1 && value !== 0;
|
|
11788
11771
|
}
|
|
11789
|
-
function
|
|
11790
|
-
|
|
11772
|
+
function validateSignedImpactScore(value, ctx, path) {
|
|
11773
|
+
if (!isSignedImpactScore(value)) {
|
|
11774
|
+
ctx.addIssue({
|
|
11775
|
+
code: z.ZodIssueCode.custom,
|
|
11776
|
+
message: "evidence-to-belief links require an explicit nonzero signed impact score in [-1, 1]",
|
|
11777
|
+
path
|
|
11778
|
+
});
|
|
11779
|
+
return false;
|
|
11780
|
+
}
|
|
11781
|
+
return true;
|
|
11782
|
+
}
|
|
11783
|
+
function validateRelationImpactConsistency(relation, weight, ctx, path) {
|
|
11784
|
+
const normalized = normalizeRelationAlias(relation);
|
|
11785
|
+
if (!normalized || !isSignedImpactScore(weight)) {
|
|
11786
|
+
return;
|
|
11787
|
+
}
|
|
11788
|
+
if (normalized === "supports" && weight < 0) {
|
|
11789
|
+
ctx.addIssue({
|
|
11790
|
+
code: z.ZodIssueCode.custom,
|
|
11791
|
+
message: "supporting evidence requires a positive impact score",
|
|
11792
|
+
path
|
|
11793
|
+
});
|
|
11794
|
+
}
|
|
11795
|
+
if (normalized === "contradicts" && weight > 0) {
|
|
11796
|
+
ctx.addIssue({
|
|
11797
|
+
code: z.ZodIssueCode.custom,
|
|
11798
|
+
message: "contradicting evidence requires a negative impact score",
|
|
11799
|
+
path
|
|
11800
|
+
});
|
|
11801
|
+
}
|
|
11791
11802
|
}
|
|
11792
11803
|
var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
11793
11804
|
(input, ctx) => {
|
|
@@ -11804,13 +11815,27 @@ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
|
11804
11815
|
input.linkedBeliefNodeId || kind === "belief" || kind === "unknown" && target
|
|
11805
11816
|
);
|
|
11806
11817
|
const weight = typeof input.weight === "number" ? input.weight : void 0;
|
|
11807
|
-
|
|
11818
|
+
const hasBeliefRelations = (input.beliefRelations?.length ?? 0) > 0;
|
|
11819
|
+
if (!linksPrimaryBelief && !hasBeliefRelations) {
|
|
11820
|
+
ctx.addIssue({
|
|
11821
|
+
code: z.ZodIssueCode.custom,
|
|
11822
|
+
message: "create_evidence requires at least one linked belief; evidence cannot be created as an orphan or linked only to a question/worktree",
|
|
11823
|
+
path: ["linkedBeliefNodeId"]
|
|
11824
|
+
});
|
|
11825
|
+
}
|
|
11826
|
+
if (kind === "question" || kind === "worktree") {
|
|
11808
11827
|
ctx.addIssue({
|
|
11809
11828
|
code: z.ZodIssueCode.custom,
|
|
11810
|
-
message: "belief
|
|
11811
|
-
path: ["
|
|
11829
|
+
message: "create_evidence targetId must be a belief. Link evidence to questions/worktrees only after the evidence has a belief impact edge.",
|
|
11830
|
+
path: ["targetId"]
|
|
11812
11831
|
});
|
|
11813
11832
|
}
|
|
11833
|
+
if (linksPrimaryBelief) {
|
|
11834
|
+
validateSignedImpactScore(weight, ctx, ["weight"]);
|
|
11835
|
+
validateRelationImpactConsistency(input.evidenceRelation, weight, ctx, [
|
|
11836
|
+
"weight"
|
|
11837
|
+
]);
|
|
11838
|
+
}
|
|
11814
11839
|
input.beliefRelations?.forEach((relation, index) => {
|
|
11815
11840
|
const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
|
|
11816
11841
|
if (!beliefNodeId) {
|
|
@@ -11821,15 +11846,18 @@ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
|
11821
11846
|
});
|
|
11822
11847
|
}
|
|
11823
11848
|
const relationWeight2 = typeof relation.weight === "number" ? relation.weight : void 0;
|
|
11824
|
-
if (beliefNodeId
|
|
11825
|
-
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
11832
|
-
|
|
11849
|
+
if (beliefNodeId) {
|
|
11850
|
+
validateSignedImpactScore(relationWeight2, ctx, [
|
|
11851
|
+
"beliefRelations",
|
|
11852
|
+
index,
|
|
11853
|
+
"weight"
|
|
11854
|
+
]);
|
|
11855
|
+
validateRelationImpactConsistency(
|
|
11856
|
+
relation.evidenceRelation ?? relation.relation,
|
|
11857
|
+
relationWeight2,
|
|
11858
|
+
ctx,
|
|
11859
|
+
["beliefRelations", index, "weight"]
|
|
11860
|
+
);
|
|
11833
11861
|
}
|
|
11834
11862
|
});
|
|
11835
11863
|
}
|
|
@@ -11883,18 +11911,28 @@ function targetKind(targetId) {
|
|
|
11883
11911
|
}
|
|
11884
11912
|
return "unknown";
|
|
11885
11913
|
}
|
|
11886
|
-
function
|
|
11914
|
+
function normalizeRelationAlias(value) {
|
|
11887
11915
|
if (value === "supports" || value === "supporting") {
|
|
11888
11916
|
return "supports";
|
|
11889
11917
|
}
|
|
11890
11918
|
if (value === "contradicts" || value === "contradicting") {
|
|
11891
11919
|
return "contradicts";
|
|
11892
11920
|
}
|
|
11921
|
+
return void 0;
|
|
11922
|
+
}
|
|
11923
|
+
function normalizeRelation(value, weight) {
|
|
11924
|
+
const alias = normalizeRelationAlias(value);
|
|
11925
|
+
if (alias) {
|
|
11926
|
+
return alias;
|
|
11927
|
+
}
|
|
11893
11928
|
if (weight === void 0 || !hasNonzeroWeight(weight)) {
|
|
11894
11929
|
return void 0;
|
|
11895
11930
|
}
|
|
11896
11931
|
return weight < 0 ? "contradicts" : "supports";
|
|
11897
11932
|
}
|
|
11933
|
+
function hasNonzeroWeight(value) {
|
|
11934
|
+
return typeof value === "number" && Number.isFinite(value) && value !== 0;
|
|
11935
|
+
}
|
|
11898
11936
|
function normalizeConfidence(confidence, weight) {
|
|
11899
11937
|
if (confidence !== void 0) {
|
|
11900
11938
|
return Math.min(1, Math.max(0, confidence));
|
|
@@ -11921,6 +11959,7 @@ function normalizeBeliefRelation(relation) {
|
|
|
11921
11959
|
beliefNodeId,
|
|
11922
11960
|
relation: evidenceRelation,
|
|
11923
11961
|
confidence: normalizeConfidence(relation.confidence, weight),
|
|
11962
|
+
weight,
|
|
11924
11963
|
rationale: relation.rationale
|
|
11925
11964
|
});
|
|
11926
11965
|
}
|
|
@@ -11969,6 +12008,7 @@ var createEvidenceProjection = defineProjection({
|
|
|
11969
12008
|
linkedBeliefNodeId,
|
|
11970
12009
|
evidenceRelation,
|
|
11971
12010
|
confidence,
|
|
12011
|
+
weight,
|
|
11972
12012
|
beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
|
|
11973
12013
|
rationale: input.rationale,
|
|
11974
12014
|
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
@@ -11998,12 +12038,14 @@ var createEvidenceProjection = defineProjection({
|
|
|
11998
12038
|
v.literal("contradicts")
|
|
11999
12039
|
)
|
|
12000
12040
|
),
|
|
12041
|
+
weight: v.optional(v.number()),
|
|
12001
12042
|
beliefRelations: v.optional(
|
|
12002
12043
|
v.array(
|
|
12003
12044
|
v.object({
|
|
12004
12045
|
beliefNodeId: v.string(),
|
|
12005
12046
|
relation: v.union(v.literal("supports"), v.literal("contradicts")),
|
|
12006
12047
|
confidence: v.optional(v.number()),
|
|
12048
|
+
weight: v.number(),
|
|
12007
12049
|
rationale: v.optional(v.string())
|
|
12008
12050
|
})
|
|
12009
12051
|
)
|
|
@@ -12121,7 +12163,7 @@ var slOpinionProjectionSchema = z.object({
|
|
|
12121
12163
|
uncertainty: z.number(),
|
|
12122
12164
|
baseRate: z.number()
|
|
12123
12165
|
});
|
|
12124
|
-
var
|
|
12166
|
+
var appendSlScoringInputObjectSchema = z.object({
|
|
12125
12167
|
nodeId: z.string().optional(),
|
|
12126
12168
|
beliefNodeId: z.string().optional(),
|
|
12127
12169
|
worktreeId: z.string().optional(),
|
|
@@ -12140,23 +12182,23 @@ var modulateConfidenceInputObjectSchema = z.object({
|
|
|
12140
12182
|
rationale: z.string(),
|
|
12141
12183
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
12142
12184
|
});
|
|
12143
|
-
var
|
|
12185
|
+
var appendSlScoringInputSchema = appendSlScoringInputObjectSchema.superRefine((input, ctx) => {
|
|
12144
12186
|
if (hasProvenance(input)) {
|
|
12145
12187
|
return;
|
|
12146
12188
|
}
|
|
12147
12189
|
ctx.addIssue({
|
|
12148
12190
|
code: z.ZodIssueCode.custom,
|
|
12149
|
-
message: "
|
|
12191
|
+
message: "append_sl_scoring requires evidence, question, answer, contradiction, or worktree provenance",
|
|
12150
12192
|
path: ["provenance"]
|
|
12151
12193
|
});
|
|
12152
12194
|
});
|
|
12153
|
-
var
|
|
12154
|
-
contractName: "
|
|
12155
|
-
inputSchema:
|
|
12195
|
+
var appendSlScoringProjection = defineProjection({
|
|
12196
|
+
contractName: "append_sl_scoring",
|
|
12197
|
+
inputSchema: appendSlScoringInputSchema,
|
|
12156
12198
|
project: (input) => {
|
|
12157
12199
|
const nodeId = input.beliefNodeId ?? input.nodeId;
|
|
12158
12200
|
if (!nodeId) {
|
|
12159
|
-
throw new Error("
|
|
12201
|
+
throw new Error("append_sl_scoring requires beliefNodeId or nodeId");
|
|
12160
12202
|
}
|
|
12161
12203
|
const opinion = input.opinion ?? {
|
|
12162
12204
|
belief: requireNumber(input.belief, "belief"),
|
|
@@ -12213,14 +12255,14 @@ var modulateConfidenceProjection = defineProjection({
|
|
|
12213
12255
|
});
|
|
12214
12256
|
function requireNumber(value, field) {
|
|
12215
12257
|
if (value === void 0) {
|
|
12216
|
-
throw new Error(`
|
|
12258
|
+
throw new Error(`append_sl_scoring requires ${field}`);
|
|
12217
12259
|
}
|
|
12218
12260
|
return value;
|
|
12219
12261
|
}
|
|
12220
12262
|
function assertProvenance(input) {
|
|
12221
12263
|
if (!hasProvenance(input)) {
|
|
12222
12264
|
throw new Error(
|
|
12223
|
-
"
|
|
12265
|
+
"append_sl_scoring requires evidence, question, answer, contradiction, or worktree provenance"
|
|
12224
12266
|
);
|
|
12225
12267
|
}
|
|
12226
12268
|
}
|
|
@@ -12563,12 +12605,12 @@ var LUCERN_OPERATION_MANIFEST = {
|
|
|
12563
12605
|
internalSystem,
|
|
12564
12606
|
"Lucern system/background operation. Available to platform code paths, hidden from public MCP discovery."
|
|
12565
12607
|
),
|
|
12566
|
-
|
|
12567
|
-
name: "
|
|
12608
|
+
append_sl_scoring: {
|
|
12609
|
+
name: "append_sl_scoring",
|
|
12568
12610
|
surfaceClass: "platform_internal",
|
|
12569
12611
|
surfaceIntent: "system",
|
|
12570
12612
|
surfaces: internalSdkRestOnly,
|
|
12571
|
-
rationale: "Internal SL
|
|
12613
|
+
rationale: "Internal SL scoring append primitive. Public callers attach evidence or contradiction relations; confidence is derived algorithmically."
|
|
12572
12614
|
},
|
|
12573
12615
|
...entries(
|
|
12574
12616
|
LEGACY_COMPAT_OPERATION_NAMES,
|
|
@@ -13122,7 +13164,15 @@ var predictionMetaSchema = z.object({
|
|
|
13122
13164
|
});
|
|
13123
13165
|
var createBeliefArgs = z.object({
|
|
13124
13166
|
canonicalText: z.string().describe("The belief statement the agent holds to be true."),
|
|
13125
|
-
|
|
13167
|
+
topicGlobalId: z.string().describe(
|
|
13168
|
+
"Required globalId of the topic epistemicNode that anchors this belief. Belief creation creates a scoped_by edge directly to that topic node."
|
|
13169
|
+
),
|
|
13170
|
+
topicNodeId: z.string().optional().describe(
|
|
13171
|
+
"Optional internal epistemicNodes _id for the topic anchor. Prefer topicGlobalId for public callers."
|
|
13172
|
+
),
|
|
13173
|
+
topicId: z.string().optional().describe(
|
|
13174
|
+
"Deprecated compatibility alias for topicGlobalId. Must identify a topic epistemicNode, not a legacy topics-table row."
|
|
13175
|
+
),
|
|
13126
13176
|
baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
|
|
13127
13177
|
beliefType: z.string().optional().describe("Schema belief type."),
|
|
13128
13178
|
metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
|
|
@@ -13141,9 +13191,14 @@ var forkBeliefArgs = z.object({
|
|
|
13141
13191
|
"refinement",
|
|
13142
13192
|
"contradiction_response",
|
|
13143
13193
|
"scope_change",
|
|
13144
|
-
"confidence_collapse"
|
|
13145
|
-
"manual"
|
|
13194
|
+
"confidence_collapse"
|
|
13146
13195
|
]).describe("Why this fork was created."),
|
|
13196
|
+
forkMode: z.enum(["supersede", "branch"]).optional().describe(
|
|
13197
|
+
"supersede marks the parent belief superseded; branch preserves the parent and creates a derived child."
|
|
13198
|
+
),
|
|
13199
|
+
triggeringEvidenceId: z.string().describe(
|
|
13200
|
+
"Evidence already attached to the parent belief through SL scoring; required for every fork."
|
|
13201
|
+
),
|
|
13147
13202
|
rationale: z.string().optional().describe("Why the fork is warranted.")
|
|
13148
13203
|
});
|
|
13149
13204
|
var beliefLookupInput = (input) => compactRecord4({
|
|
@@ -13157,7 +13212,9 @@ var createBeliefInput = (input, context) => {
|
|
|
13157
13212
|
return withUserId(
|
|
13158
13213
|
compactRecord4({
|
|
13159
13214
|
projectId: input.projectId,
|
|
13160
|
-
topicId: input.topicId,
|
|
13215
|
+
topicId: input.topicGlobalId ?? input.topicNodeId ?? input.topicId,
|
|
13216
|
+
topicGlobalId: input.topicGlobalId,
|
|
13217
|
+
topicNodeId: input.topicNodeId,
|
|
13161
13218
|
formulation: input.formulation ?? input.canonicalText,
|
|
13162
13219
|
beliefType: input.beliefType,
|
|
13163
13220
|
rationale: input.rationale,
|
|
@@ -13179,20 +13236,22 @@ var forkBeliefInput = (input, context) => withUserId(
|
|
|
13179
13236
|
parentNodeId: input.parentNodeId ?? input.nodeId ?? input.id,
|
|
13180
13237
|
newFormulation: input.newFormulation,
|
|
13181
13238
|
forkReason: input.forkReason,
|
|
13239
|
+
forkMode: input.forkMode,
|
|
13240
|
+
triggeringEvidenceId: input.triggeringEvidenceId,
|
|
13182
13241
|
rationale: input.rationale,
|
|
13183
13242
|
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
13184
13243
|
}),
|
|
13185
13244
|
context
|
|
13186
13245
|
);
|
|
13187
|
-
var
|
|
13188
|
-
const parsed =
|
|
13246
|
+
var appendSlScoringInput = (input, context) => {
|
|
13247
|
+
const parsed = appendSlScoringProjection.inputSchema.safeParse(input);
|
|
13189
13248
|
if (!parsed.success) {
|
|
13190
13249
|
throw new Error(
|
|
13191
|
-
`
|
|
13250
|
+
`append_sl_scoring projection input rejected: ${parsed.error.message}`
|
|
13192
13251
|
);
|
|
13193
13252
|
}
|
|
13194
13253
|
return withUserId(
|
|
13195
|
-
compactRecord4(
|
|
13254
|
+
compactRecord4(appendSlScoringProjection.project(parsed.data)),
|
|
13196
13255
|
context
|
|
13197
13256
|
);
|
|
13198
13257
|
};
|
|
@@ -13270,21 +13329,21 @@ var beliefsContracts = [
|
|
|
13270
13329
|
}
|
|
13271
13330
|
}),
|
|
13272
13331
|
surfaceContract({
|
|
13273
|
-
name: "
|
|
13332
|
+
name: "append_sl_scoring",
|
|
13274
13333
|
kind: "mutation",
|
|
13275
13334
|
domain: "beliefs",
|
|
13276
13335
|
surfaceClass: "platform_internal",
|
|
13277
|
-
path: "/beliefs/
|
|
13336
|
+
path: "/beliefs/sl-scoring",
|
|
13278
13337
|
sdkNamespace: "beliefs",
|
|
13279
|
-
sdkMethod: "
|
|
13280
|
-
summary: "Internal SL
|
|
13338
|
+
sdkMethod: "appendSlScoring",
|
|
13339
|
+
summary: "Internal SL scoring append. Public callers attach evidence or contradiction relations instead.",
|
|
13281
13340
|
convex: {
|
|
13282
13341
|
module: "beliefs",
|
|
13283
|
-
functionName: "
|
|
13342
|
+
functionName: "appendSlScoring",
|
|
13284
13343
|
kind: "mutation",
|
|
13285
|
-
inputProjection:
|
|
13344
|
+
inputProjection: appendSlScoringInput
|
|
13286
13345
|
},
|
|
13287
|
-
args:
|
|
13346
|
+
args: appendSlScoringInputSchema
|
|
13288
13347
|
}),
|
|
13289
13348
|
surfaceContract({
|
|
13290
13349
|
name: "fork_belief",
|
|
@@ -13390,8 +13449,12 @@ var beliefRelationSchema2 = z.object({
|
|
|
13390
13449
|
targetId: z.string().optional().describe("Belief target ID alias for beliefId/beliefNodeId."),
|
|
13391
13450
|
relation: z.enum(["supports", "contradicts", "supporting", "contradicting"]).optional().describe("Relation alias for how the evidence bears on the belief."),
|
|
13392
13451
|
evidenceRelation: evidenceRelationSchema2.optional().describe("Canonical relation: supports or contradicts."),
|
|
13393
|
-
confidence: z.number().optional().describe(
|
|
13394
|
-
|
|
13452
|
+
confidence: z.number().optional().describe(
|
|
13453
|
+
"Deprecated read-only hint. Runtime SL confidence is derived from signed weight."
|
|
13454
|
+
),
|
|
13455
|
+
weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
|
|
13456
|
+
message: "Evidence impact weight must be nonzero."
|
|
13457
|
+
}).describe("Required signed impact score from -1.0 to +1.0 for this belief."),
|
|
13395
13458
|
rationale: z.string().optional().describe("Why this relation exists.")
|
|
13396
13459
|
});
|
|
13397
13460
|
var createEvidenceArgs = z.object({
|
|
@@ -13400,7 +13463,7 @@ var createEvidenceArgs = z.object({
|
|
|
13400
13463
|
source: z.string().optional().describe("Source URL or source label."),
|
|
13401
13464
|
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
13402
13465
|
targetId: z.string().optional().describe(
|
|
13403
|
-
"Belief
|
|
13466
|
+
"Belief identifier to link immediately. Evidence creation cannot target only a question or worktree."
|
|
13404
13467
|
),
|
|
13405
13468
|
linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
|
|
13406
13469
|
evidenceRelation: evidenceRelationSchema2.optional().describe(
|
|
@@ -13409,8 +13472,14 @@ var createEvidenceArgs = z.object({
|
|
|
13409
13472
|
beliefRelations: z.array(beliefRelationSchema2).optional().describe(
|
|
13410
13473
|
"Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
|
|
13411
13474
|
),
|
|
13412
|
-
confidence: z.number().optional().describe(
|
|
13413
|
-
|
|
13475
|
+
confidence: z.number().optional().describe(
|
|
13476
|
+
"Deprecated hint. Runtime confidence is derived from signed weight."
|
|
13477
|
+
),
|
|
13478
|
+
weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
|
|
13479
|
+
message: "Evidence impact weight must be nonzero."
|
|
13480
|
+
}).describe(
|
|
13481
|
+
"Required signed impact score from -1.0 to +1.0 for targetId/linkedBeliefNodeId."
|
|
13482
|
+
),
|
|
13414
13483
|
metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
|
|
13415
13484
|
rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
|
|
13416
13485
|
reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
|
|
@@ -13432,7 +13501,9 @@ var addEvidenceArgs = z.object({
|
|
|
13432
13501
|
topicId: z.string().optional().describe("Topic scope hint."),
|
|
13433
13502
|
sourceUrl: z.string().optional().describe("URL of the source material."),
|
|
13434
13503
|
targetNodeId: z.string().describe("The belief this evidence bears on."),
|
|
13435
|
-
weight: z.number().
|
|
13504
|
+
weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
|
|
13505
|
+
message: "Evidence impact weight must be nonzero."
|
|
13506
|
+
}).describe("Required signed impact score from -1.0 to +1.0."),
|
|
13436
13507
|
reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
|
|
13437
13508
|
title: z.string().optional().describe("Optional short title."),
|
|
13438
13509
|
content: z.string().optional().describe("Optional long-form evidence content."),
|
|
@@ -13452,19 +13523,21 @@ var createEvidenceInput = (input, context) => {
|
|
|
13452
13523
|
);
|
|
13453
13524
|
};
|
|
13454
13525
|
function relationWeight(input) {
|
|
13455
|
-
if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
|
|
13526
|
+
if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0 && input.weight >= -1 && input.weight <= 1) {
|
|
13527
|
+
const relation = String(
|
|
13528
|
+
input.evidenceRelation ?? input.relation ?? input.type ?? ""
|
|
13529
|
+
);
|
|
13530
|
+
if ((relation === "supports" || relation === "supporting") && input.weight < 0) {
|
|
13531
|
+
throw new Error("Supporting evidence links require positive weight.");
|
|
13532
|
+
}
|
|
13533
|
+
if ((relation === "contradicts" || relation === "contradicting") && input.weight > 0) {
|
|
13534
|
+
throw new Error("Contradicting evidence links require negative weight.");
|
|
13535
|
+
}
|
|
13456
13536
|
return input.weight;
|
|
13457
13537
|
}
|
|
13458
|
-
|
|
13459
|
-
|
|
13538
|
+
throw new Error(
|
|
13539
|
+
"Belief evidence links require explicit nonzero weight in [-1, 1]."
|
|
13460
13540
|
);
|
|
13461
|
-
if (relation !== "supports" && relation !== "supporting" && relation !== "contradicts" && relation !== "contradicting") {
|
|
13462
|
-
throw new Error(
|
|
13463
|
-
"Belief evidence links require evidenceRelation='supports'|'contradicts' or a nonzero signed weight."
|
|
13464
|
-
);
|
|
13465
|
-
}
|
|
13466
|
-
const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
|
|
13467
|
-
return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
|
|
13468
13541
|
}
|
|
13469
13542
|
var linkEvidenceToBeliefInput = (input, context) => {
|
|
13470
13543
|
const weight = relationWeight(input);
|
|
@@ -13473,6 +13546,7 @@ var linkEvidenceToBeliefInput = (input, context) => {
|
|
|
13473
13546
|
beliefNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
|
|
13474
13547
|
insightId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
|
|
13475
13548
|
type: weight < 0 ? "contradicting" : "supporting",
|
|
13549
|
+
weight,
|
|
13476
13550
|
confidence: Math.min(1, Math.abs(weight)),
|
|
13477
13551
|
rationale: input.rationale ?? input.context,
|
|
13478
13552
|
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
@@ -13549,7 +13623,12 @@ var evidenceContracts = [
|
|
|
13549
13623
|
functionName: "create",
|
|
13550
13624
|
kind: "mutation",
|
|
13551
13625
|
inputProjection: (input, context) => {
|
|
13552
|
-
|
|
13626
|
+
if (typeof input.weight !== "number" || !Number.isFinite(input.weight) || input.weight === 0 || input.weight < -1 || input.weight > 1) {
|
|
13627
|
+
throw new Error(
|
|
13628
|
+
"add_evidence requires explicit nonzero weight in [-1, 1]."
|
|
13629
|
+
);
|
|
13630
|
+
}
|
|
13631
|
+
const weight = input.weight;
|
|
13553
13632
|
return createEvidenceInput(
|
|
13554
13633
|
{
|
|
13555
13634
|
...input,
|
|
@@ -13558,6 +13637,7 @@ var evidenceContracts = [
|
|
|
13558
13637
|
linkedBeliefNodeId: input.linkedBeliefNodeId ?? input.targetNodeId ?? input.targetId,
|
|
13559
13638
|
evidenceRelation: weight < 0 ? "contradicts" : "supports",
|
|
13560
13639
|
confidence: Math.min(1, Math.max(0, Math.abs(weight))),
|
|
13640
|
+
weight,
|
|
13561
13641
|
rationale: input.reasoning,
|
|
13562
13642
|
metadata: {
|
|
13563
13643
|
...recordValue2(input.metadata),
|