agentfootprint 9.82.0 → 9.84.0

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 (162) hide show
  1. package/CHANGELOG.md +718 -504
  2. package/CLAUDE.md +1 -0
  3. package/README.md +15 -15
  4. package/ai-instructions/claude-code/SKILL.md +1 -1
  5. package/dist/core/Agent.js +43 -1
  6. package/dist/core/Agent.js.map +1 -1
  7. package/dist/core/agent/AgentBuilder.js.map +1 -1
  8. package/dist/core/agent/evidence/evidenceIndex.js +96 -11
  9. package/dist/core/agent/evidence/evidenceIndex.js.map +1 -1
  10. package/dist/core/agent/evidence/frames.js +15 -6
  11. package/dist/core/agent/evidence/frames.js.map +1 -1
  12. package/dist/core/agent/evidence/gate.js +66 -6
  13. package/dist/core/agent/evidence/gate.js.map +1 -1
  14. package/dist/core/agent/outputEnforcement.js +7 -4
  15. package/dist/core/agent/outputEnforcement.js.map +1 -1
  16. package/dist/core/agent/selfCallNotice.js +174 -0
  17. package/dist/core/agent/selfCallNotice.js.map +1 -0
  18. package/dist/core/agent/stages/route.js +71 -12
  19. package/dist/core/agent/stages/route.js.map +1 -1
  20. package/dist/core/agent/stages/toolCalls.js +87 -2
  21. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  22. package/dist/core/agent/window/currentRequest.js +11 -13
  23. package/dist/core/agent/window/currentRequest.js.map +1 -1
  24. package/dist/core/agent/window/notice.js +9 -9
  25. package/dist/core/agent/window/notice.js.map +1 -1
  26. package/dist/core/agent/window/summarize.js +9 -9
  27. package/dist/core/agent/window/summarize.js.map +1 -1
  28. package/dist/doors/skill-graph.js +2 -1
  29. package/dist/doors/skill-graph.js.map +1 -1
  30. package/dist/esm/core/Agent.d.ts +4 -0
  31. package/dist/esm/core/Agent.js +43 -1
  32. package/dist/esm/core/Agent.js.map +1 -1
  33. package/dist/esm/core/agent/AgentBuilder.d.ts +15 -0
  34. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  35. package/dist/esm/core/agent/evidence/evidenceIndex.d.ts +91 -5
  36. package/dist/esm/core/agent/evidence/evidenceIndex.js +96 -11
  37. package/dist/esm/core/agent/evidence/evidenceIndex.js.map +1 -1
  38. package/dist/esm/core/agent/evidence/frames.d.ts +9 -4
  39. package/dist/esm/core/agent/evidence/frames.js +13 -5
  40. package/dist/esm/core/agent/evidence/frames.js.map +1 -1
  41. package/dist/esm/core/agent/evidence/gate.d.ts +27 -0
  42. package/dist/esm/core/agent/evidence/gate.js +66 -6
  43. package/dist/esm/core/agent/evidence/gate.js.map +1 -1
  44. package/dist/esm/core/agent/evidence/types.d.ts +12 -0
  45. package/dist/esm/core/agent/outputEnforcement.d.ts +1 -2
  46. package/dist/esm/core/agent/outputEnforcement.js +4 -2
  47. package/dist/esm/core/agent/outputEnforcement.js.map +1 -1
  48. package/dist/esm/core/agent/selfCallNotice.d.ts +140 -0
  49. package/dist/esm/core/agent/selfCallNotice.js +169 -0
  50. package/dist/esm/core/agent/selfCallNotice.js.map +1 -0
  51. package/dist/esm/core/agent/stages/route.d.ts +6 -1
  52. package/dist/esm/core/agent/stages/route.js +69 -10
  53. package/dist/esm/core/agent/stages/route.js.map +1 -1
  54. package/dist/esm/core/agent/stages/toolCalls.d.ts +6 -0
  55. package/dist/esm/core/agent/stages/toolCalls.js +87 -2
  56. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  57. package/dist/esm/core/agent/types.d.ts +66 -0
  58. package/dist/esm/core/agent/window/currentRequest.d.ts +9 -3
  59. package/dist/esm/core/agent/window/currentRequest.js +11 -13
  60. package/dist/esm/core/agent/window/currentRequest.js.map +1 -1
  61. package/dist/esm/core/agent/window/notice.d.ts +1 -4
  62. package/dist/esm/core/agent/window/notice.js +5 -6
  63. package/dist/esm/core/agent/window/notice.js.map +1 -1
  64. package/dist/esm/core/agent/window/summarize.d.ts +1 -4
  65. package/dist/esm/core/agent/window/summarize.js +5 -6
  66. package/dist/esm/core/agent/window/summarize.js.map +1 -1
  67. package/dist/esm/doors/skill-graph.d.ts +1 -1
  68. package/dist/esm/doors/skill-graph.js +1 -1
  69. package/dist/esm/doors/skill-graph.js.map +1 -1
  70. package/dist/esm/events/payloads.d.ts +15 -0
  71. package/dist/esm/index.d.ts +2 -0
  72. package/dist/esm/index.js +16 -0
  73. package/dist/esm/index.js.map +1 -1
  74. package/dist/esm/integrity/disposition/lifecycle.d.ts +17 -1
  75. package/dist/esm/integrity/disposition/lifecycle.js +26 -1
  76. package/dist/esm/integrity/disposition/lifecycle.js.map +1 -1
  77. package/dist/esm/integrity/finding/types.d.ts +12 -2
  78. package/dist/esm/integrity/finding/types.js.map +1 -1
  79. package/dist/esm/integrity/prior-turn-evidence/check.d.ts +145 -0
  80. package/dist/esm/integrity/prior-turn-evidence/check.js +200 -0
  81. package/dist/esm/integrity/prior-turn-evidence/check.js.map +1 -0
  82. package/dist/esm/lib/injection-engine/index.d.ts +1 -0
  83. package/dist/esm/lib/injection-engine/index.js +6 -0
  84. package/dist/esm/lib/injection-engine/index.js.map +1 -1
  85. package/dist/esm/lib/injection-engine/skillToolDescriptors.d.ts +29 -0
  86. package/dist/esm/lib/injection-engine/skillToolDescriptors.js +90 -7
  87. package/dist/esm/lib/injection-engine/skillToolDescriptors.js.map +1 -1
  88. package/dist/esm/lib/injection-engine/types.d.ts +54 -0
  89. package/dist/esm/lib/injection-engine/types.js +28 -0
  90. package/dist/esm/lib/injection-engine/types.js.map +1 -1
  91. package/dist/esm/lib/saidByPerson.d.ts +99 -0
  92. package/dist/esm/lib/saidByPerson.js +104 -0
  93. package/dist/esm/lib/saidByPerson.js.map +1 -0
  94. package/dist/esm/lib/trace-toolpack/traceToolpack.js +3 -2
  95. package/dist/esm/lib/trace-toolpack/traceToolpack.js.map +1 -1
  96. package/dist/index.js +23 -3
  97. package/dist/index.js.map +1 -1
  98. package/dist/integrity/disposition/lifecycle.js +26 -1
  99. package/dist/integrity/disposition/lifecycle.js.map +1 -1
  100. package/dist/integrity/finding/types.js.map +1 -1
  101. package/dist/integrity/prior-turn-evidence/check.js +204 -0
  102. package/dist/integrity/prior-turn-evidence/check.js.map +1 -0
  103. package/dist/lib/injection-engine/index.js +9 -2
  104. package/dist/lib/injection-engine/index.js.map +1 -1
  105. package/dist/lib/injection-engine/skillToolDescriptors.js +92 -8
  106. package/dist/lib/injection-engine/skillToolDescriptors.js.map +1 -1
  107. package/dist/lib/injection-engine/types.js +30 -1
  108. package/dist/lib/injection-engine/types.js.map +1 -1
  109. package/dist/lib/saidByPerson.js +111 -0
  110. package/dist/lib/saidByPerson.js.map +1 -0
  111. package/dist/lib/trace-toolpack/traceToolpack.js +3 -2
  112. package/dist/lib/trace-toolpack/traceToolpack.js.map +1 -1
  113. package/dist/types/core/Agent.d.ts +4 -0
  114. package/dist/types/core/Agent.d.ts.map +1 -1
  115. package/dist/types/core/agent/AgentBuilder.d.ts +15 -0
  116. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  117. package/dist/types/core/agent/evidence/evidenceIndex.d.ts +91 -5
  118. package/dist/types/core/agent/evidence/evidenceIndex.d.ts.map +1 -1
  119. package/dist/types/core/agent/evidence/frames.d.ts +9 -4
  120. package/dist/types/core/agent/evidence/frames.d.ts.map +1 -1
  121. package/dist/types/core/agent/evidence/gate.d.ts +27 -0
  122. package/dist/types/core/agent/evidence/gate.d.ts.map +1 -1
  123. package/dist/types/core/agent/evidence/types.d.ts +12 -0
  124. package/dist/types/core/agent/evidence/types.d.ts.map +1 -1
  125. package/dist/types/core/agent/outputEnforcement.d.ts +1 -2
  126. package/dist/types/core/agent/outputEnforcement.d.ts.map +1 -1
  127. package/dist/types/core/agent/selfCallNotice.d.ts +141 -0
  128. package/dist/types/core/agent/selfCallNotice.d.ts.map +1 -0
  129. package/dist/types/core/agent/stages/route.d.ts +6 -1
  130. package/dist/types/core/agent/stages/route.d.ts.map +1 -1
  131. package/dist/types/core/agent/stages/toolCalls.d.ts +6 -0
  132. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  133. package/dist/types/core/agent/types.d.ts +66 -0
  134. package/dist/types/core/agent/types.d.ts.map +1 -1
  135. package/dist/types/core/agent/window/currentRequest.d.ts +9 -3
  136. package/dist/types/core/agent/window/currentRequest.d.ts.map +1 -1
  137. package/dist/types/core/agent/window/notice.d.ts +1 -4
  138. package/dist/types/core/agent/window/notice.d.ts.map +1 -1
  139. package/dist/types/core/agent/window/summarize.d.ts +1 -4
  140. package/dist/types/core/agent/window/summarize.d.ts.map +1 -1
  141. package/dist/types/doors/skill-graph.d.ts +1 -1
  142. package/dist/types/doors/skill-graph.d.ts.map +1 -1
  143. package/dist/types/events/payloads.d.ts +15 -0
  144. package/dist/types/events/payloads.d.ts.map +1 -1
  145. package/dist/types/index.d.ts +2 -0
  146. package/dist/types/index.d.ts.map +1 -1
  147. package/dist/types/integrity/disposition/lifecycle.d.ts +17 -1
  148. package/dist/types/integrity/disposition/lifecycle.d.ts.map +1 -1
  149. package/dist/types/integrity/finding/types.d.ts +12 -2
  150. package/dist/types/integrity/finding/types.d.ts.map +1 -1
  151. package/dist/types/integrity/prior-turn-evidence/check.d.ts +146 -0
  152. package/dist/types/integrity/prior-turn-evidence/check.d.ts.map +1 -0
  153. package/dist/types/lib/injection-engine/index.d.ts +1 -0
  154. package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
  155. package/dist/types/lib/injection-engine/skillToolDescriptors.d.ts +29 -0
  156. package/dist/types/lib/injection-engine/skillToolDescriptors.d.ts.map +1 -1
  157. package/dist/types/lib/injection-engine/types.d.ts +54 -0
  158. package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
  159. package/dist/types/lib/saidByPerson.d.ts +100 -0
  160. package/dist/types/lib/saidByPerson.d.ts.map +1 -0
  161. package/dist/types/lib/trace-toolpack/traceToolpack.d.ts.map +1 -1
  162. package/package.json +2 -2
