@sema-agent/core 7.55.0 → 7.57.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 (502) hide show
  1. package/CHANGELOG.md +1054 -0
  2. package/LICENSE +1 -1
  3. package/dist/agents/cascade.js +1 -1
  4. package/dist/agents/cc-peer-directory.js +1 -0
  5. package/dist/agents/child-model-seat.d.ts +0 -11
  6. package/dist/agents/child-model-seat.js +0 -3
  7. package/dist/agents/list-agents-tool.d.ts +3 -1
  8. package/dist/agents/list-agents-tool.js +7 -7
  9. package/dist/agents/org-delivery-gate.js +3 -4
  10. package/dist/agents/peer-directory.d.ts +22 -4
  11. package/dist/agents/peer-directory.js +24 -2
  12. package/dist/agents/peer-held-queue.d.ts +69 -49
  13. package/dist/agents/peer-held-queue.js +255 -106
  14. package/dist/agents/peer-session-drain.js +65 -45
  15. package/dist/agents/repair-loop.js +2 -2
  16. package/dist/agents/send-message-tool.js +7 -6
  17. package/dist/agents/subagent.d.ts +6 -4
  18. package/dist/agents/subagent.js +72 -68
  19. package/dist/agents/tool-filter.d.ts +7 -5
  20. package/dist/agents/tool-filter.js +12 -9
  21. package/dist/agents/verify.d.ts +3 -2
  22. package/dist/agents/verify.js +3 -3
  23. package/dist/brain/anthropic.js +45 -80
  24. package/dist/brain/media-degrade.d.ts +18 -7
  25. package/dist/brain/media-degrade.js +13 -2
  26. package/dist/brain/model-capability.d.ts +37 -0
  27. package/dist/brain/model-capability.js +34 -0
  28. package/dist/brain/model-presets.d.ts +2 -8
  29. package/dist/brain/model-presets.js +1 -6
  30. package/dist/brain/open-responses.js +23 -34
  31. package/dist/brain/openai.js +25 -96
  32. package/dist/brain/provider-dialect.d.ts +3 -2
  33. package/dist/brain/provider-dialect.js +2 -2
  34. package/dist/brain/reasoning-request.d.ts +96 -0
  35. package/dist/brain/reasoning-request.js +174 -0
  36. package/dist/brain/reasoning.d.ts +11 -11
  37. package/dist/brain/reasoning.js +4 -3
  38. package/dist/brain/request-params.d.ts +13 -4
  39. package/dist/brain/request-params.js +21 -5
  40. package/dist/brain/status-sink.d.ts +20 -0
  41. package/dist/brain/status-sink.js +7 -0
  42. package/dist/brain/stream-engine.d.ts +9 -0
  43. package/dist/brain/stream-engine.js +24 -10
  44. package/dist/brain/stream-shared.d.ts +5 -4
  45. package/dist/brain/stream-shared.js +4 -4
  46. package/dist/core/a2a.d.ts +2 -1
  47. package/dist/core/a2a.js +19 -13
  48. package/dist/core/agent-definition.d.ts +10 -0
  49. package/dist/core/allow-entry.d.ts +23 -23
  50. package/dist/core/allow-entry.js +42 -46
  51. package/dist/core/allow-rule-shadow.d.ts +3 -3
  52. package/dist/core/approval-object.d.ts +21 -5
  53. package/dist/core/approval-object.js +44 -17
  54. package/dist/core/ask-origin.d.ts +66 -20
  55. package/dist/core/ask-origin.js +63 -23
  56. package/dist/core/ask-question.d.ts +51 -8
  57. package/dist/core/ask-question.js +3 -4
  58. package/dist/core/ask-unresolvable-notice.d.ts +8 -3
  59. package/dist/core/ask-unresolvable-notice.js +16 -2
  60. package/dist/core/auto-compaction.d.ts +71 -6
  61. package/dist/core/auto-compaction.js +42 -26
  62. package/dist/core/background-agent-store.d.ts +6 -2
  63. package/dist/core/background-agent-store.js +1 -1
  64. package/dist/core/checkpoint-generation.d.ts +53 -0
  65. package/dist/core/checkpoint-generation.js +35 -0
  66. package/dist/core/checkpoint-queries.d.ts +180 -0
  67. package/dist/core/checkpoint-queries.js +272 -0
  68. package/dist/core/checkpoint-requirements.d.ts +19 -1
  69. package/dist/core/checkpoint-requirements.js +6 -0
  70. package/dist/core/checkpoint-store.d.ts +105 -53
  71. package/dist/core/checkpoint-store.js +43 -20
  72. package/dist/core/cross-boundary-taint.d.ts +6 -5
  73. package/dist/core/cross-boundary-taint.js +5 -5
  74. package/dist/core/decision-receipt.d.ts +37 -3
  75. package/dist/core/decision-receipt.js +17 -17
  76. package/dist/core/delegation-not-started.d.ts +6 -0
  77. package/dist/core/delegation-not-started.js +17 -0
  78. package/dist/core/engine-attestation.d.ts +93 -0
  79. package/dist/core/engine-attestation.js +70 -0
  80. package/dist/core/engine-capabilities.d.ts +4 -1
  81. package/dist/core/engine-capabilities.js +1 -1
  82. package/dist/core/engine-notice.d.ts +32 -12
  83. package/dist/core/engine-notice.js +6 -0
  84. package/dist/core/file-history-store.d.ts +104 -22
  85. package/dist/core/file-history-store.js +37 -19
  86. package/dist/core/gate-fold.d.ts +1 -1
  87. package/dist/core/gate-fold.js +22 -10
  88. package/dist/core/gate-lanes.js +73 -65
  89. package/dist/core/gate-outcome.d.ts +26 -5
  90. package/dist/core/gate-outcome.js +26 -0
  91. package/dist/core/governance-codes.d.ts +5 -1
  92. package/dist/core/governance-codes.js +6 -0
  93. package/dist/core/hooks.d.ts +19 -18
  94. package/dist/core/hooks.js +3 -1
  95. package/dist/core/host-floor.d.ts +128 -0
  96. package/dist/core/host-floor.js +206 -0
  97. package/dist/core/host-target.d.ts +38 -3
  98. package/dist/core/host-target.js +38 -5
  99. package/dist/core/mailbox-store.d.ts +62 -1
  100. package/dist/core/mailbox-store.js +59 -0
  101. package/dist/core/mcp-name-judge.d.ts +46 -0
  102. package/dist/core/mcp-name-judge.js +61 -0
  103. package/dist/core/mcp-probe.d.ts +1 -1
  104. package/dist/core/mcp-probe.js +2 -5
  105. package/dist/core/mcp.d.ts +5 -1
  106. package/dist/core/mcp.js +70 -64
  107. package/dist/core/memory-engine/consolidation-driver.js +4 -3
  108. package/dist/core/memory-engine/delegation-settlement.js +15 -24
  109. package/dist/core/memory-engine/distiller.js +26 -17
  110. package/dist/core/memory-engine/engine.js +4 -4
  111. package/dist/core/memory-engine/layout.d.ts +60 -8
  112. package/dist/core/memory-engine/layout.js +70 -8
  113. package/dist/core/model-seat.d.ts +10 -3
  114. package/dist/core/mods/classic-events.d.ts +67 -0
  115. package/dist/core/mods/classic-events.js +1 -0
  116. package/dist/core/mods/dollar.d.ts +13 -0
  117. package/dist/core/mods/extension-call.d.ts +31 -0
  118. package/dist/core/mods/extension-call.js +43 -0
  119. package/dist/core/mods/kernel/dispatch.d.ts +20 -3
  120. package/dist/core/mods/kernel/dispatch.js +140 -69
  121. package/dist/core/mods/kernel/events.d.ts +47 -11
  122. package/dist/core/mods/kernel/events.js +66 -42
  123. package/dist/core/mods/kernel/index.d.ts +4 -4
  124. package/dist/core/mods/kernel/index.js +2 -2
  125. package/dist/core/mods/kernel/receive.d.ts +39 -5
  126. package/dist/core/mods/kernel/receive.js +290 -17
  127. package/dist/core/mods/kernel/registration.d.ts +33 -2
  128. package/dist/core/mods/kernel/registration.js +6 -7
  129. package/dist/core/mods/kernel/site-rules.d.ts +44 -16
  130. package/dist/core/mods/kernel/site-rules.js +24 -42
  131. package/dist/core/mods/spec-seats.d.ts +69 -0
  132. package/dist/core/mods/spec-seats.js +114 -0
  133. package/dist/core/mods/stations.d.ts +28 -8
  134. package/dist/core/mods/stations.js +29 -13
  135. package/dist/core/mods/tool-call.d.ts +79 -0
  136. package/dist/core/mods/tool-call.js +152 -0
  137. package/dist/core/namespaced-rule-name.d.ts +32 -38
  138. package/dist/core/namespaced-rule-name.js +29 -36
  139. package/dist/core/parent-spec-seat.d.ts +6 -1
  140. package/dist/core/parent-spec-seat.js +2 -0
  141. package/dist/core/park-selfcheck.js +3 -0
  142. package/dist/core/permission-rule-consent.d.ts +24 -3
  143. package/dist/core/permission-rule-consent.js +136 -41
  144. package/dist/core/permission-rule-model.d.ts +57 -5
  145. package/dist/core/permission-rule-model.js +90 -31
  146. package/dist/core/permission-rule-org.d.ts +6 -2
  147. package/dist/core/permission-rule-org.js +8 -4
  148. package/dist/core/permission-rule-provider.d.ts +5 -2
  149. package/dist/core/permission-rule-provider.js +41 -11
  150. package/dist/core/permission-rule-store.d.ts +3 -2
  151. package/dist/core/permission-rule-store.js +11 -2
  152. package/dist/core/permission-rule-sync.js +3 -2
  153. package/dist/core/permission-rule-syntax.d.ts +5 -4
  154. package/dist/core/permission-rule-syntax.js +2 -2
  155. package/dist/core/permission-rules.d.ts +4 -4
  156. package/dist/core/permission-rules.js +11 -20
  157. package/dist/core/persisted-rule-arms.d.ts +2 -2
  158. package/dist/core/persisted-rule-arms.js +10 -12
  159. package/dist/core/principal-name.d.ts +20 -0
  160. package/dist/core/principal-name.js +22 -0
  161. package/dist/core/prompt-section-seat.js +4 -6
  162. package/dist/core/protocol-http-auth.d.ts +40 -5
  163. package/dist/core/protocol-http-auth.js +168 -4
  164. package/dist/core/protocol-naming.d.ts +20 -0
  165. package/dist/core/protocol-naming.js +20 -3
  166. package/dist/core/read-only-shell.d.ts +20 -5
  167. package/dist/core/read-only-shell.js +29 -14
  168. package/dist/core/remote-env.d.ts +37 -1
  169. package/dist/core/remote-env.js +11 -0
  170. package/dist/core/resume-startup-cause.d.ts +24 -2
  171. package/dist/core/resume-startup-cause.js +20 -1
  172. package/dist/core/retired-keys.d.ts +16 -0
  173. package/dist/core/retired-keys.js +16 -4
  174. package/dist/core/rewrite-rejudge.d.ts +60 -0
  175. package/dist/core/rewrite-rejudge.js +36 -0
  176. package/dist/core/roles.d.ts +28 -1
  177. package/dist/core/roles.js +81 -26
  178. package/dist/core/rule-lane-reads.d.ts +20 -15
  179. package/dist/core/rule-lane-reads.js +45 -17
  180. package/dist/core/rule-owner.d.ts +3 -3
  181. package/dist/core/rule-owner.js +3 -2
  182. package/dist/core/runner/announce-once-ledger.d.ts +14 -0
  183. package/dist/core/runner/announce-once-ledger.js +5 -0
  184. package/dist/core/runner/assemble-result.d.ts +1 -0
  185. package/dist/core/runner/assemble-result.js +1 -1
  186. package/dist/core/runner/call-hook-stations.d.ts +3 -2
  187. package/dist/core/runner/caller-roster.d.ts +16 -4
  188. package/dist/core/runner/caller-roster.js +33 -6
  189. package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
  190. package/dist/core/runner/capability-withheld-seat.js +24 -0
  191. package/dist/core/runner/classifier-ladder.d.ts +7 -9
  192. package/dist/core/runner/classifier-ladder.js +3 -3
  193. package/dist/core/runner/compact-session.d.ts +10 -0
  194. package/dist/core/runner/compact-session.js +202 -0
  195. package/dist/core/runner/compaction-call-options.d.ts +2 -2
  196. package/dist/core/runner/compaction-seams.d.ts +21 -1
  197. package/dist/core/runner/compaction-seams.js +11 -8
  198. package/dist/core/runner/construction-doors.js +3 -0
  199. package/dist/core/runner/contracts.d.ts +50 -40
  200. package/dist/core/runner/cross-boundary-lane.d.ts +17 -13
  201. package/dist/core/runner/cross-boundary-lane.js +40 -27
  202. package/dist/core/runner/denial-limit-arms.d.ts +2 -2
  203. package/dist/core/runner/denial-limit-arms.js +1 -1
  204. package/dist/core/runner/derived-route-fallback.d.ts +13 -0
  205. package/dist/core/runner/derived-route-fallback.js +6 -0
  206. package/dist/core/runner/env-capability-census.d.ts +3 -2
  207. package/dist/core/runner/env-capability-census.js +9 -3
  208. package/dist/core/runner/file-history-request.d.ts +18 -0
  209. package/dist/core/runner/file-history-request.js +21 -13
  210. package/dist/core/runner/file-history-restore.d.ts +45 -0
  211. package/dist/core/runner/file-history-restore.js +46 -0
  212. package/dist/core/runner/gate-exit.d.ts +3 -3
  213. package/dist/core/runner/gate-exit.js +4 -3
  214. package/dist/core/runner/image.d.ts +7 -17
  215. package/dist/core/runner/image.js +9 -60
  216. package/dist/core/runner/permission-rule-lanes.d.ts +11 -11
  217. package/dist/core/runner/permission-rule-lanes.js +39 -17
  218. package/dist/core/runner/person-path-rows.d.ts +12 -9
  219. package/dist/core/runner/person-path-rows.js +18 -7
  220. package/dist/core/runner/prepare-acquire-reconcile.d.ts +3 -0
  221. package/dist/core/runner/prepare-acquire-reconcile.js +2 -1
  222. package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
  223. package/dist/core/runner/prepare-ask-lane.js +5 -2
  224. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
  225. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  226. package/dist/core/runner/prepare-config-doors.d.ts +35 -38
  227. package/dist/core/runner/prepare-config-doors.js +46 -28
  228. package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
  229. package/dist/core/runner/prepare-defer-classify.js +7 -8
  230. package/dist/core/runner/prepare-file-history.d.ts +48 -8
  231. package/dist/core/runner/prepare-file-history.js +7 -39
  232. package/dist/core/runner/prepare-gate-stations.d.ts +1 -1
  233. package/dist/core/runner/prepare-gate-stations.js +10 -1
  234. package/dist/core/runner/prepare-hands-readface.d.ts +5 -9
  235. package/dist/core/runner/prepare-hands-readface.js +17 -14
  236. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  237. package/dist/core/runner/prepare-inherited-gate.js +5 -3
  238. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  239. package/dist/core/runner/prepare-park-ask.d.ts +2 -0
  240. package/dist/core/runner/prepare-park-ask.js +7 -7
  241. package/dist/core/runner/prepare-policy-chain.d.ts +6 -3
  242. package/dist/core/runner/prepare-policy-chain.js +67 -76
  243. package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
  244. package/dist/core/runner/prepare-prompt-assembly.js +10 -8
  245. package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
  246. package/dist/core/runner/prepare-prompt-inputs.js +3 -5
  247. package/dist/core/runner/prepare-protocol-tools.d.ts +2 -0
  248. package/dist/core/runner/prepare-protocol-tools.js +3 -3
  249. package/dist/core/runner/prepare-safety-scan.d.ts +1 -1
  250. package/dist/core/runner/prepare-safety-scan.js +0 -17
  251. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  252. package/dist/core/runner/prepare-suspend-saga.js +5 -6
  253. package/dist/core/runner/prepare-task.d.ts +5 -2
  254. package/dist/core/runner/prepare-task.js +48 -43
  255. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +20 -4
  256. package/dist/core/runner/prepare-tool-disclosure-mount.js +33 -23
  257. package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
  258. package/dist/core/runner/prepare-turn-wiring.js +2 -7
  259. package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -2
  260. package/dist/core/runner/prepare-wiring-manifest.js +3 -3
  261. package/dist/core/runner/resume-admission.js +1 -1
  262. package/dist/core/runner/resume-apply.js +11 -12
  263. package/dist/core/runner/resume-checkpoint-screen.js +3 -0
  264. package/dist/core/runner/resume-claim.d.ts +4 -2
  265. package/dist/core/runner/resume-claim.js +15 -8
  266. package/dist/core/runner/retired-runner-deps.js +1 -0
  267. package/dist/core/runner/rewind-files.d.ts +12 -0
  268. package/dist/core/runner/rewind-files.js +90 -0
  269. package/dist/core/runner/run-attachment-seats.js +2 -1
  270. package/dist/core/runner/run-brain-sinks.d.ts +4 -1
  271. package/dist/core/runner/run-brain-sinks.js +4 -2
  272. package/dist/core/runner/run-harness-handlers.js +12 -4
  273. package/dist/core/runner/run-leg.d.ts +1 -1
  274. package/dist/core/runner/run-leg.js +40 -39
  275. package/dist/core/runner/run-notification-lane.d.ts +2 -0
  276. package/dist/core/runner/run-notification-lane.js +2 -2
  277. package/dist/core/runner/run-recovery-lanes.js +3 -4
  278. package/dist/core/runner/run-settle-and-teardown.js +7 -12
  279. package/dist/core/runner/run-terminal-adoption.js +3 -4
  280. package/dist/core/runner/run-turn-boundary.js +4 -15
  281. package/dist/core/runner/runtask.d.ts +10 -0
  282. package/dist/core/runner/runtask.js +35 -42
  283. package/dist/core/runner/send-message-continuation.js +1 -1
  284. package/dist/core/runner/session-read-file-states.d.ts +15 -0
  285. package/dist/core/runner/session-read-file-states.js +28 -0
  286. package/dist/core/runner/session-rule-policy.js +4 -3
  287. package/dist/core/runner/session-verb-doors.d.ts +28 -0
  288. package/dist/core/runner/session-verb-doors.js +48 -0
  289. package/dist/core/runner/session-write-ledger.d.ts +30 -0
  290. package/dist/core/runner/session-write-ledger.js +101 -0
  291. package/dist/core/runner/shell-env-withheld.d.ts +33 -0
  292. package/dist/core/runner/shell-env-withheld.js +51 -0
  293. package/dist/core/runner/skills-seat.js +6 -2
  294. package/dist/core/runner/stream-settle-backstop.js +12 -15
  295. package/dist/core/runner/sub-agent-deny-lists.d.ts +25 -3
  296. package/dist/core/runner/sub-agent-deny-lists.js +25 -17
  297. package/dist/core/runner/synthetic-tools.d.ts +6 -0
  298. package/dist/core/runner/synthetic-tools.js +4 -1
  299. package/dist/core/runner/teardown-bounded.d.ts +1 -0
  300. package/dist/core/runner/teardown-bounded.js +1 -0
  301. package/dist/core/runner/tool-disclosure.d.ts +10 -12
  302. package/dist/core/runner/tool-disclosure.js +1 -3
  303. package/dist/core/runner/tool-end-body.d.ts +1 -1
  304. package/dist/core/runner/tool-end-body.js +10 -9
  305. package/dist/core/runner/tool-not-executed.d.ts +5 -0
  306. package/dist/core/runner/tool-not-executed.js +11 -0
  307. package/dist/core/runner/tool-occurrence.d.ts +8 -0
  308. package/dist/core/runner/tool-occurrence.js +7 -0
  309. package/dist/core/runner/turn-attachments.d.ts +33 -15
  310. package/dist/core/runner/turn-attachments.js +62 -37
  311. package/dist/core/runner-deps.d.ts +7 -7
  312. package/dist/core/safety-axis-vocab.d.ts +6 -4
  313. package/dist/core/safety-axis-vocab.js +6 -5
  314. package/dist/core/safety-merge-corpus.js +11 -3
  315. package/dist/core/secret-env.d.ts +30 -3
  316. package/dist/core/secret-env.js +47 -8
  317. package/dist/core/select-model.js +3 -3
  318. package/dist/core/session-policy-store.d.ts +32 -15
  319. package/dist/core/session-policy-store.js +156 -36
  320. package/dist/core/session-store.d.ts +29 -10
  321. package/dist/core/session-store.js +51 -19
  322. package/dist/core/session.d.ts +82 -16
  323. package/dist/core/session.js +53 -0
  324. package/dist/core/shell-read-silence.d.ts +11 -12
  325. package/dist/core/shell-read-silence.js +9 -5
  326. package/dist/core/shell-run-candidates.js +3 -1
  327. package/dist/core/shell-wrapper-projection.d.ts +1 -1
  328. package/dist/core/shell-wrapper-projection.js +1 -1
  329. package/dist/core/shell-wrapper-table.d.ts +14 -7
  330. package/dist/core/shell-wrapper-table.js +5 -4
  331. package/dist/core/side-query.js +10 -1
  332. package/dist/core/skill-grant.d.ts +7 -2
  333. package/dist/core/skill-grant.js +5 -0
  334. package/dist/core/skills-directory.js +6 -2
  335. package/dist/core/store-contracts/background-agent-store-contract.js +1 -0
  336. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
  337. package/dist/core/store-contracts/checkpoint-store-contract.js +141 -2
  338. package/dist/core/store-contracts/file-history-store-contract.js +40 -1
  339. package/dist/core/store-contracts/mailbox-store-contract.js +49 -1
  340. package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
  341. package/dist/core/store-contracts/peer-directory-contract.js +14 -2
  342. package/dist/core/store-contracts/session-repo-contract.js +51 -0
  343. package/dist/core/store-contracts/session-store-contract.d.ts +2 -1
  344. package/dist/core/store-contracts/session-store-contract.js +150 -14
  345. package/dist/core/stub-env.d.ts +2 -0
  346. package/dist/core/stub-env.js +1 -0
  347. package/dist/core/synthetic-read-verdict.js +3 -3
  348. package/dist/core/task-event.d.ts +32 -4
  349. package/dist/core/task-notification.d.ts +16 -12
  350. package/dist/core/task-registry-agent.d.ts +8 -4
  351. package/dist/core/task-registry-agent.js +14 -8
  352. package/dist/core/task-registry-shared.d.ts +35 -6
  353. package/dist/core/task-registry-shared.js +11 -0
  354. package/dist/core/task-registry.d.ts +10 -1
  355. package/dist/core/task-registry.js +12 -2
  356. package/dist/core/task-result.d.ts +18 -0
  357. package/dist/core/task-spec.d.ts +18 -13
  358. package/dist/core/tighten-task-spec.js +2 -1
  359. package/dist/core/tool-catalog-entries.d.ts +23 -0
  360. package/dist/core/tool-catalog-entries.js +14 -2
  361. package/dist/core/tool-check-reading.d.ts +11 -0
  362. package/dist/core/tool-check-reading.js +11 -6
  363. package/dist/core/tool-model-gate.d.ts +2 -2
  364. package/dist/core/tool-name-aliases.d.ts +48 -18
  365. package/dist/core/tool-name-aliases.js +36 -19
  366. package/dist/core/tool-name-readings.d.ts +6 -32
  367. package/dist/core/tool-name-readings.js +2 -9
  368. package/dist/core/tool-policy.d.ts +78 -204
  369. package/dist/core/tool-policy.js +152 -204
  370. package/dist/core/tool-result-store.js +3 -0
  371. package/dist/core/tool-roster.d.ts +14 -19
  372. package/dist/core/tool-roster.js +11 -44
  373. package/dist/core/tool-spec-members.js +7 -2
  374. package/dist/core/tool-spec.d.ts +19 -11
  375. package/dist/core/tools.js +49 -9
  376. package/dist/core/trace.d.ts +6 -3
  377. package/dist/core/trace.js +2 -1
  378. package/dist/core/types.d.ts +1 -1
  379. package/dist/core/untrusted-egress.d.ts +20 -0
  380. package/dist/core/untrusted-egress.js +77 -3
  381. package/dist/core/user-attachment.d.ts +8 -1
  382. package/dist/core/user-attachment.js +64 -4
  383. package/dist/core/wiring-manifest.d.ts +9 -0
  384. package/dist/core/wiring-manifest.js +1 -0
  385. package/dist/core/workflow-journal-store.js +1 -1
  386. package/dist/engine/compaction/compaction.js +3 -2
  387. package/dist/engine/execution-env/node-execution-env.d.ts +7 -3
  388. package/dist/engine/execution-env/node-execution-env.js +11 -2
  389. package/dist/engine/harness/agent-harness.d.ts +32 -6
  390. package/dist/engine/harness/agent-harness.js +65 -9
  391. package/dist/engine/harness/types.d.ts +29 -2
  392. package/dist/engine/llm/types.d.ts +28 -11
  393. package/dist/engine/loop/agent-loop.d.ts +23 -4
  394. package/dist/engine/loop/agent-loop.js +42 -30
  395. package/dist/engine/loop/types.d.ts +16 -6
  396. package/dist/engine/session/memory-repo.d.ts +9 -2
  397. package/dist/engine/session/memory-repo.js +11 -1
  398. package/dist/engine/session/repo-utils.d.ts +6 -5
  399. package/dist/engine/session/repo-utils.js +14 -6
  400. package/dist/index.d.ts +34 -17
  401. package/dist/index.js +22 -11
  402. package/dist/internal/harness-types.d.ts +1 -1
  403. package/dist/internal/harness.d.ts +2 -1
  404. package/dist/internal/harness.js +1 -0
  405. package/dist/internal/llm.d.ts +1 -1
  406. package/dist/orchestration/run-workflow-tool.d.ts +6 -4
  407. package/dist/orchestration/run-workflow-tool.js +5 -3
  408. package/dist/orchestration/workflow.d.ts +3 -0
  409. package/dist/orchestration/workflow.js +36 -18
  410. package/dist/primitives/credential-ref.d.ts +89 -0
  411. package/dist/primitives/credential-ref.js +125 -0
  412. package/dist/primitives/index.d.ts +2 -0
  413. package/dist/primitives/index.js +1 -0
  414. package/dist/prompt-assembly/artifact.d.ts +2 -2
  415. package/dist/prompt-assembly/artifact.js +5 -3
  416. package/dist/prompt-assembly/assemble.d.ts +3 -2
  417. package/dist/prompt-assembly/assemble.js +1 -1
  418. package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
  419. package/dist/prompt-assembly/catalog/schema.js +34 -2
  420. package/dist/prompt-assembly/catalog/sections.js +0 -1
  421. package/dist/prompt-assembly/composer.d.ts +3 -1
  422. package/dist/prompt-assembly/composer.js +1 -1
  423. package/dist/prompt-assembly/event-registry.js +1 -0
  424. package/dist/prompt-assembly/overlay.js +3 -3
  425. package/dist/prompt-assembly/renderers.d.ts +1 -1
  426. package/dist/prompt-assembly/renderers.js +0 -3
  427. package/dist/prompt-assembly/role-base.d.ts +15 -0
  428. package/dist/prompt-assembly/role-base.js +9 -0
  429. package/dist/prompt-assembly/select.d.ts +39 -14
  430. package/dist/prompt-assembly/select.js +47 -16
  431. package/dist/prompt-assembly/sugar.d.ts +17 -11
  432. package/dist/prompt-assembly/sugar.js +8 -3
  433. package/dist/prompt-assembly/tool-catalog.d.ts +37 -3
  434. package/dist/prompt-assembly/tool-catalog.js +114 -4
  435. package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
  436. package/dist/prompt-assembly/turn-snapshot.js +0 -3
  437. package/dist/prompt-assembly/types.d.ts +0 -7
  438. package/dist/scenarios/full-body.d.ts +11 -11
  439. package/dist/scenarios/full-body.js +4 -3
  440. package/dist/shell/lex.js +10 -1
  441. package/dist/stores/file/adoption/adopt.js +4 -3
  442. package/dist/stores/file/adoption/marker.js +3 -2
  443. package/dist/stores/file/checkpoint-store.d.ts +21 -4
  444. package/dist/stores/file/checkpoint-store.js +38 -7
  445. package/dist/stores/file/file-history-store.js +18 -11
  446. package/dist/stores/file/index.js +2 -1
  447. package/dist/stores/file/mailbox-store.d.ts +2 -1
  448. package/dist/stores/file/mailbox-store.js +26 -1
  449. package/dist/stores/file/permission-rule-adopt.js +4 -3
  450. package/dist/stores/file/permission-rule-store.js +11 -5
  451. package/dist/stores/file/session-store.d.ts +29 -6
  452. package/dist/stores/file/session-store.js +42 -50
  453. package/dist/tools/artifact/artifact-tool.js +3 -2
  454. package/dist/tools/fs/bash-program-position.d.ts +19 -2
  455. package/dist/tools/fs/bash-program-position.js +56 -9
  456. package/dist/tools/fs/bash-readonly-classifier.d.ts +15 -19
  457. package/dist/tools/fs/bash-readonly-classifier.js +5 -10
  458. package/dist/tools/fs/fs-bash.js +15 -8
  459. package/dist/tools/fs/fs-glob.d.ts +86 -0
  460. package/dist/tools/fs/fs-glob.js +226 -0
  461. package/dist/tools/fs/fs-read.js +14 -14
  462. package/dist/tools/fs/fs-search-tools.js +7 -7
  463. package/dist/tools/fs/pattern-kill-guard.d.ts +23 -0
  464. package/dist/tools/fs/pattern-kill-guard.js +429 -0
  465. package/dist/tools/fs/pdf.d.ts +9 -6
  466. package/dist/tools/fs/pdf.js +3 -3
  467. package/dist/tools/fs/program-read-model.d.ts +57 -7
  468. package/dist/tools/fs/program-read-model.js +11 -1
  469. package/dist/tools/fs/program-read-model.rows.js +78 -21
  470. package/dist/tools/fs/read-deny-home.js +3 -2
  471. package/dist/tools/fs/removal-targets.d.ts +17 -7
  472. package/dist/tools/fs/removal-targets.js +47 -20
  473. package/dist/tools/fs/search.d.ts +10 -0
  474. package/dist/tools/fs/search.js +20 -26
  475. package/dist/tools/fs/shell-read-argv.js +89 -12
  476. package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
  477. package/dist/tools/fs/shell-read-bindings.js +41 -0
  478. package/dist/tools/fs/shell-read-check.d.ts +10 -0
  479. package/dist/tools/fs/shell-read-check.js +13 -20
  480. package/dist/tools/fs/shell-read-environment.d.ts +5 -1
  481. package/dist/tools/fs/shell-read-environment.js +3 -2
  482. package/dist/tools/fs/shell-read-establish.d.ts +15 -0
  483. package/dist/tools/fs/shell-read-establish.js +19 -20
  484. package/dist/tools/fs/shell-read-identity.d.ts +12 -9
  485. package/dist/tools/fs/shell-read-identity.js +9 -4
  486. package/dist/tools/fs/shell-read-plan.js +24 -16
  487. package/dist/tools/fs/shell-read-start.d.ts +6 -1
  488. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
  489. package/dist/tools/fs/shell-read-write-targets.js +2 -3
  490. package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
  491. package/dist/tools/fs/shell-reentry-text.js +40 -2
  492. package/dist/tools/todo.js +63 -63
  493. package/dist/tools/web.d.ts +19 -14
  494. package/dist/tools/web.js +46 -61
  495. package/package.json +1 -1
  496. package/test/export-surface.snapshot.json +221 -7
  497. package/wire-changes/core-stores-sql@7.57.0.json +29 -0
  498. package/wire-changes/core@7.56.0.json +3891 -0
  499. package/wire-changes/core@7.57.0.json +1487 -0
  500. package/wire-changes/mods-kernel@7.56.0.json +303 -0
  501. package/wire-changes/mods-kernel@7.57.0.json +29 -0
  502. package/wire-changes/primitives@7.57.0.json +245 -0
