@lucern/contracts 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.
Files changed (116) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/dist/api-enums.contract.d.ts +2 -2
  3. package/dist/api-enums.contract.js +2 -8
  4. package/dist/api-enums.contract.js.map +1 -1
  5. package/dist/context-pack.contract.d.ts +27 -7
  6. package/dist/context-pack.contract.js.map +1 -1
  7. package/dist/function-registry/beliefs.js +109 -115
  8. package/dist/function-registry/beliefs.js.map +1 -1
  9. package/dist/function-registry/coding.js +68 -91
  10. package/dist/function-registry/coding.js.map +1 -1
  11. package/dist/function-registry/context.js +68 -91
  12. package/dist/function-registry/context.js.map +1 -1
  13. package/dist/function-registry/contracts.js +68 -91
  14. package/dist/function-registry/contracts.js.map +1 -1
  15. package/dist/function-registry/coordination.js +68 -91
  16. package/dist/function-registry/coordination.js.map +1 -1
  17. package/dist/function-registry/edges.js +68 -91
  18. package/dist/function-registry/edges.js.map +1 -1
  19. package/dist/function-registry/evidence.js +182 -125
  20. package/dist/function-registry/evidence.js.map +1 -1
  21. package/dist/function-registry/graph.js +68 -91
  22. package/dist/function-registry/graph.js.map +1 -1
  23. package/dist/function-registry/helpers.js +68 -91
  24. package/dist/function-registry/helpers.js.map +1 -1
  25. package/dist/function-registry/identity.js +68 -91
  26. package/dist/function-registry/identity.js.map +1 -1
  27. package/dist/function-registry/index.js +68 -91
  28. package/dist/function-registry/index.js.map +1 -1
  29. package/dist/function-registry/judgments.js +68 -91
  30. package/dist/function-registry/judgments.js.map +1 -1
  31. package/dist/function-registry/legacy.js +68 -91
  32. package/dist/function-registry/legacy.js.map +1 -1
  33. package/dist/function-registry/lenses.js +68 -91
  34. package/dist/function-registry/lenses.js.map +1 -1
  35. package/dist/function-registry/manifest.d.ts +3 -3
  36. package/dist/function-registry/manifest.js +3 -3
  37. package/dist/function-registry/manifest.js.map +1 -1
  38. package/dist/function-registry/nodes.js +68 -91
  39. package/dist/function-registry/nodes.js.map +1 -1
  40. package/dist/function-registry/ontologies.js +68 -91
  41. package/dist/function-registry/ontologies.js.map +1 -1
  42. package/dist/function-registry/pipeline.js +68 -91
  43. package/dist/function-registry/pipeline.js.map +1 -1
  44. package/dist/function-registry/questions.js +68 -91
  45. package/dist/function-registry/questions.js.map +1 -1
  46. package/dist/function-registry/tasks.js +68 -91
  47. package/dist/function-registry/tasks.js.map +1 -1
  48. package/dist/function-registry/topics.js +68 -91
  49. package/dist/function-registry/topics.js.map +1 -1
  50. package/dist/function-registry/worktrees.js +68 -91
  51. package/dist/function-registry/worktrees.js.map +1 -1
  52. package/dist/generated/convexSchemas.js +2 -2
  53. package/dist/generated/convexSchemas.js.map +1 -1
  54. package/dist/index.d.ts +4 -4
  55. package/dist/index.js +162 -130
  56. package/dist/index.js.map +1 -1
  57. package/dist/manifests/invariant-manifest.d.ts +1 -1
  58. package/dist/manifests/invariants/index.d.ts +1 -1
  59. package/dist/manifests/invariants/index.js +1 -1
  60. package/dist/manifests/invariants/index.js.map +1 -1
  61. package/dist/manifests/invariants/inv-1-beliefs-append-only.d.ts +1 -1
  62. package/dist/manifests/invariants/inv-14-no-silent-transitions.d.ts +1 -1
  63. package/dist/manifests/invariants/manifest-1-projections-declare-audit.d.ts +1 -1
  64. package/dist/manifests/invariants/manifest-1-projections-declare-audit.js +1 -1
  65. package/dist/manifests/invariants/manifest-1-projections-declare-audit.js.map +1 -1
  66. package/dist/projections/{modulate-confidence.projection.d.ts → append-sl-scoring.projection.d.ts} +69 -69
  67. package/dist/projections/{modulate-confidence.projection.js → append-sl-scoring.projection.js} +14 -14
  68. package/dist/projections/append-sl-scoring.projection.js.map +1 -0
  69. package/dist/projections/check-convex-args-shape.js +88 -29
  70. package/dist/projections/check-convex-args-shape.js.map +1 -1
  71. package/dist/projections/create-evidence.projection.js +76 -17
  72. package/dist/projections/create-evidence.projection.js.map +1 -1
  73. package/dist/projections/index.d.ts +47 -47
  74. package/dist/projections/index.js +88 -29
  75. package/dist/projections/index.js.map +1 -1
  76. package/dist/proof-attestation.json +3 -3
  77. package/dist/schemas/index.js +6 -4
  78. package/dist/schemas/index.js.map +1 -1
  79. package/dist/schemas/manifest.d.ts +110 -60
  80. package/dist/schemas/manifest.js +6 -4
  81. package/dist/schemas/manifest.js.map +1 -1
  82. package/dist/schemas/tables/kernel/intelligence.d.ts +20 -10
  83. package/dist/schemas/tables/kernel/intelligence.js +4 -2
  84. package/dist/schemas/tables/kernel/intelligence.js.map +1 -1
  85. package/dist/schemas/tables/kernel/spine.d.ts +2 -2
  86. package/dist/schemas/tables/kernel/spine.js +2 -2
  87. package/dist/schemas/tables/kernel/spine.js.map +1 -1
  88. package/dist/schemas.values.js +6 -4
  89. package/dist/schemas.values.js.map +1 -1
  90. package/dist/sdk-methods.contract.d.ts +6 -16
  91. package/dist/sdk-tools.contract.js +65 -88
  92. package/dist/sdk-tools.contract.js.map +1 -1
  93. package/dist/sdk-tools.contract.registry.js +65 -88
  94. package/dist/sdk-tools.contract.registry.js.map +1 -1
  95. package/dist/sdk-tools.contract.values.js +65 -88
  96. package/dist/sdk-tools.contract.values.js.map +1 -1
  97. package/dist/tool-contracts.d.ts +1 -1
  98. package/dist/tool-contracts.graph.js +3 -3
  99. package/dist/tool-contracts.graph.js.map +1 -1
  100. package/dist/tool-contracts.intelligence-evidence.js +7 -7
  101. package/dist/tool-contracts.intelligence-evidence.js.map +1 -1
  102. package/dist/tool-contracts.js +66 -89
  103. package/dist/tool-contracts.js.map +1 -1
  104. package/dist/tool-contracts.lifecycle.d.ts +2 -2
  105. package/dist/tool-contracts.lifecycle.js +49 -68
  106. package/dist/tool-contracts.lifecycle.js.map +1 -1
  107. package/dist/tool-contracts.pipeline-coordination.js +1 -1
  108. package/dist/tool-contracts.pipeline-coordination.js.map +1 -1
  109. package/dist/tool-contracts.questions-listing.js +5 -9
  110. package/dist/tool-contracts.questions-listing.js.map +1 -1
  111. package/dist/{tool-contracts.values-BhxfrXS5.d.ts → tool-contracts.values-CCoI3qQY.d.ts} +3 -3
  112. package/dist/tool-contracts.values.d.ts +1 -1
  113. package/dist/tool-contracts.values.js +66 -89
  114. package/dist/tool-contracts.values.js.map +1 -1
  115. package/package.json +1 -1
  116. package/dist/projections/modulate-confidence.projection.js.map +0 -1