@@ -42,6 +42,13 @@
42
42
  * unexamined. A missed fabrication is a miss; a false accusation costs a real
43
43
  * turn and can refuse a good answer, so the bias points the way it does.
44
44
  *
45
+ * **And it does not ask WHEN.** A value read four turns ago for a different
46
+ * question is as grounded here as one read a second ago — which is a measured
47
+ * failure, not a hypothetical (see `../../../integrity/prior-turn-evidence`).
48
+ * That fact is reported beside this check, never folded into it: the gate's
49
+ * job is "was this read at all", and answering a second question through the
50
+ * same verdict would make one dial control two decisions.
51
+ *
45
52
  * ## Why the check is DETERMINISTIC
46
53
  *
47
54
  * No model call, no embedding, no judge. The library's thesis is that
@@ -69,6 +76,13 @@ export declare function resolveEvidenceGate(opts?: NamesAndNumbersOptions): Reso
69
76
  *
70
77
  * `exempt` is checked BEFORE the evidence: a value the user supplied is not a
71
78
  * fabrication whether or not a tool ever echoed it back.
79
+ *
80
+ * The same pass reports WHEN each grounded value was read (`grounding`) — the
81
+ * time axis the corpus gained in 9.83.0. Three buckets, and an exempt value is
82
+ * in none of them: exemption is a statement about who SUPPLIED a value, and a
83
+ * value the app or the person put in front of the model was never something
84
+ * the run had to go and look up. Counting one as tool evidence — of any turn —
85
+ * would answer a question nobody asked.
72
86
  */
