@telora/daemon 0.18.55 → 0.18.58

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 (45) hide show
  1. package/build-info.json +5 -3
  2. package/dist/ai-inspection-context.d.ts.map +1 -1
  3. package/dist/ai-inspection-context.js +11 -1
  4. package/dist/ai-inspection-context.js.map +1 -1
  5. package/dist/ai-inspection-runner.d.ts.map +1 -1
  6. package/dist/ai-inspection-runner.js +0 -1
  7. package/dist/ai-inspection-runner.js.map +1 -1
  8. package/dist/audit-phase.d.ts.map +1 -1
  9. package/dist/audit-phase.js +4 -0
  10. package/dist/audit-phase.js.map +1 -1
  11. package/dist/cascade-restatement.d.ts +14 -5
  12. package/dist/cascade-restatement.d.ts.map +1 -1
  13. package/dist/cascade-restatement.js +35 -6
  14. package/dist/cascade-restatement.js.map +1 -1
  15. package/dist/de-restatement.d.ts.map +1 -1
  16. package/dist/de-restatement.js +0 -1
  17. package/dist/de-restatement.js.map +1 -1
  18. package/dist/directive/close-loop-stage.d.ts.map +1 -1
  19. package/dist/directive/close-loop-stage.js +10 -2
  20. package/dist/directive/close-loop-stage.js.map +1 -1
  21. package/dist/negative-branch.d.ts +32 -1
  22. package/dist/negative-branch.d.ts.map +1 -1
  23. package/dist/negative-branch.js +55 -9
  24. package/dist/negative-branch.js.map +1 -1
  25. package/dist/queries/verification.d.ts +132 -0
  26. package/dist/queries/verification.d.ts.map +1 -1
  27. package/dist/queries/verification.js +271 -0
  28. package/dist/queries/verification.js.map +1 -1
  29. package/dist/reality-writeback.d.ts +257 -0
  30. package/dist/reality-writeback.d.ts.map +1 -0
  31. package/dist/reality-writeback.js +179 -0
  32. package/dist/reality-writeback.js.map +1 -0
  33. package/dist/resolvers/shared/reality-tree.d.ts +39 -1
  34. package/dist/resolvers/shared/reality-tree.d.ts.map +1 -1
  35. package/dist/resolvers/shared/reality-tree.js +51 -1
  36. package/dist/resolvers/shared/reality-tree.js.map +1 -1
  37. package/dist/verification-engine.d.ts +10 -0
  38. package/dist/verification-engine.d.ts.map +1 -1
  39. package/dist/verification-engine.js +32 -1
  40. package/dist/verification-engine.js.map +1 -1
  41. package/dist/verify-restatement.d.ts +16 -0
  42. package/dist/verify-restatement.d.ts.map +1 -1
  43. package/dist/verify-restatement.js +7 -0
  44. package/dist/verify-restatement.js.map +1 -1
  45. package/package.json +2 -2
@@ -78,18 +78,27 @@ export function parseNegativeBranchCandidates(raw) {
78
78
  }
79
79
  return out;
80
80
  }
