@sema-agent/core 7.62.0 → 7.64.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 (320) hide show
  1. package/CHANGELOG.md +936 -0
  2. package/dist/agents/cc-peer-directory.js +1 -0
  3. package/dist/agents/cc-peer-wire.d.ts +4 -0
  4. package/dist/agents/cc-peer-wire.js +1 -0
  5. package/dist/agents/cc-uds-peer-channel.js +5 -0
  6. package/dist/agents/cross-session-judge.d.ts +3 -1
  7. package/dist/agents/cross-session-judge.js +4 -1
  8. package/dist/agents/peer-directory.d.ts +8 -0
  9. package/dist/agents/peer-directory.js +4 -0
  10. package/dist/agents/peer-held-queue.d.ts +9 -3
  11. package/dist/agents/peer-held-queue.js +12 -9
  12. package/dist/agents/peer-idle.d.ts +20 -1
  13. package/dist/agents/peer-idle.js +23 -12
  14. package/dist/agents/peer-notice-route.d.ts +16 -5
  15. package/dist/agents/peer-notice-route.js +11 -9
  16. package/dist/agents/peer-notices.d.ts +25 -8
  17. package/dist/agents/peer-notices.js +6 -1
  18. package/dist/agents/peer-session-drain.d.ts +32 -6
  19. package/dist/agents/peer-session-drain.js +100 -26
  20. package/dist/agents/send-message-tool.d.ts +7 -0
  21. package/dist/agents/send-message-tool.js +18 -6
  22. package/dist/agents/subagent-transcript-placement.d.ts +23 -0
  23. package/dist/agents/subagent-transcript-placement.js +14 -0
  24. package/dist/agents/subagent.js +102 -54
  25. package/dist/brain/route-adjudicator.js +9 -4
  26. package/dist/core/allow-entry.d.ts +4 -0
  27. package/dist/core/approval-object.js +1 -1
  28. package/dist/core/arg-summary.js +1 -1
  29. package/dist/core/ask-origin.d.ts +1 -1
  30. package/dist/core/ask-origin.js +2 -2
  31. package/dist/core/ask-question.d.ts +2 -2
  32. package/dist/core/ask-unresolvable-notice.d.ts +13 -4
  33. package/dist/core/ask-unresolvable-notice.js +10 -3
  34. package/dist/core/auto-compaction.d.ts +7 -5
  35. package/dist/core/background-agent-store.d.ts +7 -0
  36. package/dist/core/background-agent-store.js +3 -0
  37. package/dist/core/canonical-json.d.ts +23 -13
  38. package/dist/core/canonical-json.js +4 -4
  39. package/dist/core/checkpoint-queries.d.ts +50 -4
  40. package/dist/core/checkpoint-queries.js +42 -17
  41. package/dist/core/checkpoint-requirements.d.ts +3 -3
  42. package/dist/core/checkpoint-requirements.js +2 -1
  43. package/dist/core/checkpoint-row-verdict.d.ts +15 -4
  44. package/dist/core/checkpoint-row-verdict.js +22 -2
  45. package/dist/core/checkpoint-store.d.ts +28 -11
  46. package/dist/core/checkpoint-store.js +45 -4
  47. package/dist/core/compliance.d.ts +6 -2
  48. package/dist/core/compliance.js +3 -3
  49. package/dist/core/context-settings.d.ts +40 -9
  50. package/dist/core/context-settings.js +32 -10
  51. package/dist/core/engine-attestation.d.ts +27 -7
  52. package/dist/core/engine-attestation.js +5 -1
  53. package/dist/core/engine-notice.d.ts +43 -5
  54. package/dist/core/extension-requester.d.ts +9 -0
  55. package/dist/core/extension-requester.js +7 -0
  56. package/dist/core/file-history-store.d.ts +28 -0
  57. package/dist/core/file-history-store.js +48 -5
  58. package/dist/core/fs-write-gate-policy.js +1 -1
  59. package/dist/core/gate-fold.js +2 -0
  60. package/dist/core/gate-lanes.js +2 -0
  61. package/dist/core/gate-outcome.d.ts +39 -2
  62. package/dist/core/gate-outcome.js +20 -1
  63. package/dist/core/git-worktree-env.d.ts +62 -3
  64. package/dist/core/git-worktree-env.js +91 -30
  65. package/dist/core/governance-codes.d.ts +9 -3
  66. package/dist/core/governance-codes.js +17 -3
  67. package/dist/core/leg-identity.d.ts +19 -1
  68. package/dist/core/leg-identity.js +12 -0
  69. package/dist/core/mailbox-store.d.ts +39 -4
  70. package/dist/core/mailbox-store.js +14 -2
  71. package/dist/core/memory-engine/consolidation-driver.d.ts +32 -17
  72. package/dist/core/memory-engine/consolidation-driver.js +99 -98
  73. package/dist/core/memory-engine/consolidation.d.ts +74 -10
  74. package/dist/core/memory-engine/consolidation.js +183 -11
  75. package/dist/core/memory-engine/control-objects.d.ts +25 -0
  76. package/dist/core/memory-engine/control-objects.js +151 -0
  77. package/dist/core/memory-engine/control-plane-adoption.d.ts +48 -0
  78. package/dist/core/memory-engine/control-plane-adoption.js +159 -0
  79. package/dist/core/memory-engine/data-plane.d.ts +8 -4
  80. package/dist/core/memory-engine/data-plane.js +11 -6
  81. package/dist/core/memory-engine/delegation-settlement.d.ts +58 -40
  82. package/dist/core/memory-engine/delegation-settlement.js +270 -85
  83. package/dist/core/memory-engine/dual-root.d.ts +12 -6
  84. package/dist/core/memory-engine/dual-root.js +11 -7
  85. package/dist/core/memory-engine/engine.d.ts +136 -58
  86. package/dist/core/memory-engine/engine.js +491 -394
  87. package/dist/core/memory-engine/entry-scan.d.ts +8 -0
  88. package/dist/core/memory-engine/entry-scan.js +3 -0
  89. package/dist/core/memory-engine/file-backend.d.ts +62 -60
  90. package/dist/core/memory-engine/file-backend.js +122 -198
  91. package/dist/core/memory-engine/index.d.ts +8 -7
  92. package/dist/core/memory-engine/index.js +7 -6
  93. package/dist/core/memory-engine/landing-admission.d.ts +5 -3
  94. package/dist/core/memory-engine/landing-admission.js +3 -3
  95. package/dist/core/memory-engine/layout.d.ts +127 -46
  96. package/dist/core/memory-engine/layout.js +264 -109
  97. package/dist/core/memory-engine/memory-backend-contract.d.ts +26 -1
  98. package/dist/core/memory-engine/memory-backend-contract.js +476 -0
  99. package/dist/core/memory-engine/memory-deployment.d.ts +42 -11
  100. package/dist/core/memory-engine/memory-deployment.js +54 -15
  101. package/dist/core/memory-engine/origin-clearance.d.ts +12 -3
  102. package/dist/core/memory-engine/origin-clearance.js +68 -9
  103. package/dist/core/memory-engine/scope-contract.d.ts +52 -11
  104. package/dist/core/memory-engine/scope-contract.js +68 -19
  105. package/dist/core/memory-engine/session-write-home.d.ts +37 -2
  106. package/dist/core/memory-engine/session-write-home.js +38 -11
  107. package/dist/core/memory-engine/sync-client.d.ts +3 -1
  108. package/dist/core/memory-engine/sync-client.js +7 -0
  109. package/dist/core/memory-engine/sync-report.d.ts +3 -2
  110. package/dist/core/memory-engine/sync-report.js +6 -2
  111. package/dist/core/memory-engine/tools.d.ts +2 -2
  112. package/dist/core/memory-engine/tools.js +10 -10
  113. package/dist/core/memory-engine/types.d.ts +155 -19
  114. package/dist/core/memory-engine/types.js +2 -0
  115. package/dist/core/memory.js +15 -6
  116. package/dist/core/mode-policy.js +3 -3
  117. package/dist/core/mods/agent-stations.d.ts +18 -0
  118. package/dist/core/mods/agent-stations.js +8 -6
  119. package/dist/core/mods/extension-call.d.ts +4 -0
  120. package/dist/core/mods/extension-call.js +8 -0
  121. package/dist/core/mods/stations.d.ts +20 -1
  122. package/dist/core/mods/stations.js +21 -2
  123. package/dist/core/mods/tool-call.js +3 -4
  124. package/dist/core/parent-spec-seat.d.ts +2 -2
  125. package/dist/core/park-selfcheck.js +2 -2
  126. package/dist/core/pause-registry.d.ts +2 -0
  127. package/dist/core/pause-registry.js +3 -0
  128. package/dist/core/peer-channel.d.ts +5 -0
  129. package/dist/core/permission-rule-consent.d.ts +26 -8
  130. package/dist/core/permission-rule-consent.js +76 -36
  131. package/dist/core/permission-rule-store.d.ts +72 -13
  132. package/dist/core/permission-rule-store.js +29 -8
  133. package/dist/core/read-only-shell.js +3 -2
  134. package/dist/core/redaction-marks.d.ts +8 -0
  135. package/dist/core/redaction-marks.js +6 -0
  136. package/dist/core/refusal-echo.d.ts +20 -0
  137. package/dist/core/refusal-echo.js +33 -0
  138. package/dist/core/remote-env.d.ts +12 -1
  139. package/dist/core/remote-env.js +3 -0
  140. package/dist/core/retention.d.ts +180 -10
  141. package/dist/core/retention.js +45 -0
  142. package/dist/core/retired-keys.d.ts +5 -0
  143. package/dist/core/retired-keys.js +3 -0
  144. package/dist/core/rule-offer-read.d.ts +0 -4
  145. package/dist/core/rule-offer-read.js +2 -18
  146. package/dist/core/runner/child-tree.d.ts +29 -3
  147. package/dist/core/runner/child-tree.js +39 -16
  148. package/dist/core/runner/classifier-ladder.d.ts +7 -1
  149. package/dist/core/runner/classifier-ladder.js +4 -2
  150. package/dist/core/runner/compact-session.js +10 -7
  151. package/dist/core/runner/compaction-call-options.d.ts +7 -7
  152. package/dist/core/runner/compaction-call-options.js +3 -2
  153. package/dist/core/runner/contracts.d.ts +39 -11
  154. package/dist/core/runner/delegation-owner.d.ts +10 -3
  155. package/dist/core/runner/delegation-owner.js +4 -1
  156. package/dist/core/runner/gate-exit.d.ts +6 -0
  157. package/dist/core/runner/gate-exit.js +13 -4
  158. package/dist/core/runner/inherited-ask-grants.js +1 -1
  159. package/dist/core/runner/memory-consolidation-driver.d.ts +10 -5
  160. package/dist/core/runner/memory-consolidation-driver.js +12 -9
  161. package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
  162. package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
  163. package/dist/core/runner/person-path-rows.d.ts +8 -3
  164. package/dist/core/runner/person-path-rows.js +5 -1
  165. package/dist/core/runner/placement-fence.d.ts +12 -0
  166. package/dist/core/runner/placement-fence.js +20 -6
  167. package/dist/core/runner/prepare-ask-lane.js +5 -5
  168. package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -2
  169. package/dist/core/runner/prepare-caps-and-workflow.js +7 -4
  170. package/dist/core/runner/prepare-config-doors.js +4 -0
  171. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  172. package/dist/core/runner/prepare-delegation-surface.js +2 -2
  173. package/dist/core/runner/prepare-execution-env.js +17 -6
  174. package/dist/core/runner/prepare-gate-stations.d.ts +5 -0
  175. package/dist/core/runner/prepare-gate-stations.js +5 -5
  176. package/dist/core/runner/prepare-hands-readface.d.ts +2 -1
  177. package/dist/core/runner/prepare-hands-readface.js +5 -4
  178. package/dist/core/runner/prepare-inherited-gate.d.ts +13 -9
  179. package/dist/core/runner/prepare-inherited-gate.js +12 -6
  180. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
  181. package/dist/core/runner/prepare-memory-engine-session.js +4 -4
  182. package/dist/core/runner/prepare-memory.d.ts +7 -2
  183. package/dist/core/runner/prepare-memory.js +41 -39
  184. package/dist/core/runner/prepare-park-ask.js +4 -3
  185. package/dist/core/runner/prepare-policy-chain.js +7 -7
  186. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  187. package/dist/core/runner/prepare-task.js +26 -18
  188. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  189. package/dist/core/runner/prepare-wiring-manifest.js +3 -2
  190. package/dist/core/runner/prepare-workspace-restore.js +3 -6
  191. package/dist/core/runner/resume-admission.d.ts +2 -2
  192. package/dist/core/runner/resume-admission.js +2 -23
  193. package/dist/core/runner/role-resolution-table.d.ts +98 -0
  194. package/dist/core/runner/role-resolution-table.js +62 -0
  195. package/dist/core/runner/run-compaction-machinery.js +2 -2
  196. package/dist/core/runner/run-identity-wiring.js +12 -9
  197. package/dist/core/runner/run-leg.js +9 -5
  198. package/dist/core/runner/run-notification-lane.js +22 -22
  199. package/dist/core/runner/run-recovery-lanes.js +3 -3
  200. package/dist/core/runner/run-settle-and-teardown.js +3 -2
  201. package/dist/core/runner/run-terminal-adoption.js +1 -1
  202. package/dist/core/runner/run-turn-boundary.js +14 -15
  203. package/dist/core/runner/runtask.js +1 -1
  204. package/dist/core/runner/terminal-account.js +1 -1
  205. package/dist/core/runner/tool-occurrence.d.ts +4 -2
  206. package/dist/core/runner/tool-occurrence.js +2 -2
  207. package/dist/core/runner-deps.d.ts +7 -3
  208. package/dist/core/secret-env.d.ts +1 -1
  209. package/dist/core/secret-env.js +4 -4
  210. package/dist/core/session-checkout.d.ts +168 -0
  211. package/dist/core/session-checkout.js +579 -0
  212. package/dist/core/session-store.d.ts +12 -4
  213. package/dist/core/session-store.js +23 -3
  214. package/dist/core/session.d.ts +16 -2
  215. package/dist/core/session.js +3 -0
  216. package/dist/core/shell-read-silence.js +8 -0
  217. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +0 -12
  218. package/dist/core/store-contracts/checkpoint-store-contract.js +6 -7
  219. package/dist/core/store-contracts/peer-directory-contract.js +8 -1
  220. package/dist/core/store-contracts/session-store-contract.js +39 -0
  221. package/dist/core/task-event.d.ts +30 -5
  222. package/dist/core/task-notification.d.ts +119 -32
  223. package/dist/core/task-notification.js +186 -100
  224. package/dist/core/task-registry-agent.d.ts +25 -2
  225. package/dist/core/task-registry-agent.js +56 -22
  226. package/dist/core/task-registry-shared.d.ts +33 -11
  227. package/dist/core/task-registry.d.ts +33 -9
  228. package/dist/core/task-registry.js +36 -18
  229. package/dist/core/task-spec-members.js +1 -1
  230. package/dist/core/task-spec.d.ts +27 -2
  231. package/dist/core/tool-errors.d.ts +14 -6
  232. package/dist/core/tool-errors.js +1 -1
  233. package/dist/core/tool-policy.d.ts +32 -13
  234. package/dist/core/tool-policy.js +27 -17
  235. package/dist/core/tool-result-store.d.ts +20 -0
  236. package/dist/core/tool-spec.d.ts +42 -19
  237. package/dist/core/trace.d.ts +3 -2
  238. package/dist/core/types.d.ts +1 -1
  239. package/dist/core/untrusted-egress.d.ts +15 -4
  240. package/dist/core/untrusted-egress.js +23 -22
  241. package/dist/core/workflow-journal-store.d.ts +11 -0
  242. package/dist/core/workflow-journal-store.js +7 -0
  243. package/dist/core/workflow-run-store.d.ts +9 -0
  244. package/dist/core/workflow-run-store.js +6 -0
  245. package/dist/core/workspace-snapshot.d.ts +3 -1
  246. package/dist/core/workspace-snapshot.js +1 -0
  247. package/dist/engine/compaction/compaction.d.ts +2 -1
  248. package/dist/engine/harness/types.d.ts +67 -1
  249. package/dist/engine/harness/types.js +108 -0
  250. package/dist/engine/session/import-validate.js +6 -1
  251. package/dist/engine/session/session.d.ts +30 -1
  252. package/dist/engine/session/session.js +48 -1
  253. package/dist/index.d.ts +12 -7
  254. package/dist/index.js +12 -7
  255. package/dist/internal/harness-types.d.ts +1 -1
  256. package/dist/orchestration/run-workflow-tool.d.ts +8 -1
  257. package/dist/orchestration/run-workflow-tool.js +8 -0
  258. package/dist/orchestration/workflow-types.d.ts +2 -1
  259. package/dist/orchestration/workflow.d.ts +6 -0
  260. package/dist/orchestration/workflow.js +5 -2
  261. package/dist/stores/file/checkpoint-store.d.ts +6 -0
  262. package/dist/stores/file/checkpoint-store.js +4 -1
  263. package/dist/stores/file/file-history-store.d.ts +13 -0
  264. package/dist/stores/file/file-history-store.js +75 -13
  265. package/dist/stores/file/index.d.ts +11 -1
  266. package/dist/stores/file/index.js +7 -11
  267. package/dist/stores/file/permission-rule-store.d.ts +23 -0
  268. package/dist/stores/file/permission-rule-store.js +75 -7
  269. package/dist/stores/file/session-store.js +2 -1
  270. package/dist/stores/file/tool-result-store.d.ts +14 -0
  271. package/dist/stores/file/tool-result-store.js +39 -2
  272. package/dist/stores/file/workflow-journal-store.d.ts +4 -0
  273. package/dist/stores/file/workflow-journal-store.js +17 -0
  274. package/dist/stores/file/workflow-run-store.d.ts +3 -0
  275. package/dist/stores/file/workflow-run-store.js +15 -0
  276. package/dist/tools/fs/bash-program-position.js +3 -3
  277. package/dist/tools/fs/program-read-model.d.ts +34 -10
  278. package/dist/tools/fs/program-read-model.js +37 -7
  279. package/dist/tools/fs/program-read-model.rows.js +13 -2
  280. package/dist/tools/fs/read-deny.d.ts +28 -3
  281. package/dist/tools/fs/read-deny.js +18 -2
  282. package/dist/tools/fs/removal-targets.js +3 -3
  283. package/dist/tools/fs/safety.d.ts +2 -0
  284. package/dist/tools/fs/safety.js +1 -1
  285. package/dist/tools/fs/shell-read-argv.d.ts +8 -1
  286. package/dist/tools/fs/shell-read-argv.js +34 -29
  287. package/dist/tools/fs/shell-read-bindings.d.ts +2 -0
  288. package/dist/tools/fs/shell-read-bindings.js +5 -1
  289. package/dist/tools/fs/shell-read-brace.d.ts +18 -0
  290. package/dist/tools/fs/shell-read-brace.js +79 -0
  291. package/dist/tools/fs/shell-read-check.d.ts +8 -2
  292. package/dist/tools/fs/shell-read-check.js +16 -14
  293. package/dist/tools/fs/shell-read-establish.js +23 -16
  294. package/dist/tools/fs/shell-read-judge.d.ts +11 -0
  295. package/dist/tools/fs/shell-read-judge.js +3 -3
  296. package/dist/tools/fs/shell-read-plan.d.ts +10 -0
  297. package/dist/tools/fs/shell-read-plan.js +189 -93
  298. package/dist/tools/fs/shell-read-start.d.ts +19 -9
  299. package/dist/tools/fs/shell-read-start.js +20 -12
  300. package/dist/tools/fs/shell-read-word.d.ts +10 -0
  301. package/dist/tools/fs/shell-read-word.js +9 -5
  302. package/dist/tools/fs/shell-read-workdir.d.ts +26 -7
  303. package/dist/tools/fs/shell-read-workdir.js +73 -12
  304. package/dist/tools/fs/shell-read-write-targets.js +13 -8
  305. package/dist/tools/worktree.d.ts +3 -2
  306. package/dist/tools/worktree.js +7 -35
  307. package/package.json +3 -2
  308. package/test/export-surface.snapshot.json +135 -11
  309. package/wire-changes/core-stores-sql@7.63.0.json +30 -0
  310. package/wire-changes/core-stores-sql@7.64.0.json +30 -0
  311. package/wire-changes/core@7.63.0.json +3523 -0
  312. package/wire-changes/core@7.64.0.json +2653 -0
  313. package/wire-changes/mods-kernel@7.63.0.json +30 -0
  314. package/wire-changes/mods-kernel@7.64.0.json +30 -0
  315. package/wire-changes/primitives@7.63.0.json +445 -0
  316. package/wire-changes/primitives@7.64.0.json +30 -0
  317. package/dist/core/credential-vocabulary.d.ts +0 -176
  318. package/dist/core/credential-vocabulary.js +0 -190
  319. package/dist/core/redaction-passes.d.ts +0 -82
  320. package/dist/core/redaction-passes.js +0 -377