73
87
  export declare function checkAnswer(answer: string, args: {
74
88
  readonly gate: ResolvedEvidenceGate;
@@ -92,6 +106,19 @@ export declare function describeValues(values: readonly UnsupportedValue[]): str
92
106
  * compaction frame and the schema frame follow, and a rule with an exception
93
107
  * is not a rule.
94
108
  *
109
+ * ## The scope this sentence used to claim, and no longer does (9.83.0)
110
+ *
111
+ * Both this frame and {@link evidenceRefusalSentence} said the flagged values
112
+ * "appear in NO tool result FROM THIS TURN". The index they are written from
113
+ * has never been turn-scoped — it walks every `role: 'tool'` turn in
114
+ * `scope.history` — so the sentence named a boundary the check did not honour,
115
+ * in the two places the claim is read by a model and by an operator. It was
116
+ * also needlessly weak: a flagged value appears in no tool result the run can
117
+ * point at AT ALL, which is a stronger and true thing to say. So the words
118
+ * changed to the check's real reach. The recency fact the old wording gestured
119
+ * at is now reported where it can be measured — `prior-turn-evidence`, off by
120
+ * default — instead of asserted here where it could not be.
121
+ *
95
122
  * `stagedRefs` (optional) is the staged-refs join computed by the recheck
96
123
  * stage: when this turn holds placed artifact tickets a served `wants` tool
97
124
  * can spend, the frame names the refs and the spender by their declared names
@@ -42,6 +42,13 @@
42
42
  * unexamined. A missed fabrication is a miss; a false accusation costs a real
43
43
  * turn and can refuse a good answer, so the bias points the way it does.
44
44
  *
45
+ * **And it does not ask WHEN.** A value read four turns ago for a different
46
+ * question is as grounded here as one read a second ago — which is a measured
47
+ * failure, not a hypothetical (see `../../../integrity/prior-turn-evidence`).
48
+ * That fact is reported beside this check, never folded into it: the gate's
49
+ * job is "was this read at all", and answering a second question through the
50
+ * same verdict would make one dial control two decisions.
51
+ *
45
52
  * ## Why the check is DETERMINISTIC
46
53
  *
47
54
  * No model call, no embedding, no judge. The library's thesis is that
@@ -148,20 +155,58 @@ function anchor(re) {
148
155
  *
149
156
  * `exempt` is checked BEFORE the evidence: a value the user supplied is not a
150
157
  * fabrication whether or not a tool ever echoed it back.
158
+ *
159
+ * The same pass reports WHEN each grounded value was read (`grounding`) — the
160
+ * time axis the corpus gained in 9.83.0. Three buckets, and an exempt value is
161
+ * in none of them: exemption is a statement about who SUPPLIED a value, and a
162
+ * value the app or the person put in front of the model was never something
163
+ * the run had to go and look up. Counting one as tool evidence — of any turn —
164
+ * would answer a question nobody asked.
151
165
  */
152
166
  export function checkAnswer(answer, args) {
153
167
  const candidates = extractCandidates(answer, args.gate);
154
168
  const unsupported = [];
169
+ let fromThisTurn = 0;
170
+ let fromPriorTurns = 0;
171
+ let latestPriorTurn;
155
172
  for (const candidate of candidates) {
156
173
  const forms = lookupForms(candidate.value);
157
- const known = forms.some((f) => args.exempt.has(f) || args.evidence.values.has(f));
158
- if (!known)
174
+ if (forms.some((f) => args.exempt.has(f)))
175
+ continue;
176
+ // The NEWEST turn any spelling of this value was served in. Newest,
177
+ // because the question is whether this turn could have supplied it — an
178
+ // identifier echoed back by a lookup this turn is this turn's, whatever
179
+ // else served it three turns ago.
180
+ let turn;
181
+ for (const form of forms) {
182
+ const seen = args.evidence.values.get(form);
183
+ if (seen !== undefined && (turn === undefined || seen > turn))
184
+ turn = seen;
185
+ }
186
+ if (turn === undefined) {
159
187
  unsupported.push({ value: clip(candidate.value), shape: candidate.shape });
188
+ continue;
189
+ }
190
+ if (turn >= args.evidence.currentTurn) {
191
+ fromThisTurn += 1;
192
+ continue;
193
+ }
194
+ fromPriorTurns += 1;
195
+ if (latestPriorTurn === undefined || turn > latestPriorTurn)
196
+ latestPriorTurn = turn;
160
197
  }
161
198
  return {
162
199
  unsupported,
163
200
  candidates: candidates.length,
164
201
  evidenceTruncated: args.evidence.truncated,
202
+ grounding: {
203
+ fromThisTurn,
204
+ fromPriorTurns,
205
+ ...(latestPriorTurn !== undefined && { latestPriorTurn }),
206
+ currentTurn: args.evidence.currentTurn,
207
+ toolResultsThisTurn: args.evidence.toolResultsThisTurn,
208
+ indexTruncated: args.evidence.truncated,
209
+ },
165
210
  };
166
211
  }
167
212
  /** Render the flagged values for a human or a model: `` `x` (shape) ``. */
@@ -186,6 +231,19 @@ export function describeValues(values) {
186
231
  * compaction frame and the schema frame follow, and a rule with an exception
187
232
  * is not a rule.
188
233
  *
234
+ * ## The scope this sentence used to claim, and no longer does (9.83.0)
235
+ *
236
+ * Both this frame and {@link evidenceRefusalSentence} said the flagged values
237
+ * "appear in NO tool result FROM THIS TURN". The index they are written from
238
+ * has never been turn-scoped — it walks every `role: 'tool'` turn in
239
+ * `scope.history` — so the sentence named a boundary the check did not honour,
240
+ * in the two places the claim is read by a model and by an operator. It was
241
+ * also needlessly weak: a flagged value appears in no tool result the run can
242
+ * point at AT ALL, which is a stronger and true thing to say. So the words
243
+ * changed to the check's real reach. The recency fact the old wording gestured
244
+ * at is now reported where it can be measured — `prior-turn-evidence`, off by
245
+ * default — instead of asserted here where it could not be.
246
+ *
189
247
  * `stagedRefs` (optional) is the staged-refs join computed by the recheck
190
248
  * stage: when this turn holds placed artifact tickets a served `wants` tool
191
249
  * can spend, the frame names the refs and the spender by their declared names
@@ -197,7 +255,7 @@ export function describeValues(values) {
197
255
  */
198
256
  export function buildEvidenceCorrection(failedAnswer, values, stagedRefs) {
199
257
  const frame = `${EVIDENCE_CHECK_FRAME_PREFIX} — the answer above states values that appear in NO tool ` +
200
- `result from this turn, so they were not read from the data. Reply again using only names ` +
258
+ `result this run read, so they were not read from the data. Reply again using only names ` +
201
259
  `and numbers a tool actually returned. If you need one of these values, call the tool that ` +
202
260
  `provides it.` +
203
261
  (stagedRefs === undefined ? '' : stagedRefsTeachingClause(stagedRefs)) +
@@ -220,14 +278,16 @@ export function buildEvidenceCorrection(failedAnswer, values, stagedRefs) {
220
278
  */
221
279
  export function evidenceRefusalSentence(values, posture, revised) {
222
280
  const head = posture === 'rails'
223
- ? `[agentfootprint] this answer was NOT returned: ${values.length} value(s) in it appear in no tool result from this turn`
224
- : `[agentfootprint] this answer states ${values.length} value(s) that appear in no tool result from this turn`;
281
+ ? `[agentfootprint] this answer was NOT returned: ${values.length} value(s) in it appear in no tool result this run read`
282
+ : `[agentfootprint] this answer states ${values.length} value(s) that appear in no tool result this run read`;
225
283
  return (`${head} — ${describeValues(values)}. ` +
226
284
  (revised ? 'The model was asked once to correct them and they survived the revision. ' : '') +
227
285
  'What would satisfy the check: every name and number in the answer appears in a tool ' +
228
286
  'result (or in the message you sent). Call a tool that returns these values, declare their ' +
229
287
  'shape via `shapes` if they are legitimate and the extractor mis-read them, or accept the ' +
230
288
  "answer with `posture: 'assist'`. This check catches INVENTED values only — it cannot " +
231
- 'tell you whether a claim built from real values is true.');
289
+ 'tell you whether a claim built from real values is true, and it does not ask WHEN a value ' +
290
+ 'was read (`noticePriorTurnEvidence` reports that). What it reads is the live window: a ' +
291
+ 'result a window strategy has already dropped is not in it.');
232
292
  }
233
293
  //# sourceMappingURL=gate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gate.js","sourceRoot":"","sources":["../../../../../src/core/agent/evidence/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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CAAC,MAAM,CAAC,IAAI;QACvC,CAAC,OAAO,CAAC,CAAC,CAAC,2EAA2E,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5F,sFAAsF;QACtF,4FAA4F;QAC5F,2FAA2F;QAC3F,uFAAuF;QACvF,4FAA4F;QAC5F,yFAAyF;QACzF,4DAA4D,CAC7D,CAAC;AACJ,CAAC"}
@@ -6,6 +6,7 @@
6
6
  * Role: core/ layer. Nothing here runs; it is the contract.
7
7
  * Emits: N/A.
8
8
  */
9
+ import type { AnswerGroundingReading } from '../../../integrity/prior-turn-evidence/check.js';
9
10
  /**
10
11
  * How hard the check pushes back. **Same three words as the skill-graph
11
12
  * routing dial, deliberately** — one posture vocabulary across the library —
@@ -138,4 +139,15 @@ export interface EvidenceVerdict {
138
139
  * accusation.
139
140
  */
140
141
  readonly evidenceTruncated: boolean;
142
+ /**
143
+ * WHEN the answer's grounded values were read (9.83.0) — the same pass,
144
+ * one time axis.
145
+ *
146
+ * Always computed, because it is three counters over a loop that was
147
+ * already running. It is only READ when the operator armed
148
+ * `AgentOptions.noticePriorTurnEvidence`, which is what turns it into a
149
+ * `prior-turn-evidence` finding; nothing else in the gate consults it and
150
+ * no posture changes because of it.
151
+ */
152
+ readonly grounding: AnswerGroundingReading;
141
153
  }
@@ -105,8 +105,7 @@ export interface OutputFailure {
105
105
  * the two paths report a failure the same way.
106
106
  */
107
107
  export declare function describeFailure(err: unknown): OutputFailure;
108
- /** Opening of the authored frame. Stable — tests and readers match on it. */
109
- export declare const SCHEMA_CHECK_FRAME_PREFIX = "[schema check";
108
+ export { SCHEMA_CHECK_FRAME_PREFIX } from '../../lib/saidByPerson.js';
110
109
  /**
111
110
  * The two messages a failed attempt adds to the conversation: the answer
112
111
  * that failed, and the correction.
@@ -35,6 +35,7 @@
35
35
  */
36
36
  import { fnv1a } from '../slots/helpers.js';
37
37
  import { applyOutputSchema } from '../outputSchema.js';
38
+ import { SCHEMA_CHECK_FRAME_PREFIX } from '../../lib/saidByPerson.js';
38
39
  /**
39
40
  * Append one row to the run's output-attempt ledger.
40
41
  *
@@ -65,8 +66,9 @@ export function describeFailure(err) {
65
66
  };
66
67
  }
67
68
  // ─── The corrective turn ─────────────────────────────────────────────
68
- /** Opening of the authored frame. Stable — tests and readers match on it. */
69
- export const SCHEMA_CHECK_FRAME_PREFIX = '[schema check';
69
+ // The marker lives in the authorship registry both this file and a rule author
70
+ // can import (9.84.0) — see `lib/saidByPerson.ts`. The frame below is ours.
71
+ export { SCHEMA_CHECK_FRAME_PREFIX } from '../../lib/saidByPerson.js';
70
72
  /**
71
73
  * The two messages a failed attempt adds to the conversation: the answer
72
74
  * that failed, and the correction.
@@ -1 +1 @@
1
- {"version":3,"file":"outputEnforcement.js","sourceRoot":"","sources":["../../../../src/core/agent/outputEnforcement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAA2B,MAAM,oBAAoB,CAAC;AAoDhF;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAwB,EAAE,GAAkB;IAC9E,MAAM,IAAI,GAAI,KAAK,CAAC,cAAuD,IAAI,EAAE,CAAC;IAClF,2EAA2E;IAC3E,+DAA+D;IAC/D,KAAK,CAAC,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC;AAcD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,MAAM,CAAC,GAAG,GAOT,CAAC;IACF,MAAM,UAAU,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,IAAI,GACR,UAAU,EAAE,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,C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AAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * The answer a `read_skill` SELF-CALL gets back (9.84.0).
3
+ *
4
+ * A self-call is `read_skill("X")` from a cursor already standing on X. It used
5
+ * to fall through the skill-graph gate's reachability arm — `makeReachableSkills`
6
+ * filters the cursor out of its own successor set (a MOVE to where you already
7
+ * are is not a move) and `openSkillIds()` excludes every graph-wired skill, so
8
+ * the cursor's own id is in neither half of `hops ∪ open`. The model was told:
9
+ *
10
+ * read_skill("X") is not reachable from here. Reachable skills: …
11
+ *
12
+ * while X's body was in its system prompt and X's tools were in that very call's
13
+ * tool list. Read as a statement about AVAILABILITY — which is how a model reads
14
+ * "not reachable" — that is a flat contradiction of the request it arrived in,
15
+ * and the observed behaviour was to stop and answer that it could not help.
16
+ *
17
+ * ── THE LAW THIS FILE IS WRITTEN AGAINST ──────────────────────────────────
18
+ *
19
+ * A TOOL RESULT IS NOT READ ONCE. It is composed during iteration N, written
20
+ * into `history`, and then read by the model on call N+1 AND ON EVERY CALL
21
+ * AFTER IT for the rest of the turn — including the out-of-budget WRAP-UP,
22
+ * which `callLLM` serves with an EMPTY tool list under a user message saying
23
+ * "Do not request tools".
24
+ *
25
+ * The consequence is the whole design: NO COMPOSE-TIME CHECK CAN MAKE A
26
+ * FORWARD-LOOKING SENTENCE SAFE. A budget test, a posture test, a cursor test
27
+ * — each is true at the instant it runs and each is outlived by the sentence
28
+ * it admitted. Three rounds of this file fixed one clause at a time and each
29
+ * time a different clause was still false, because every one of them was a
30
+ * PREDICTION and the fix was always a better prediction.
31
+ *
32
+ * So the notice makes no predictions at all. Every clause is a fact about ONE
33
+ * already-finished event — the call the model made `read_skill` on — and every
34
+ * clause is anchored to that call by name ("that call"), never by deixis ("the
35
+ * call you just made", which denotes a different call each time it is re-read).
36
+ * A past fact about a named call cannot be falsified by anything that happens
37
+ * afterwards: not by the budget running out, not by a posture refusing a hop,
38
+ * not by a sibling tool in the same batch moving the cursor.
39
+ *
40
+ * ── WHAT WAS DELETED, AND WHY THE NOTICE STILL DOES ITS JOB ───────────────
41
+ *
42
+ * Gone: the exhortation ("Go ahead and act on the request"), the move offer
43
+ * ("read_skill MOVES you somewhere else — from here that would be: beta"), the
44
+ * open-skill offer ("These activate without moving you: gamma"), and the
45
+ * budget clause that was added to gate them. Each was false somewhere:
46
+ *
47
+ * • the exhortation, on the wrap-up call, beside "Do not request tools";
48
+ * • the move offer, on the wrap-up call (a hop is a tool call), under
49
+ * `strictness: 'rails'` (every model hop refused) and under `'guard'` on a
50
+ * decisively-routed turn (every hop not on an outstanding menu refused) —
51
+ * where the sibling posture arm answers a taken-up offer with "read_skill
52
+ * here reaches only the open skills: gamma", contradicting the notice from
53
+ * the arm immediately above it, and spending escalation budget to do so;
54
+ * • the budget clause, because a budget read at compose time is a claim
55
+ * about a call that has not happened.
56
+ *
57
+ * The notice's JOB is to stop a model concluding its capability is gone. It
58
+ * does that by stating what it held, not by promising what it may do: you were
59
+ * standing in this skill, its instructions were in that call's prompt, its
60
+ * tools were on that call's wire, and asking took nothing away. A model that
61
+ * reads those four facts has no ground left for "I cannot help".
62
+ *
63
+ * The forward-looking half had a rightful owner all along, and it is not a
64
+ * tool result: the `read_skill` DESCRIPTION is recomposed on every single call,
65
+ * so it can safely speak in the present ("You are in 'beta'."), it is filtered
66
+ * for per-role visibility at source, and it is absent from the wrap-up because
67
+ * the whole tool list is. One owner for the present tense, one for the past,
68
+ * and they can no longer disagree — which is the only property that survived
69
+ * every round of this bug.
70
+ */
71
+ import type { ActiveInjection } from '../../lib/injection-engine/types.js';
72
+ import type { LLMToolSchema } from '../../adapters/types.js';
73
+ /** What the current skill's tools did on the call the model made `read_skill` on. */
74
+ export interface SelfSkillTools {
75
+ /** Every tool the skill declares — `[]` for a skill that declares none. */
76
+ readonly declared: readonly string[];
77
+ /** Those actually on that call's wire. A subset of `declared`. */
78
+ readonly served: readonly string[];
79
+ }
80
+ /**
81
+ * The skill's tools, as of the call the model just made — or `undefined` when
82
+ * that cannot be established, which is not the same answer and must not be
83
+ * reported as one.
84
+ *
85
+ * `undefined` means the notice says nothing about tools at all. It happens when
86
+ * the tools slot composed no per-iteration list (`reactMode: 'classic'` caches
87
+ * the slot, and `callLLM` falls back to its build-time schemas), or when the
88
+ * cursor's skill is not in the active set. Silence is the only honest output
89
+ * there: the alternative is a sentence naming tools the model may not have.
90
+ *
91
+ * The out-of-budget wrap-up is NOT one of these cases and must not be modelled
92
+ * as one. Its empty tool list belongs to a LATER call; the wire read here is
93
+ * always the one the model was really handed on the call being answered, and
94
+ * the notice speaks of that call and only that call.
95
+ */
96
+ export declare function selfSkillTools(skillId: string, activeInjections: readonly ActiveInjection[] | undefined, wire: readonly LLMToolSchema[] | undefined): SelfSkillTools | undefined;
97
+ /**
98
+ * The self-call's tool result.
99
+ *
100
+ * NOT a refusal to the MODEL, and deliberately so. The gate's other two arms
101
+ * refuse because the model asked for something it may not have; a self-call
102
+ * asks for a body it already holds, and the useful reply is the fact — where
103
+ * you stood, and what rode that call — not a decline. It is still counted as a
104
+ * refusal by the ESCALATION BUDGET (`noteSkillRefusal`, beside the emit), and
105
+ * those two facts do not fight: the budget is not measuring how the sentence
106
+ * reads, it is measuring a model that keeps asking the graph where it is
107
+ * instead of working, which is exactly the stuck run the budget escalates.
108
+ *
109
+ * It still OVERWRITES the tool's own result the way every other arm does,
110
+ * because that overwrite is what puts the authoritative sentence in front of
111
+ * the governance rules, the refusal cap and the after-tool moment, on both
112
+ * channels, before the model reads anything.
113
+ *
114
+ * The one thing not overwritten is a BODY. The live case is `surfaceMode:
115
+ * 'both'` — `'tool-only'` cannot arise here, because `skillBodyDelivery`
116
+ * refuses it at BUILD time for anything but an `llm-activated` skill and only a
117
+ * graph-wired skill can be the cursor. Under `'both'` the body is in the system
118
+ * prompt AND rides the tool result, and the second copy is the whole point of
119
+ * the mode: recency-first delivery, the body at the end of the window rather
120
+ * than only at the top of the prompt. Dropping it here would quietly demote
121
+ * `'both'` to `'system-prompt'` on the one call that asked to re-read.
122
+ *
123
+ * TENSE IS LOAD-BEARING, AND SO IS DEIXIS. Every clause below is past tense
124
+ * about a single named call, and every reference to that call is "that call" —
125
+ * bound by the opening clause, which says which call it was. "The call you just
126
+ * made" was the earlier wording and it is not safe: re-read four calls later it
127
+ * denotes call four, and the tools it names rode call one.
128
+ *
129
+ * There are exactly two present-tense phrases in the output and both are
130
+ * timeless rather than temporal: "It declares no tools of its own" (a
131
+ * declaration is fixed when the skill is defined and cannot vary within a run)
132
+ * and "Its instructions are repeated below" (the body is appended to this very
133
+ * string, so the sentence is true wherever the string is read).
134
+ */
135
+ export declare function selfCallNotice(args: {
136
+ readonly skillId: string;
137
+ /** `undefined` when the wire could not be established — see `selfSkillTools`. */
138
+ readonly tools: SelfSkillTools | undefined;
139
+ readonly body?: string;
140
+ }): string;
@@ -0,0 +1,169 @@
1
+ /**
2
+ * The answer a `read_skill` SELF-CALL gets back (9.84.0).
3
+ *
4
+ * A self-call is `read_skill("X")` from a cursor already standing on X. It used
5
+ * to fall through the skill-graph gate's reachability arm — `makeReachableSkills`
6
+ * filters the cursor out of its own successor set (a MOVE to where you already
7
+ * are is not a move) and `openSkillIds()` excludes every graph-wired skill, so
8
+ * the cursor's own id is in neither half of `hops ∪ open`. The model was told:
9
+ *
10
+ * read_skill("X") is not reachable from here. Reachable skills: …
11
+ *
12
+ * while X's body was in its system prompt and X's tools were in that very call's
13
+ * tool list. Read as a statement about AVAILABILITY — which is how a model reads
14
+ * "not reachable" — that is a flat contradiction of the request it arrived in,
15
+ * and the observed behaviour was to stop and answer that it could not help.
16
+ *
17
+ * ── THE LAW THIS FILE IS WRITTEN AGAINST ──────────────────────────────────
18
+ *
19
+ * A TOOL RESULT IS NOT READ ONCE. It is composed during iteration N, written
20
+ * into `history`, and then read by the model on call N+1 AND ON EVERY CALL
21
+ * AFTER IT for the rest of the turn — including the out-of-budget WRAP-UP,
22
+ * which `callLLM` serves with an EMPTY tool list under a user message saying
23
+ * "Do not request tools".
24
+ *
25
+ * The consequence is the whole design: NO COMPOSE-TIME CHECK CAN MAKE A
26
+ * FORWARD-LOOKING SENTENCE SAFE. A budget test, a posture test, a cursor test
27
+ * — each is true at the instant it runs and each is outlived by the sentence
28
+ * it admitted. Three rounds of this file fixed one clause at a time and each
29
+ * time a different clause was still false, because every one of them was a
30
+ * PREDICTION and the fix was always a better prediction.
31
+ *
32
+ * So the notice makes no predictions at all. Every clause is a fact about ONE
33
+ * already-finished event — the call the model made `read_skill` on — and every
34
+ * clause is anchored to that call by name ("that call"), never by deixis ("the
35
+ * call you just made", which denotes a different call each time it is re-read).
36
+ * A past fact about a named call cannot be falsified by anything that happens
37
+ * afterwards: not by the budget running out, not by a posture refusing a hop,
38
+ * not by a sibling tool in the same batch moving the cursor.
39
+ *
40
+ * ── WHAT WAS DELETED, AND WHY THE NOTICE STILL DOES ITS JOB ───────────────
41
+ *
42
+ * Gone: the exhortation ("Go ahead and act on the request"), the move offer
43
+ * ("read_skill MOVES you somewhere else — from here that would be: beta"), the
44
+ * open-skill offer ("These activate without moving you: gamma"), and the
45
+ * budget clause that was added to gate them. Each was false somewhere:
46
+ *
47
+ * • the exhortation, on the wrap-up call, beside "Do not request tools";
48
+ * • the move offer, on the wrap-up call (a hop is a tool call), under
49
+ * `strictness: 'rails'` (every model hop refused) and under `'guard'` on a
50
+ * decisively-routed turn (every hop not on an outstanding menu refused) —
51
+ * where the sibling posture arm answers a taken-up offer with "read_skill
52
+ * here reaches only the open skills: gamma", contradicting the notice from
53
+ * the arm immediately above it, and spending escalation budget to do so;
54
+ * • the budget clause, because a budget read at compose time is a claim
55
+ * about a call that has not happened.
56
+ *
57
+ * The notice's JOB is to stop a model concluding its capability is gone. It
58
+ * does that by stating what it held, not by promising what it may do: you were
59
+ * standing in this skill, its instructions were in that call's prompt, its
60
+ * tools were on that call's wire, and asking took nothing away. A model that
61
+ * reads those four facts has no ground left for "I cannot help".
62
+ *
63
+ * The forward-looking half had a rightful owner all along, and it is not a
64
+ * tool result: the `read_skill` DESCRIPTION is recomposed on every single call,
65
+ * so it can safely speak in the present ("You are in 'beta'."), it is filtered
66
+ * for per-role visibility at source, and it is absent from the wrap-up because
67
+ * the whole tool list is. One owner for the present tense, one for the past,
68
+ * and they can no longer disagree — which is the only property that survived
69
+ * every round of this bug.
70
+ */
71
+ /**
72
+ * The skill's tools, as of the call the model just made — or `undefined` when
73
+ * that cannot be established, which is not the same answer and must not be
74
+ * reported as one.
75
+ *
76
+ * `undefined` means the notice says nothing about tools at all. It happens when
77
+ * the tools slot composed no per-iteration list (`reactMode: 'classic'` caches
78
+ * the slot, and `callLLM` falls back to its build-time schemas), or when the
79
+ * cursor's skill is not in the active set. Silence is the only honest output
80
+ * there: the alternative is a sentence naming tools the model may not have.
81
+ *
82
+ * The out-of-budget wrap-up is NOT one of these cases and must not be modelled
83
+ * as one. Its empty tool list belongs to a LATER call; the wire read here is
84
+ * always the one the model was really handed on the call being answered, and
85
+ * the notice speaks of that call and only that call.
86
+ */
87
+ export function selfSkillTools(skillId, activeInjections, wire) {
88
+ if (wire === undefined || activeInjections === undefined)
89
+ return undefined;
90
+ const mine = activeInjections.find((i) => i.id === skillId);
91
+ if (mine === undefined)
92
+ return undefined;
93
+ const declared = (mine.inject.tools ?? []).map((t) => t.schema.name);
94
+ const onWire = new Set(wire.map((s) => s.name));
95
+ return { declared, served: declared.filter((n) => onWire.has(n)) };
96
+ }
97
+ /**
98
+ * The self-call's tool result.
99
+ *
100
+ * NOT a refusal to the MODEL, and deliberately so. The gate's other two arms
101
+ * refuse because the model asked for something it may not have; a self-call
102
+ * asks for a body it already holds, and the useful reply is the fact — where
103
+ * you stood, and what rode that call — not a decline. It is still counted as a
104
+ * refusal by the ESCALATION BUDGET (`noteSkillRefusal`, beside the emit), and
105
+ * those two facts do not fight: the budget is not measuring how the sentence
106
+ * reads, it is measuring a model that keeps asking the graph where it is
107
+ * instead of working, which is exactly the stuck run the budget escalates.
108
+ *
109
+ * It still OVERWRITES the tool's own result the way every other arm does,
110
+ * because that overwrite is what puts the authoritative sentence in front of
111
+ * the governance rules, the refusal cap and the after-tool moment, on both
112
+ * channels, before the model reads anything.
113
+ *
114
+ * The one thing not overwritten is a BODY. The live case is `surfaceMode:
115
+ * 'both'` — `'tool-only'` cannot arise here, because `skillBodyDelivery`
116
+ * refuses it at BUILD time for anything but an `llm-activated` skill and only a
117
+ * graph-wired skill can be the cursor. Under `'both'` the body is in the system
118
+ * prompt AND rides the tool result, and the second copy is the whole point of
119
+ * the mode: recency-first delivery, the body at the end of the window rather
120
+ * than only at the top of the prompt. Dropping it here would quietly demote
121
+ * `'both'` to `'system-prompt'` on the one call that asked to re-read.
122
+ *
123
+ * TENSE IS LOAD-BEARING, AND SO IS DEIXIS. Every clause below is past tense
124
+ * about a single named call, and every reference to that call is "that call" —
125
+ * bound by the opening clause, which says which call it was. "The call you just
126
+ * made" was the earlier wording and it is not safe: re-read four calls later it
127
+ * denotes call four, and the tools it names rode call one.
128
+ *
129
+ * There are exactly two present-tense phrases in the output and both are
130
+ * timeless rather than temporal: "It declares no tools of its own" (a
131
+ * declaration is fixed when the skill is defined and cannot vary within a run)
132
+ * and "Its instructions are repeated below" (the body is appended to this very
133
+ * string, so the sentence is true wherever the string is read).
134
+ */
135
+ export function selfCallNotice(args) {
136
+ const { skillId, tools, body } = args;
137
+ // "were in that call's system prompt" is a claim about the prompt, and the
138
+ // evidence for it is that the skill was in the ACTIVE set for that call —
139
+ // which is exactly what `tools !== undefined` establishes (see
140
+ // `selfSkillTools`). With no body to append and no proof it was mounted, the
141
+ // notice says nothing about the instructions rather than asserting where
142
+ // they were.
143
+ const bodyClause = body !== undefined
144
+ ? `Its instructions are repeated below. `
145
+ : tools !== undefined
146
+ ? `Its instructions were in that call's system prompt. `
147
+ : '';
148
+ const toolClause = tools === undefined
149
+ ? ''
150
+ : tools.declared.length === 0
151
+ ? `It declares no tools of its own. `
152
+ : tools.served.length > 0
153
+ ? `Its own tools were on that call's tool list: ${tools.served.join(', ')}.`
154
+ : `None of its own tools were on that call's tool list (${tools.declared.join(', ')} ` +
155
+ `${tools.declared.length === 1 ? 'was' : 'were'} withheld).`;
156
+ // The opening clause is what binds "that call" for every clause after it, so
157
+ // it names the event rather than the state: not where the cursor IS, but
158
+ // where it stood when this call was made. A sibling tool in the SAME batch
159
+ // can fire a step edge and move the cursor before the model reads this — the
160
+ // read_skill description in that request will then say "You are in 'beta'",
161
+ // and the two must not contradict each other. Only one of them is entitled
162
+ // to the present tense, and it is the one recomposed on every call.
163
+ const notice = `read_skill("${skillId}") named the skill you were already standing in when you ` +
164
+ `made that call, so the cursor did not move — nothing was activated, and nothing ` +
165
+ `was taken away. ${bodyClause}${toolClause}`;
166
+ const trimmed = notice.trimEnd();
167
+ return body === undefined ? trimmed : `${trimmed}\n\n${body}`;
168
+ }
169
+ //# sourceMappingURL=selfCallNotice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selfCallNotice.js","sourceRoot":"","sources":["../../../../src/core/agent/selfCallNotice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAaH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAe,EACf,gBAAwD,EACxD,IAA0C;IAE1C,IAAI,IAAI,KAAK,SAAS,IAAI,gBAAgB,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3E,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC;IAC5D,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,C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CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC;IACnE,6EAA6E;IAC7E,yEAAyE;IACzE,2EAA2E;IAC3E,6EAA6E;IAC7E,4EAA4E;IAC5E,2EAA2E;IAC3E,oEAAoE;IACpE,MAAM,MAAM,GACV,eAAe,OAAO,2DAA2D;QACjF,kFAAkF;QAClF,mBAAmB,UAAU,GAAG,UAAU,EAAE,CAAC;IAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IACjC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,OAAO,IAAI,EAAE,CAAC;AAChE,CAAC"}
@@ -75,4 +75,9 @@ hasWrapUp?: boolean,
75
75
  * Both absent → the claim seam never runs and not one line changes. */
76
76
  claims?: readonly DeclaredClaim[], integrityLedger?: {
77
77
  current: DispositionLedger | undefined;
78
- }): (scope: TypedScope<AgentState>) => RouteBranch | Promise<RouteBranch>;
78
+ },
79
+ /** `AgentOptions.noticePriorTurnEvidence` (9.83.0) — the claim seam's
80
+ * recency read. Needs the evidence gate to be armed too (it owns the
81
+ * extractor), so absent OR gate-less → not one row, not one event, and
82
+ * the decider a pre-9.83.0 chart was handed. */
83
+ noticePriorTurnEvidence?: boolean): (scope: TypedScope<AgentState>) => RouteBranch | Promise<RouteBranch>;