81
- /** Default model invocation: spawn the `claude` CLI in print mode and return stdout. */
82
- function invokeClaudeCli(systemPrompt, userMessage, opts) {
83
- const claudeBin = opts.claudeBin ?? 'claude';
84
- const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
85
- const spawnFn = opts.spawnFn ?? ((cmd, args, sopts) => spawn(cmd, args, sopts));
86
- const args = [
81
+ /**
82
+ * Build the argv for the claude CLI invocation. Exposed for tests.
83
+ *
84
+ * NOTE: must NOT include `--bare` -- that flag makes the CLI skip credential
85
+ * loading, print "Not logged in" to stdout, and exit 1 (the negative-branch
86
+ * pass died silently before it ran).
87
+ */
88
+ export function buildNegativeBranchCliArgs(systemPrompt) {
89
+ return [
87
90
  '--print',
88
91
  '--output-format', 'text',
89
- '--bare',
90
92
  '--no-session-persistence',
91
93
  '--system-prompt', systemPrompt,
92
94
  ];
95
+ }
96
+ /** Default model invocation: spawn the `claude` CLI in print mode and return stdout. */
97
+ function invokeClaudeCli(systemPrompt, userMessage, opts) {
98
+ const claudeBin = opts.claudeBin ?? 'claude';
99
+ const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
100
+ const spawnFn = opts.spawnFn ?? ((cmd, args, sopts) => spawn(cmd, args, sopts));
101
+ const args = buildNegativeBranchCliArgs(systemPrompt);
93
102
  return new Promise((resolve, reject) => {
94
103
  let child;
95
104
  try {
@@ -153,11 +162,18 @@ export async function generateNegativeBranches(inputs, opts = {}) {
153
162
  * injection that introduces it. Idempotency / dedupe is a human concern --
154
163
  * proposals are surfaced, not auto-applied.
155
164
  *
156
- * A clean injection produces no candidates and creates no proposals.
165
+ * A clean injection produces no candidates and creates no proposals -- but the
166
+ * pass still COMPLETED, so the injection's `negative_branch_pass_ran_at` marker
167
+ * is stamped regardless of candidate count (as long as generation did not
168
+ * throw). That durable marker, not the candidate count, is what later gates
169
+ * tree presentability: "ran clean" must be distinguishable from "never ran".
157
170
  */
158
171
  export async function proposeNegativeBranchesForInjection(inputs, deps = {}) {
159
172
  const callApi = deps.callApi ?? defaultCallApi;
160
173
  const generate = deps.generate ?? generateNegativeBranches;
174
+ const now = deps.now ?? (() => new Date().toISOString());
175
+ // If generation throws, the pass did NOT complete -- the caller catches and
176
+ // the marker stays null so the injection remains a surfaced doubt (no stamp).
161
177
  const candidates = await generate({
162
178
  injectionStatement: inputs.injectionStatement,
163
179
  targetUdeStatements: inputs.targetUdeStatements,
@@ -190,6 +206,36 @@ export async function proposeNegativeBranchesForInjection(inputs, deps = {}) {
190
206
  errors.push(`negative-branch proposal create failed: ${err.message}`);
191
207
  }
192
208
  }
193
- return { candidates, proposalIds, errors };
209
+ // Generation completed (did not throw) -- stamp the durable per-injection
210
+ // marker so a clean (zero-candidate) pass leaves a trace. This is the whole
211
+ // point: presentability gates on a pass having RUN, never on the branch set
212
+ // being non-empty. Stamping is best-effort -- a write failure leaves the
213
+ // marker null (the injection re-runs next tick) but never aborts the result.
214
+ //
215
+ // RESIDUAL (documented, tolerated): the "RUN" signal is "generate() did not
216
+ // throw", so a DEGRADED model call that returns an empty body would be
217
+ // recorded as a clean pass (zero candidates, marker stamped) even though it
218
+ // surfaced nothing real. We accept this for two reasons: (1) the dominant
219
+ // silent-failure mode -- the `--bare` flag printing "Not logged in" and
220
+ // exiting 1 -- was removed (see buildNegativeBranchCliArgs), so a non-zero
221
+ // exit now throws and correctly leaves the marker null; and (2) a genuinely
222
+ // empty negative-branch set is the LEGITIMATE clean case this marker exists to
223
+ // record, and "did the model degrade vs honestly find nothing" is not
224
+ // mechanically separable here without a check that could itself be confidently
225
+ // wrong -- the negative-branch signal is deliberately advisory, not a hard
226
+ // gate, so a rare false-clean costs an advisory hint, never a blocked tree.
227
+ let passRanAt = null;
228
+ const stampedAt = now();
229
+ try {
230
+ await callApi('reality_tree_node_update', {
231
+ nodeId: inputs.injectionNodeId,
232
+ negativeBranchPassRanAt: stampedAt,
233
+ });
234
+ passRanAt = stampedAt;
235
+ }
236
+ catch (err) {
237
+ errors.push(`negative-branch pass-marker stamp failed: ${err.message}`);
238
+ }
239
+ return { candidates, proposalIds, errors, passRanAt };
194
240
  }
195
241
  //# sourceMappingURL=negative-branch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"negative-branch.js","sourceRoot":"","sources":["../src/negative-branch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AA4BjE,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEzC,MAAM,CAAC,MAAM,6BAA6B,GAAG;;;;;;;;sFAQyC,CAAC;AAEvF,gEAAgE;AAChE,MAAM,UAAU,+BAA+B;IAC7C,OAAO,6BAA6B,CAAC;AACvC,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,8BAA8B,CAAC,MAA4B;IACzE,MAAM,KAAK,GAAa,CAAC,eAAe,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAErE,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvF,IAAI,O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YACb,MAAM,CAAC,IAAI,CAAC,2CAA4C,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;IAED,0EAA0E;IAC1E,4EAA4E;IAC5E,4EAA4E;IAC5E,yEAAyE;IACzE,6EAA6E;IAC7E,EAAE;IACF,4EAA4E;IAC5E,uEAAuE;IACvE,4EAA4E;IAC5E,0EAA0E;IAC1E,wEAAwE;IACxE,2EAA2E;IAC3E,4EAA4E;IAC5E,+EAA+E;IAC/E,sEAAsE;IACtE,+EAA+E;IAC/E,2EAA2E;IAC3E,4EAA4E;IAC5E,IAAI,SAAS,GAAkB,IAAI,CAAC;IACpC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC;IACxB,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,0BAA0B,EAAE;YACxC,MAAM,EAAE,MAAM,CAAC,eAAe;YAC9B,uBAAuB,EAAE,SAAS;SACnC,CAAC,CAAC;QACH,SAAS,GAAG,SAAS,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,6CAA8C,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACxD,CAAC"}
@@ -5,6 +5,7 @@
5
5
  * - Record the outcome of a verification attempt.
6
6
  * - Trigger the existing reality_tree_verify_injection compound op on pass.
7
7
  */
8
+ import { type NodeWriteback, type WritebackClassification } from '../reality-writeback.js';
8
9
  export type VerificationMethod = 'deterministic' | 'behavioral' | 'ai_inspection';
9
10
  export type VerificationOutcome = 'pending' | 'passed' | 'failed' | 'escalated';
10
11
  export interface PendingVerification {
@@ -56,4 +57,135 @@ export declare function verifyInjectionOnPass(injectionNodeId: string, restateme
56
57
  * the verify decision.
57
58
  */
58
59
  export declare function verifyInjectionWithEvidence(injectionNodeId: string, evidence: string): Promise<void>;
60
+ /**
61
+ * Translate the pure `decideNodeWriteback` output into the verify call's
62
+ * `restatements` payload.
63
+ *
64
+ * The flip endpoint (`reality_tree_verify_injection`) is the only seam that
65
+ * persists a node's `verify_classification` / `verify_divergence_reason`, and
66
+ * it does so per-restatement -- but ONLY when the restatement carries a
67
+ * non-empty `statement` (an empty statement is dropped whole, classification
68
+ * included). So a writeback can be applied iff it carries achieved prose.
69
+ *
70
+ * Mapping:
71
+ * - match | legitimate_divergence WITH a non-empty statement -> a
72
+ * VerifyRestatement carried into the flip so classification (+ reason)
73
+ * lands atomically with the promotion. The achieved statement is the prose
74
+ * written as the targeted UDE's new base statement (for a match this equals
75
+ * the declared desired effect carried forward unchanged).
76
+ * - any writeback WITHOUT achieved prose, or a `shortfall` -> NOT emitted as
77
+ * a restatement (there is no edge path that stamps classification without
78
+ * prose, and a shortfall must not flip the node). Reported back via
79
+ * `skipped` so the caller can see what was not stamped.
80
+ *
81
+ * Pure (no I/O); exported for unit testing the mapping.
82
+ */
83
+ export declare function planNodeWritebackApply(writebacks: readonly NodeWriteback[]): {
84
+ restatements: VerifyRestatement[];
85
+ skipped: Array<{
86
+ nodeId: string;
87
+ reason: string;
88
+ }>;
89
+ };
90
+ /**
91
+ * Same as `verifyInjectionWithEvidence` but additionally stamps the per-node
92
+ * realized/diverged writeback computed by `decideNodeWriteback`. Closes the
93
+ * reality-tree writeback loop: as a delivery lands, the nodes its injection
94
+ * targeted carry an explicit match / legitimate_divergence status legible to a
95
+ * later reader.
96
+ *
97
+ * Order of operations:
98
+ * 1. `reality_tree_node_update` on the injection node -> persist evidence.
99
+ * 2. `reality_tree_verify_injection` with the per-node restatements -> flips
100
+ * the injection and promotes overlays, applying the classification (+
101
+ * reason) to each targeted UDE atomically. Writebacks with no achieved
102
+ * prose, and shortfalls, are skipped (logged) -- there is no edge path
103
+ * that persists a classification without prose / a flip.
104
+ *
105
+ * Non-destructive: only stamps status + evidence/reason on nodes the injection
106
+ * owns; a match carries the declared desired effect forward unchanged. When
107
+ * `writebacks` is empty this is byte-equivalent to `verifyInjectionWithEvidence`.
108
+ */
109
+ export declare function verifyInjectionWithWriteback(injectionNodeId: string, evidence: string, writebacks: readonly NodeWriteback[], realityTreeId?: string): Promise<void>;
110
+ /**
111
+ * Surface inward drift proposals for the contradicted nodes in a writeback.
112
+ *
113
+ * For each writeback the pure `detectInwardDrift` deems a contradicted claim
114
+ * (`legitimate_divergence` / `shortfall`), create one `update_statement`
115
+ * crt_drift_proposal flagged `inward:true` via the EXISTING
116
+ * `crt_drift_proposal_create` pipeline. A `match` (or unstamped) node yields
117
+ * nothing, so a clean landing emits no proposals.
118
+ *
119
+ * Requires the reality tree id (the create action keys off it). When the tree
120
+ * id is unknown, the proposals cannot be created -- we log and skip, leaving
121
+ * the per-node stamps in place (a later reader still sees the divergence).
122
+ *
123
+ * Non-fatal: each create is independently try/caught so one failure neither
124
+ * blocks the others nor unwinds the already-applied verify flip.
125
+ */
126
+ export declare function emitInwardDriftProposals(injectionNodeId: string, writebacks: readonly NodeWriteback[], realityTreeId?: string): Promise<void>;
127
+ /**
128
+ * One targeted UDE node resolved at landing: its id plus its declared
129
+ * desired-effect prose, used as the achieved statement on a clean match (the
130
+ * achieved effect equals the declared one, carried forward unchanged).
131
+ */
132
+ export interface ResolvedTargetedNode {
133
+ nodeId: string;
134
+ /** The declared desired-effect prose (frt_statement, else statement). */
135
+ achievedStatement: string;
136
+ /**
137
+ * The node's ORIGINAL claim prose (frt_statement, else statement) AS IT
138
+ * STANDS NOW. For a close-loop clean landing the achieved effect equals the
139
+ * declared one, so this equals `achievedStatement`; it is carried separately
140
+ * so a divergent landing (where achieved != claim) can frame the inward drift
141
+ * proposal against the tree's claim rather than the achieved reality.
142
+ */
143
+ originalClaim: string;
144
+ /**
145
+ * The node's EXISTING stamped verify_classification, if any (e.g. stamped
146
+ * `legitimate_divergence`/`shortfall` by the per-delivery verify path before
147
+ * the focus reached close_loop). Used so the close-loop sweep does NOT
148
+ * clobber an already-diverged stamp back to `match` (TEL-3). `null`/absent =>
149
+ * unstamped, the sweep stamps a clean match.
150
+ */
151
+ existingClassification?: WritebackClassification | null;
152
+ }
153
+ /**
154
+ * Resolve the targeted UDE nodes of an injection via the existing
155
+ * `reality_tree_edge_list` ('targets' edges out of the injection) joined to
156
+ * `reality_tree_node_list` for each target's declared prose. Returns [] when
157
+ * the tree id is unknown or a lookup fails -- the writeback then degrades to a
158
+ * plain injection verify (no per-node stamping), which is non-destructive and
159
+ * matches prior behavior.
160
+ */
161
+ export declare function resolveTargetedNodes(injectionId: string, treeId: string | undefined): Promise<ResolvedTargetedNode[]>;
162
+ /**
163
+ * Build the writeback-applying verify callback used by the close-loop sweep.
164
+ *
165
+ * For each injection the sweep verifies, this closure:
166
+ * 1. Resolves the injection's targeted UDE node ids (edge-list) + each node's
167
+ * EXISTING verify_classification.
168
+ * 2. Models the landing as a CLEAN realization for the still-unstamped (or
169
+ * already-match) targets -- the anchoring delivery closed successfully, so
170
+ * the cascade is treated as flipped and the injection as delivered. A
171
+ * target the per-delivery verify path ALREADY stamped as a contradiction
172
+ * (legitimate_divergence / shortfall) is EXCLUDED from the landing so the
173
+ * close-loop sweep never clobbers a diverged stamp back to 'match' (TEL-3).
174
+ * 3. Computes the per-node writeback and applies it via
175
+ * `verifyInjectionWithWriteback`, stamping match/evidence on each targeted
176
+ * UDE so a later reader sees which claims actually held.
177
+ *
178
+ * No targeted nodes -> the writeback is empty and the call is byte-equivalent
179
+ * to the plain `verifyInjectionWithEvidence`.
180
+ *
181
+ * `treeIdByInjection` maps an injection node id to its reality_tree id, captured
182
+ * by the dispatcher from the focus-injections snapshot. The returned callback
183
+ * matches the `(injectionId, evidence) => Promise<void>` shape the close-loop
184
+ * sweep expects, so it drops into `advanceFocusToDoneWithSweep` unchanged.
185
+ *
186
+ * Exported here (rather than in the dispatcher) so the wiring is unit-testable
187
+ * against the callApi mock seam without dragging the dispatcher's heavy import
188
+ * graph.
189
+ */
190
+ export declare function buildWritebackVerify(treeIdByInjection: ReadonlyMap<string, string>): (injectionId: string, evidence: string) => Promise<void>;
59
191
  //# sourceMappingURL=verification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../src/queries/verification.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG,YAAY,GAAG,eAAe,CAAC;AAClF,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEhF,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACnD,mBAAmB,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAChD,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,wBAAsB,uBAAuB,CAC3C,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAMhC;AAED,wBAAsB,iCAAiC,CACrD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,GAAG,uBAAuB,CAAC;IAClD,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,eAAe,EAAE,MAAM,EACvB,YAAY,CAAC,EAAE,iBAAiB,EAAE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;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAAC,oBAAoB,EAAE,CAAC,CA6CjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAClC,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7C,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAiC1D"}
@@ -6,6 +6,7 @@
6
6
  * - Trigger the existing reality_tree_verify_injection compound op on pass.
7
7
  */
8
8
  import { callApi } from './shared.js';
9
+ import { decideNodeWriteback, detectInwardDrift, } from '../reality-writeback.js';
9
10
  export async function getPendingVerifications(productId) {
10
11
  const response = await callApi('daemon_get_pending_verifications', productId ? { productId } : {});
11
12
  return response.items ?? [];
@@ -46,4 +47,274 @@ export async function verifyInjectionWithEvidence(injectionNodeId, evidence) {
46
47
  });
47
48
  await callApi('reality_tree_verify_injection', { injectionNodeId });
48
49
  }
50
+ /**
51
+ * Translate the pure `decideNodeWriteback` output into the verify call's
52
+ * `restatements` payload.
53
+ *
54
+ * The flip endpoint (`reality_tree_verify_injection`) is the only seam that
55
+ * persists a node's `verify_classification` / `verify_divergence_reason`, and
56
+ * it does so per-restatement -- but ONLY when the restatement carries a
57
+ * non-empty `statement` (an empty statement is dropped whole, classification
58
+ * included). So a writeback can be applied iff it carries achieved prose.
59
+ *
60
+ * Mapping:
61
+ * - match | legitimate_divergence WITH a non-empty statement -> a
62
+ * VerifyRestatement carried into the flip so classification (+ reason)
63
+ * lands atomically with the promotion. The achieved statement is the prose
64
+ * written as the targeted UDE's new base statement (for a match this equals
65
+ * the declared desired effect carried forward unchanged).
66
+ * - any writeback WITHOUT achieved prose, or a `shortfall` -> NOT emitted as
67
+ * a restatement (there is no edge path that stamps classification without
68
+ * prose, and a shortfall must not flip the node). Reported back via
69
+ * `skipped` so the caller can see what was not stamped.
70
+ *
71
+ * Pure (no I/O); exported for unit testing the mapping.
72
+ */
73
+ export function planNodeWritebackApply(writebacks) {
74
+ const restatements = [];
75
+ const skipped = [];
76
+ for (const wb of writebacks) {
77
+ if (wb.classification === 'shortfall') {
78
+ skipped.push({
79
+ nodeId: wb.nodeId,
80
+ reason: 'shortfall: no flip; classification not persisted (claim did not hold)',
81
+ });
82
+ continue;
83
+ }
84
+ // TEL-6: an `assumed` match carries no evidence. Persisting a
85
+ // verify_classification='match' for it would record an UNEARNED "verified"
86
+ // claim, so skip it -- the node stays unstamped until grounded by evidence.
87
+ if (wb.classification === 'match' && wb.assumed === true) {
88
+ skipped.push({
89
+ nodeId: wb.nodeId,
90
+ reason: 'assumed match: no evidence; not stamped verified (unearned certainty)',
91
+ });
92
+ continue;
93
+ }
94
+ const statement = wb.statement;
95
+ if (typeof statement !== 'string' || statement.trim().length === 0) {
96
+ skipped.push({
97
+ nodeId: wb.nodeId,
98
+ reason: 'no achieved statement: verify edge drops a restatement with empty prose',
99
+ });
100
+ continue;
101
+ }
102
+ // match | legitimate_divergence WITH prose -> restatement.
103
+ const entry = {
104
+ nodeId: wb.nodeId,
105
+ statement,
106
+ classification: wb.classification,
107
+ };
108
+ if (wb.classification === 'legitimate_divergence' && wb.verifyDivergenceReason) {
109
+ entry.divergenceReason = wb.verifyDivergenceReason;
110
+ }
111
+ restatements.push(entry);
112
+ }
113
+ return { restatements, skipped };
114
+ }
115
+ /**
116
+ * Same as `verifyInjectionWithEvidence` but additionally stamps the per-node
117
+ * realized/diverged writeback computed by `decideNodeWriteback`. Closes the
118
+ * reality-tree writeback loop: as a delivery lands, the nodes its injection
119
+ * targeted carry an explicit match / legitimate_divergence status legible to a
120
+ * later reader.
121
+ *
122
+ * Order of operations:
123
+ * 1. `reality_tree_node_update` on the injection node -> persist evidence.
124
+ * 2. `reality_tree_verify_injection` with the per-node restatements -> flips
125
+ * the injection and promotes overlays, applying the classification (+
126
+ * reason) to each targeted UDE atomically. Writebacks with no achieved
127
+ * prose, and shortfalls, are skipped (logged) -- there is no edge path
128
+ * that persists a classification without prose / a flip.
129
+ *
130
+ * Non-destructive: only stamps status + evidence/reason on nodes the injection
131
+ * owns; a match carries the declared desired effect forward unchanged. When
132
+ * `writebacks` is empty this is byte-equivalent to `verifyInjectionWithEvidence`.
133
+ */
134
+ export async function verifyInjectionWithWriteback(injectionNodeId, evidence, writebacks, realityTreeId) {
135
+ await callApi('reality_tree_node_update', {
136
+ nodeId: injectionNodeId,
137
+ evidence,
138
+ });
139
+ const { restatements, skipped } = planNodeWritebackApply(writebacks);
140
+ if (skipped.length > 0) {
141
+ console.warn(`[reality-writeback] injection ${injectionNodeId.slice(0, 8)}: ` +
142
+ `${skipped.length} targeted node writeback(s) not stamped -- ` +
143
+ skipped.map((s) => `${s.nodeId.slice(0, 8)} (${s.reason})`).join('; '));
144
+ }
145
+ const verifyBody = { injectionNodeId };
146
+ if (restatements.length > 0)
147
+ verifyBody.restatements = restatements;
148
+ await callApi('reality_tree_verify_injection', verifyBody);
149
+ // Inward drift: any node reality CONTRADICTED (legitimate_divergence /
150
+ // shortfall) is a claim the tree got wrong. Turn each one into an inward
151
+ // crt_drift_proposal so the tree-owner can correct the asserting claim,
152
+ // instead of leaving a mistaken assertion frozen. Surfaced for human ratify;
153
+ // never auto-applied. Best-effort + non-fatal: a proposal-emit failure must
154
+ // not undo the verify/flip that already landed.
155
+ await emitInwardDriftProposals(injectionNodeId, writebacks, realityTreeId);
156
+ }
157
+ /**
158
+ * Surface inward drift proposals for the contradicted nodes in a writeback.
159
+ *
160
+ * For each writeback the pure `detectInwardDrift` deems a contradicted claim
161
+ * (`legitimate_divergence` / `shortfall`), create one `update_statement`
162
+ * crt_drift_proposal flagged `inward:true` via the EXISTING
163
+ * `crt_drift_proposal_create` pipeline. A `match` (or unstamped) node yields
164
+ * nothing, so a clean landing emits no proposals.
165
+ *
166
+ * Requires the reality tree id (the create action keys off it). When the tree
167
+ * id is unknown, the proposals cannot be created -- we log and skip, leaving
168
+ * the per-node stamps in place (a later reader still sees the divergence).
169
+ *
170
+ * Non-fatal: each create is independently try/caught so one failure neither
171
+ * blocks the others nor unwinds the already-applied verify flip.
172
+ */
173
+ export async function emitInwardDriftProposals(injectionNodeId, writebacks, realityTreeId) {
174
+ const proposals = writebacks
175
+ .map((wb) => {
176
+ const stamped = {
177
+ nodeId: wb.nodeId,
178
+ verifyClassification: wb.classification,
179
+ verifyDivergenceReason: wb.verifyDivergenceReason ?? null,
180
+ // TEL-5: the claim a human ratifier must reconsider is the tree's
181
+ // ORIGINAL assertion (the claim reality CONTRADICTED), NOT the achieved
182
+ // reality prose. Carry `originalClaim`; the detector falls back to a
183
+ // placeholder when it is absent. (`wb.statement` is the achieved prose
184
+ // -- it belongs in proposedCorrection / the divergence reason, never in
185
+ // observedState.)
186
+ claimStatement: wb.originalClaim ?? null,
187
+ };
188
+ return detectInwardDrift(stamped);
189
+ })
190
+ .filter((p) => p !== null);
191
+ if (proposals.length === 0)
192
+ return;
193
+ if (!realityTreeId) {
194
+ console.warn(`[reality-writeback] injection ${injectionNodeId.slice(0, 8)}: ` +
195
+ `${proposals.length} contradicted node(s) detected but no realityTreeId -- ` +
196
+ `inward drift proposals NOT created (per-node stamps retained).`);
197
+ return;
198
+ }
199
+ for (const proposal of proposals) {
200
+ try {
201
+ await callApi('crt_drift_proposal_create', {
202
+ realityTreeId,
203
+ proposalKind: proposal.proposalKind,
204
+ observedState: proposal.observedState,
205
+ proposedCorrection: proposal.proposedCorrection,
206
+ nodeId: proposal.nodeId,
207
+ proposedMetadata: proposal.proposedMetadata,
208
+ });
209
+ }
210
+ catch (err) {
211
+ console.warn(`[reality-writeback] Failed to create inward drift proposal for node ` +
212
+ `${proposal.nodeId.slice(0, 8)} (tree ${realityTreeId.slice(0, 8)}): ` +
213
+ `${err.message}. Stamp retained; proposal not surfaced.`);
214
+ }
215
+ }
216
+ }
217
+ /**
218
+ * Resolve the targeted UDE nodes of an injection via the existing
219
+ * `reality_tree_edge_list` ('targets' edges out of the injection) joined to
220
+ * `reality_tree_node_list` for each target's declared prose. Returns [] when
221
+ * the tree id is unknown or a lookup fails -- the writeback then degrades to a
222
+ * plain injection verify (no per-node stamping), which is non-destructive and
223
+ * matches prior behavior.
224
+ */
225
+ export async function resolveTargetedNodes(injectionId, treeId) {
226
+ if (!treeId)
227
+ return [];
228
+ try {
229
+ const [edgesResp, nodesResp] = await Promise.all([
230
+ callApi('reality_tree_edge_list', { treeId }),
231
+ callApi('reality_tree_node_list', { treeId }),
232
+ ]);
233
+ const targetIds = (edgesResp.items ?? [])
234
+ .filter((e) => e.edgeType === 'targets' && e.fromNodeId === injectionId)
235
+ .map((e) => e.toNodeId);
236
+ if (targetIds.length === 0)
237
+ return [];
238
+ const nodeById = new Map();
239
+ for (const n of nodesResp.items ?? [])
240
+ nodeById.set(n.id, n);
241
+ const isClassification = (v) => v === 'match' || v === 'legitimate_divergence' || v === 'shortfall';
242
+ return targetIds.map((nodeId) => {
243
+ const node = nodeById.get(nodeId);
244
+ const declared = node?.frtStatement ?? node?.statement ?? '';
245
+ const existing = node?.verifyClassification;
246
+ return {
247
+ nodeId,
248
+ achievedStatement: declared,
249
+ originalClaim: declared,
250
+ existingClassification: isClassification(existing) ? existing : null,
251
+ };
252
+ });
253
+ }
254
+ catch (err) {
255
+ console.warn(`[reality-writeback] Failed to resolve targeted nodes for injection ` +
256
+ `${injectionId.slice(0, 8)} (tree ${treeId.slice(0, 8)}): ${err.message}. ` +
257
+ `Falling back to plain verify (no per-node writeback).`);
258
+ return [];
259
+ }
260
+ }
261
+ /**
262
+ * Build the writeback-applying verify callback used by the close-loop sweep.
263
+ *
264
+ * For each injection the sweep verifies, this closure:
265
+ * 1. Resolves the injection's targeted UDE node ids (edge-list) + each node's
266
+ * EXISTING verify_classification.
267
+ * 2. Models the landing as a CLEAN realization for the still-unstamped (or
268
+ * already-match) targets -- the anchoring delivery closed successfully, so
269
+ * the cascade is treated as flipped and the injection as delivered. A
270
+ * target the per-delivery verify path ALREADY stamped as a contradiction
271
+ * (legitimate_divergence / shortfall) is EXCLUDED from the landing so the
272
+ * close-loop sweep never clobbers a diverged stamp back to 'match' (TEL-3).
273
+ * 3. Computes the per-node writeback and applies it via
274
+ * `verifyInjectionWithWriteback`, stamping match/evidence on each targeted
275
+ * UDE so a later reader sees which claims actually held.
276
+ *
277
+ * No targeted nodes -> the writeback is empty and the call is byte-equivalent
278
+ * to the plain `verifyInjectionWithEvidence`.
279
+ *
280
+ * `treeIdByInjection` maps an injection node id to its reality_tree id, captured
281
+ * by the dispatcher from the focus-injections snapshot. The returned callback
282
+ * matches the `(injectionId, evidence) => Promise<void>` shape the close-loop
283
+ * sweep expects, so it drops into `advanceFocusToDoneWithSweep` unchanged.
284
+ *
285
+ * Exported here (rather than in the dispatcher) so the wiring is unit-testable
286
+ * against the callApi mock seam without dragging the dispatcher's heavy import
287
+ * graph.
288
+ */
289
+ export function buildWritebackVerify(treeIdByInjection) {
290
+ return async (injectionId, evidence) => {
291
+ const treeId = treeIdByInjection.get(injectionId);
292
+ const resolved = await resolveTargetedNodes(injectionId, treeId);
293
+ // TEL-3: a node the per-delivery verify path ALREADY stamped as a
294
+ // contradiction (legitimate_divergence / shortfall) must NOT be clobbered
295
+ // back to 'match' at close-loop. Exclude it from the clean-match landing --
296
+ // its stamp (and its inward drift proposal) already landed at verify time.
297
+ // Only un-stamped (or already-match) nodes get a fresh close-loop match.
298
+ const targetedNodes = resolved
299
+ .filter((n) => n.existingClassification !== 'legitimate_divergence' &&
300
+ n.existingClassification !== 'shortfall')
301
+ .map((n) => ({
302
+ nodeId: n.nodeId,
303
+ achievedStatement: n.achievedStatement,
304
+ originalClaim: n.originalClaim,
305
+ }));
306
+ const writebacks = decideNodeWriteback({
307
+ injectionId,
308
+ targetedNodes,
309
+ cascadeFlipped: true,
310
+ delivered: true,
311
+ evidence,
312
+ });
313
+ // Pass the tree id so any contradicted node (divergence/shortfall) can be
314
+ // surfaced as an inward drift proposal. The close-loop sweep models a clean
315
+ // landing (all 'match'), so this emits nothing here today -- but the seam is
316
+ // wired so a divergent landing routed through this path corrects the tree.
317
+ await verifyInjectionWithWriteback(injectionId, evidence, writebacks, treeId);
318
+ };
319
+ }
49
320
  //# sourceMappingURL=verification.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"verification.js","sourceRoot":"","sources":["../../src/queries/verification.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAiBtC,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,SAAkB;IAElB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAC5B,kCAAkC,EAClC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAC/B,CAAC;IACF,OAAO,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,UAAkB,EAClB,OAA4B;IAE5B,MAAM,OAAO,CAAC,6CAA6C,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;AACxF,CAAC;AAiBD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,eAAuB,EACvB,YAAkC;IAElC,MAAM,IAAI,GAA4B,EAAE,eAAe,EAAE,CAAC;IAC1D,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;QAAE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IAC9E,MAAM,OAAO,CAAC,+BAA+B,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,eAAuB,EACvB,QAAgB;IAEhB,MAAM,OAAO,CAAC,0BAA0B,EAAE;QACxC,MAAM,EAAE,eAAe;QACvB,QAAQ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