@@ -1,6 +1,8 @@
1
1
  import type { GateOutcome, HostDecisionFacts } from "./gate-outcome.js";
2
2
  import { type ExecutionOutcomeRecordWord } from "./checkpoint-execution-record.js";
3
+ import { type HolderJudge } from "./checkpoint-generation.js";
3
4
  import { type CheckpointPause } from "./pause-registry.js";
5
+ import { type CheckpointDeleteGuard, type CheckpointOverdueCursor, type CheckpointOverdueQuery, type CheckpointPage, type CheckpointRowRead, type CheckpointSessionCursor, type CheckpointSessionQuery } from "./checkpoint-queries.js";
4
6
  import type { SystemInjectionPriority } from "./task-notification.js";
5
7
  import { type SteerReplayFacet } from "./steer-replay.js";
6
8
  import type { QuestionAnswer } from "./ask-question.js";
@@ -898,9 +900,15 @@ export type PendingAction = {
898
900
  * them, as the live gate judged the original, and the resume re-mints its face under the spelling while it still
899
901
  * resolves to the row's tool. Absent on a row minted before it ⇒ the row's `toolName` alone. */
900
902
  names?: readonly string[];
903
+ /** `true` iff one of the engine's own mount sites mounted the parked tool (the roster entry's fact `ToolCallFace.engineMounted`
904
+ * carries): what the identity members above cannot say (a host-mounted engine definition has the same ones). The pre-CAS
905
+ * recheck rebuilds the face from the row (`parkedCallFaceOf`); absent ⇒ judged as an ordinary tool. Word `mount_site`. */
906
+ engineMounted?: true;
901
907
  /** The approval object's TARGETS (`approvalTargetsOf`): per reading of the path slot, where it resolved when the card
902
908
  * was asked; absent ⇒ not judged. A role resolving elsewhere at the execution vetoes the call (`resume.target_moved`). */
903
909
  targets?: import("./approval-object.js").ApprovalTargets;
910
+ /** The same member's shell reading (`approvalTargetsOf`): per read candidate the shell read station judged for the parked bytes, where it landed (digests); absent ⇒ not judged. A read landing elsewhere at the execution vetoes the call (`resume.target_moved`). Word `approval_target_reads`. */
911
+ targetReads?: import("./approval-object.js").ApprovalTargetReads;
904
912
  /**
905
913
  * #438 (additive; no checkpoint-version bump — the `reminderMark` precedent: an optional field an
906
914
  * older reader ignores. Unlike that precedent seat — which resume DOES read, through its
@@ -1031,6 +1039,9 @@ export interface CheckpointState {
1031
1039
  };
1032
1040
  /** The grant rows the run grew ({@link import("./skill-grant.js").frozenSkillGrants}); absent = none, damaged = refused pre-CAS. */
1033
1041
  skillGrants?: import("./skill-grant.js").SkillGrantRecord[];
1042
+ /** The skills active on the leg whose hooks were open (`SkillSpec.mods`; {@link import("./mods/spec-seats.js").SkillScopes}`.frozen`):
1043
+ * the resumed leg reopens them at its admission. Absent = none; damaged = refused pre-CAS. */
1044
+ skillScopes?: string[];
1034
1045
  /**
1035
1046
  * design/319 (A ticket) — the session's reminder provenance mark
1036
1047
  * ({@link import("./reminder-mint.js").mintReminderMark}), persisted so a durable resume keeps
@@ -1655,8 +1666,17 @@ export { REOPEN_REASONS, type ReopenReason } from "./resume-startup-cause.js";
1655
1666
  * (legacy callers / direct store tests) → no OCC.
1656
1667
  */
1657
1668
  export interface ResolveExpectation {
1658
- /** The monotonic {@link Checkpoint.rev} the caller observed at `get()` (absent rev ⇒ legacy `0`). */
1669
+ /** The monotonic {@link Checkpoint.rev} the caller observed at `get()`, read through {@link checkpointRevOf} (absent rev ⇒ legacy `0`). */
1659
1670
  rev: number;
1671
+ /**
1672
+ * The deployment's credential for the claim the resolving run acts under (`RunInternals.holder`, carried verbatim — the engine
1673
+ * never judges, stores or prints it). Every member of this object is a precondition the store evaluates in the SAME atomic step
1674
+ * as the flip: the CAS wins only if the grant `holder` names is still the deployment's current one at that instant (no claim
1675
+ * transfer may commit between the judgement and the flip). Judged only by a store that declares {@link CheckpointStore.fence}
1676
+ * `holder`; any other store LOSES a CAS that carries one (never ignores it — `checkpointHolderMatches`). A miss is an ordinary
1677
+ * loss: the row is untouched, so it reads `pending` at the generation the caller validated.
1678
+ */
1679
+ holder?: string;
1660
1680
  }
1661
1681
  /** design/384 slice 2 / S-25-R1 — the terminal intents a claim can carry. Deliberately the
1662
1682
  * TERMINAL pair only: `resolve` and `expire` are the two verbs that race one pending row to
@@ -1671,16 +1691,17 @@ export type TerminalClaimIntent = {
1671
1691
  };
1672
1692
  /** design/384 slice 2 / S-25-R1 — the single-round-trip answer: EITHER the claim won, OR it lost and
1673
1693
  * the SAME atomic operation reports what the row is now. `current` reuses the row's own vocabulary
1674
- * (status / rev / resolvedOutcome) — no new value domain. `status:"pending"` on a loss is the OCC
1675
- * arm only (`expect.rev` mismatch): the row is still open — re-get + re-validate, zero backoff (a
1676
- * cleanly KNOWN state is never "unknown"). */
1694
+ * (status / rev / resolvedOutcome) — no new value domain. `status:"pending"` on a loss is one of the
1695
+ * two expectation arms: a `rev` other than `expect.rev` is the OCC arm (the row is still open — re-get +
1696
+ * re-validate, zero backoff; a cleanly KNOWN state is never "unknown"); `expect.rev` itself means the
1697
+ * row did not move and the claim holder (`expect.holder`) was not current. */
1677
1698
  export type TerminalClaimOutcome = {
1678
1699
  claimed: true;
1679
1700
  } | {
1680
1701
  claimed: false;
1681
1702
  current: {
1682
1703
  status: "pending" | "resolved" | "expired";
1683
- /** `(cp.rev ?? 0)` — the absent-rev-reads-as-0 rule the OCC key already uses. */
1704
+ /** {@link checkpointRevOf} — the absent-rev-reads-as-0 rule the OCC key already uses. */
1684
1705
  rev: number;
1685
1706
  /** Row-field PASSTHROUGH on every present status: the row PRESERVES it across `reopen`
1686
1707
  * (resolved→pending rows carry it), `expire` never clears it, and a winnerless resolve
@@ -1817,7 +1838,7 @@ export interface CheckpointRow {
1817
1838
  * key ({@link ResolveExpectation}): a resume reads it at `get()` and `resolve` requires the live `rev` to
1818
1839
  * still equal it, so any resolve/reopen cycle landing in the get→resolve window loses the CAS (fail-closed).
1819
1840
  * Unlike the 2-valued `reopenReason`, it cannot ABA back to a prior value. Absent ⇒ legacy `0` (a checkpoint
1820
- * minted before this field; treated as never mutated).
1841
+ * minted before this field; treated as never mutated) — read it through {@link checkpointRevOf}.
1821
1842
  */
1822
1843
  rev?: number;
1823
1844
  /**
@@ -2146,14 +2167,16 @@ export declare function summarizeCheckpoint(cp: Checkpoint, disclose?: (sentence
2146
2167
  * steer seat, which no worker version reads and the host decides itself, or a retired mode-seed member of
2147
2168
  * `inheritedGate`, which an engine at 7.38.x or earlier still reads once).
2148
2169
  * · `invalid_outcome` pre-CAS row-integrity arms: `"real_approval_damaged"`, `"real_approval_forged"`,
2149
- * `"read_face_damaged"`, `"read_face_forged"`, `"write_face_damaged"`, `"skill_grants_damaged"`, `"constraint_chain_missing"`, `"hands_coordinates_damaged"`, `"requirements_damaged"` (all terminal for the row's
2170
+ * `"read_face_damaged"`, `"read_face_forged"`, `"write_face_damaged"`, `"skill_grants_damaged"`, `"skill_scopes_damaged"`, `"constraint_chain_missing"`, `"hands_coordinates_damaged"`, `"requirements_damaged"` (all terminal for the row's
2150
2171
  * current bytes — no worker version redeems a damaged row).
2151
2172
  */
2152
2173
  export type CheckpointErrorReason = "version_newer" | "env_factory_missing" | "governed_unwired" | "origin_missing" | "ledger_event_unknown" | "seat_retired" | "real_approval_damaged" | "real_approval_forged" | "read_face_damaged" | "read_face_forged"
2153
2174
  /** `state.writeFace` is present but not a well-formed section. No `_forged` twin: the section is
2154
2175
  * legal-and-absent at every version, so there is no version to judge a fabrication against — and a
2155
2176
  * fabricated "open" still needs the LIVE resolution to say open too. */
2156
- | "write_face_damaged" | "skill_grants_damaged" | "constraint_chain_missing"
2177
+ | "write_face_damaged" | "skill_grants_damaged"
2178
+ /** `state.skillScopes` is present but not a list of skill names (the active skills whose hooks the resumed leg reopens). */
2179
+ | "skill_scopes_damaged" | "constraint_chain_missing"
2157
2180
  /** `state.handsRoot` / `state.handsHome` / `state.handsCwd` is present but not an absolute path (the row's hands' coordinates). */
2158
2181
  | "hands_coordinates_damaged"
2159
2182
  /** The row's reader-requirement list ({@link CheckpointRow.requires}) is missing on a v10 row, is not a list of words,
@@ -2187,13 +2210,13 @@ export type CheckpointErrorReason = "version_newer" | "env_factory_missing" | "g
2187
2210
  * read, so `resume_at.invalid_mode` is a fresh run's word only), the containment faces, the add-only seats and the MCP / A2A `toolAxes` (`config.invalid_argument`), an MCP server's `toolFaces` (`config.tool_face_invalid`), the three memory seats, the cross-boundary posture, the advisor switch and the advisor model's shape,
2188
2211
  * the auto-consolidation arming (its role key too, and the role seats and tier bindings it reads: `config.unknown_role`, `detail.reason` naming the arm), the materialize strategy and persistence flag, the lock layer (`config.locked_registry`,
2189
2212
  * `config.locked_key`), an MCP server's content class, the skills-listing seats (`config.skill_listing_budget_invalid`), the limits and the
2190
- * resource-suspend knobs, the attachment modes, the governance windows, the brain-call guardrail and the retention declaration over the stores the leg
2213
+ * resource-suspend knobs, the attachment modes, the governance windows, the brain-call guardrail, the host floor (`config.host_floor_invalid`) and the retention declaration over the stores the leg
2191
2214
  * would run on (`config.retention_policy`, `config.retention_capability`), and the checkpoint store seat itself (`config.invalid_checkpoint_store`: the
2192
2215
  * retired `null` spelling, a store that declares no execution outcome), and the skills seat and the hands band (`config.invalid_argument`;
2193
2216
  * a skill's `baseDir` by its own reader, `config.skill_base_dir_invalid`). A door not entered here (the leg's model, its rebuilt
2194
2217
  * roster, its answer face, the approval seat's value) still refuses after the claim, each for a stated reason (INTEGRATION-CORE, "A resume's two doors").
2195
2218
  */
2196
- export declare const CHECKPOINT_CONFIG_REFUSAL_CODES: readonly ["config.spec_retired_key", "config.output_style_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_invalid", "config.user_invoked_skill_unknown", "config.skill_deny_unreadable", "config.user_attachment_invalid", "config.tool_face_control", "config.deps_retired_key", "config.peer_presence_invalid", "config.tool_model_gate_invalid", "config.microcompact_invalid", "config.prompt_selector_invalid", "resume_at.conflicts_resume", "resume_at.mode_without_target", "config.read_face_invalid", "config.write_face_invalid", "config.invalid_argument", "config.tool_face_invalid", "config.memory_delegation_evidence", "config.memory_provenance", "config.memory_capture_policy", "config.cross_boundary_posture", "config.advisor_tool_invalid", "config.advisor_model_invalid", "config.auto_consolidation", "config.unknown_role", "config.tool_materialize_invalid", "config.memory_persistence_invalid", "config.tool_materialize_unreachable", "config.locked_registry", "config.locked_key", "config.mcp_content_class", "config.skill_listing_budget_invalid", "config.limit_unknown_key", "config.limit_invalid", "config.attachment_invalid", "config.usage_window_invalid", "config.brain_call_guardrail_invalid", "config.retention_policy", "config.retention_capability", "config.invalid_checkpoint_store", "config.skill_base_dir_invalid"];
2219
+ export declare const CHECKPOINT_CONFIG_REFUSAL_CODES: readonly ["config.spec_retired_key", "config.output_style_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_invalid", "config.user_invoked_skill_unknown", "config.skill_deny_unreadable", "config.user_attachment_invalid", "config.tool_face_control", "config.deps_retired_key", "config.peer_presence_invalid", "config.tool_model_gate_invalid", "config.microcompact_invalid", "config.prompt_selector_invalid", "resume_at.conflicts_resume", "resume_at.mode_without_target", "config.read_face_invalid", "config.write_face_invalid", "config.invalid_argument", "config.tool_face_invalid", "config.memory_delegation_evidence", "config.memory_provenance", "config.memory_capture_policy", "config.cross_boundary_posture", "config.advisor_tool_invalid", "config.advisor_model_invalid", "config.auto_consolidation", "config.unknown_role", "config.tool_materialize_invalid", "config.memory_persistence_invalid", "config.tool_materialize_unreachable", "config.locked_registry", "config.locked_key", "config.mcp_content_class", "config.skill_listing_budget_invalid", "config.limit_unknown_key", "config.limit_invalid", "config.attachment_invalid", "config.usage_window_invalid", "config.brain_call_guardrail_invalid", "config.retention_policy", "config.retention_capability", "config.invalid_checkpoint_store", "config.skill_base_dir_invalid", "config.host_floor_invalid"];
2197
2220
  export type CheckpointConfigRefusalCode = (typeof CHECKPOINT_CONFIG_REFUSAL_CODES)[number];
2198
2221
  export declare const isCheckpointConfigRefusalCode: (word: unknown) => word is CheckpointConfigRefusalCode;
2199
2222
  /** The words of a {@link CheckpointError}'s optional `detail.field` (what each means: the `detail` member's doc). A CLOSED SET with one home, registered in
@@ -2352,9 +2375,15 @@ export declare class CheckpointError extends Error {
2352
2375
  * parity) before this throw — the token is NOT redeemable, by the deployment's own permanent
2353
2376
  * verdict (a dead binding must not be redialed forever). */
2354
2377
  | "resume.preflight_rejected"
2378
+ /** The resume carried a claim holder ({@link ResolveExpectation.holder}) and lost its CAS while the row is still the one it
2379
+ * validated — same scope, `pending`, the same generation — so the holder was not the deployment's current grant: nothing was
2380
+ * applied and the row is unchanged by this resume. The run is superseded; do not retry it (the current holder delivers).
2381
+ * Read off the CAS's own loss answer on `claimTerminal`; on the two-step route off its diagnostic read (a later instant —
2382
+ * under a race the row's later state answers instead, fail-closed either way). */
2383
+ | "resume.holder_superseded"
2355
2384
  /** F-012 L3: the resume carried an approver EDIT (`updatedInput`) and a FROZEN inherited ancestor
2356
2385
  * constraint (the persisted projection chain) — or the deployment's resume-edit policy — DENIES the
2357
- * edited args. Refused PRE-CAS with fresh-redecision semantics: the checkpoint stays `pending` and
2386
+ * edited args, or the policy accepts them only rewritten (`detail.editRewritten` names that form). Refused PRE-CAS with fresh-redecision semantics: the checkpoint stays `pending` and
2358
2387
  * the same token remains decidable (approve as shown, deny, or edit differently) — the rejection
2359
2388
  * consumed the decision's INPUT, never the ask itself. */
2360
2389
  | "resume.constraint_rejected"
@@ -2404,6 +2433,9 @@ export declare class CheckpointError extends Error {
2404
2433
  * {@link SteerReplayFacet}, in that set's order; always present on that code, never empty). Absent on
2405
2434
  * every other code. The live verb's refusal carries the same value. */
2406
2435
  differs?: readonly SteerReplayFacet[];
2436
+ /** On `resume.constraint_rejected` ⇔ the resume-edit policy accepts the person's edit only rewritten: `acceptableForm`
2437
+ * is that form, the outlet a host may offer; a decide carrying it as `updatedInput` runs exactly those bytes. */
2438
+ editRewritten?: import("./rewrite-rejudge.js").EditRewritten;
2407
2439
  } | undefined;
2408
2440
  constructor(code: "checkpoint.already_exists" | "checkpoint.already_resolved" | "checkpoint.not_found"
2409
2441
  /** `runner.resume` was handed an {@link ResumeOutcome} whose `gate` arm does not match the
@@ -2556,9 +2588,15 @@ export declare class CheckpointError extends Error {
2556
2588
  * parity) before this throw — the token is NOT redeemable, by the deployment's own permanent
2557
2589
  * verdict (a dead binding must not be redialed forever). */
2558
2590
  | "resume.preflight_rejected"
2591
+ /** The resume carried a claim holder ({@link ResolveExpectation.holder}) and lost its CAS while the row is still the one it
2592
+ * validated — same scope, `pending`, the same generation — so the holder was not the deployment's current grant: nothing was
2593
+ * applied and the row is unchanged by this resume. The run is superseded; do not retry it (the current holder delivers).
2594
+ * Read off the CAS's own loss answer on `claimTerminal`; on the two-step route off its diagnostic read (a later instant —
2595
+ * under a race the row's later state answers instead, fail-closed either way). */
2596
+ | "resume.holder_superseded"
2559
2597
  /** F-012 L3: the resume carried an approver EDIT (`updatedInput`) and a FROZEN inherited ancestor
2560
2598
  * constraint (the persisted projection chain) — or the deployment's resume-edit policy — DENIES the
2561
- * edited args. Refused PRE-CAS with fresh-redecision semantics: the checkpoint stays `pending` and
2599
+ * edited args, or the policy accepts them only rewritten (`detail.editRewritten` names that form). Refused PRE-CAS with fresh-redecision semantics: the checkpoint stays `pending` and
2562
2600
  * the same token remains decidable (approve as shown, deny, or edit differently) — the rejection
2563
2601
  * consumed the decision's INPUT, never the ask itself. */
2564
2602
  | "resume.constraint_rejected"
@@ -2608,6 +2646,9 @@ export declare class CheckpointError extends Error {
2608
2646
  * {@link SteerReplayFacet}, in that set's order; always present on that code, never empty). Absent on
2609
2647
  * every other code. The live verb's refusal carries the same value. */
2610
2648
  differs?: readonly SteerReplayFacet[];
2649
+ /** On `resume.constraint_rejected` ⇔ the resume-edit policy accepts the person's edit only rewritten: `acceptableForm`
2650
+ * is that form, the outlet a host may offer; a decide carrying it as `updatedInput` runs exactly those bytes. */
2651
+ editRewritten?: import("./rewrite-rejudge.js").EditRewritten;
2611
2652
  } | undefined);
2612
2653
  }
2613
2654
  /**
@@ -2732,19 +2773,6 @@ export interface CheckpointStore {
2732
2773
  * that still matches.
2733
2774
  */
2734
2775
  readonly fidelity?: StoreFidelity;
2735
- /**
2736
- * F-012 L2/L3 — the RE-DECISION capability declaration: whether this store's `reopen` (and, when
2737
- * present, a durable validating-lease discipline) actually works — a promise, not a method-presence
2738
- * sniff (`reopen` is optional and a stub that returns `false` still satisfies the type). The
2739
- * sandbox-admission mode's pre-flight REQUIRES `redecision.reopen === true` (its boundary asks park
2740
- * to a human and must be re-decidable); absent reads fail-closed as "no declared re-decision face"
2741
- * and the mode refuses to arm, loudly. Same "declaration, never duck-typing" posture as
2742
- * {@link retention}/{@link durability}/{@link fidelity}.
2743
- */
2744
- readonly redecision?: {
2745
- reopen: boolean;
2746
- validatingLease?: boolean;
2747
- };
2748
2776
  /**
2749
2777
  * The EXECUTION-OUTCOME declaration — REQUIRED, and required to be exactly `{ outcome: true }`: the
2750
2778
  * store promises that {@link recordExecutionOutcome} is the real CAS this contract describes (the
@@ -2759,6 +2787,15 @@ export interface CheckpointStore {
2759
2787
  readonly execution: {
2760
2788
  readonly outcome: true;
2761
2789
  };
2790
+ /**
2791
+ * The CLAIM-HOLDER declaration: this store judges {@link ResolveExpectation.holder} in the same atomic step as the resolve's flip.
2792
+ * Same "declaration, never duck-typing" posture as {@link execution}: ABSENT reads as "does not judge holders", and a run handed a
2793
+ * holder over such a store is refused at its store seat (`config.invalid_checkpoint_store`) — a holder the store would ignore would
2794
+ * fence nothing while the deployment believed it fenced.
2795
+ */
2796
+ readonly fence?: {
2797
+ readonly holder: true;
2798
+ };
2762
2799
  /** Create-once. Throws {@link CheckpointError} `already_exists` on a token collision (never a silent
2763
2800
  * overwrite — a reused token would clobber a live suspension). */
2764
2801
  put(token: CheckpointToken, cp: Checkpoint): Promise<void>;
@@ -2798,9 +2835,12 @@ export interface CheckpointStore {
2798
2835
  * `resolve` CAS *before* the workspace `resumeVM` runs; if that restore then fails (`resume.env_failed`)
2799
2836
  * the pending action never executed yet the checkpoint is consumed — without this the suspended work is
2800
2837
  * lost to a forced "re-initiate" (fine for a short approval, ruinous for a long unattended task).
2801
- * Reopening lets a retry re-resume the SAME work. Optional: a store that omits it keeps the prior (lossy)
2802
- * behavior, and the runner degrades gracefully. Safe by the `status='resolved'` guard — only the run that
2803
- * consumed the checkpoint (and then failed to restore) can reopen it, and only while it is still `resolved`.
2838
+ * Reopening lets a retry re-resume the SAME work. REQUIRED — the verb is the contract (no declaration stands
2839
+ * for it; the store seat, {@link resolveCheckpointStore}, refuses a store that does not carry it): a claimed
2840
+ * resume that ends before its decided action is disposed — a failed restore, a refusal at the leg's prepare, an
2841
+ * abort, a leg that returns failed — returns the row here, and the engine has no lane for a store that cannot. Safe by
2842
+ * the `status='resolved'` guard — only the run that consumed the checkpoint (and then failed to restore) can
2843
+ * reopen it, and only while it is still `resolved`.
2804
2844
  *
2805
2845
  * **design/80 D-1 (reopen-by-reason):** the `reason` distinguishes the two reopen triggers (both shipped at
2806
2846
  * runtask.ts) so re-resume can validate per reason (§3 inv #1): `env_failed` (the action is still valid,
@@ -2815,7 +2855,7 @@ export interface CheckpointStore {
2815
2855
  * already ran or re-decide one already refused. Answers `false` like every other predicate miss; the
2816
2856
  * reasons and the winner are untouched.
2817
2857
  */
2818
- reopen?(token: CheckpointToken, scope: string, reason: ReopenReason): Promise<boolean>;
2858
+ reopen(token: CheckpointToken, scope: string, reason: ReopenReason): Promise<boolean>;
2819
2859
  /**
2820
2860
  * Record how the DECIDED action was finally disposed on the resumed leg — the {@link GateOutcome} its
2821
2861
  * `tool_end` frame carried (see {@link CheckpointRow.executionOutcome} for what the record means and why
@@ -2939,9 +2979,8 @@ export interface CheckpointStore {
2939
2979
  * needed semantics; "who beat me / with what" is claimant-identity territory this contract
2940
2980
  * does not mint.
2941
2981
  * 7. **No declaration bit** — presence of the method IS the contract (an implementation
2942
- * obligation at the same level as `resolve`'s CAS promise); no `redecision`-style declaration,
2943
- * because that family guards against a stub satisfying a type, and a `claimTerminal` stub has
2944
- * no such shape — the return form itself carries the obligation.
2982
+ * obligation at the same level as `resolve`'s CAS promise), as it is for the required {@link reopen}:
2983
+ * the return form itself carries the obligation.
2945
2984
  *
2946
2985
  * Deployment correspondence (an ask-row store implementing the same law maps its own vocabulary):
2947
2986
  * token+scope ↔ the ask id (+ its run binding); pending/resolved/expired ↔ the ask row's
@@ -2993,10 +3032,21 @@ export interface CheckpointStore {
2993
3032
  * enumeration face `listByScope` lacks. A host keeping its own scope registry (e.g. a sidecar file for a
2994
3033
  * cross-scope inbox) can rebuild it from the data itself when the registry is lost/corrupt, instead of the
2995
3034
  * enumeration silently going empty and pending approvals turning invisible. Scoped to PENDING deliberately:
2996
- * it matches `listByScope`'s visible surface, so `listScopes() × listByScope()` is exactly the full inbox.
3035
+ * it matches `listByScope`'s visible surface, so `listScopes() × listByScope()` is exactly the full inbox,
3036
+ * and a member the summary does not project is read with `get(token)` on the listed token — the composition
3037
+ * a deployment's approval queue is, rather than a query of its own over the store's rows.
2997
3038
  * **OPTIONAL** like {@link listByScope}; the in-memory and file first-party impls provide it.
2998
3039
  */
2999
3040
  listScopes?(): Promise<string[]>;
3041
+ /** The PENDING rows of every scope past their deadline, one facet per call ({@link CheckpointOverdueQuery}; read by
3042
+ * `readCheckpointOverdueQuery`, keyset-paged, bounded). OPTIONAL, probed by presence; both first-party stores provide it. */
3043
+ listOverdue?(query: CheckpointOverdueQuery): Promise<CheckpointPage<CheckpointSummary, CheckpointOverdueCursor>>;
3044
+ /** The rows of ONE session in any status ({@link CheckpointSessionQuery}; read by `readCheckpointSessionQuery`, keyset-paged,
3045
+ * bounded; a damaged row of the session answers `unreadable`, never skipped — a row with no string session id belongs to no session and is left out, disclosed; the file replay drops a row with a non-string token, scope or status, disclosed there). OPTIONAL, probed by presence; both first-party stores provide it. */
3046
+ listBySession?(query: CheckpointSessionQuery): Promise<CheckpointPage<CheckpointRowRead, CheckpointSessionCursor>>;
3047
+ /** Delete the checkpoint rows of one session that exist when the call starts, in any status, when the guard admits it
3048
+ * ({@link CheckpointDeleteGuard}); answers the count. Present exactly when the store can judge the guard (a session head read). */
3049
+ deleteSessionCheckpoints?(sessionId: string, guard: CheckpointDeleteGuard): Promise<number>;
3000
3050
  }
3001
3051
  /**
3002
3052
  * The SINGLE resolution of "which CheckpointStore does this run use" (ruled 2026-08-04; re-homed
@@ -3020,12 +3070,13 @@ export declare function resolveCheckpointStore(spec: {
3020
3070
  }, deps: {
3021
3071
  checkpointStore?: CheckpointStore;
3022
3072
  }): CheckpointStore | undefined;
3023
- /** The ONE refusal of a store seat whose {@link CheckpointStore} does not declare `execution = { outcome: true }`
3024
- * (named by seat and by the store's constructor when it has one). Same door, same code, as the retired-`null`
3025
- * refusal above: a configuration the run cannot honour is refused at the first read, never carried. */
3026
- export declare function checkpointStoreExecutionUndeclared(seat: "TaskSpec.checkpointStore" | "RunnerDeps.checkpointStore", store: object): Error & {
3073
+ /** The ONE refusal of a store seat whose {@link CheckpointStore} lacks a required member (the {@link CheckpointStore.execution}
3074
+ * declaration, the {@link CheckpointStore.reopen} verb) — every missing one named, with the seat and the store's constructor when it
3075
+ * has one — or `undefined` when the store carries them all. Same door, same code, as the retired-`null` refusal below: a configuration
3076
+ * the run cannot honour is refused at the first read, never carried. */
3077
+ export declare function checkpointStoreIncomplete(seat: "TaskSpec.checkpointStore" | "RunnerDeps.checkpointStore", store: object): (Error & {
3027
3078
  code: "config.invalid_checkpoint_store";
3028
- };
3079
+ }) | undefined;
3029
3080
  /** The ONE refusal of the retired `checkpointStore: null` spelling (the resolver and the workflow baseline overlay both throw it). */
3030
3081
  export declare function retiredCheckpointStoreNull(): Error & {
3031
3082
  code: "config.invalid_checkpoint_store";
@@ -3093,15 +3144,6 @@ export declare function appendPendingSteer(state: Pick<CheckpointState, "pending
3093
3144
  * that backend's own correctness core and must never be absorbed into a shared abstraction).
3094
3145
  */
3095
3146
  export declare function checkpointRowMatches(cp: Checkpoint | undefined, scope: string, status: Checkpoint["status"]): cp is Checkpoint;
3096
- /**
3097
- * REF-A4 — THE optimistic-concurrency half of `resolve`'s CAS predicate (design/80 D-1), shared by every
3098
- * backend. The caller validated its reopen-by-reason guard against a `get()` snapshot; if a concurrent
3099
- * resolve/reopen cycle moved the monotonic `rev` in the get→resolve window, that validation is stale ⇒
3100
- * lose the CAS (fail-closed), forcing a re-get + re-validate. Keyed on `rev`, NOT on `reopenReason` — a
3101
- * 2-valued enum can ABA back to a prior value while the winner changed (round-2 BLOCKER fix). An absent
3102
- * expectation opts out of the guard entirely.
3103
- */
3104
- export declare function checkpointOccMatches(cp: Checkpoint, expect?: ResolveExpectation): boolean;
3105
3147
  /** Fault-injection mode for {@link InMemoryCheckpointStore.testInjectFault} (council #5). One-shot. */
3106
3148
  export type CheckpointFaultMode =
3107
3149
  /** `resolve` commits the CAS (status → resolved) then throws — simulates a crash *after* the commit
@@ -3132,21 +3174,29 @@ export declare class InMemoryCheckpointStore implements CheckpointStore {
3132
3174
  /** Honest declaration on the fidelity axis: `put`/`get` are `structuredClone`, so a row keeps the
3133
3175
  * whole structured-clone domain — a `Date` filed here is a `Date` when it comes back. */
3134
3176
  readonly fidelity: "structured-clone";
3135
- /** F-012 L2: this store's `reopen` is a real resolved→pending CAS (below) — declared, not sniffed. */
3136
- readonly redecision: {
3137
- readonly reopen: true;
3138
- };
3139
3177
  /** The execution-outcome record verb below is the contract's CAS, and `reopen` honours the record. */
3140
3178
  readonly execution: {
3141
3179
  readonly outcome: true;
3142
3180
  };
3181
+ /** Declared exactly when the store was built with a `holderIsCurrent` judge ({@link CheckpointStore.fence}). */
3182
+ readonly fence?: {
3183
+ readonly holder: true;
3184
+ };
3143
3185
  private cps;
3144
3186
  private fault;
3145
3187
  private readonly disclose;
3146
- /** `disclose` is the listing projection's own seat ({@link summarizeCheckpoint}'s): this store has no path, so it
3147
- * forwards the projection's sentence for a row read past a damage, called synchronously by {@link listByScope}. */
3188
+ private readonly holderIsCurrent;
3189
+ readonly deleteSessionCheckpoints?: (sessionId: string, guard: CheckpointDeleteGuard) => Promise<number>;
3190
+ /** `disclose` is the listing projections' own seat ({@link summarizeCheckpoint}'s and the listing faces'): this store has no
3191
+ * path, so it forwards each sentence for a row read past a damage, called synchronously by the listing that read it.
3192
+ * `sessionHeadOf` (a session store's `headOf`) is what {@link CheckpointStore.deleteSessionCheckpoints} judges its guard by.
3193
+ * `holderIsCurrent` ({@link HolderJudge}) is what a resolve's `expect.holder` is judged by. */
3148
3194
  constructor(opts?: {
3149
3195
  disclose?: (sentence: string) => void;
3196
+ sessionHeadOf?: (sessionId: string) => Promise<{
3197
+ readonly owner: string | null;
3198
+ } | undefined>;
3199
+ holderIsCurrent?: HolderJudge;
3150
3200
  });
3151
3201
  put(token: CheckpointToken, cp: Checkpoint): Promise<void>;
3152
3202
  get(token: CheckpointToken): Promise<Checkpoint | null>;
@@ -3205,6 +3255,8 @@ export declare class InMemoryCheckpointStore implements CheckpointStore {
3205
3255
  reap(scope: string, cutoff: number): Promise<number>;
3206
3256
  listByScope(scope: string): Promise<CheckpointSummary[]>;
3207
3257
  listScopes(): Promise<string[]>;
3258
+ listOverdue(query: CheckpointOverdueQuery): Promise<CheckpointPage<CheckpointSummary, CheckpointOverdueCursor>>;
3259
+ listBySession(query: CheckpointSessionQuery): Promise<CheckpointPage<CheckpointRowRead, CheckpointSessionCursor>>;
3208
3260
  /** Arm a one-shot fault on the next `resolve` (council #5: makes crash-recovery unit-testable). */
3209
3261
  testInjectFault(mode: CheckpointFaultMode | null): void;
3210
3262
  /** Test/inspection helper: number of stored checkpoints. */
@@ -6,7 +6,9 @@ import { isAutoModeFallbackCause, readDenialLimitFallback } from "./auto-mode.js
6
6
  import { isAskOrigin, isPersistedRuleMandate } from "./ask-origin.js";
7
7
  import { readBoundBinding } from "./skill-grant-binding.js";
8
8
  import { checkpointExecutionRecorded, executionRecordDisposition, ExecutionOutcomeConflictError, } from "./checkpoint-execution-record.js";
9
+ import { checkpointHolderMatches, checkpointOccMatches, checkpointRevOf } from "./checkpoint-generation.js";
9
10
  import { parkedApprovalCardOf } from "./pause-registry.js";
11
+ import { checkpointDeadlinePassed, deleteSessionRowsAtStart, readCheckpointOverdueQuery, readCheckpointSessionQuery, selectOverduePage, selectSessionPage } from "./checkpoint-queries.js";
10
12
  import { renderUntrustedCommandText, stripFormatCharacters } from "./permission-rule-model.js";
11
13
  import { egressText } from "./untrusted-egress.js";
12
14
  import { steerReplayRefusal } from "./steer-replay.js";
@@ -333,7 +335,7 @@ export function summarizeCheckpoint(cp, disclose) {
333
335
  ...(hasBidi ? { hasBidiControls: true } : {}),
334
336
  };
335
337
  }
336
- export const CHECKPOINT_CONFIG_REFUSAL_CODES = Object.freeze(["config.spec_retired_key", "config.output_style_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_invalid", "config.user_invoked_skill_unknown", "config.skill_deny_unreadable", "config.user_attachment_invalid", "config.tool_face_control", "config.deps_retired_key", "config.peer_presence_invalid", "config.tool_model_gate_invalid", "config.microcompact_invalid", "config.prompt_selector_invalid", "resume_at.conflicts_resume", "resume_at.mode_without_target", "config.read_face_invalid", "config.write_face_invalid", "config.invalid_argument", "config.tool_face_invalid", "config.memory_delegation_evidence", "config.memory_provenance", "config.memory_capture_policy", "config.cross_boundary_posture", "config.advisor_tool_invalid", "config.advisor_model_invalid", "config.auto_consolidation", "config.unknown_role", "config.tool_materialize_invalid", "config.memory_persistence_invalid", "config.tool_materialize_unreachable", "config.locked_registry", "config.locked_key", "config.mcp_content_class", "config.skill_listing_budget_invalid", "config.limit_unknown_key", "config.limit_invalid", "config.attachment_invalid", "config.usage_window_invalid", "config.brain_call_guardrail_invalid", "config.retention_policy", "config.retention_capability", "config.invalid_checkpoint_store", "config.skill_base_dir_invalid"]);
338
+ export const CHECKPOINT_CONFIG_REFUSAL_CODES = Object.freeze(["config.spec_retired_key", "config.output_style_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_invalid", "config.user_invoked_skill_unknown", "config.skill_deny_unreadable", "config.user_attachment_invalid", "config.tool_face_control", "config.deps_retired_key", "config.peer_presence_invalid", "config.tool_model_gate_invalid", "config.microcompact_invalid", "config.prompt_selector_invalid", "resume_at.conflicts_resume", "resume_at.mode_without_target", "config.read_face_invalid", "config.write_face_invalid", "config.invalid_argument", "config.tool_face_invalid", "config.memory_delegation_evidence", "config.memory_provenance", "config.memory_capture_policy", "config.cross_boundary_posture", "config.advisor_tool_invalid", "config.advisor_model_invalid", "config.auto_consolidation", "config.unknown_role", "config.tool_materialize_invalid", "config.memory_persistence_invalid", "config.tool_materialize_unreachable", "config.locked_registry", "config.locked_key", "config.mcp_content_class", "config.skill_listing_budget_invalid", "config.limit_unknown_key", "config.limit_invalid", "config.attachment_invalid", "config.usage_window_invalid", "config.brain_call_guardrail_invalid", "config.retention_policy", "config.retention_capability", "config.invalid_checkpoint_store", "config.skill_base_dir_invalid", "config.host_floor_invalid"]);
337
339
  export const isCheckpointConfigRefusalCode = (word) => CHECKPOINT_CONFIG_REFUSAL_CODES.some((w) => w === word);
338
340
  export class CheckpointError extends Error {
339
341
  code;
@@ -373,22 +375,31 @@ export function resolveCheckpointStore(spec, deps) {
373
375
  if (spec.checkpointStore === "disabled")
374
376
  return undefined;
375
377
  if (spec.checkpointStore !== undefined) {
376
- if (spec.checkpointStore.execution?.outcome !== true)
377
- throw checkpointStoreExecutionUndeclared("TaskSpec.checkpointStore", spec.checkpointStore);
378
+ const refused = checkpointStoreIncomplete("TaskSpec.checkpointStore", spec.checkpointStore);
379
+ if (refused !== undefined)
380
+ throw refused;
378
381
  return spec.checkpointStore;
379
382
  }
380
- if (deps.checkpointStore !== undefined && deps.checkpointStore?.execution?.outcome !== true) {
381
- throw checkpointStoreExecutionUndeclared("RunnerDeps.checkpointStore", deps.checkpointStore);
383
+ if (deps.checkpointStore !== undefined) {
384
+ const refused = checkpointStoreIncomplete("RunnerDeps.checkpointStore", deps.checkpointStore);
385
+ if (refused !== undefined)
386
+ throw refused;
382
387
  }
383
388
  return deps.checkpointStore;
384
389
  }
385
- export function checkpointStoreExecutionUndeclared(seat, store) {
386
- const ctor = store?.constructor?.name;
390
+ const REQUIRED_STORE_MEMBERS = [
391
+ { carried: (store) => store?.execution?.outcome === true, lacks: "does not declare `execution = { outcome: true }`", cost: "the execution-outcome record (recordExecutionOutcome, and reopen refusing a recorded row) — without it no reader can settle how a resumed approval was disposed" },
392
+ { carried: (store) => typeof store?.reopen === "function", lacks: "does not carry the `reopen` verb", cost: "the claim's reversal (reopen) — without it a resume the engine claimed and then refused before its decided action was disposed would consume the approval" },
393
+ ];
394
+ export function checkpointStoreIncomplete(seat, store) {
395
+ const read = store;
396
+ const missing = REQUIRED_STORE_MEMBERS.filter((m) => !m.carried(read));
397
+ if (missing.length === 0)
398
+ return undefined;
399
+ const ctor = read?.constructor?.name;
387
400
  const name = typeof ctor === "string" && ctor.length > 0 && ctor !== "Object" ? ` (${ctor})` : "";
388
- const e = new Error(`${seat}: the wired CheckpointStore${name} does not declare \`execution = { outcome: true }\` — the execution-outcome ` +
389
- "record (recordExecutionOutcome, and reopen refusing a recorded row) is a required member of the store contract; " +
390
- "a store without it cannot record how a resumed approval was disposed, so the run is refused here rather than " +
391
- "resolving rows no reader can settle. Implement the verb and add the declaration (the in-tree stores and the " +
401
+ const e = new Error(`${seat}: the wired CheckpointStore${name} ${missing.map((m) => m.lacks).join(" and ")} — ${missing.map((m) => m.cost).join("; ")}. ` +
402
+ "Each is a required member of the store contract, so the run is refused here. Implement it (the in-tree stores and the " +
392
403
  "store-contract kit are the reference).");
393
404
  e.code = "config.invalid_checkpoint_store";
394
405
  return e;
@@ -542,20 +553,24 @@ export function appendPendingSteer(state, entry) {
542
553
  export function checkpointRowMatches(cp, scope, status) {
543
554
  return cp !== undefined && cp.scope === scope && cp.status === status;
544
555
  }
545
- export function checkpointOccMatches(cp, expect) {
546
- return expect === undefined || (cp.rev ?? 0) === expect.rev;
547
- }
548
556
  export class InMemoryCheckpointStore {
549
557
  retention = "none";
550
558
  durability = "process-local";
551
559
  fidelity = "structured-clone";
552
- redecision = { reopen: true };
553
560
  execution = { outcome: true };
554
561
  cps = new Map();
555
562
  fault = null;
556
563
  disclose;
564
+ holderIsCurrent;
557
565
  constructor(opts = {}) {
558
566
  this.disclose = opts.disclose;
567
+ this.holderIsCurrent = opts.holderIsCurrent;
568
+ if (opts.holderIsCurrent !== undefined)
569
+ this.fence = Object.freeze({ holder: true });
570
+ const headOf = opts.sessionHeadOf;
571
+ if (headOf !== undefined) {
572
+ this.deleteSessionCheckpoints = (sessionId, guard) => deleteSessionRowsAtStart(this.cps, sessionId, guard, headOf, (token, row) => this.cps.get(token) === row && this.cps.delete(token));
573
+ }
559
574
  }
560
575
  async put(token, cp) {
561
576
  if (this.cps.has(token)) {
@@ -574,7 +589,7 @@ export class InMemoryCheckpointStore {
574
589
  claimed: false,
575
590
  current: {
576
591
  status: cp.status,
577
- rev: cp.rev ?? 0,
592
+ rev: checkpointRevOf(cp),
578
593
  ...(cp.resolvedOutcome !== undefined ? { resolvedOutcome: structuredClone(cp.resolvedOutcome) } : {}),
579
594
  },
580
595
  };
@@ -587,10 +602,13 @@ export class InMemoryCheckpointStore {
587
602
  if (!checkpointOccMatches(cp, expect)) {
588
603
  return this.claimLossFrom(cp, scope);
589
604
  }
605
+ if (!checkpointHolderMatches(expect, this.holderIsCurrent)) {
606
+ return this.claimLossFrom(cp, scope);
607
+ }
590
608
  const winner = winnerFromOutcome(outcome);
591
609
  const winnerClone = winner ? structuredClone(winner) : undefined;
592
610
  cp.status = "resolved";
593
- cp.rev = (cp.rev ?? 0) + 1;
611
+ cp.rev = checkpointRevOf(cp) + 1;
594
612
  if (winnerClone)
595
613
  cp.resolvedOutcome = winnerClone;
596
614
  cp.reopenReason = undefined;
@@ -651,7 +669,7 @@ export class InMemoryCheckpointStore {
651
669
  return false;
652
670
  }
653
671
  cp.status = "pending";
654
- cp.rev = (cp.rev ?? 0) + 1;
672
+ cp.rev = checkpointRevOf(cp) + 1;
655
673
  cp.reopenReason = reason;
656
674
  return true;
657
675
  }
@@ -673,8 +691,7 @@ export class InMemoryCheckpointStore {
673
691
  async reap(scope, cutoff) {
674
692
  let n = 0;
675
693
  for (const cp of this.cps.values()) {
676
- const deadlinePassed = cp.deadline !== undefined && (Number.isFinite(cp.deadline) ? cp.deadline <= cutoff : true);
677
- if (cp.scope === scope && cp.status === "pending" && deadlinePassed) {
694
+ if (cp.scope === scope && cp.status === "pending" && checkpointDeadlinePassed(cp.deadline, cutoff)) {
678
695
  cp.status = "expired";
679
696
  n++;
680
697
  }
@@ -696,6 +713,12 @@ export class InMemoryCheckpointStore {
696
713
  out.add(cp.scope);
697
714
  return [...out];
698
715
  }
716
+ async listOverdue(query) {
717
+ return selectOverduePage(this.cps.entries(), readCheckpointOverdueQuery(query), (cp) => summarizeCheckpoint(cp, this.disclose), this.disclose);
718
+ }
719
+ async listBySession(query) {
720
+ return selectSessionPage(this.cps.entries(), readCheckpointSessionQuery(query), (cp) => structuredClone(cp), this.disclose);
721
+ }
699
722
  testInjectFault(mode) {
700
723
  this.fault = mode;
701
724
  }
@@ -58,6 +58,9 @@ export interface BoundaryLegsGiven {
58
58
  readonly externalContentTarget?: boolean;
59
59
  };
60
60
  }
61
+ /** What a leg's session is still owed when the leg ends: the legs each unfinished background task its access (the TaskOutput reach) delivers
62
+ * along, read as the poll the session's next leg — another tree — would make of it (`TaskRegistry.owedDeliveries`). */
63
+ export type OwedDeliveries = () => readonly BoundaryLegsGiven[];
61
64
  declare const CROSS_BOUNDARY_TREE_TOKEN: unique symbol;
62
65
  /** A run tree's cross-boundary IDENTITY — opaque and frozen, minted by the engine alone: a tool is handed it so a delegation or
63
66
  * workflow lane can join its children to the same tree and a registry handle can name the tree that spawned it, compared by
@@ -186,17 +189,15 @@ export declare function crossBoundaryPostureUndeclaredNotice(at: {
186
189
  /** Where a session record's write was owed: a leg's prepare, an exit before its call runs, a suspend before its row, a settle. */
187
190
  export type CrossBoundaryRecordPhase = "prepare" | "exit" | "suspend" | "settle";
188
191
  /** The one mint of `config.cross_boundary_record_unwritten`: a session record that could not be written and refused nothing — on a tree
189
- * that is not governed (no judgment reads the record), or at a governed leg's prepare / settle (no call to refuse; the next leg then
190
- * reads the content after the newest record as off-target). A governed exit refuses its call and a governed suspend its row instead.
191
- * `catchUp`: an earlier record of the same write landed and the one that carries the tree's newer bits did not — on a governed tree
192
- * that earlier record covers the content before it, so the sentence says the next leg may not route its device calls to a person.
192
+ * that is not governed (no judgment reads the record), or at a governed leg's prepare / settle (no call to refuse). On a governed tree
193
+ * the record stays owed: a prepare's by the leg's next write, and once none lands — a settle's failure is the leg's last — the next leg
194
+ * reads the content after the newest record as off-target. A governed exit refuses its call and a governed suspend its row instead.
193
195
  * Minted once per state a leg could not write. */
194
196
  export declare function crossBoundaryRecordUnwrittenNotice(at: {
195
197
  readonly sessionId: string;
196
198
  readonly runId: string;
197
199
  readonly phase: CrossBoundaryRecordPhase;
198
200
  readonly governed: boolean;
199
- readonly catchUp: boolean;
200
201
  readonly cause: string;
201
202
  }): EngineNotice;
202
203
  /** The face a protocol tool (an MCP tool, an A2A skill) carries for its JUDGED `toolAxes` entry (`readToolAxes`' copy): the empty leg
@@ -1,4 +1,5 @@
1
1
  import { hasConversationContent } from "./session.js";
2
+ import { egressText } from "./untrusted-egress.js";
2
3
  export const CROSS_BOUNDARY_TAINT_BITS = Object.freeze(["targetExecutionArmed", "offTargetReadObserved"]);
3
4
  export const CROSS_BOUNDARY_POSTURES = Object.freeze(["single_user", "multi_tenant"]);
4
5
  const postureSeatIsTheSet = true;
@@ -152,15 +153,14 @@ export function crossBoundaryPostureUndeclaredNotice(at) {
152
153
  };
153
154
  }
154
155
  export function crossBoundaryRecordUnwrittenNotice(at) {
156
+ const cause = egressText("same-principal", at.cause).slice(0, 300);
155
157
  return {
156
158
  code: "config.cross_boundary_record_unwritten",
157
- message: `The session's cross-boundary record could not be written at ${at.phase} (${at.cause.slice(0, 300)}) — ` +
159
+ message: `The session's cross-boundary record could not be written at ${at.phase} (${cause}) — ` +
158
160
  (!at.governed
159
161
  ? "the tree is not governed: no judgment reads the record, so its failure refused nothing; the tree's growth, or the leg's end, writes next, and a failure of this same state is not reported again."
160
- : at.catchUp
161
- ? "the tree is governed, and an earlier record of this write landed: the catch-up record that carries the tree's newer bits has not been written. Until #2160 lands, the next leg on this session may read the content before that earlier record as covered and may not route its device calls to a person (KNOWN-LIMITS KL-469-c); the terminal shape is fail-closed."
162
- : "the tree is governed: the next leg on this session reads the content after its newest record as off-target, so its device calls are put to a person."),
163
- detail: { sessionId: at.sessionId, runId: at.runId, phase: at.phase, governed: at.governed, cause: at.cause.slice(0, 300) },
162
+ : `the tree is governed: ${at.phase === "prepare" ? "the leg's next write (an exit before its call runs, a suspend before its row, its end) owes the record again; if none lands, " : ""}the next leg on this session reads the content after its newest record as off-target, so its device calls are put to a person.`),
163
+ detail: { sessionId: at.sessionId, runId: at.runId, phase: at.phase, governed: at.governed, cause },
164
164
  };
165
165
  }
166
166
  const NO_LEGS = Object.freeze([]);