@@ -6,15 +6,23 @@ import { v } from 'convex/values';
6
6
  // src/tool-contracts.lifecycle.ts
7
7
  var CREATE_BELIEF = {
8
8
  name: "create_belief",
9
- 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.",
9
+ 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.",
10
10
  parameters: {
11
11
  canonicalText: {
12
12
  type: "string",
13
13
  description: "The belief statement \u2014 what the agent holds to be true"
14
14
  },
15
+ topicGlobalId: {
16
+ type: "string",
17
+ description: "Required globalId (UUID) of the topic node in epistemicNodes that anchors the belief"
18
+ },
19
+ topicNodeId: {
20
+ type: "string",
21
+ description: "Optional internal epistemicNodes _id for the topic anchor. Prefer topicGlobalId for public callers."
22
+ },
15
23
  topicId: {
16
24
  type: "string",
17
- description: "Optional topic scope hint for the belief"
25
+ description: "Deprecated compatibility alias for topicGlobalId. Must identify a topic epistemicNode, not a legacy topics-table row."
18
26
  },
19
27
  baseRate: {
20
28
  type: "number",
@@ -29,7 +37,7 @@ var CREATE_BELIEF = {
29
37
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
30
38
  }
31
39
  },
32
- required: ["canonicalText"],
40
+ required: ["canonicalText", "topicGlobalId"],
33
41
  response: {
34
42
  description: "The created canonical belief record",
35
43
  fields: {
@@ -38,7 +46,7 @@ var CREATE_BELIEF = {
38
46
  beliefId: "string \u2014 canonical belief ID",
39
47
  text: "string \u2014 canonical belief formulation",
40
48
  topicId: "string",
41
- status: "string \u2014 active | superseded | archived",
49
+ beliefStatus: "string \u2014 assumption | hypothesis | active | superseded | resolved_true | resolved_false",
42
50
  scoringState: "string \u2014 unscored | scored"
43
51
  }
44
52
  },
@@ -61,7 +69,7 @@ var GET_BELIEF = {
61
69
  beliefId: "string \u2014 canonical belief ID",
62
70
  text: "string \u2014 canonical belief formulation",
63
71
  topicId: "string",
64
- status: "string \u2014 active | superseded | archived",
72
+ beliefStatus: "string \u2014 assumption | hypothesis | active | superseded | resolved_true | resolved_false",
65
73
  scoringState: "string \u2014 unscored | scored"
66
74
  }
67
75
  },
@@ -90,34 +98,24 @@ var REFINE_BELIEF = {
90
98
  ontologyPrimitive: "belief",
91
99
  tier: "showcase"
92
100
  };
93
- var MODULATE_CONFIDENCE = {
94
- name: "modulate_confidence",
95
- description: "Internal-only subjective-logic ledger append. Like `git commit` to the credence log for the scoring engine \u2014 never an operator-facing way to assert confidence. Agents, SDK callers, CLI users, and MCP clients must instead create or link evidence with `evidenceRelation: supports|contradicts`; the kernel derives the next opinion from that evidence. This compatibility primitive is reserved for governed system scoring paths that already hold a full subjective-logic tuple and truth-bearing provenance.",
101
+ var APPEND_SL_SCORING = {
102
+ name: "append_sl_scoring",
103
+ 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.",
96
104
  parameters: {
97
- nodeId: { type: "string", description: "The belief to score" },
98
- belief: {
99
- type: "number",
100
- description: "Subjective-logic belief mass `b` in [0, 1]"
101
- },
105
+ nodeId: { type: "string", description: "The belief receiving the SL score" },
106
+ belief: { type: "number", description: "Subjective Logic belief mass b" },
102
107
  disbelief: {
103
108
  type: "number",
104
- description: "Subjective-logic disbelief mass `d` in [0, 1]"
109
+ description: "Subjective Logic disbelief mass d"
105
110
  },
106
111
  uncertainty: {
107
112
  type: "number",
108
- description: "Subjective-logic uncertainty mass `u` in [0, 1]"
109
- },
110
- baseRate: {
111
- type: "number",
112
- description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
113
- },
114
- worktreeId: {
115
- type: "string",
116
- description: "Completed worktree that tested this belief when confidence policy requires merge-backed scoring."
113
+ description: "Subjective Logic uncertainty mass u"
117
114
  },
115
+ baseRate: { type: "number", description: "Subjective Logic base rate a" },
118
116
  trigger: {
119
117
  type: "string",
120
- description: "What caused this confidence change",
118
+ description: "Evidence-bearing cause of the scoring event",
121
119
  enum: [
122
120
  "evidence_added",
123
121
  "evidence_removed",
@@ -128,64 +126,39 @@ var MODULATE_CONFIDENCE = {
128
126
  "worktree_completed",
129
127
  "fusion",
130
128
  "discount",
131
- "deduction"
129
+ "deduction",
130
+ "backfill_synthetic"
132
131
  ]
133
132
  },
134
- triggeringEvidenceId: {
135
- type: "string",
136
- description: "Evidence node that caused an evidence-triggered modulation"
137
- },
138
- triggeringQuestionId: {
139
- type: "string",
140
- description: "Answered question whose resolution supports this modulation"
141
- },
142
- triggeringAnswerId: {
143
- type: "string",
144
- description: "Answer node whose content supports this modulation"
145
- },
146
- triggeringContradictionId: {
147
- type: "string",
148
- description: "Contradiction record that caused a contradiction-triggered modulation"
149
- },
150
- triggeringWorktreeId: {
151
- type: "string",
152
- description: "Completed worktree whose outcome caused a worktree-triggered modulation"
133
+ provenance: {
134
+ type: "object",
135
+ description: "At least one of evidence, question, answer, contradiction, or worktree."
153
136
  },
154
137
  rationale: {
155
138
  type: "string",
156
- description: "Human-readable explanation of why confidence changed"
139
+ description: "Why this evidence-bearing event moved the SL tuple"
157
140
  }
158
141
  },
159
- required: [
160
- "nodeId",
161
- "belief",
162
- "disbelief",
163
- "uncertainty",
164
- "baseRate",
165
- "trigger",
166
- "rationale"
167
- ],
142
+ required: ["nodeId", "belief", "disbelief", "uncertainty", "baseRate", "trigger", "rationale"],
168
143
  response: {
169
- description: "Confidence modulation result",
144
+ description: "Internal SL scoring append receipt",
170
145
  fields: {
171
- beliefId: "string \u2014 canonical belief ID",
172
- nodeId: "string \u2014 canonical belief ID",
173
- newConfidence: "number",
146
+ nodeId: "string",
174
147
  previousConfidence: "number",
175
- trigger: "string",
176
- requestId: "string \u2014 request identifier for the scheduled cascade",
177
- propagationSummary: "object \u2014 bounded inline cascade summary with totalCandidateTargets, inlineTargets, and remainingTargetCount"
148
+ newConfidence: "number",
149
+ beliefConfidenceId: "string"
178
150
  }
179
151
  },
180
152
  ownerModule: "graph-primitives",
181
153
  ontologyPrimitive: "belief",
182
- tier: "showcase"
154
+ tier: "workhorse",
155
+ internal: true
183
156
  };
184
157
  var FORK_BELIEF = {
185
158
  name: "fork_belief",
186
- description: "Branch off a scored belief to create a new version with a different formulation. Like `git fork` \u2014 the parent remains immutable with full history. The new belief gets a `supersedes` edge to the parent. Fork reasons: refinement, contradiction_response, scope_change, confidence_collapse, manual.",
159
+ 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.",
187
160
  parameters: {
188
- nodeId: { type: "string", description: "The scored belief to fork from" },
161
+ nodeId: { type: "string", description: "The belief to fork from" },
189
162
  newFormulation: {
190
163
  type: "string",
191
164
  description: "The evolved belief statement"
@@ -197,12 +170,20 @@ var FORK_BELIEF = {
197
170
  "refinement",
198
171
  "contradiction_response",
199
172
  "scope_change",
200
- "confidence_collapse",
201
- "manual"
173
+ "confidence_collapse"
202
174
  ]
175
+ },
176
+ forkMode: {
177
+ type: "string",
178
+ description: "supersede replaces the parent; branch creates a child while preserving the parent.",
179
+ enum: ["supersede", "branch"]
180
+ },
181
+ triggeringEvidenceId: {
182
+ type: "string",
183
+ description: "Evidence already attached to the parent belief that caused the fork."
203
184
  }
204
185
  },
205
- required: ["nodeId", "newFormulation", "forkReason"],
186
+ required: ["nodeId", "newFormulation", "forkReason", "triggeringEvidenceId"],
206
187
  response: {
207
188
  description: "The forked canonical belief record",
208
189
  fields: {
@@ -704,7 +685,7 @@ var REASONING_METHODS = [
704
685
  // src/tool-contracts.graph.ts
705
686
  var QUERY_LINEAGE = {
706
687
  name: "query_lineage",
707
- description: "Trace a belief's full ancestry \u2014 every fork, score, and confidence modulation. 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).",
688
+ 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).",
708
689
  parameters: {
709
690
  nodeId: { type: "string", description: "Starting node to trace from" },
710
691
  depth: {
@@ -903,7 +884,7 @@ var FIND_CONTRADICTIONS = {
903
884
  };
904
885
  var BISECT_CONFIDENCE = {
905
886
  name: "bisect_confidence",
906
- 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 confidence modulations to identify which evidence or event caused the divergence.",
887
+ 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.",
907
888
  parameters: {
908
889
  nodeId: { type: "string", description: "The belief to bisect" },
909
890
  expectedDirection: {
@@ -922,7 +903,7 @@ var BISECT_CONFIDENCE = {
922
903
  fields: {
923
904
  beliefId: "string \u2014 canonical belief ID",
924
905
  expectedDirection: "string \u2014 overconfident | underconfident",
925
- inflectionEntry: "object \u2014 the confidence modulation where divergence began",
906
+ inflectionEntry: "object \u2014 the scoring event where divergence began",
926
907
  triggerEvent: "string | null \u2014 what caused the divergence",
927
908
  confidenceBefore: "number | null",
928
909
  confidenceAfter: "number | null",
@@ -1867,18 +1848,18 @@ var SEARCH_EVIDENCE = {
1867
1848
  };
1868
1849
  var CREATE_EVIDENCE = {
1869
1850
  name: "create_evidence",
1870
- description: "Commit evidence to the reasoning graph. Like `git commit` \u2014 creates a traceable evidence record with canonical public IDs. Optionally links the evidence to a belief or question in the same operation. When evidence bears on beliefs, state whether it supports or contradicts; SL confidence is derived from these evidence relations.",
1851
+ 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.",
1871
1852
  parameters: {
1872
1853
  topicId: { type: "string", description: "Topic scope" },
1873
1854
  text: { type: "string", description: "Canonical evidence text" },
1874
1855
  source: { type: "string", description: "Source URL or source label" },
1875
1856
  targetId: {
1876
1857
  type: "string",
1877
- description: "Optional belief or question identifier to link immediately"
1858
+ description: "Belief identifier to link immediately"
1878
1859
  },
1879
1860
  weight: {
1880
1861
  type: "number",
1881
- description: "Optional support weight: -1.0 (contradicts) to +1.0 (supports). If omitted, evidenceRelation + confidence determine the weight."
1862
+ description: "Required nonzero signed impact score: -1.0 (contradicts) to +1.0 (supports)."
1882
1863
  },
1883
1864
  evidenceRelation: {
1884
1865
  type: "string",
@@ -1887,7 +1868,7 @@ var CREATE_EVIDENCE = {
1887
1868
  },
1888
1869
  confidence: {
1889
1870
  type: "number",
1890
- description: "Confidence in the evidence relation, 0.0 to 1.0"
1871
+ description: "Deprecated hint. Runtime confidence is derived from the signed impact score."
1891
1872
  },
1892
1873
  beliefRelations: {
1893
1874
  type: "array",
@@ -1909,7 +1890,7 @@ var CREATE_EVIDENCE = {
1909
1890
  },
1910
1891
  kind: { type: "string", description: "Optional evidence kind" }
1911
1892
  },
1912
- required: ["text", "rationale"],
1893
+ required: ["text", "rationale", "weight"],
1913
1894
  response: {
1914
1895
  description: "The created canonical evidence record",
1915
1896
  fields: {
@@ -1984,7 +1965,7 @@ var LINK_EVIDENCE = {
1984
1965
  },
1985
1966
  rationale: { type: "string", description: "Why this link exists" }
1986
1967
  },
1987
- required: ["evidenceId", "targetId"],
1968
+ required: ["evidenceId", "targetId", "weight"],
1988
1969
  response: {
1989
1970
  description: "The created canonical evidence edge summary",
1990
1971
  fields: {
@@ -2020,7 +2001,7 @@ var LINK_EVIDENCE_TO_BELIEF = {
2020
2001
  },
2021
2002
  rationale: { type: "string", description: "Why this evidence is relevant" }
2022
2003
  },
2023
- required: ["evidenceId", "beliefId"],
2004
+ required: ["evidenceId", "beliefId", "weight"],
2024
2005
  response: {
2025
2006
  description: "The created edge linking evidence to belief",
2026
2007
  fields: {
@@ -2839,6 +2820,11 @@ var COMPILE_CONTEXT = {
2839
2820
  response: {
2840
2821
  description: "Compiled context pack for the requested topic",
2841
2822
  fields: {
2823
+ contextNarrative: "array \u2014 first field; ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
2824
+ narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, topicsSynthesized, topicsEnriched, topicContentOmitted, enrichmentMode, and blocksEmitted for the narrative",
2825
+ synthesisLints: "array \u2014 inline quality warnings for degenerate synthesis blocks or weak narrative coverage",
2826
+ retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
2827
+ supportingObjects: "object \u2014 raw graph records grouped behind the synthesis: invariants, activeBeliefs, openQuestions, recentEvidence, worktrees, lanes, entities, and contradictions",
2842
2828
  schemaVersion: "string",
2843
2829
  topicId: "string",
2844
2830
  topicName: "string",
@@ -2846,15 +2832,6 @@ var COMPILE_CONTEXT = {
2846
2832
  generatedAt: "number \u2014 deterministic graph-backed reference timestamp for this compilation",
2847
2833
  ranking: "string \u2014 baseline_v1 | weighted_v1",
2848
2834
  summary: "object \u2014 counts and scoped health signals",
2849
- invariants: "array \u2014 high-confidence invariant beliefs",
2850
- activeBeliefs: "array \u2014 current high-signal beliefs",
2851
- openQuestions: "array \u2014 unresolved questions ranked for this query",
2852
- recentEvidence: "array \u2014 recent evidence ranked for this query",
2853
- contradictions: "array \u2014 unresolved contradiction records",
2854
- relatedEntities: "array | undefined \u2014 ranked ontological entities in scope",
2855
- contextNarrative: "array \u2014 ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
2856
- retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
2857
- narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, topicsSynthesized, topicsEnriched, topicContentOmitted, enrichmentMode, and blocksEmitted for the narrative",
2858
2835
  injectionPolicy: "object \u2014 token-budgeted section selections",
2859
2836
  diagnostics: "object \u2014 scoring and utilization telemetry"
2860
2837
  }
@@ -4273,7 +4250,7 @@ var TRIGGER_BELIEF_REVIEW = {
4273
4250
  };
4274
4251
  var EVALUATE_CONTRACT = {
4275
4252
  name: "evaluate_contract",
4276
- 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 confidence modulation.",
4253
+ 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.",
4277
4254
  parameters: {
4278
4255
  contractId: { type: "string", description: "Which contract to evaluate" },
4279
4256
  trigger: {
@@ -4629,7 +4606,7 @@ var MCP_TOOL_CONTRACTS = {
4629
4606
  create_belief: CREATE_BELIEF,
4630
4607
  get_belief: GET_BELIEF,
4631
4608
  refine_belief: REFINE_BELIEF,
4632
- modulate_confidence: MODULATE_CONFIDENCE,
4609
+ append_sl_scoring: APPEND_SL_SCORING,
4633
4610
  fork_belief: FORK_BELIEF,
4634
4611
  archive_belief: ARCHIVE_BELIEF,
4635
4612
  create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
@@ -5124,12 +5101,12 @@ var LUCERN_OPERATION_MANIFEST = {
5124
5101
  internalSystem,
5125
5102
  "Lucern system/background operation. Available to platform code paths, hidden from public MCP discovery."
5126
5103
  ),
5127
- modulate_confidence: {
5128
- name: "modulate_confidence",
5104
+ append_sl_scoring: {
5105
+ name: "append_sl_scoring",
5129
5106
  surfaceClass: "platform_internal",
5130
5107
  surfaceIntent: "system",
5131
5108
  surfaces: internalSdkRestOnly,
5132
- rationale: "Internal SL ledger append primitive. Public callers attach evidence or contradiction relations; confidence is derived algorithmically."
5109
+ rationale: "Internal SL scoring append primitive. Public callers attach evidence or contradiction relations; confidence is derived algorithmically."
5133
5110
  },
5134
5111
  ...entries(
5135
5112
  LEGACY_COMPAT_OPERATION_NAMES,
@@ -5517,11 +5494,39 @@ var createEvidenceInputSchemaBase = z.object({
5517
5494
  metadata: jsonRecordSchema.optional(),
5518
5495
  trustedBypassAccessCheck: z.boolean().optional()
5519
5496
  }).passthrough();
5520
- function hasNonzeroWeight(value) {
5521
- return typeof value === "number" && Number.isFinite(value) && value !== 0;
5497
+ function isSignedImpactScore(value) {
5498
+ return typeof value === "number" && Number.isFinite(value) && value >= -1 && value <= 1 && value !== 0;
5522
5499
  }
5523
- function hasRelationSignal(value, weight) {
5524
- return Boolean(normalizeRelation(value, weight));
5500
+ function validateSignedImpactScore(value, ctx, path) {
5501
+ if (!isSignedImpactScore(value)) {
5502
+ ctx.addIssue({
5503
+ code: z.ZodIssueCode.custom,
5504
+ message: "evidence-to-belief links require an explicit nonzero signed impact score in [-1, 1]",
5505
+ path
5506
+ });
5507
+ return false;
5508
+ }
5509
+ return true;
5510
+ }
5511
+ function validateRelationImpactConsistency(relation, weight, ctx, path) {
5512
+ const normalized = normalizeRelationAlias(relation);
5513
+ if (!normalized || !isSignedImpactScore(weight)) {
5514
+ return;
5515
+ }
5516
+ if (normalized === "supports" && weight < 0) {
5517
+ ctx.addIssue({
5518
+ code: z.ZodIssueCode.custom,
5519
+ message: "supporting evidence requires a positive impact score",
5520
+ path
5521
+ });
5522
+ }
5523
+ if (normalized === "contradicts" && weight > 0) {
5524
+ ctx.addIssue({
5525
+ code: z.ZodIssueCode.custom,
5526
+ message: "contradicting evidence requires a negative impact score",
5527
+ path
5528
+ });
5529
+ }
5525
5530
  }
5526
5531
  var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
5527
5532
  (input, ctx) => {
@@ -5538,13 +5543,27 @@ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
5538
5543
  input.linkedBeliefNodeId || kind === "belief" || kind === "unknown" && target
5539
5544
  );
5540
5545
  const weight = typeof input.weight === "number" ? input.weight : void 0;
5541
- if (linksPrimaryBelief && !hasRelationSignal(input.evidenceRelation, weight)) {
5546
+ const hasBeliefRelations = (input.beliefRelations?.length ?? 0) > 0;
5547
+ if (!linksPrimaryBelief && !hasBeliefRelations) {
5548
+ ctx.addIssue({
5549
+ code: z.ZodIssueCode.custom,
5550
+ message: "create_evidence requires at least one linked belief; evidence cannot be created as an orphan or linked only to a question/worktree",
5551
+ path: ["linkedBeliefNodeId"]
5552
+ });
5553
+ }
5554
+ if (kind === "question" || kind === "worktree") {
5542
5555
  ctx.addIssue({
5543
5556
  code: z.ZodIssueCode.custom,
5544
- message: "belief-targeted evidence requires evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
5545
- path: ["evidenceRelation"]
5557
+ message: "create_evidence targetId must be a belief. Link evidence to questions/worktrees only after the evidence has a belief impact edge.",
5558
+ path: ["targetId"]
5546
5559
  });
5547
5560
  }
5561
+ if (linksPrimaryBelief) {
5562
+ validateSignedImpactScore(weight, ctx, ["weight"]);
5563
+ validateRelationImpactConsistency(input.evidenceRelation, weight, ctx, [
5564
+ "weight"
5565
+ ]);
5566
+ }
5548
5567
  input.beliefRelations?.forEach((relation, index) => {
5549
5568
  const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
5550
5569
  if (!beliefNodeId) {
@@ -5555,15 +5574,18 @@ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
5555
5574
  });
5556
5575
  }
5557
5576
  const relationWeight2 = typeof relation.weight === "number" ? relation.weight : void 0;
5558
- if (beliefNodeId && !hasRelationSignal(
5559
- relation.evidenceRelation ?? relation.relation,
5560
- relationWeight2
5561
- )) {
5562
- ctx.addIssue({
5563
- code: z.ZodIssueCode.custom,
5564
- message: "beliefRelations entries require evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
5565
- path: ["beliefRelations", index, "evidenceRelation"]
5566
- });
5577
+ if (beliefNodeId) {
5578
+ validateSignedImpactScore(relationWeight2, ctx, [
5579
+ "beliefRelations",
5580
+ index,
5581
+ "weight"
5582
+ ]);
5583
+ validateRelationImpactConsistency(
5584
+ relation.evidenceRelation ?? relation.relation,
5585
+ relationWeight2,
5586
+ ctx,
5587
+ ["beliefRelations", index, "weight"]
5588
+ );
5567
5589
  }
5568
5590
  });
5569
5591
  }
@@ -5617,18 +5639,28 @@ function targetKind(targetId) {
5617
5639
  }
5618
5640
  return "unknown";
5619
5641
  }
5620
- function normalizeRelation(value, weight) {
5642
+ function normalizeRelationAlias(value) {
5621
5643
  if (value === "supports" || value === "supporting") {
5622
5644
  return "supports";
5623
5645
  }
5624
5646
  if (value === "contradicts" || value === "contradicting") {
5625
5647
  return "contradicts";
5626
5648
  }
5649
+ return void 0;
5650
+ }
5651
+ function normalizeRelation(value, weight) {
5652
+ const alias = normalizeRelationAlias(value);
5653
+ if (alias) {
5654
+ return alias;
5655
+ }
5627
5656
  if (weight === void 0 || !hasNonzeroWeight(weight)) {
5628
5657
  return void 0;
5629
5658
  }
5630
5659
  return weight < 0 ? "contradicts" : "supports";
5631
5660
  }
5661
+ function hasNonzeroWeight(value) {
5662
+ return typeof value === "number" && Number.isFinite(value) && value !== 0;
5663
+ }
5632
5664
  function normalizeConfidence(confidence, weight) {
5633
5665
  if (confidence !== void 0) {
5634
5666
  return Math.min(1, Math.max(0, confidence));
@@ -5655,6 +5687,7 @@ function normalizeBeliefRelation(relation) {
5655
5687
  beliefNodeId,
5656
5688
  relation: evidenceRelation,
5657
5689
  confidence: normalizeConfidence(relation.confidence, weight),
5690
+ weight,
5658
5691
  rationale: relation.rationale
5659
5692
  });
5660
5693
  }
@@ -5703,6 +5736,7 @@ var createEvidenceProjection = defineProjection({
5703
5736
  linkedBeliefNodeId,
5704
5737
  evidenceRelation,
5705
5738
  confidence,
5739
+ weight,
5706
5740
  beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
5707
5741
  rationale: input.rationale,
5708
5742
  trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
@@ -5732,12 +5766,14 @@ var createEvidenceProjection = defineProjection({
5732
5766
  v.literal("contradicts")
5733
5767
  )
5734
5768
  ),
5769
+ weight: v.optional(v.number()),
5735
5770
  beliefRelations: v.optional(
5736
5771
  v.array(
5737
5772
  v.object({
5738
5773
  beliefNodeId: v.string(),
5739
5774
  relation: v.union(v.literal("supports"), v.literal("contradicts")),
5740
5775
  confidence: v.optional(v.number()),
5776
+ weight: v.number(),
5741
5777
  rationale: v.optional(v.string())
5742
5778
  })
5743
5779
  )
@@ -5755,8 +5791,12 @@ var beliefRelationSchema2 = z.object({
5755
5791
  targetId: z.string().optional().describe("Belief target ID alias for beliefId/beliefNodeId."),
5756
5792
  relation: z.enum(["supports", "contradicts", "supporting", "contradicting"]).optional().describe("Relation alias for how the evidence bears on the belief."),
5757
5793
  evidenceRelation: evidenceRelationSchema2.optional().describe("Canonical relation: supports or contradicts."),
5758
- confidence: z.number().optional().describe("Confidence in this evidence-to-belief relation."),
5759
- weight: z.number().optional().describe("Support weight from -1.0 to +1.0 for this belief."),
5794
+ confidence: z.number().optional().describe(
5795
+ "Deprecated read-only hint. Runtime SL confidence is derived from signed weight."
5796
+ ),
5797
+ weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
5798
+ message: "Evidence impact weight must be nonzero."
5799
+ }).describe("Required signed impact score from -1.0 to +1.0 for this belief."),
5760
5800
  rationale: z.string().optional().describe("Why this relation exists.")
5761
5801
  });
5762
5802
  var createEvidenceArgs = z.object({
@@ -5765,7 +5805,7 @@ var createEvidenceArgs = z.object({
5765
5805
  source: z.string().optional().describe("Source URL or source label."),
5766
5806
  sourceUrl: z.string().optional().describe("Canonical source URL."),
5767
5807
  targetId: z.string().optional().describe(
5768
- "Belief, question, or worktree identifier to link or preserve on the evidence record. Belief targets require evidenceRelation or a nonzero signed weight."
5808
+ "Belief identifier to link immediately. Evidence creation cannot target only a question or worktree."
5769
5809
  ),
5770
5810
  linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
5771
5811
  evidenceRelation: evidenceRelationSchema2.optional().describe(
@@ -5774,8 +5814,14 @@ var createEvidenceArgs = z.object({
5774
5814
  beliefRelations: z.array(beliefRelationSchema2).optional().describe(
5775
5815
  "Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
5776
5816
  ),
5777
- confidence: z.number().optional().describe("Confidence in the evidence relation."),
5778
- weight: z.number().optional().describe("Nonzero support weight from -1.0 to +1.0."),
5817
+ confidence: z.number().optional().describe(
5818
+ "Deprecated hint. Runtime confidence is derived from signed weight."
5819
+ ),
5820
+ weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
5821
+ message: "Evidence impact weight must be nonzero."
5822
+ }).describe(
5823
+ "Required signed impact score from -1.0 to +1.0 for targetId/linkedBeliefNodeId."
5824
+ ),
5779
5825
  metadata: jsonRecordSchema2.optional().describe("Metadata merged into the canonical evidence node."),
5780
5826
  rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
5781
5827
  reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
@@ -5797,7 +5843,9 @@ var addEvidenceArgs = z.object({
5797
5843
  topicId: z.string().optional().describe("Topic scope hint."),
5798
5844
  sourceUrl: z.string().optional().describe("URL of the source material."),
5799
5845
  targetNodeId: z.string().describe("The belief this evidence bears on."),
5800
- weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
5846
+ weight: z.number().min(-1).max(1).refine((value) => value !== 0, {
5847
+ message: "Evidence impact weight must be nonzero."
5848
+ }).describe("Required signed impact score from -1.0 to +1.0."),
5801
5849
  reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
5802
5850
  title: z.string().optional().describe("Optional short title."),
5803
5851
  content: z.string().optional().describe("Optional long-form evidence content."),
@@ -5817,19 +5865,21 @@ var createEvidenceInput = (input, context) => {
5817
5865
  );
5818
5866
  };
5819
5867
  function relationWeight(input) {
5820
- if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
5868
+ if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0 && input.weight >= -1 && input.weight <= 1) {
5869
+ const relation = String(
5870
+ input.evidenceRelation ?? input.relation ?? input.type ?? ""
5871
+ );
5872
+ if ((relation === "supports" || relation === "supporting") && input.weight < 0) {
5873
+ throw new Error("Supporting evidence links require positive weight.");
5874
+ }
5875
+ if ((relation === "contradicts" || relation === "contradicting") && input.weight > 0) {
5876
+ throw new Error("Contradicting evidence links require negative weight.");
5877
+ }
5821
5878
  return input.weight;
5822
5879
  }
5823
- const relation = String(
5824
- input.evidenceRelation ?? input.relation ?? input.type ?? ""
5880
+ throw new Error(
5881
+ "Belief evidence links require explicit nonzero weight in [-1, 1]."
5825
5882
  );
5826
- if (relation !== "supports" && relation !== "supporting" && relation !== "contradicts" && relation !== "contradicting") {
5827
- throw new Error(
5828
- "Belief evidence links require evidenceRelation='supports'|'contradicts' or a nonzero signed weight."
5829
- );
5830
- }
5831
- const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
5832
- return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
5833
5883
  }
5834
5884
  var linkEvidenceToBeliefInput = (input, context) => {
5835
5885
  const weight = relationWeight(input);
@@ -5838,6 +5888,7 @@ var linkEvidenceToBeliefInput = (input, context) => {
5838
5888
  beliefNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
5839
5889
  insightId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
5840
5890
  type: weight < 0 ? "contradicting" : "supporting",
5891
+ weight,
5841
5892
  confidence: Math.min(1, Math.abs(weight)),
5842
5893
  rationale: input.rationale ?? input.context,
5843
5894
  trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
@@ -5914,7 +5965,12 @@ var evidenceContracts = [
5914
5965
  functionName: "create",
5915
5966
  kind: "mutation",
5916
5967
  inputProjection: (input, context) => {
5917
- const weight = typeof input.weight === "number" ? input.weight : 0.7;
5968
+ if (typeof input.weight !== "number" || !Number.isFinite(input.weight) || input.weight === 0 || input.weight < -1 || input.weight > 1) {
5969
+ throw new Error(
5970
+ "add_evidence requires explicit nonzero weight in [-1, 1]."
5971
+ );
5972
+ }
5973
+ const weight = input.weight;
5918
5974
  return createEvidenceInput(
5919
5975
  {
5920
5976
  ...input,
@@ -5923,6 +5979,7 @@ var evidenceContracts = [
5923
5979
  linkedBeliefNodeId: input.linkedBeliefNodeId ?? input.targetNodeId ?? input.targetId,
5924
5980
  evidenceRelation: weight < 0 ? "contradicts" : "supports",
5925
5981
  confidence: Math.min(1, Math.max(0, Math.abs(weight))),
5982
+ weight,
5926
5983
  rationale: input.reasoning,
5927
5984
  metadata: {
5928
5985
  ...recordValue(input.metadata),