@@ -24,8 +24,10 @@
24
24
  * a live approver reachable for delegated children — is a deployment posture the operator hears through
25
25
  * the sink like every other code; the row only adds the session-stream projection so the person whose
26
26
  * call was refused sees WHY it did not run. `sessionId` is therefore REQUIRED at the mint (the routing
27
- * half of a user row). Dedup unit: per tool call — the gate's obligation (it owns the call); this module
28
- * is pure.
27
+ * half of a user row). On a delegated leg it is the delegation tree's root — the session a person
28
+ * watches; the child's own session has no reader — and `sourceSessionId` / `agentId` say which leg the
29
+ * refused call was (the gate station's notice address, `noticeAddressOf`). Dedup unit: per tool call —
30
+ * the gate's obligation (it owns the call); this module is pure.
29
31
  */
30
32
  import type { EngineNotice } from "./engine-notice.js";
31
33
  import { type ApprovalRemedy, type AssertAllKeysHandled, type HeadlessApproverSeat } from "./ask-origin.js";
@@ -36,8 +38,14 @@ export type AskUnresolvableCause = (typeof ASK_UNRESOLVABLE_CAUSES)[number];
36
38
  export declare function isAskUnresolvableCause(v: unknown): v is AskUnresolvableCause;
37
39
  /** What the gate knows at the deny exit — facts only, no words of the engine's vocabulary composed. */
38
40
  export interface AskUnresolvableFacts {
39
- /** The session whose call was refused — the notice's routing key, required (see module note). */
41
+ /** The session the notice is addressed to — its routing key, required (see module note): the refused leg's own session on a
42
+ * top-level leg, the delegation tree's root on a delegated one (`noticeAddressOf`, leg-identity.ts). */
40
43
  readonly sessionId: string;
44
+ /** Present exactly when the refused call was a delegated leg's: that leg's session (the call's own conversation). */
45
+ readonly sourceSessionId?: string;
46
+ /** The delegated leg's agent id, beside {@link sourceSessionId} (never without it): the id the spawner's card and the leg's
47
+ * events carry. */
48
+ readonly agentId?: string;
41
49
  /** The tool the ask was for (the message quotes it verbatim). */
42
50
  readonly toolName: string;
43
51
  /** The refused call's id — the correlation key to the `tool_end` frame carrying the same deny. */
@@ -86,7 +94,8 @@ export declare function askUnresolvableRemedySeat(cause: AskUnresolvableCause):
86
94
  * an empty session or tool name, or a cause outside the closed set, is refused at the mint with a
87
95
  * `TypeError` rather than shaped into a notice that would route nowhere or say nothing.
88
96
  *
89
- * `detail: { sessionId, toolName, toolCallId, cause, parkLaneExisted, remedy?, remedies? }` — `remedy` rides the causes that say nobody
97
+ * `detail: { sessionId, sourceSessionId?, agentId?, toolName, toolCallId, cause, parkLaneExisted, remedy?, remedies? }` — `sourceSessionId`
98
+ * and `agentId` ride a delegated leg's refusal only (the leg the call was, the notice being addressed to the tree's root); `remedy` rides the causes that say nobody
90
99
  * could be asked ({@link askUnresolvableRemedySeat}: the sentence the refusal's tool text carries) and `remedies` beside it, the same
91
100
  * way out as data ({@link ApprovalRemedy}); `sessionId` is lifted onto the typed key by {@link import("./engine-notice.js").deliverEngineNotice}, the one throat.
92
101
  */
@@ -19,10 +19,17 @@ export function askUnresolvableRemedySeat(cause) {
19
19
  return CAUSE_REMEDY_SEAT[cause];
20
20
  }
21
21
  export function askUnresolvableNotice(facts) {
22
- const { sessionId, toolName, toolCallId, cause, parkLaneExisted, remedy, remedies } = facts;
22
+ const { sessionId, sourceSessionId, agentId, toolName, toolCallId, cause, parkLaneExisted, remedy, remedies } = facts;
23
23
  if (typeof sessionId !== "string" || sessionId.length === 0) {
24
24
  throw new TypeError("delegation.ask_unresolvable: sessionId is required — a user-audience notice with no session routes nowhere");
25
25
  }
26
+ if (sourceSessionId !== undefined && (typeof sourceSessionId !== "string" || sourceSessionId.length === 0)) {
27
+ throw new TypeError("delegation.ask_unresolvable: sourceSessionId, when present, names the delegated leg's session");
28
+ }
29
+ if (agentId !== undefined && (sourceSessionId === undefined || typeof agentId !== "string" || agentId.length === 0)) {
30
+ throw new TypeError("delegation.ask_unresolvable: agentId, when present, is a non-empty id riding beside sourceSessionId");
31
+ }
32
+ const delegated = sourceSessionId !== undefined;
26
33
  if (typeof toolName !== "string" || toolName.length === 0) {
27
34
  throw new TypeError("delegation.ask_unresolvable: toolName is required");
28
35
  }
@@ -48,9 +55,9 @@ export function askUnresolvableNotice(facts) {
48
55
  const park = parkLaneExisted ? "the durable approval park did not take it" : "no durable approval park is armed for this run";
49
56
  return {
50
57
  code: "delegation.ask_unresolvable",
51
- message: `approval for "${toolName}" could not be resolved: ${CAUSE_CLAUSE[cause]} and ${park} — ` +
58
+ message: `approval for "${toolName}"${delegated ? " (a delegated agent's call)" : ""} could not be resolved: ${CAUSE_CLAUSE[cause]} and ${park} — ` +
52
59
  `the call was denied fail-closed and did not run. ${typeof remedy === "string" && remedy.length > 0 ? `To let it run: ${remedy}. ` : ""}To let such approvals wait for a person, run with a checkpoint store and a ` +
53
60
  `durable approval opt-in (or a live approver reachable for delegated children).`,
54
- detail: { sessionId, toolName, toolCallId, cause, parkLaneExisted: parkLaneExisted === true, ...(typeof remedy === "string" && remedy.length > 0 ? { remedy } : {}), ...(remedyList !== undefined ? { remedies: remedyList } : {}) },
61
+ detail: { sessionId, ...(delegated ? { sourceSessionId } : {}), ...(agentId !== undefined ? { agentId } : {}), toolName, toolCallId, cause, parkLaneExisted: parkLaneExisted === true, ...(typeof remedy === "string" && remedy.length > 0 ? { remedy } : {}), ...(remedyList !== undefined ? { remedies: remedyList } : {}) },
55
62
  };
56
63
  }
@@ -579,9 +579,10 @@ export declare function maybeCompact(opts: MaybeCompactOptions): Promise<{
579
579
  * (auto/manual triggers only — never on "forced"). NOT a failure: the caller must not count it
580
580
  * toward the compaction breaker; the next boundary consults the callback again. */
581
581
  blocked?: boolean;
582
- /** MF-18 修①: set (with `compacted:false`) when compaction is DISABLED by settings
583
- * (`enabled:false`) — the request can never be honored this run. Lets the caller resolve a manual
584
- * /compact with the honest `"disabled"` outcome (and trace frame) instead of a structural noop. */
582
+ /** MF-18 修①: set (with `compacted:false`) when this pass is DISABLED by its settings (`enabled:false`
583
+ * — the pass's own gate; a run's lanes resolve it from the seat of the pass they run, `autoCompact` or
584
+ * `manualCompact`). Lets the caller resolve a manual /compact with the honest `"disabled"` outcome (and
585
+ * trace frame) instead of a structural noop. */
585
586
  disabled?: boolean;
586
587
  /** Set (with `compacted:false`) when the pass PASSED the trigger gate
587
588
  * (natural or forced) but found nothing to summarize — no valid cut point / empty history. Was
@@ -755,8 +756,9 @@ export interface CompactSessionRequest {
755
756
  /** This pass's summarization instructions: they REPLACE `compaction.instructions` and the default for this pass (the
756
757
  * `TaskStream.compact` reading); sanitized and capped like every instructions channel. */
757
758
  instructions?: string;
758
- /** The members of `TaskSpec.compaction` a pass reads, as a run would carry them. */
759
- compaction?: Pick<NonNullable<TaskSpec["compaction"]>, "enabled" | "reserveTokens" | "keepRecentTokens" | "instructions" | "clampTolerance">;
759
+ /** The members of `TaskSpec.compaction` a pass reads, as a run would carry them — of the two seats only `manualCompact`
760
+ * (this pass is a requested one; `false` answers `"disabled"`, and absent reads the deployment's twin, else on). */
761
+ compaction?: Pick<NonNullable<TaskSpec["compaction"]>, "manualCompact" | "reserveTokens" | "keepRecentTokens" | "instructions" | "clampTolerance">;
760
762
  /** The independent summary model (`TaskSpec.compactionModel`); absent ⇒ the deployment's `summarize` role (or its tier
761
763
  * default), else the main model. A role-derived model whose key↔URL pairing is broken falls back to the main model,
762
764
  * announced, as on a run. */
@@ -1,5 +1,6 @@
1
1
  import type { SubagentEditedFile, SubagentStep } from "../agents/subagent-steps.js";
2
2
  import type { SubagentTranscriptTier } from "./wiring-manifest.js";
3
+ import type { ExtensionRequester } from "./task-event.js";
3
4
  /** Terminal/live usage rollup persisted on the row (mirror of the task_notification/BCE fields). */
4
5
  export interface BackgroundAgentUsage {
5
6
  totalTokens?: number;
@@ -44,6 +45,11 @@ export interface BackgroundAgentRecord {
44
45
  * earlier version wrote without one derives it from `handle` with the same function. */
45
46
  name: string;
46
47
  agentType?: string;
48
+ /** Who started the agent when an extension did: the extension, by its registration name (`$.agent.spawn`). Written once, by the
49
+ * registration that creates the row; a revival keeps it (the row's origin, not the waker's). ABSENT = not an extension's spawn
50
+ * (the model's own, the host's) — and every row an earlier release wrote: the one reading, with no word for either. A display and
51
+ * audit fact only — it decides nothing. */
52
+ requestedBy?: ExtensionRequester;
47
53
  description?: string;
48
54
  /** Revival lookup key (CC meta-sidecar parity); populated when known, never required. The team
49
55
  * key is {@link rootSessionId} — one implicit team per session, no column of its own. */
@@ -208,6 +214,7 @@ export interface BackgroundAgentRowSummary {
208
214
  rootSessionId?: string;
209
215
  name: string;
210
216
  agentType?: string;
217
+ requestedBy?: ExtensionRequester;
211
218
  status: BackgroundAgentRecord["status"];
212
219
  spawnedAt: number;
213
220
  updatedAt: number;
@@ -1,5 +1,6 @@
1
1
  import { uuidv7 } from "../internal/harness.js";
2
2
  import { receiveRetentionPolicy } from "./retention-policy.js";
3
+ import { readExtensionRequester } from "./extension-requester.js";
3
4
  export const REVIVED_ROW_CLEARED_FIELDS = Object.freeze([
4
5
  "settledAt",
5
6
  "stoppedBy",
@@ -178,6 +179,7 @@ export async function reconcileParkedAgents(stores, scope, now, opts) {
178
179
  return out;
179
180
  }
180
181
  function toSummary(r) {
182
+ const requestedBy = readExtensionRequester(r.requestedBy);
181
183
  return {
182
184
  handle: r.handle,
183
185
  owner: r.owner,
@@ -187,6 +189,7 @@ function toSummary(r) {
187
189
  ...(r.rootSessionId !== undefined ? { rootSessionId: r.rootSessionId } : {}),
188
190
  name: r.name,
189
191
  ...(r.agentType !== undefined ? { agentType: r.agentType } : {}),
192
+ ...(requestedBy !== undefined ? { requestedBy } : {}),
190
193
  status: r.status,
191
194
  spawnedAt: r.spawnedAt,
192
195
  updatedAt: r.updatedAt,
@@ -1,7 +1,7 @@
1
1
  import { type ReceiptFault } from "./mods/kernel/receive.js";
2
2
  /**
3
3
  * design/80 D-1 §2 (slice 1a.2) — the engine-only **vetted canonical serializer** used to mint a stable,
4
- * opaque {@link boundInputHashOf | boundInputHash} over a pending tool call's arguments.
4
+ * opaque {@link exactBoundInputHashOf | boundInputHash} over a pending tool call: its tool's name and its arguments.
5
5
  *
6
6
  * ## Why a bespoke serializer (and why engine-ONLY)
7
7
  * The package's only runtime deps are typebox + the MCP SDK — there is no canonical/stable JSON serializer,
@@ -19,7 +19,9 @@ import { type ReceiptFault } from "./mods/kernel/receive.js";
19
19
  * ## Canonical form
20
20
  * A total function (never throws) that emits a **type-tagged, length-prefixed** string so distinct values of
21
21
  * distinct types can never collide (`number 1` ≠ `string "1"` ≠ `boolean`, and `{"a":"b"}` ≠ `{"ab":""}`):
22
- * - `null` → `N`, `undefined` → `U` (encoded distinctly — `{a:undefined}` must not collide with `{}`)
22
+ * - `null` → `N`, `undefined` → `U`, at any depth: `{a:undefined}` and `{}` are two forms — the form a workflow call's journal
23
+ * key, the rewrite judge, a file rule store's checksum, a wiring fingerprint and every other digest of a value taken here
24
+ * read; a call's approval binding digests the arguments' JSON form ({@link exactBoundInputHashOf})
23
25
  * - boolean → `b1` / `b0`
24
26
  * - number → `n:<canonical>`; finite via `String(x)` (shortest round-trippable, deterministic per value);
25
27
  * `-0` normalized to `0`; `NaN`/`±Infinity` get explicit distinct tokens (never collapsed to `null`)
@@ -55,18 +57,26 @@ export declare function canonicalize(value: unknown, standsAt?: number): string;
55
57
  * constant (the checkpoint row digest) refuses on it. */
56
58
  export declare const UNCANONICALIZABLE = "<uncanonicalizable>";
57
59
  /**
58
- * design/80 D-1 §2 — the server-minted **opaque** boundInputHash: a SHA-256 (hex) over {@link canonicalize}.
59
- * Bound at suspend-mint to the pending tool call's input (`pendingAction.args`) and persisted on the
60
- * checkpoint; a resume verifies the echoed value by string equality (never re-hashing the resume-side args).
61
- * The hex digest is fixed-length and opaque — exactly what the operator sees / the D-G signer signs.
60
+ * design/80 D-1 §2 — a SHA-256 (hex) over {@link canonicalize}: the engine's one digest of a value. A call's binding is this digest
61
+ * over `{ tool, input }` ({@link exactBoundInputHashOf}); the other digests the engine takes of a value (a Skill card's lists, a
62
+ * tool's declaration, a question batch) are this digest over that value. The hex digest is fixed-length and opaque — exactly
63
+ * what the operator sees / the D-G signer signs.
62
64
  */
63
65
  export declare function boundInputHashOf(value: unknown): string;
64
66
  /**
65
- * The {@link boundInputHashOf} digest of `value` when an approval can be bound to it ({@link bindableValueOf}), else `undefined` —
66
- * the digest a license is compared by, one only those bytes have. Over the bindable domain the canonical form is exact (no
67
- * sentinel token stands for part of it), so the digest is the bytes; outside it there is none to give.
67
+ * THE digest an approval binds a CALL by: SHA-256 (hex) over the canonical form of the one record `{ tool, input }` — the tool's name as the
68
+ * call spells it and the arguments in their JSON form ({@link capturedJsonOf}: a record member holding `undefined` absent), one
69
+ * digest for the call in memory and after a durable store's JSON round trip — when an approval can be bound to the arguments
70
+ * ({@link bindableValueOf}), else `undefined`.
71
+ * Every binding of a call mints through it and every comparison of one reads it: the park row's `boundInputHash`, the live ask's
72
+ * and the routed question's reconciliation hash, and an answer's licensed bytes (`inputDigest`, compared by `licenseCovers`) — so
73
+ * one approval covers one tool over one set of bytes, and a call of another tool over the same bytes under the same call id is
74
+ * another question. The name is read as given (no alias or case is resolved: the row, the ask and the record each carry the
75
+ * call's own `toolName`). The record only HOLDS the two members (it is canonicalized at depth −1, {@link canonicalize}), so the
76
+ * arguments count their containers as when digested alone and the form is exact over the whole bindable domain; key order is
77
+ * the serializer's own (sorted), so the two members cannot be permuted.
68
78
  */
69
- export declare function exactBoundInputHashOf(value: unknown): string | undefined;
79
+ export declare function exactBoundInputHashOf(tool: string, input: unknown): string | undefined;
70
80
  /**
71
81
  * Why a value is outside the bindable domain: its top is not the payload's shape, a refusal of the receipt it is read by, or one of
72
82
  * JSON's own five — a number that is not finite, a hole in a list, a named member on a list, an `undefined` list element, one
@@ -78,8 +88,8 @@ export type BindingFault = ReceiptFault | {
78
88
  };
79
89
  /**
80
90
  * THE judge of the BINDABLE domain — the values an approval can be bound to, and so the only values with an exact digest: plain
81
- * JSON data (records, dense lists, strings, finite numbers, booleans, `null`; a record member that is `undefined` is kept as it
82
- * is, as absent from JSON) under a top of the payload's own shape (`top`: a call's arguments are a RECORD — the default, and the
91
+ * JSON data (records, dense lists, strings, finite numbers, booleans, `null`; a record member holding `undefined` is legal and
92
+ * kept on the copy as given) under a top of the payload's own shape (`top`: a call's arguments are a RECORD — the default, and the
83
93
  * only shape an exact digest is taken of; a question's answers are a LIST), a tree (no object met twice), at most 256 levels of
84
94
  * containers. Read by the engine's one receipt of a caller's value in {@link BINDING_RECEIPT} (nothing of the caller's runs: a
85
95
  * getter, a hidden or symbol-keyed member, a Proxy, a function, a symbol, a bigint, a Map / Set / Date / binary or any other kind
@@ -96,7 +106,7 @@ export declare function bindableValueOf(value: unknown, top?: BindingTop): {
96
106
  export type BindingTop = "record" | "list";
97
107
  /** THE capture of a caller-supplied payload the engine persists and later compares (a durable decide's edit — a record —, a
98
108
  * question's answers — a list): the judge's receipt ({@link bindableValueOf}) kept in the form a durable store's JSON round trip
99
- * hands back ({@link jsonFormOf}). */
109
+ * hands back ({@link jsonFormOf}) — the form a call's binding digests ({@link exactBoundInputHashOf}). */
100
110
  export declare function capturedJsonOf(value: unknown, top?: BindingTop): {
101
111
  readonly ok: true;
102
112
  readonly value: unknown;
@@ -13,11 +13,11 @@ export const UNCANONICALIZABLE = "<uncanonicalizable>";
13
13
  export function boundInputHashOf(value) {
14
14
  return createHash("sha256").update(canonicalize(value), "utf8").digest("hex");
15
15
  }
16
- export function exactBoundInputHashOf(value) {
17
- const bound = bindableValueOf(value);
18
- if (!bound.ok)
16
+ export function exactBoundInputHashOf(tool, input) {
17
+ const captured = capturedJsonOf(input);
18
+ if (!captured.ok)
19
19
  return undefined;
20
- const form = canonicalize(bound.value);
20
+ const form = canonicalize({ tool, input: captured.value }, -1);
21
21
  return form === UNCANONICALIZABLE ? undefined : createHash("sha256").update(form, "utf8").digest("hex");
22
22
  }
23
23
  export function bindableValueOf(value, top = "record") {
@@ -159,13 +159,59 @@ export declare function deleteSessionRowsAtStart(rows: Iterable<readonly [string
159
159
  * {@link selectOverduePage} read this one rule.
160
160
  */
161
161
  export declare function checkpointDeadlinePassed(deadline: number | null | undefined, cutoff: number): boolean;
162
+ /** A row's members as the listing faces read them: each read once and widened to `unknown`, since the stored shape is what is judged
163
+ * (a row came back from storage; its type says what was written, not what is there). */
164
+ interface RowMembers {
165
+ /** The key the store files the row under — the authoritative token (the row's own `token` member is judged against it). */
166
+ readonly key: string;
167
+ readonly token: unknown;
168
+ readonly sessionId: unknown;
169
+ readonly scope: unknown;
170
+ readonly status: unknown;
171
+ readonly gate: unknown;
172
+ readonly pendingAction: unknown;
173
+ readonly createdAt: unknown;
174
+ readonly deadline: unknown;
175
+ readonly state: unknown;
176
+ readonly checkpointId: unknown;
177
+ readonly resourceLedger: unknown;
178
+ }
179
+ /** The members {@link ROW_MEMBER_SHAPES} reads — no other (none a store's own transitions rewrite). */
180
+ type ShapeMembers = Pick<RowMembers, "gate" | "pendingAction" | "state" | "createdAt" | "deadline" | "resourceLedger" | "checkpointId">;
181
+ /**
182
+ * THE ROW'S MEMBER SHAPES — the reading every reader of a stored row makes of the members it reaches into, written once: the row
183
+ * judge (`judgeCheckpointRow`, the resume's first rung), the listing projection (`summarizeCheckpoint`) and the listing faces read
184
+ * this table and no shape test of their own, so over these members no face answers `ok` for a row another cannot read. The gate a
185
+ * record of a registered gate kind; the pending action a record of a registered pending kind — the one the gate's kind pairs with in
186
+ * the pause registry — a tool approval carrying a tool call id; the state a record; `createdAt` a finite number; `deadline` absent or a finite number; the resource ledger absent or a record
187
+ * (the summary reads its spend); the checkpoint id absent or a non-empty string (the summary echoes it and names the row by it: an
188
+ * empty one names no row, and no writer mints one). Each entry names the member by its shape, never a particular value; `undefined`
189
+ * = it reads.
190
+ */
191
+ declare const ROW_MEMBER_SHAPES: readonly [readonly ["gate", (m: ShapeMembers) => string | undefined], readonly ["pendingAction", (m: ShapeMembers) => string | undefined], readonly ["state", (m: ShapeMembers) => string | undefined], readonly ["createdAt", (m: ShapeMembers) => string | undefined], readonly ["deadline", (m: ShapeMembers) => string | undefined], readonly ["resourceLedger", (m: ShapeMembers) => string | undefined], readonly ["checkpointId", (m: ShapeMembers) => string | undefined]];
192
+ /** A member {@link ROW_MEMBER_SHAPES} names. */
193
+ export type RowMemberName = (typeof ROW_MEMBER_SHAPES)[number][0];
194
+ /** The first member of a row that does not read as {@link ROW_MEMBER_SHAPES} says, and the table's words for it. */
195
+ export interface RowMemberProblem {
196
+ readonly member: RowMemberName;
197
+ readonly problem: string;
198
+ }
199
+ /**
200
+ * Where a row's members fail {@link ROW_MEMBER_SHAPES} — the one reading the row judge, the summary projection and the listing faces
201
+ * make of them: the first member that does not read and the table's words for it; `undefined` = every member reads. Reads the seven
202
+ * members the table names, each once. May throw (a member that throws when read); the caller is total.
203
+ */
204
+ export declare function rowMemberProblem(cp: Checkpoint): RowMemberProblem | undefined;
162
205
  /**
163
206
  * The overdue page over a store's rows (`[key, row]` pairs — the key is the authoritative token): pending ∧
164
207
  * {@link checkpointDeadlinePassed} ∧ `facetOf(gate) === facet`, after the cursor, ordered (deadline key, token) ascending, filled up
165
- * to `limit` with the rows whose summary `project` mints. A candidate whose shape the face cannot read, or whose summary cannot be
166
- * projected, is left out and disclosed (`disclose` gets one sentence per such row, on every call) and the page fills on from the
167
- * next candidate; only the rows of the page are projected. `next` is present when a candidate remains after the page's last row
168
- * (a page after it can come back shorter, even empty, when every remaining candidate is damaged).
208
+ * to `limit` with the rows whose summary `project` mints. A candidate the face cannot place ({@link placementDamage}: no string
209
+ * session id, a token other than its key, no readable scope, status or gate kind — the facet reads them) is left out and disclosed
210
+ * (`disclose` gets one sentence per such row, on every call) and the page fills on from the next candidate. Every other row is
211
+ * answered, a damaged one in the summary's unreadable form (`project` is total, as `summarizeCheckpoint` is — the listing of a
212
+ * scope answers that row the same way); only the rows of the page are projected. A `project` of a caller's own that throws
213
+ * leaves its row out, disclosed. `next` is present when a candidate remains after the page's last row (a page after it can come
214
+ * back shorter, even empty, when every remaining candidate is unplaced).
169
215
  */
170
216
  export declare function selectOverduePage(rows: Iterable<readonly [string, Checkpoint]>, query: CheckpointOverdueQueryReading, project: (cp: Checkpoint) => CheckpointSummary, disclose?: (sentence: string) => void): CheckpointPage<CheckpointSummary, CheckpointOverdueCursor>;
171
217
  /**
@@ -1,5 +1,5 @@
1
1
  import { types } from "node:util";
2
- import { facetOf, isGateKind } from "./pause-registry.js";
2
+ import { facetOf, isGateKind, isPendingKind, PAUSE_REGISTRY } from "./pause-registry.js";
3
3
  import { receiptRefusal, receiveOwnProperties } from "./own-property-receipt.js";
4
4
  import { principalNameOf } from "./principal-name.js";
5
5
  export const CHECKPOINT_LIST_LIMITS = Object.freeze({
@@ -132,32 +132,57 @@ function orderKey(value) {
132
132
  return typeof value === "number" && Number.isFinite(value) ? value : -Infinity;
133
133
  }
134
134
  function membersOf(key, cp) {
135
- return { key, token: cp.token, sessionId: cp.sessionId, scope: cp.scope, status: cp.status, gate: cp.gate, pendingAction: cp.pendingAction, createdAt: cp.createdAt, deadline: cp.deadline, state: cp.state, checkpointId: cp.checkpointId };
135
+ return { key, token: cp.token, sessionId: cp.sessionId, scope: cp.scope, status: cp.status, gate: cp.gate, pendingAction: cp.pendingAction, createdAt: cp.createdAt, deadline: cp.deadline, state: cp.state, checkpointId: cp.checkpointId, resourceLedger: cp.resourceLedger };
136
136
  }
137
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
137
138
  function memberOf(value, key) {
138
- return typeof value === "object" && value !== null && key in value ? value[key] : undefined;
139
+ return isRecord(value) && key in value ? value[key] : undefined;
139
140
  }
140
141
  const isStatusWord = (v) => STATUSES.some((s) => s === v);
141
142
  const isFiniteNumber = (v) => typeof v === "number" && Number.isFinite(v);
142
- function listingDamage(m) {
143
+ const gateShape = (m) => (isGateKind(memberOf(m.gate, "kind")) ? undefined : "its gate is not an object of a registered gate kind");
144
+ const ROW_MEMBER_SHAPES = Object.freeze([
145
+ ["gate", gateShape],
146
+ [
147
+ "pendingAction",
148
+ (m) => {
149
+ const kind = memberOf(m.pendingAction, "kind");
150
+ if (!isPendingKind(kind))
151
+ return "its pending action is not an object of a registered pending kind";
152
+ const gateKind = memberOf(m.gate, "kind");
153
+ if (isGateKind(gateKind) && PAUSE_REGISTRY[gateKind].pending !== kind)
154
+ return "its pending action is not the one its gate kind pairs with";
155
+ return kind === "tool_approval" && typeof memberOf(m.pendingAction, "toolCallId") !== "string" ? "its tool approval carries no tool call id" : undefined;
156
+ },
157
+ ],
158
+ ["state", (m) => (isRecord(m.state) ? undefined : "its state is not an object")],
159
+ ["createdAt", (m) => (isFiniteNumber(m.createdAt) ? undefined : "its createdAt is not a finite number")],
160
+ ["deadline", (m) => (m.deadline === undefined || isFiniteNumber(m.deadline) ? undefined : "its deadline is not a finite number")],
161
+ ["resourceLedger", (m) => (m.resourceLedger === undefined || isRecord(m.resourceLedger) ? undefined : "its resource ledger is not an object")],
162
+ ["checkpointId", (m) => (m.checkpointId === undefined || (typeof m.checkpointId === "string" && m.checkpointId !== "") ? undefined : "its checkpoint id is not a non-empty string")],
163
+ ]);
164
+ function shapeProblemOf(m) {
165
+ for (const [member, shape] of ROW_MEMBER_SHAPES) {
166
+ const problem = shape(m);
167
+ if (problem !== undefined)
168
+ return { member, problem };
169
+ }
170
+ return undefined;
171
+ }
172
+ function placementDamage(m) {
143
173
  if (m.token !== m.key)
144
174
  return "its token member is not the key the store files it under";
145
175
  if (typeof m.scope !== "string")
146
176
  return "its scope is not a string";
147
177
  if (!isStatusWord(m.status))
148
178
  return "its status is not one of pending / resolved / expired";
149
- if (!isGateKind(memberOf(m.gate, "kind")))
150
- return "its gate is not an object of a registered gate kind";
151
- const actionKind = memberOf(m.pendingAction, "kind");
152
- if (typeof actionKind !== "string")
153
- return "its pending action is not an object with a kind";
154
- if (actionKind === "tool_approval" && typeof memberOf(m.pendingAction, "toolCallId") !== "string")
155
- return "its tool approval carries no tool call id";
156
- if (!isFiniteNumber(m.createdAt))
157
- return "its createdAt is not a finite number";
158
- if (typeof m.state !== "object" || m.state === null)
159
- return "its state is not an object";
160
- return undefined;
179
+ return gateShape(m);
180
+ }
181
+ function listingDamage(m) {
182
+ return placementDamage(m) ?? shapeProblemOf(m)?.problem;
183
+ }
184
+ export function rowMemberProblem(cp) {
185
+ return shapeProblemOf({ gate: cp.gate, pendingAction: cp.pendingAction, state: cp.state, createdAt: cp.createdAt, deadline: cp.deadline, resourceLedger: cp.resourceLedger, checkpointId: cp.checkpointId });
161
186
  }
162
187
  function thrownName(e) {
163
188
  return e instanceof Error ? e.constructor.name : typeof e;
@@ -181,7 +206,7 @@ export function selectOverduePage(rows, query, project, disclose) {
181
206
  const m = membersOf(token, cp);
182
207
  if (m.status !== "pending" || !checkpointDeadlinePassed(m.deadline, query.cutoff))
183
208
  continue;
184
- const damage = typeof m.sessionId !== "string" ? "its sessionId is not a string" : listingDamage(m);
209
+ const damage = typeof m.sessionId !== "string" ? "its sessionId is not a string" : placementDamage(m);
185
210
  if (damage !== undefined) {
186
211
  disclose?.(`${rowName(m)}: ${damage} — the overdue listing cannot read it, so it leaves it out`);
187
212
  continue;
@@ -7,7 +7,7 @@ import type { StoreFidelity, Checkpoint, CheckpointGate, PendingAction } from ".
7
7
  * had carried beside the one its word now names, and the members added after the table, each a capability a reader
8
8
  * must have. Downstream reads them for display only (`CheckpointError.detail.requires`).
9
9
  */
10
- export declare const REQUIREMENT_WORDS: readonly ["resource", "binding", "token", "orgAdmission", "f012", "realApproval", "face", "requirements_digest", "org_admission_inherited", "org_write_grant", "org_governed", "delegation_provenance", "skill_grants", "skill_card_binding", "hands_coordinates", "hands_home", "path_rule_anchors", "path_rule_installations", "permission_mode", "plan_mode_restore", "persisted_rule_mandate", "deployment_authored", "call_names", "write_face", "denial_limit_fallback", "leg_scope", "tool_ceiling", "tool_lists_judged", "own_tool_lists", "approval_targets", "approval_target_reads", "cross_boundary", "mount_site", "skill_scopes", "run_origin", "tool_declaration", "composition_leg", "row_task_id", "held_rows", "source_session"];
10
+ export declare const REQUIREMENT_WORDS: readonly ["resource", "binding", "token", "orgAdmission", "f012", "realApproval", "face", "requirements_digest", "org_admission_inherited", "org_write_grant", "org_governed", "delegation_provenance", "skill_grants", "skill_card_binding", "hands_coordinates", "hands_home", "path_rule_anchors", "path_rule_installations", "permission_mode", "plan_mode_restore", "persisted_rule_mandate", "deployment_authored", "call_names", "write_face", "denial_limit_fallback", "leg_scope", "tool_ceiling", "tool_lists_judged", "own_tool_lists", "approval_targets", "approval_target_reads", "cross_boundary", "mount_site", "skill_scopes", "run_origin", "tool_declaration", "composition_leg", "row_task_id", "held_rows", "source_session", "tool_binding"];
11
11
  export type RequirementWord = (typeof REQUIREMENT_WORDS)[number];
12
12
  /** Runtime twin of {@link RequirementWord}. */
13
13
  export declare function isRequirementWord(word: unknown): word is RequirementWord;
@@ -304,7 +304,7 @@ export declare const PENDING_ACTION_REQUIREMENTS: {
304
304
  readonly ignorable: "shown, never decided (card, listing, transcript or reported count): every read of the name renders, carries transcript or counts";
305
305
  };
306
306
  readonly boundInputHash: {
307
- readonly digest: "decision-read";
307
+ readonly word: "tool_binding";
308
308
  };
309
309
  readonly boundGrantDigest: {
310
310
  readonly word: "skill_card_binding";
@@ -840,7 +840,7 @@ export declare const CHECKPOINT_REQUIREMENTS: {
840
840
  readonly ignorable: "shown, never decided (card, listing, transcript or reported count): every read of the name renders, carries transcript or counts";
841
841
  };
842
842
  readonly boundInputHash: {
843
- readonly digest: "decision-read";
843
+ readonly word: "tool_binding";
844
844
  };
845
845
  readonly boundGrantDigest: {
846
846
  readonly word: "skill_card_binding";
@@ -43,6 +43,7 @@ export const REQUIREMENT_WORDS = Object.freeze([
43
43
  "row_task_id",
44
44
  "held_rows",
45
45
  "source_session",
46
+ "tool_binding",
46
47
  ]);
47
48
  export function isRequirementWord(word) {
48
49
  return typeof word === "string" && REQUIREMENT_WORDS.includes(word);
@@ -131,7 +132,7 @@ export const PENDING_ACTION_REQUIREMENTS = {
131
132
  askClass: DECISION_READ,
132
133
  classes: DECISION_READ,
133
134
  askReasons: SHOWN,
134
- boundInputHash: DECISION_READ,
135
+ boundInputHash: { word: "tool_binding" },
135
136
  boundGrantDigest: { word: "skill_card_binding" },
136
137
  boundGrants: SHOWN,
137
138
  boundGrantAbsence: SHOWN,
@@ -18,15 +18,18 @@
18
18
  * are still told at the resume.
19
19
  *
20
20
  * ORDER (one law: the specific before the general): a newer row is refused as newer before any segment of it is read (the
21
- * version ceiling, then a reader word this worker lacks); then the seats and the axis a release retired (each names what
21
+ * version ceiling, then a reader word this worker lacks); then a row whose members do not read as every reader reads them — its
22
+ * pause, its state, its stamps (a row with no segment for the arms below to read is damaged, whatever its version; the one table
23
+ * of those shapes is the listing faces' too); then the seats and the axis a release retired (each names what
22
24
  * to do about it); then the reader-requirement list and the row digest — "its content does not read the way it was
23
25
  * written", told only when nothing more specific is; then the recorded mode words, the sections by their shapes, the
24
26
  * frozen chain's tool names, the recorded run origin, and the parent-constraint record's own integrity. The first refusal
25
27
  * is the verdict.
26
28
  *
27
- * TOTAL: a row the judge cannot read (a member that throws when read, a container that is not one) is `damaged`
28
- * (`requirements_damaged`); the resume error's `detail.thrownName` names what was thrown, so an engine defect and a
29
- * damaged row are told apart.
29
+ * TOTAL: a row the judge cannot read (a member that throws when read) is `damaged` (`requirements_damaged`); the resume
30
+ * error's `detail.thrownName` names what was thrown, so an engine defect and a damaged row are told apart. A row whose member does
31
+ * not read as the member-shape table says (`rowMemberProblem`, checkpoint-queries.ts: the gate, the pending action, the state,
32
+ * `createdAt`, `deadline`) is the same word with nothing thrown: its refusal names the member in the table's words.
30
33
  *
31
34
  * The row-seat readers the judge asks and other readers share live here too — the retired seats' refusals and the recorded
32
35
  * mode seed (prepare reads the seed; the parked-steer queue's read asks the retired steer seat's refusal).
@@ -58,6 +61,12 @@ export declare const ROW_REFUSAL_SENTENCES: Readonly<{
58
61
  readonly "config.run_origin_invalid": "This engine cannot resume this checkpoint: the run origin it records is not a word this engine knows. The checkpoint stays pending; finish it on a worker of the release that parked it, or expire it.";
59
62
  readonly "config.tool_face_control": "This engine cannot resume this checkpoint: its frozen inherited constraint chain records a tool name in a spelling this engine does not replay. The checkpoint stays pending; finish it on a worker of the release that parked it, or expire it and run the work again.";
60
63
  }>;
64
+ /**
65
+ * The verdict of a row nothing could read — one the judge threw on, or one the listing projection could not project: `damaged` /
66
+ * `requirements_damaged` under the fixed sentence. The total judge answers it, and the projection answers it for a row the judge
67
+ * called `ok` but a summary cannot be made of, so a listing never presents a row it cannot read as an approvable card.
68
+ */
69
+ export declare const UNREADABLE_ROW_VERDICT: CheckpointRowVerdict;
61
70
  /**
62
71
  * The ONE refusal of the RETIRED pre-queue single steer seat (`state.pendingSteer`, written before the queue existed): the
63
72
  * seat has no `inputId`, `seq` or actor, so folding it in would mint a synthetic identity nothing else can name. The refusal is
@@ -87,6 +96,8 @@ export declare function recordedModeSeed(gate: Pick<NonNullable<CheckpointState[
87
96
  prePlanMode?: PermissionMode;
88
97
  shellGate?: ShellGateDoctrine;
89
98
  };
99
+ /** What a total judge carries when the row could not be judged: the name of what was thrown, bounded (never its message — a message can quote a stored value). */
100
+ export declare function boundedThrownName(e: unknown): string;
90
101
  /**
91
102
  * The row's verdict for THIS engine: `ok`, `lacking` (a newer engine can resume it: `checkpoint.unsupported_version` /
92
103
  * `version_newer`, `requires` the reader words it lacks when its requirement list named them), or `damaged` (this engine
@@ -10,6 +10,8 @@ import { asResumeConfigRefusal } from "./mode-policy.js";
10
10
  import { screenRecordedRunOrigin } from "./run-origin.js";
11
11
  import { refusePersistedToolNames } from "./runner/sub-agent-deny-lists.js";
12
12
  import { thrownName } from "./thrown-value.js";
13
+ import { memberPresent } from "./own-property-receipt.js";
14
+ import { rowMemberProblem } from "./checkpoint-queries.js";
13
15
  export const ROW_REFUSAL_SENTENCES = Object.freeze({
14
16
  "checkpoint.unsupported_version|version_newer": "This engine cannot resume this checkpoint: it was parked by a newer engine release, whose row this release cannot read. The checkpoint stays pending; resume it on a worker at or above the release that parked it.",
15
17
  "checkpoint.unsupported_version|seat_retired": "This engine cannot resume this checkpoint: it carries a seat an earlier engine release wrote and this release retired. The checkpoint stays pending and nothing was consumed; finish it on a worker of a release that still reads that seat, or expire it.",
@@ -33,6 +35,12 @@ const LISTED_REQUIREMENT_WORD = /^[a-z][a-z_]{0,39}$/;
33
35
  const MAX_LISTED_REQUIREMENT_WORDS = 8;
34
36
  const MAX_THROWN_NAME_CHARS = 64;
35
37
  const OK = Object.freeze({ kind: "ok" });
38
+ export const UNREADABLE_ROW_VERDICT = Object.freeze({
39
+ kind: "damaged",
40
+ code: "checkpoint.invalid_outcome",
41
+ reason: "requirements_damaged",
42
+ sentence: ROW_REFUSAL_SENTENCES["checkpoint.invalid_outcome|requirements_damaged"],
43
+ });
36
44
  export function retiredSteerSeatRefusal(state) {
37
45
  if (state.pendingSteer === undefined)
38
46
  return undefined;
@@ -82,6 +90,13 @@ function recordedWordRefusal(screen) {
82
90
  throw e;
83
91
  }
84
92
  }
93
+ function bindingPredatesTool(cp) {
94
+ const pending = cp.pendingAction;
95
+ if (typeof pending !== "object" || pending === null || Reflect.get(pending, "kind") !== "tool_approval" || !memberPresent(pending, "boundInputHash"))
96
+ return false;
97
+ const declared = Reflect.get(cp, "requires");
98
+ return !(Array.isArray(declared) && declared.includes("tool_binding"));
99
+ }
85
100
  function rowRefusalOf(cp) {
86
101
  const { realApproval: realApprovalRow, face: faceRow, f012: f012Row } = CHECKPOINT_FEATURES;
87
102
  if (checkpointVersionOf(cp) > MAX_SUPPORTED_CHECKPOINT_VERSION) {
@@ -90,6 +105,9 @@ function rowRefusalOf(cp) {
90
105
  const requirements = judgeCheckpointRequirements(cp);
91
106
  if (requirements.kind === "lacking")
92
107
  return new CheckpointError("checkpoint.unsupported_version", `checkpoint requires reader capabilities this worker lacks (${requirements.words.join(", ")}) — resume it on a worker at or above the version that parked it`, { reason: "version_newer", requires: requirements.words });
108
+ const shape = rowMemberProblem(cp);
109
+ if (shape !== undefined)
110
+ return new CheckpointError("checkpoint.invalid_outcome", `this checkpoint's \`${shape.member}\` does not read as every reader of a row reads it (${shape.problem}) — a damaged row`, { reason: "requirements_damaged" });
93
111
  const retiredSeed = retiredModeSeedRefusal(cp.state);
94
112
  if (retiredSeed !== undefined)
95
113
  return retiredSeed;
@@ -102,6 +120,8 @@ function rowRefusalOf(cp) {
102
120
  "resuming here would run the leg with that ceiling unenforced. Rejected pre-CAS (the checkpoint stays pending): finish it on a worker of the " +
103
121
  "previous release, or start a fresh task bounded by resourceSuspend.totalTokens / totalBudgetUsd.");
104
122
  }
123
+ if (bindingPredatesTool(cp))
124
+ return new CheckpointError("checkpoint.invalid_outcome", "the pending approval's bound hash predates tool binding: an earlier engine release digested the call's arguments alone, and this release binds the tool's name with them, so no decision is matched to this row here — ask again", { reason: "requirements_damaged" });
105
125
  if (requirements.kind === "damaged")
106
126
  return new CheckpointError("checkpoint.invalid_outcome", `this checkpoint's reader-requirement list does not match the row (${requirements.why})`, { reason: "requirements_damaged" });
107
127
  const modeWords = recordedWordRefusal(() => void recordedModeSeed(cp.state.inheritedGate));
@@ -200,7 +220,7 @@ function readRow(cp) {
200
220
  refusal.message = `${sentence} Diagnostic: ${refusal.message}`;
201
221
  return { verdict, refusal };
202
222
  }
203
- function boundedThrownName(e) {
223
+ export function boundedThrownName(e) {
204
224
  const name = thrownName(e);
205
225
  return name === undefined || name === "" ? typeof e : name.slice(0, MAX_THROWN_NAME_CHARS);
206
226
  }
@@ -212,7 +232,7 @@ function readRowTotal(cp) {
212
232
  const name = boundedThrownName(e);
213
233
  const sentence = ROW_REFUSAL_SENTENCES["checkpoint.invalid_outcome|requirements_damaged"];
214
234
  return {
215
- verdict: Object.freeze({ kind: "damaged", code: "checkpoint.invalid_outcome", reason: "requirements_damaged", sentence }),
235
+ verdict: UNREADABLE_ROW_VERDICT,
216
236
  refusal: new CheckpointError("checkpoint.invalid_outcome", `${sentence} Diagnostic: the row could not be read (${name} thrown while judging it)`, { reason: "requirements_damaged", thrownName: name }),
217
237
  };
218
238
  }