@sema-agent/core 7.70.0 → 7.71.1

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 (439) hide show
  1. package/CHANGELOG.md +740 -0
  2. package/dist/agents/agent-transcript-tool.js +43 -19
  3. package/dist/agents/inherited-tool-pool.d.ts +5 -1
  4. package/dist/agents/inherited-tool-pool.js +6 -0
  5. package/dist/agents/retain-ledger.js +2 -0
  6. package/dist/agents/send-message-tool.d.ts +12 -1
  7. package/dist/agents/send-message-tool.js +47 -9
  8. package/dist/agents/subagent.js +31 -10
  9. package/dist/agents/tool-filter.js +1 -2
  10. package/dist/agents/verify.js +13 -2
  11. package/dist/agents/yield-adoption.js +11 -1
  12. package/dist/brain/claude-model-id.d.ts +11 -0
  13. package/dist/brain/claude-model-id.js +3 -1
  14. package/dist/config/catalog.js +10 -1
  15. package/dist/config/defaults.d.ts +3 -0
  16. package/dist/config/defaults.js +1 -0
  17. package/dist/core/allow-entry.js +1 -2
  18. package/dist/core/ask-origin.d.ts +55 -21
  19. package/dist/core/ask-origin.js +19 -11
  20. package/dist/core/ask-question.d.ts +4 -7
  21. package/dist/core/ask-question.js +2 -4
  22. package/dist/core/ask-unresolvable-notice.d.ts +17 -3
  23. package/dist/core/ask-unresolvable-notice.js +18 -4
  24. package/dist/core/attachment-source.d.ts +1 -1
  25. package/dist/core/attachment-source.js +2 -0
  26. package/dist/core/auto-compaction.d.ts +14 -4
  27. package/dist/core/auto-compaction.js +3 -2
  28. package/dist/core/auto-strip.js +2 -0
  29. package/dist/core/caller-text.d.ts +2 -33
  30. package/dist/core/caller-text.js +2 -23
  31. package/dist/core/caller-tool-name.js +1 -2
  32. package/dist/core/canonical-json.d.ts +9 -0
  33. package/dist/core/canonical-json.js +6 -0
  34. package/dist/core/checkpoint-features.d.ts +43 -80
  35. package/dist/core/checkpoint-features.js +10 -20
  36. package/dist/core/checkpoint-generation.d.ts +89 -19
  37. package/dist/core/checkpoint-generation.js +89 -14
  38. package/dist/core/checkpoint-queries.d.ts +95 -15
  39. package/dist/core/checkpoint-queries.js +108 -7
  40. package/dist/core/checkpoint-rekey.d.ts +2 -1
  41. package/dist/core/checkpoint-rekey.js +2 -2
  42. package/dist/core/checkpoint-requirements.d.ts +21 -7
  43. package/dist/core/checkpoint-requirements.js +2 -5
  44. package/dist/core/checkpoint-row-verdict.d.ts +3 -4
  45. package/dist/core/checkpoint-row-verdict.js +20 -41
  46. package/dist/core/checkpoint-store.d.ts +69 -41
  47. package/dist/core/checkpoint-store.js +28 -14
  48. package/dist/core/command-sandbox.d.ts +5 -3
  49. package/dist/core/command-sandbox.js +17 -9
  50. package/dist/core/config-refusal-codes.d.ts +1 -1
  51. package/dist/core/config-refusal-codes.js +1 -0
  52. package/dist/core/declaration-words.d.ts +2 -1
  53. package/dist/core/declaration-words.js +13 -2
  54. package/dist/core/effective-path-target.d.ts +23 -0
  55. package/dist/core/effective-path-target.js +15 -1
  56. package/dist/core/engine-attestation.d.ts +5 -1
  57. package/dist/core/engine-attestation.js +1 -0
  58. package/dist/core/engine-capabilities.d.ts +14 -9
  59. package/dist/core/engine-capabilities.js +1 -1
  60. package/dist/core/engine-notice.d.ts +62 -32
  61. package/dist/core/engine-version.js +1 -1
  62. package/dist/core/entries-not-applied.d.ts +1 -1
  63. package/dist/core/entries-not-applied.js +1 -0
  64. package/dist/core/file-history-store.d.ts +95 -11
  65. package/dist/core/file-history-store.js +117 -19
  66. package/dist/core/gate-fold.js +13 -7
  67. package/dist/core/gate-lanes.js +9 -9
  68. package/dist/core/governance-codes.d.ts +56 -7
  69. package/dist/core/governance-codes.js +105 -7
  70. package/dist/core/grant-holder.d.ts +53 -0
  71. package/dist/core/grant-holder.js +80 -0
  72. package/dist/core/hooks.d.ts +7 -3
  73. package/dist/core/hooks.js +2 -2
  74. package/dist/core/locked-config.d.ts +7 -1
  75. package/dist/core/locked-config.js +9 -2
  76. package/dist/core/mcp-call-meta.d.ts +52 -7
  77. package/dist/core/mcp-call-meta.js +21 -2
  78. package/dist/core/mcp-host-read.d.ts +1 -1
  79. package/dist/core/mcp-server-spec.d.ts +18 -0
  80. package/dist/core/mcp-server-spec.js +1 -0
  81. package/dist/core/mcp.js +2 -2
  82. package/dist/core/member-outcome.d.ts +22 -1
  83. package/dist/core/member-outcome.js +18 -6
  84. package/dist/core/memory-engine/delegation-settlement.js +5 -5
  85. package/dist/core/memory-engine/engine.js +19 -19
  86. package/dist/core/memory-engine/file-backend.d.ts +7 -2
  87. package/dist/core/memory-engine/file-backend.js +14 -12
  88. package/dist/core/memory-engine/frontmatter.js +1 -1
  89. package/dist/core/memory-engine/index.d.ts +1 -0
  90. package/dist/core/memory-engine/index.js +1 -0
  91. package/dist/core/memory-engine/layout.d.ts +34 -9
  92. package/dist/core/memory-engine/layout.js +36 -19
  93. package/dist/core/memory-engine/memory-deployment.js +8 -8
  94. package/dist/core/memory-engine/mount-failed-notice.d.ts +8 -5
  95. package/dist/core/memory-engine/mount-failed-notice.js +5 -2
  96. package/dist/core/mode-policy.d.ts +5 -0
  97. package/dist/core/mode-policy.js +6 -0
  98. package/dist/core/mods/host.d.ts +2 -1
  99. package/dist/core/mods/host.js +7 -6
  100. package/dist/core/mods/kernel/index.d.ts +1 -1
  101. package/dist/core/mods/kernel/index.js +1 -1
  102. package/dist/core/mods/kernel/registration.d.ts +5 -2
  103. package/dist/core/mods/kernel/registration.js +19 -3
  104. package/dist/core/mods/package.d.ts +12 -1
  105. package/dist/core/mods/package.js +36 -9
  106. package/dist/core/mods/stations.d.ts +7 -1
  107. package/dist/core/mods/stations.js +17 -3
  108. package/dist/core/mods/teammate-stations.d.ts +4 -1
  109. package/dist/core/mods/teammate-stations.js +1 -1
  110. package/dist/core/native-signal.d.ts +13 -0
  111. package/dist/core/native-signal.js +18 -0
  112. package/dist/core/park-resumability.d.ts +16 -14
  113. package/dist/core/park-resumability.js +9 -4
  114. package/dist/core/path-rule-binding.js +1 -1
  115. package/dist/core/permission-rule-model.d.ts +11 -5
  116. package/dist/core/permission-rule-model.js +5 -3
  117. package/dist/core/permission-rule-org.js +1 -1
  118. package/dist/core/permission-rule-provider.d.ts +5 -1
  119. package/dist/core/permission-rule-provider.js +6 -1
  120. package/dist/core/permission-rule-session.d.ts +35 -5
  121. package/dist/core/permission-rule-session.js +32 -1
  122. package/dist/core/permission-rule-store.d.ts +5 -1
  123. package/dist/core/permission-rule-store.js +28 -5
  124. package/dist/core/permission-rules.d.ts +2 -2
  125. package/dist/core/permission-rules.js +2 -3
  126. package/dist/core/principal-name.d.ts +12 -0
  127. package/dist/core/principal-name.js +6 -2
  128. package/dist/core/read-root-grant-screen.d.ts +7 -6
  129. package/dist/core/read-root-grant-screen.js +7 -8
  130. package/dist/core/remote-env.d.ts +42 -8
  131. package/dist/core/resume-config-judge.js +1 -1
  132. package/dist/core/resume-startup-cause.d.ts +19 -4
  133. package/dist/core/resume-startup-cause.js +25 -6
  134. package/dist/core/rewind-conversation.d.ts +4 -0
  135. package/dist/core/rewrite-rejudge.d.ts +9 -1
  136. package/dist/core/rewrite-rejudge.js +11 -1
  137. package/dist/core/rule-offer-read.js +3 -2
  138. package/dist/core/runner/assemble-result.d.ts +21 -11
  139. package/dist/core/runner/assemble-result.js +24 -4
  140. package/dist/core/runner/boundary-reminders.d.ts +104 -0
  141. package/dist/core/runner/boundary-reminders.js +108 -0
  142. package/dist/core/runner/branch-writeback.d.ts +21 -7
  143. package/dist/core/runner/branch-writeback.js +44 -6
  144. package/dist/core/runner/command-sandbox-frame.js +2 -1
  145. package/dist/core/runner/compact-session.js +11 -4
  146. package/dist/core/runner/constraint-layers.d.ts +24 -5
  147. package/dist/core/runner/constraint-layers.js +21 -2
  148. package/dist/core/runner/continuation-gate.js +3 -1
  149. package/dist/core/runner/contracts.d.ts +83 -13
  150. package/dist/core/runner/cross-boundary-lane.js +2 -1
  151. package/dist/core/runner/delegation-owner.d.ts +246 -45
  152. package/dist/core/runner/delegation-owner.js +237 -63
  153. package/dist/core/runner/expire-settle.d.ts +17 -0
  154. package/dist/core/runner/expire-settle.js +8 -2
  155. package/dist/core/runner/file-history-request.d.ts +4 -3
  156. package/dist/core/runner/file-history-request.js +4 -1
  157. package/dist/core/runner/file-history-restore.d.ts +11 -3
  158. package/dist/core/runner/file-history-restore.js +11 -3
  159. package/dist/core/runner/gate-exit.d.ts +22 -1
  160. package/dist/core/runner/gate-exit.js +12 -14
  161. package/dist/core/runner/nested-memory-content.js +1 -1
  162. package/dist/core/runner/nested-memory-lane.d.ts +10 -2
  163. package/dist/core/runner/nested-memory-lane.js +29 -8
  164. package/dist/core/runner/own-model-money-door.d.ts +13 -0
  165. package/dist/core/runner/own-model-money-door.js +17 -0
  166. package/dist/core/runner/park-commit.d.ts +4 -2
  167. package/dist/core/runner/park-commit.js +2 -1
  168. package/dist/core/runner/permission-rule-lanes.d.ts +4 -0
  169. package/dist/core/runner/permission-rule-lanes.js +7 -0
  170. package/dist/core/runner/person-path-rows.js +1 -1
  171. package/dist/core/runner/placement-fence.d.ts +8 -2
  172. package/dist/core/runner/placement-fence.js +8 -3
  173. package/dist/core/runner/policy-throw.d.ts +3 -2
  174. package/dist/core/runner/policy-throw.js +2 -2
  175. package/dist/core/runner/prepare-acquire-reconcile.d.ts +23 -14
  176. package/dist/core/runner/prepare-acquire-reconcile.js +33 -15
  177. package/dist/core/runner/prepare-artifact.d.ts +14 -1
  178. package/dist/core/runner/prepare-artifact.js +7 -2
  179. package/dist/core/runner/prepare-ask-lane.d.ts +8 -0
  180. package/dist/core/runner/prepare-ask-lane.js +14 -5
  181. package/dist/core/runner/prepare-boundary-parks.js +5 -4
  182. package/dist/core/runner/prepare-config-doors.d.ts +9 -4
  183. package/dist/core/runner/prepare-config-doors.js +25 -8
  184. package/dist/core/runner/prepare-defer-classify.d.ts +8 -4
  185. package/dist/core/runner/prepare-defer-classify.js +6 -6
  186. package/dist/core/runner/prepare-execution-env.d.ts +4 -1
  187. package/dist/core/runner/prepare-execution-env.js +8 -3
  188. package/dist/core/runner/prepare-file-history.d.ts +26 -0
  189. package/dist/core/runner/prepare-file-history.js +15 -1
  190. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -3
  191. package/dist/core/runner/prepare-inherited-gate.js +9 -2
  192. package/dist/core/runner/prepare-leg-adoption.d.ts +2 -2
  193. package/dist/core/runner/prepare-park-ask.js +8 -5
  194. package/dist/core/runner/prepare-policy-chain.d.ts +5 -0
  195. package/dist/core/runner/prepare-policy-chain.js +18 -7
  196. package/dist/core/runner/prepare-prompt-assembly.d.ts +3 -0
  197. package/dist/core/runner/prepare-prompt-assembly.js +4 -3
  198. package/dist/core/runner/prepare-suspend-saga.d.ts +4 -1
  199. package/dist/core/runner/prepare-suspend-saga.js +19 -5
  200. package/dist/core/runner/prepare-task.d.ts +2 -5
  201. package/dist/core/runner/prepare-task.js +71 -26
  202. package/dist/core/runner/prepare-turn-wiring.js +7 -5
  203. package/dist/core/runner/prepare-workspace-restore.js +59 -28
  204. package/dist/core/runner/read-root-grant.d.ts +1 -0
  205. package/dist/core/runner/read-root-grant.js +1 -2
  206. package/dist/core/runner/resume-admission.d.ts +3 -0
  207. package/dist/core/runner/resume-admission.js +6 -4
  208. package/dist/core/runner/resume-apply.js +7 -5
  209. package/dist/core/runner/resume-claim.d.ts +2 -2
  210. package/dist/core/runner/resume-claim.js +4 -4
  211. package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
  212. package/dist/core/runner/resume-policy-outcome.js +6 -4
  213. package/dist/core/runner/resume-preflight.d.ts +3 -0
  214. package/dist/core/runner/resume-preflight.js +10 -3
  215. package/dist/core/runner/rewind-conversation.js +11 -4
  216. package/dist/core/runner/rewind-files.js +29 -14
  217. package/dist/core/runner/rewind-outcome.d.ts +27 -0
  218. package/dist/core/runner/rewind-outcome.js +14 -0
  219. package/dist/core/runner/run-attachment-seats.js +2 -1
  220. package/dist/core/runner/run-clock-and-content.js +2 -0
  221. package/dist/core/runner/run-identity-wiring.js +2 -0
  222. package/dist/core/runner/run-leg.js +11 -1
  223. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  224. package/dist/core/runner/run-notification-lane.js +2 -2
  225. package/dist/core/runner/run-settle-and-teardown.d.ts +4 -2
  226. package/dist/core/runner/run-settle-and-teardown.js +52 -40
  227. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  228. package/dist/core/runner/run-stop-and-final-verify.js +5 -4
  229. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  230. package/dist/core/runner/run-terminal-adoption.js +3 -3
  231. package/dist/core/runner/run-turn-boundary.js +7 -0
  232. package/dist/core/runner/runtask.d.ts +7 -4
  233. package/dist/core/runner/runtask.js +18 -9
  234. package/dist/core/runner/session-call-grant-station.d.ts +64 -0
  235. package/dist/core/runner/session-call-grant-station.js +119 -0
  236. package/dist/core/runner/session-file-state-replay.js +2 -2
  237. package/dist/core/runner/session-prompt-seats.d.ts +95 -0
  238. package/dist/core/runner/session-prompt-seats.js +62 -0
  239. package/dist/core/runner/session-rule-policy.js +1 -1
  240. package/dist/core/runner/session-write-ledger.d.ts +8 -0
  241. package/dist/core/runner/session-write-ledger.js +16 -0
  242. package/dist/core/runner/side-call-account.js +5 -1
  243. package/dist/core/runner/stop-tail-notice.d.ts +7 -0
  244. package/dist/core/runner/stop-tail-notice.js +23 -8
  245. package/dist/core/runner/stream-reap.js +4 -2
  246. package/dist/core/runner/stream-settle-backstop.d.ts +1 -1
  247. package/dist/core/runner/stream-settle-backstop.js +17 -18
  248. package/dist/core/runner/terminal-account.js +17 -8
  249. package/dist/core/runner/terminal-projection.d.ts +3 -2
  250. package/dist/core/runner/terminal-projection.js +1 -1
  251. package/dist/core/runner/tool-turn-repair-seat.d.ts +2 -2
  252. package/dist/core/runner/tool-turn-repair-seat.js +12 -7
  253. package/dist/core/runner/turn-attachments.d.ts +22 -1
  254. package/dist/core/runner/turn-attachments.js +20 -3
  255. package/dist/core/runner-deps.d.ts +6 -2
  256. package/dist/core/secret-env.d.ts +26 -6
  257. package/dist/core/secret-env.js +6 -6
  258. package/dist/core/session-call-grant-screen.d.ts +58 -0
  259. package/dist/core/session-call-grant-screen.js +18 -0
  260. package/dist/core/session-call-grant.d.ts +93 -0
  261. package/dist/core/session-call-grant.js +524 -0
  262. package/dist/core/session-checkout.d.ts +3 -0
  263. package/dist/core/session-checkout.js +8 -3
  264. package/dist/core/session-policy-store.d.ts +14 -0
  265. package/dist/core/session-policy-store.js +16 -2
  266. package/dist/core/session-store.d.ts +18 -1
  267. package/dist/core/session-store.js +20 -4
  268. package/dist/core/session.d.ts +36 -4
  269. package/dist/core/shared-artifact-reads.d.ts +93 -0
  270. package/dist/core/shared-artifact-reads.js +94 -0
  271. package/dist/core/skill-grant.js +1 -1
  272. package/dist/core/skills-directory.d.ts +9 -45
  273. package/dist/core/skills-directory.js +9 -722
  274. package/dist/core/spend-account.js +3 -0
  275. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +22 -4
  276. package/dist/core/store-contracts/checkpoint-store-contract.js +363 -29
  277. package/dist/core/store-contracts/file-history-store-contract.d.ts +11 -3
  278. package/dist/core/store-contracts/file-history-store-contract.js +62 -2
  279. package/dist/core/store-contracts/grant-fixture.d.ts +52 -0
  280. package/dist/core/store-contracts/grant-fixture.js +84 -0
  281. package/dist/core/store-contracts/session-repo-contract.js +18 -0
  282. package/dist/core/store-contracts/session-store-contract.d.ts +15 -1
  283. package/dist/core/store-contracts/session-store-contract.js +211 -2
  284. package/dist/core/store-contracts/workflow-journal-store-contract.js +47 -8
  285. package/dist/core/suspend-lane-reasons.d.ts +13 -0
  286. package/dist/core/suspend-lane-reasons.js +5 -0
  287. package/dist/core/synthetic-read-verdict.d.ts +5 -3
  288. package/dist/core/synthetic-read-verdict.js +1 -1
  289. package/dist/core/task-limits.d.ts +15 -0
  290. package/dist/core/task-notification.d.ts +33 -7
  291. package/dist/core/task-notification.js +34 -9
  292. package/dist/core/task-registry-agent.d.ts +1 -1
  293. package/dist/core/task-registry-agent.js +18 -7
  294. package/dist/core/task-registry-shared.d.ts +29 -4
  295. package/dist/core/task-registry-shared.js +7 -0
  296. package/dist/core/task-registry.d.ts +21 -1
  297. package/dist/core/task-registry.js +36 -9
  298. package/dist/core/task-result.d.ts +55 -1
  299. package/dist/core/task-spec.d.ts +17 -3
  300. package/dist/core/terminal-cause.d.ts +68 -5
  301. package/dist/core/tool-catalog-entries.js +1 -1
  302. package/dist/core/tool-check-reading.js +2 -1
  303. package/dist/core/tool-errors.js +1 -0
  304. package/dist/core/tool-list-grammar.d.ts +0 -47
  305. package/dist/core/tool-list-grammar.js +1 -75
  306. package/dist/core/tool-model-gate.d.ts +7 -11
  307. package/dist/core/tool-model-gate.js +5 -8
  308. package/dist/core/tool-name-aliases.js +2 -3
  309. package/dist/core/tool-name-readings.d.ts +4 -0
  310. package/dist/core/tool-name-readings.js +1 -0
  311. package/dist/core/tool-policy.d.ts +46 -4
  312. package/dist/core/tool-policy.js +47 -18
  313. package/dist/core/tool-result-store.d.ts +0 -24
  314. package/dist/core/tool-result-store.js +1 -36
  315. package/dist/core/tool-spec.d.ts +8 -4
  316. package/dist/core/untrusted-egress.js +2 -2
  317. package/dist/core/untrusted-text.d.ts +8 -0
  318. package/dist/core/untrusted-text.js +14 -0
  319. package/dist/core/user-attachment.d.ts +16 -1
  320. package/dist/core/user-attachment.js +42 -18
  321. package/dist/core/wiring-manifest.d.ts +4 -9
  322. package/dist/core/wiring-manifest.js +1 -1
  323. package/dist/core/workflow-journal-store.d.ts +55 -8
  324. package/dist/core/workflow-journal-store.js +34 -10
  325. package/dist/core/workflow-run-store-contract.js +56 -1
  326. package/dist/core/workflow-run-store.d.ts +43 -19
  327. package/dist/core/workflow-run-store.js +17 -2
  328. package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
  329. package/dist/engine/execution-env/node-execution-env.js +4 -0
  330. package/dist/engine/harness/agent-harness.d.ts +10 -5
  331. package/dist/engine/harness/agent-harness.js +12 -4
  332. package/dist/engine/harness/types.d.ts +18 -0
  333. package/dist/engine/llm/tool-turns.d.ts +1 -1
  334. package/dist/engine/llm/types.d.ts +5 -4
  335. package/dist/engine/session/memory-repo.d.ts +15 -3
  336. package/dist/engine/session/memory-repo.js +21 -3
  337. package/dist/engine/session/memory-storage.d.ts +5 -0
  338. package/dist/engine/session/memory-storage.js +8 -3
  339. package/dist/engine/session/repo-utils.d.ts +9 -0
  340. package/dist/engine/session/repo-utils.js +14 -0
  341. package/dist/engine/session/storage-base.d.ts +20 -7
  342. package/dist/engine/session/storage-base.js +13 -1
  343. package/dist/index.d.ts +39 -21
  344. package/dist/index.js +32 -17
  345. package/dist/internal/harness.d.ts +1 -1
  346. package/dist/internal/harness.js +1 -1
  347. package/dist/orchestration/run-workflow-tool.d.ts +13 -1
  348. package/dist/orchestration/run-workflow-tool.js +101 -32
  349. package/dist/orchestration/workflow-park-adoption.d.ts +309 -92
  350. package/dist/orchestration/workflow-park-adoption.js +588 -323
  351. package/dist/orchestration/workflow-tree-id.d.ts +66 -0
  352. package/dist/orchestration/workflow-tree-id.js +66 -0
  353. package/dist/orchestration/workflow-types.d.ts +90 -11
  354. package/dist/orchestration/workflow-types.js +10 -1
  355. package/dist/orchestration/workflow.d.ts +30 -4
  356. package/dist/orchestration/workflow.js +424 -114
  357. package/dist/prompt-assembly/catalog/constitution.js +5 -1
  358. package/dist/prompt-assembly/catalog/core-behavior.d.ts +3 -4
  359. package/dist/prompt-assembly/catalog/core-behavior.js +61 -22
  360. package/dist/prompt-assembly/catalog/environment.js +2 -2
  361. package/dist/prompt-assembly/catalog/events.d.ts +16 -0
  362. package/dist/prompt-assembly/catalog/events.js +2 -0
  363. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +72 -44
  364. package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +2 -2
  365. package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
  366. package/dist/prompt-assembly/catalog/schema.d.ts +5 -1
  367. package/dist/prompt-assembly/catalog/schema.js +2 -0
  368. package/dist/prompt-assembly/catalog/sections.js +3 -14
  369. package/dist/prompt-assembly/event-registry.js +2 -0
  370. package/dist/prompt-assembly/select.js +1 -0
  371. package/dist/prompt-assembly/tool-catalog.d.ts +10 -7
  372. package/dist/prompt-assembly/tool-catalog.js +21 -7
  373. package/dist/prompt-assembly/types.d.ts +3 -0
  374. package/dist/prompts/default.d.ts +4 -1
  375. package/dist/prompts/default.js +6 -0
  376. package/dist/stores/file/checkpoint-store.d.ts +11 -10
  377. package/dist/stores/file/checkpoint-store.js +36 -10
  378. package/dist/stores/file/file-history-store.d.ts +6 -0
  379. package/dist/stores/file/file-history-store.js +21 -4
  380. package/dist/stores/file/fs-atomic.d.ts +1 -1
  381. package/dist/stores/file/index.d.ts +14 -4
  382. package/dist/stores/file/index.js +21 -5
  383. package/dist/stores/file/process-anchor.d.ts +9 -1
  384. package/dist/stores/file/session-policy-store.js +2 -17
  385. package/dist/stores/file/session-store.d.ts +27 -0
  386. package/dist/stores/file/session-store.js +81 -9
  387. package/dist/stores/file/workflow-journal-store.d.ts +14 -4
  388. package/dist/stores/file/workflow-journal-store.js +32 -24
  389. package/dist/stores/file/workflow-run-store.d.ts +15 -4
  390. package/dist/stores/file/workflow-run-store.js +76 -0
  391. package/dist/tools/artifact/artifact-tool.d.ts +10 -3
  392. package/dist/tools/artifact/artifact-tool.js +16 -1
  393. package/dist/tools/fs/bash-program-position.d.ts +10 -4
  394. package/dist/tools/fs/bash-program-position.js +11 -8
  395. package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -1
  396. package/dist/tools/fs/bash-readonly-classifier.js +9 -2
  397. package/dist/tools/fs/find-actions.d.ts +30 -16
  398. package/dist/tools/fs/find-actions.js +272 -19
  399. package/dist/tools/fs/fs-bash.js +8 -5
  400. package/dist/tools/fs/fs-shared.d.ts +0 -29
  401. package/dist/tools/fs/fs-shared.js +0 -5
  402. package/dist/tools/fs/fs-write.js +2 -1
  403. package/dist/tools/fs/read-deny.d.ts +6 -1
  404. package/dist/tools/fs/read-deny.js +6 -1
  405. package/dist/tools/fs/read-floor.d.ts +6 -0
  406. package/dist/tools/fs/read-floor.js +5 -1
  407. package/dist/tools/fs/removal-actions.d.ts +43 -0
  408. package/dist/tools/fs/removal-actions.js +25 -0
  409. package/dist/tools/fs/removal-targets.d.ts +2 -21
  410. package/dist/tools/fs/removal-targets.js +2 -3
  411. package/dist/tools/fs/safety.d.ts +37 -1
  412. package/dist/tools/fs/safety.js +52 -0
  413. package/dist/tools/fs/shell-climb.d.ts +46 -0
  414. package/dist/tools/fs/shell-climb.js +79 -0
  415. package/dist/tools/fs/shell-read-check.js +47 -19
  416. package/dist/tools/fs/shell-read-establish.js +36 -22
  417. package/dist/tools/fs/shell-read-judge.d.ts +10 -2
  418. package/dist/tools/fs/shell-read-judge.js +4 -4
  419. package/dist/tools/fs/shell-read-plan.d.ts +3 -0
  420. package/dist/tools/fs/shell-read-plan.js +1 -1
  421. package/dist/tools/fs/shell-read-workdir.js +3 -2
  422. package/dist/tools/fs/shell-read-write-targets.d.ts +4 -3
  423. package/dist/tools/fs/shell-read-write-targets.js +3 -0
  424. package/package.json +2 -2
  425. package/test/export-surface.snapshot.json +173 -15
  426. package/wire-changes/core-stores-sql@7.71.0.json +40 -0
  427. package/wire-changes/core-stores-sql@7.71.1.json +40 -0
  428. package/wire-changes/core@7.71.0.json +5827 -0
  429. package/wire-changes/core@7.71.1.json +118 -0
  430. package/wire-changes/mods-kernel@7.71.0.json +52 -0
  431. package/wire-changes/mods-kernel@7.71.1.json +40 -0
  432. package/wire-changes/primitives@7.71.0.json +473 -0
  433. package/wire-changes/primitives@7.71.1.json +40 -0
  434. package/wire-changes/wiki-gate@7.71.0.json +40 -0
  435. package/wire-changes/wiki-gate@7.71.1.json +40 -0
  436. package/dist/core/frontmatter-fence.d.ts +0 -10
  437. package/dist/core/frontmatter-fence.js +0 -6
  438. package/dist/core/permission-rule-syntax.d.ts +0 -46
  439. package/dist/core/permission-rule-syntax.js +0 -52
@@ -1,6 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { canonicalize, MAX_DEPTH, UNCANONICALIZABLE } from "./canonical-json.js";
3
- import { CHECKPOINT_FEATURES, checkpointVersionOf, encodeAtFidelity } from "./checkpoint-features.js";
3
+ import { encodeAtFidelity, MAX_SUPPORTED_CHECKPOINT_VERSION } from "./checkpoint-features.js";
4
4
  import { memberPresent } from "./own-property-receipt.js";
5
5
  import { identityHoldsNoServerName } from "./tool-roster.js";
6
6
  export const REQUIREMENT_WORDS = Object.freeze([
@@ -353,7 +353,7 @@ function presentMembersOf(record) {
353
353
  }
354
354
  export function stampCheckpointRequirements(row, fidelity) {
355
355
  const omitted = presentMembersOf(row);
356
- const { requirementsDigest: _stale, ...framed } = { ...omitted, ...(typeof omitted.state === "object" && omitted.state !== null ? { state: presentMembersOf(omitted.state) } : {}), version: CHECKPOINT_FEATURES.requirements.version };
356
+ const { requirementsDigest: _stale, ...framed } = { ...omitted, ...(typeof omitted.state === "object" && omitted.state !== null ? { state: presentMembersOf(omitted.state) } : {}), version: MAX_SUPPORTED_CHECKPOINT_VERSION };
357
357
  const stored = encodeAtFidelity(fidelity, framed);
358
358
  const held = (stored.ok ? stored.value : framed);
359
359
  const got = stored.ok ? digestOrUnencodable(held) : { at: { path: "(row)", kind: "codec" } };
@@ -365,11 +365,8 @@ export function judgeAsStored(cp, fidelity) {
365
365
  return stored.ok ? judgeCheckpointRequirements(stored.value) : { kind: "damaged", why: unencodableWhy({ path: "(row)", kind: "codec" }) };
366
366
  }
367
367
  export function judgeCheckpointRequirements(cp) {
368
- const version = checkpointVersionOf(cp);
369
368
  const declared = Reflect.get(cp, "requires");
370
369
  const digest = Reflect.get(cp, "requirementsDigest");
371
- if (version < CHECKPOINT_FEATURES.requirements.version)
372
- return declared === undefined && digest === undefined ? { kind: "ok" } : { kind: "damaged", why: `a v${version} row carries a requirement list or digest no release of that version wrote` };
373
370
  if (!Array.isArray(declared))
374
371
  return { kind: "damaged", why: declared === undefined ? "the v10 row carries no requirement list" : "the requirement list is not a list" };
375
372
  const said = [];
@@ -18,11 +18,12 @@
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 a row whose members do not read as every reader reads them — its
21
+ * version ceiling, then a reader word this worker lacks); then a pending row that records its action's outcome; then a row below
22
+ * the format, as a retired seat (the floor: no arm reads such a row); then a row whose members do not read as every reader reads them — its
22
23
  * 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
24
  * of those shapes is the listing faces' too); then the seats and the axis a release retired (each names what
24
25
  * to do about it); then the reader-requirement list and the row digest — a row changed in storage (`requirements_damaged`), else an
25
- * earlier release's intact row (`reading_changed`; below the requirements format, an input hash written before the tool binding), told
26
+ * earlier release's intact row (`reading_changed`), told
26
27
  * only when nothing more specific is; then the recorded mode words, the sections by their shapes, the
27
28
  * frozen chain's tool names, the recorded run origin, and the parent-constraint record's own integrity. The first refusal
28
29
  * is the verdict.
@@ -83,9 +84,7 @@ export declare const ROW_REFUSAL_SENTENCES: Readonly<{
83
84
  readonly "checkpoint.invalid_outcome|requirements_damaged": "This engine cannot resume this checkpoint: its content does not read the way it was recorded when it was parked — it was changed or lost in storage. The checkpoint stays pending and nothing was consumed. Expire it, then start the task again.";
84
85
  readonly "checkpoint.invalid_outcome|execution_recorded": "This engine cannot resume this checkpoint: it reads pending, yet it records what became of the action it was decided for — the decision was lost in storage after the action was taken up, so the action may already have run, or been refused. The checkpoint stays pending. Check what the row records (`executionOutcome`) and whether the action already took effect — running it again may repeat it. Expire it, then start the task again.";
85
86
  readonly "checkpoint.invalid_outcome|real_approval_damaged": "This engine cannot resume this checkpoint: its real-approval mark is missing or malformed (a corruption or downgrade guard). The checkpoint stays pending. Expire it, then start the task again.";
86
- readonly "checkpoint.invalid_outcome|real_approval_forged": "This engine cannot resume this checkpoint: it carries a real-approval mark no release of its row format ever wrote (a corruption or forgery guard). The checkpoint stays pending. Expire it, then start the task again.";
87
87
  readonly "checkpoint.invalid_outcome|read_face_damaged": "This engine cannot resume this checkpoint: its read-face section is missing or malformed (a corruption or downgrade guard). The checkpoint stays pending. Expire it, then start the task again.";
88
- readonly "checkpoint.invalid_outcome|read_face_forged": "This engine cannot resume this checkpoint: it carries a read-face section no release of its row format ever wrote (a corruption or forgery guard). The checkpoint stays pending. Expire it, then start the task again.";
89
88
  readonly "checkpoint.invalid_outcome|write_face_damaged": "This engine cannot resume this checkpoint: its write-face section is malformed (a corruption guard). The checkpoint stays pending. Expire it, then start the task again.";
90
89
  readonly "checkpoint.invalid_outcome|skill_grants_damaged": "This engine cannot resume this checkpoint: its skill-grant section does not read as grant rows under this engine — damaged, or written by an earlier release whose entries this release reads differently. The checkpoint stays pending. Expire it and run the work again.";
91
90
  readonly "checkpoint.invalid_outcome|skill_scopes_damaged": "This engine cannot resume this checkpoint: its skill-scope section does not read as a list of named skills (a damaged section). The checkpoint stays pending. Expire it and run the work again.";
@@ -1,4 +1,4 @@
1
- import { CHECKPOINT_FEATURES, CheckpointError, checkpointVersionOf, MAX_SUPPORTED_CHECKPOINT_VERSION } from "./checkpoint-features.js";
1
+ import { CheckpointError, checkpointVersionOf, MAX_SUPPORTED_CHECKPOINT_VERSION } from "./checkpoint-features.js";
2
2
  import { judgeCheckpointRequirements } from "./checkpoint-requirements.js";
3
3
  import { isAskOrigin, isPermissionMode } from "./ask-origin.js";
4
4
  import { validatePath } from "./effective-path-target.js";
@@ -11,7 +11,7 @@ import { screenRecordedRunOrigin } from "./run-origin.js";
11
11
  import { refusePersistedToolNames } from "./runner/sub-agent-deny-lists.js";
12
12
  import { boundedThrownName } from "./thrown-value.js";
13
13
  import { memberPresent } from "./own-property-receipt.js";
14
- import { CHECKPOINT_ROW_DAMAGED_SENTENCE, rowMemberProblem } from "./checkpoint-queries.js";
14
+ import { CHECKPOINT_ROW_DAMAGED_SENTENCE, checkpointRowUnreadable, rowMemberProblem } from "./checkpoint-queries.js";
15
15
  import { SYNC_CHILD_BLOCK_MEMBERS } from "./leg-identity.js";
16
16
  import { checkpointExecutionRecorded } from "./checkpoint-execution-record.js";
17
17
  import { readStoredPrincipal, recordedPrincipalNameOf } from "./principal-name.js";
@@ -38,9 +38,7 @@ export const ROW_REFUSAL_SENTENCES = Object.freeze({
38
38
  "checkpoint.invalid_outcome|requirements_damaged": CHECKPOINT_ROW_DAMAGED_SENTENCE,
39
39
  "checkpoint.invalid_outcome|execution_recorded": "This engine cannot resume this checkpoint: it reads pending, yet it records what became of the action it was decided for — the decision was lost in storage after the action was taken up, so the action may already have run, or been refused. The checkpoint stays pending. Check what the row records (`executionOutcome`) and whether the action already took effect — running it again may repeat it. Expire it, then start the task again.",
40
40
  "checkpoint.invalid_outcome|real_approval_damaged": "This engine cannot resume this checkpoint: its real-approval mark is missing or malformed (a corruption or downgrade guard). The checkpoint stays pending. Expire it, then start the task again.",
41
- "checkpoint.invalid_outcome|real_approval_forged": "This engine cannot resume this checkpoint: it carries a real-approval mark no release of its row format ever wrote (a corruption or forgery guard). The checkpoint stays pending. Expire it, then start the task again.",
42
41
  "checkpoint.invalid_outcome|read_face_damaged": "This engine cannot resume this checkpoint: its read-face section is missing or malformed (a corruption or downgrade guard). The checkpoint stays pending. Expire it, then start the task again.",
43
- "checkpoint.invalid_outcome|read_face_forged": "This engine cannot resume this checkpoint: it carries a read-face section no release of its row format ever wrote (a corruption or forgery guard). The checkpoint stays pending. Expire it, then start the task again.",
44
42
  "checkpoint.invalid_outcome|write_face_damaged": "This engine cannot resume this checkpoint: its write-face section is malformed (a corruption guard). The checkpoint stays pending. Expire it, then start the task again.",
45
43
  "checkpoint.invalid_outcome|skill_grants_damaged": "This engine cannot resume this checkpoint: its skill-grant section does not read as grant rows under this engine — damaged, or written by an earlier release whose entries this release reads differently. The checkpoint stays pending. Expire it and run the work again.",
46
44
  "checkpoint.invalid_outcome|skill_scopes_damaged": "This engine cannot resume this checkpoint: its skill-scope section does not read as a list of named skills (a damaged section). The checkpoint stays pending. Expire it and run the work again.",
@@ -60,9 +58,7 @@ export const ROW_REFUSAL_TERMINAL = Object.freeze({
60
58
  "checkpoint.invalid_outcome|requirements_damaged": true,
61
59
  "checkpoint.invalid_outcome|execution_recorded": true,
62
60
  "checkpoint.invalid_outcome|real_approval_damaged": true,
63
- "checkpoint.invalid_outcome|real_approval_forged": true,
64
61
  "checkpoint.invalid_outcome|read_face_damaged": true,
65
- "checkpoint.invalid_outcome|read_face_forged": true,
66
62
  "checkpoint.invalid_outcome|write_face_damaged": true,
67
63
  "checkpoint.invalid_outcome|skill_grants_damaged": false,
68
64
  "checkpoint.invalid_outcome|skill_scopes_damaged": false,
@@ -139,11 +135,9 @@ function recordedWordRefusal(screen) {
139
135
  throw e;
140
136
  }
141
137
  }
142
- function bindingPredatesTool(cp) {
143
- const pending = cp.pendingAction;
144
- if (typeof pending !== "object" || pending === null || Reflect.get(pending, "kind") !== "tool_approval" || !memberPresent(pending, "boundInputHash"))
145
- return false;
146
- return checkpointVersionOf(cp) < CHECKPOINT_FEATURES.requirements.version;
138
+ function belowFormatRefusal(recorded) {
139
+ const format = recorded === undefined || recorded === null ? "unrecorded (read as v0)" : typeof recorded === "number" ? `v${recorded}` : `${/^[aeiou]/.test(typeof recorded) ? "an" : "a"} ${typeof recorded} that reads below v${MAX_SUPPORTED_CHECKPOINT_VERSION}`;
140
+ return new CheckpointError("checkpoint.unsupported_version", `this checkpoint's row format is ${format}, below the one this engine reads (v${MAX_SUPPORTED_CHECKPOINT_VERSION}): an engine release of 7.48.x or earlier parked it, and this release reads no row of an earlier format — expire it and run the work again; nothing was consumed`, { reason: "seat_retired" });
147
141
  }
148
142
  function recordedIdentityRefusal(cp) {
149
143
  const members = [["principal", cp.principal], ["isolationScope", cp.isolationScope]];
@@ -162,15 +156,18 @@ function recordedIdentityRefusal(cp) {
162
156
  return undefined;
163
157
  }
164
158
  function rowRefusalOf(cp) {
165
- const { realApproval: realApprovalRow, face: faceRow, f012: f012Row } = CHECKPOINT_FEATURES;
166
- if (checkpointVersionOf(cp) > MAX_SUPPORTED_CHECKPOINT_VERSION) {
167
- return new CheckpointError("checkpoint.unsupported_version", `checkpoint requires reader capabilities this worker lacks (row format v${checkpointVersionOf(cp)}; this worker reads up to v${MAX_SUPPORTED_CHECKPOINT_VERSION}) — resume it on a worker at or above the version that parked it`, { reason: "version_newer" });
159
+ const recorded = cp.version;
160
+ const version = checkpointVersionOf({ version: recorded });
161
+ if (version > MAX_SUPPORTED_CHECKPOINT_VERSION) {
162
+ return new CheckpointError("checkpoint.unsupported_version", `checkpoint requires reader capabilities this worker lacks (row format v${version}; this worker reads up to v${MAX_SUPPORTED_CHECKPOINT_VERSION}) — resume it on a worker at or above the version that parked it`, { reason: "version_newer" });
168
163
  }
169
- const requirements = judgeCheckpointRequirements(cp);
170
- if (requirements.kind === "lacking")
164
+ const requirements = version < MAX_SUPPORTED_CHECKPOINT_VERSION ? undefined : judgeCheckpointRequirements(cp);
165
+ if (requirements?.kind === "lacking")
171
166
  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 });
172
167
  if (cp.status === "pending" && checkpointExecutionRecorded(cp))
173
168
  return new CheckpointError("checkpoint.invalid_outcome", "this checkpoint reads pending yet already records what became of its decided action (`executionOutcome`) — the decision before it was lost in storage, and its action is not run a second time", { reason: "execution_recorded" });
169
+ if (requirements === undefined)
170
+ return belowFormatRefusal(recorded);
174
171
  const shape = rowMemberProblem(cp);
175
172
  if (shape !== undefined)
176
173
  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" });
@@ -192,8 +189,6 @@ function rowRefusalOf(cp) {
192
189
  return new CheckpointError("checkpoint.invalid_outcome", `this checkpoint's reader-requirement list does not match the row (${requirements.why})`, { reason: "requirements_damaged" });
193
190
  if (requirements.kind === "earlier")
194
191
  return readingChanged(`this checkpoint reads as an earlier engine release wrote it, and this release reads a member the decision binds differently (${requirements.why})`);
195
- if (bindingPredatesTool(cp))
196
- return readingChanged("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");
197
192
  const identity = recordedIdentityRefusal(cp);
198
193
  if (identity !== undefined)
199
194
  return identity;
@@ -203,17 +198,8 @@ function rowRefusalOf(cp) {
203
198
  const gateBit = cp.gate.kind === "irreversible_ask" ? cp.gate.realApproval : undefined;
204
199
  const bitWellFormed = gateBit !== undefined && typeof gateBit === "object" && isAskOrigin(gateBit.origin);
205
200
  const faceSaysGoverned = (cp.state.readFace?.realApproval) === true;
206
- const bitViolation = checkpointVersionOf(cp) === realApprovalRow.version
207
- ? !bitWellFormed
208
- : checkpointVersionOf(cp) < realApprovalRow.version
209
- ? gateBit !== undefined
210
- : faceSaysGoverned
211
- ? !bitWellFormed
212
- : gateBit !== undefined && !bitWellFormed;
213
- if (bitViolation) {
214
- return new CheckpointError("checkpoint.invalid_outcome", checkpointVersionOf(cp) >= realApprovalRow.version
215
- ? `a v${checkpointVersionOf(cp)} checkpoint's realApproval gate bit must be well-formed (origin a member of the closed ask-origin set)${checkpointVersionOf(cp) === realApprovalRow.version ? " and present on an irreversible_ask gate" : ""} — this row's is not; refusing to resume a damaged real-approval row (corruption / downgrade guard), the checkpoint stays pending`
216
- : `a v${checkpointVersionOf(cp)} checkpoint carries a realApproval gate bit no release of that version ever minted — refusing to honor a fabricated origin (corruption / forgery guard), the checkpoint stays pending`, { reason: checkpointVersionOf(cp) >= realApprovalRow.version ? "real_approval_damaged" : "real_approval_forged" });
201
+ if (faceSaysGoverned ? !bitWellFormed : gateBit !== undefined && !bitWellFormed) {
202
+ return new CheckpointError("checkpoint.invalid_outcome", `a v${version} checkpoint's realApproval gate bit must be well-formed (origin a member of the closed ask-origin set) — this row's is not; refusing to resume a damaged real-approval row (corruption / downgrade guard), the checkpoint stays pending`, { reason: "real_approval_damaged" });
217
203
  }
218
204
  const faceSectionRaw = cp.state.readFace;
219
205
  const faceCandidate = faceSectionRaw !== undefined && typeof faceSectionRaw === "object" && faceSectionRaw !== null
@@ -224,11 +210,8 @@ function rowRefusalOf(cp) {
224
210
  (faceCandidate.realApproval === undefined || faceCandidate.realApproval === true) &&
225
211
  (faceCandidate.denyEntries === undefined ||
226
212
  (Array.isArray(faceCandidate.denyEntries) && faceCandidate.denyEntries.every((e) => persistedReadDenyEntryProblem(e) === null)));
227
- const v = checkpointVersionOf(cp);
228
- if (v === faceRow.version ? !faceWellFormed : v < faceRow.version ? faceSectionRaw !== undefined : faceSectionRaw !== undefined && !faceWellFormed) {
229
- return new CheckpointError("checkpoint.invalid_outcome", checkpointVersionOf(cp) >= faceRow.version
230
- ? `a v${checkpointVersionOf(cp)} checkpoint must carry a well-formed read-face section (state.readFace) — this row's is missing or malformed; refusing to resume a damaged read-face row (corruption / downgrade guard), the checkpoint stays pending`
231
- : `a v${checkpointVersionOf(cp)} checkpoint carries a read-face section no release of that version ever minted — refusing to honor a fabricated read-face state (corruption / forgery guard), the checkpoint stays pending`, { reason: checkpointVersionOf(cp) >= faceRow.version ? "read_face_damaged" : "read_face_forged" });
213
+ if (faceSectionRaw !== undefined && !faceWellFormed) {
214
+ return new CheckpointError("checkpoint.invalid_outcome", `a v${version} checkpoint must carry a well-formed read-face section (state.readFace) — this row's is missing or malformed; refusing to resume a damaged read-face row (corruption / downgrade guard), the checkpoint stays pending`, { reason: "read_face_damaged" });
232
215
  }
233
216
  const writeFaceSectionRaw = cp.state.writeFace;
234
217
  if (writeFaceSectionRaw !== undefined) {
@@ -257,8 +240,8 @@ function rowRefusalOf(cp) {
257
240
  return runOrigin;
258
241
  const gate = cp.state.inheritedGate;
259
242
  if (gate?.requiresParentConstraint === true) {
260
- if (checkpointVersionOf(cp) >= f012Row.version && (gate.constraintChain === undefined || gate.constraintDigest === undefined)) {
261
- return new CheckpointError("checkpoint.invalid_outcome", `a v${checkpointVersionOf(cp)} checkpoint that requires parent constraints must carry BOTH the frozen constraintChain and its constraintDigest (they are minted in one write with the version stamp) — this row carries neither or only one; refusing to fall back to the count-only contract on a damaged row (corruption / downgrade guard), the checkpoint stays pending`, { reason: "constraint_chain_missing" });
243
+ if (gate.constraintChain === undefined || gate.constraintDigest === undefined) {
244
+ return new CheckpointError("checkpoint.invalid_outcome", `a v${version} checkpoint that requires parent constraints must carry BOTH the frozen constraintChain and its constraintDigest (they are minted in one write with the version stamp) — this row carries neither or only one; refusing to fall back to the count-only contract on a damaged row (corruption / downgrade guard), the checkpoint stays pending`, { reason: "constraint_chain_missing" });
262
245
  }
263
246
  const expectedDigest = gate.constraintDigest;
264
247
  const reading = expectedDigest === undefined || gate.constraintChain === undefined ? undefined : constraintChainDigestReading(gate.constraintChain, expectedDigest);
@@ -309,11 +292,7 @@ function readRowTotal(cp) {
309
292
  }
310
293
  catch (e) {
311
294
  const name = boundedThrownName(e);
312
- const sentence = ROW_REFUSAL_SENTENCES["checkpoint.invalid_outcome|requirements_damaged"];
313
- return {
314
- verdict: UNREADABLE_ROW_VERDICT,
315
- refusal: new CheckpointError("checkpoint.invalid_outcome", `${sentence} Diagnostic: the row could not be read (${name} thrown while judging it)`, { reason: "requirements_damaged", thrownName: name }),
316
- };
295
+ return { verdict: UNREADABLE_ROW_VERDICT, refusal: checkpointRowUnreadable(`the row could not be read (${name} thrown while judging it)`, "pending", name) };
317
296
  }
318
297
  }
319
298
  export function judgeCheckpointRow(cp) {
@@ -2,7 +2,7 @@ import { CheckpointError, type CheckpointConfigRefusalCode, type CheckpointError
2
2
  import { type CallRiskAxes } from "./ask-origin.js";
3
3
  import type { GateOutcome, HostDecisionFacts } from "./gate-outcome.js";
4
4
  import { type ExecutionOutcomeRecordWord } from "./checkpoint-execution-record.js";
5
- import { type HolderJudge } from "./checkpoint-generation.js";
5
+ import { type HolderJudge, type StoreHolderFence } from "./checkpoint-generation.js";
6
6
  import { type CheckpointPause } from "./pause-registry.js";
7
7
  import { type CheckpointDeleteGuard, type CheckpointOverdueCursor, type CheckpointOverdueQuery, type CheckpointPage, type CheckpointRowRead, type CheckpointSessionCursor, type CheckpointSessionQuery } from "./checkpoint-queries.js";
8
8
  import type { SystemInjectionPriority } from "./task-notification.js";
@@ -19,7 +19,7 @@ import { type RetentionDeclaration } from "./retention.js";
19
19
  import { MAX_PENDING_STEER_CHARS } from "./input-author.js";
20
20
  import { type IdentityRekeyInput, type IdentityRekeyPlan, type RekeyDone } from "./identity-rekey.js";
21
21
  export { MAX_PENDING_STEER_CHARS };
22
- export { BINDING_CHECKPOINT_VERSION, CHECKPOINT_CONFIG_REFUSAL_CODES, CHECKPOINT_ERROR_CODES, CHECKPOINT_FEATURES, CheckpointError, checkpointVersionOf, CURRENT_CHECKPOINT_VERSION, encodeAtFidelity, F012_CHECKPOINT_VERSION, FACE_CHECKPOINT_VERSION, isCheckpointConfigRefusalCode, isCheckpointErrorCode, isPlainRecord, MAX_SUPPORTED_CHECKPOINT_VERSION, normalizeProbeCause, ORG_ADMISSION_CHECKPOINT_VERSION, REAL_APPROVAL_CHECKPOINT_VERSION, RESOURCE_CHECKPOINT_VERSION, safeDataValue, SPAWN_RESUME_REFUSAL_CODES, TOKEN_CHECKPOINT_VERSION, type CheckpointConfigRefusalCode, type CheckpointErrorCode, type CheckpointErrorField, type CheckpointErrorReason, type CheckpointFeature, type CheckpointFeatureRow, type SpawnResumeRefusalCode, } from "./checkpoint-features.js";
22
+ export { CHECKPOINT_CONFIG_REFUSAL_CODES, CHECKPOINT_ERROR_CODES, CHECKPOINT_FEATURES, CheckpointError, checkpointVersionOf, encodeAtFidelity, isCheckpointConfigRefusalCode, isCheckpointErrorCode, isPlainRecord, MAX_SUPPORTED_CHECKPOINT_VERSION, normalizeProbeCause, safeDataValue, SPAWN_RESUME_REFUSAL_CODES, type CheckpointConfigRefusalCode, type CheckpointErrorCode, type CheckpointErrorField, type CheckpointErrorReason, type CheckpointFeature, type CheckpointFeatureRow, type SpawnResumeRefusalCode, } from "./checkpoint-features.js";
23
23
  /**
24
24
  * design/45 — the **durable-checkpoint** primitive: cross-process / resumable `suspend`/`resume`.
25
25
  *
@@ -400,8 +400,8 @@ export declare function buildRiskDescriptor(input: {
400
400
  * to DIE at the park: the mint keyed the gate kind on the static tool marks only, so an org-governed
401
401
  * ask on an unmarked tool minted a plain `{kind:"human"}` — the one kind a network budget resolver may
402
402
  * auto-approve — and the org's "only judgment clears this" demand was silently budgetable after the
403
- * durability boundary. Present ⇒ the mint escalates to `irreversible_ask` (non-budgetable) and stamps
404
- * {@link REAL_APPROVAL_CHECKPOINT_VERSION}. `origin` additionally records WHY, for the resume belts:
403
+ * durability boundary. Present ⇒ the mint escalates to `irreversible_ask` (non-budgetable) and the row lists the
404
+ * `realApproval` reader-requirement word. `origin` additionally records WHY, for the resume belts:
405
405
  * · `"org_rule"` — an org ASK rule fired (governance was READABLE at mint). Resume keeps the strict
406
406
  * posture: org unavailable at resume still refuses (newly-blind ⇒ fail-closed).
407
407
  * · `"org_unavailable"` — governance could NOT be read at mint and the gate's own message promised
@@ -1044,8 +1044,8 @@ export interface CheckpointState {
1044
1044
  * (NOT part of Prepared — §15.2 net-add #8). Without it a resumed `edit_file` is rejected "not read". */
1045
1045
  readFileState?: Array<[string, ReadEntry]>;
1046
1046
  /**
1047
- * design/199 — the READ-face containment state at suspend (v9,
1048
- * {@link FACE_CHECKPOINT_VERSION}): the RESOLVED face plus the NORMALIZED deny-set ADDITIONS in
1047
+ * design/199 — the READ-face containment state at suspend (reader-requirement word
1048
+ * `face`): the RESOLVED face plus the NORMALIZED deny-set ADDITIONS in
1049
1049
  * force (deployment ∪ task layers; the built-in table is engine code under the RESUMING deployment's
1050
1050
  * own tier selection — empty unless it made one — never frozen here). Written ONLY when the posture
1051
1051
  * is non-default (face "open", or additions present) — an absent section IS the default posture and
@@ -1253,8 +1253,8 @@ export interface CheckpointState {
1253
1253
  * revoked grant refuses the resume), but a policy widened mid-session cannot widen THIS
1254
1254
  * session's mount or the chain its children inherit. Present (possibly EMPTY — an adjudicated
1255
1255
  * empty verdict is not "org-less") iff the suspend leg adjudicated an org plane; absent on
1256
- * older checkpoints / org-less tasks. Checkpoints carrying this state are stamped
1257
- * {@link ORG_ADMISSION_CHECKPOINT_VERSION} so a pre-admission worker rejects them pre-CAS. */
1256
+ * older checkpoints / org-less tasks. Checkpoints carrying this state list the `orgAdmission`
1257
+ * reader-requirement word. */
1258
1258
  ownAdmittedOrgScopes?: readonly string[];
1259
1259
  /** The WRITE half of the session freeze: the org write grant this session held at suspend —
1260
1260
  * `null` = the org write face was read-only (a resume must not gain write authority the
@@ -1303,9 +1303,9 @@ export interface CheckpointState {
1303
1303
  * matches the digest but behaves differently cannot un-deny what the suspend froze. Present iff
1304
1304
  * `requiresParentConstraint` on new mints; absent on PRE-F-012 checkpoints (⇒ no frozen deny data —
1305
1305
  * the count-only contract governs, and an EDIT resume is refused for want of a validatable chain).
1306
- * "Older" is version-decidable, not guessed: chain, digest and the {@link F012_CHECKPOINT_VERSION}
1307
- * stamp are one write, so on a v7+ row the pair is REQUIRED — its absence there is a damaged row and
1308
- * the resume ladder refuses it pre-CAS rather than falling back to the count-only contract. */
1306
+ * Chain and digest are one write, so on a row that requires parent constraints the pair is REQUIRED — its
1307
+ * absence is a damaged row and the resume ladder refuses it pre-CAS rather than falling back to the
1308
+ * count-only contract. */
1309
1309
  constraintChain?: ReadonlyArray<import("./tool-policy.js").ConstraintChainEntry>;
1310
1310
  /**
1311
1311
  * F-012 L1 — the content digest over `constraintChain` ({@link import("./tool-policy.js").constraintChainDigest}):
@@ -1313,8 +1313,8 @@ export interface CheckpointState {
1313
1313
  * content. The resume pre-CAS ladder recomputes the digest over the RE-SUPPLIED chain's
1314
1314
  * projections and rejects a mismatch (`resume.parent_constraint_mismatch`) — replacing the
1315
1315
  * count-only shape check with a content contract (a same-length chain of different frozen deny
1316
- * data no longer passes). Present iff `constraintChain` is — and on a v7+ row both are required
1317
- * (see {@link constraintChain}: the pair and the version stamp are minted together). */
1316
+ * data no longer passes). Present iff `constraintChain` is — and on a row that requires parent
1317
+ * constraints both are required (see {@link constraintChain}: the pair is minted together). */
1318
1318
  constraintDigest?: string;
1319
1319
  };
1320
1320
  /**
@@ -1655,7 +1655,7 @@ export interface ResolveExpectation {
1655
1655
  * never judges, stores or prints it). Every member of this object is a precondition the store evaluates in the SAME atomic step
1656
1656
  * as the flip: the CAS wins only if the grant `holder` names is still the deployment's current one at that instant (no claim
1657
1657
  * transfer may commit between the judgement and the flip). Judged only by a store that declares {@link CheckpointStore.fence}
1658
- * `holder`; any other store LOSES a CAS that carries one (never ignores it — `checkpointHolderMatches`). A miss is an ordinary
1658
+ * `{ holder: "writes" }`; any other store LOSES a CAS that carries one (never ignores it — `checkpointHolderMatches`). A miss is an ordinary
1659
1659
  * loss: the row is untouched, so it reads `pending` at the generation the caller validated.
1660
1660
  */
1661
1661
  holder?: string;
@@ -1668,9 +1668,19 @@ export type TerminalClaimIntent = {
1668
1668
  kind: "resolve";
1669
1669
  outcome: ResumeOutcome;
1670
1670
  expect?: ResolveExpectation;
1671
- } | {
1671
+ }
1672
+ /** `expect.holder`: the expire arm's grant holder, the same precondition as {@link CheckpointStore.expire}'s `opts.holder` — a holder
1673
+ * that is not current loses, the loss reading the row as it is (`pending` at its generation). */
1674
+ | {
1672
1675
  kind: "expire";
1676
+ expect?: Pick<ResolveExpectation, "holder">;
1673
1677
  };
1678
+ /** The options of a checkpoint write that has no row expectation of its own (`put`, `setPendingSteer`, `expire`). */
1679
+ export interface CheckpointWriteOptions {
1680
+ /** The run's grant holder (`RunInternals.holder`, verbatim — the engine never reads it), judged by a store declaring
1681
+ * `fence = { holder: "writes" }` in the write's own atomic step ({@link CheckpointStore.fence}); absent ⇒ nothing to judge. */
1682
+ readonly holder?: string;
1683
+ }
1674
1684
  /** design/384 slice 2 / S-25-R1 — the single-round-trip answer: EITHER the claim won, OR it lost and
1675
1685
  * the SAME atomic operation reports what the row is now. `current` reuses the row's own vocabulary
1676
1686
  * (status / rev / resolvedOutcome) — no new value domain. `status:"pending"` on a loss is one of the
@@ -1734,10 +1744,9 @@ export interface CheckpointRow {
1734
1744
  * the other half of the root anchor's address. Part of the block; absent when the root run recorded none. */
1735
1745
  rootSessionIncarnation?: string;
1736
1746
  /**
1737
- * Schema version of this checkpoint (design/49 v1.5), FROZEN at the `requirements` row's 10: every live mint
1738
- * stamps 10 beside {@link requires}, and a segment added later adds a word there, never a number here. A v≤9 row
1739
- * (stamped the highest feature it carried) is read by the feature table's numbers; absent ⇒ legacy `0`. Resume
1740
- * rejects `> MAX_SUPPORTED_CHECKPOINT_VERSION` pre-CAS. Read via {@link checkpointVersionOf}.
1747
+ * Schema version of this checkpoint (design/49 v1.5), FROZEN at the row format, 10: every live mint
1748
+ * stamps 10 beside {@link requires}, and a segment added later adds a word there, never a number here. A row
1749
+ * below it (absent ⇒ `0`) is refused pre-CAS as a retired seat, a row above it as newer. Read via {@link checkpointVersionOf}.
1741
1750
  */
1742
1751
  version?: number;
1743
1752
  /** The reader-requirement words of a v10 row: what a resuming worker must know to resume it right, derived from
@@ -1958,6 +1967,8 @@ export interface CheckpointIndexFacts {
1958
1967
  readonly token: CheckpointToken;
1959
1968
  readonly scope: string;
1960
1969
  readonly sessionId: string;
1970
+ /** `checkpointRunSessionOf` of the row (`null` = no run: never matched) — the column `CheckpointSessionQuery.axis: "run"` reads. */
1971
+ readonly runSessionId: string | null;
1961
1972
  /** {@link checkpointVersionOf}. */
1962
1973
  readonly version: number;
1963
1974
  readonly gateKind: CheckpointGate["kind"];
@@ -2403,6 +2414,10 @@ export type StoreFidelity = "structured-clone" | "json";
2403
2414
  * Resolve a store's declared {@link StoreFidelity} (the read half of the declaration — the exact shape
2404
2415
  * `resolveDeclaredFidelity`'s durability twin has): ABSENT → the fail-closed `"json"`, a recognized
2405
2416
  * value verbatim, anything else refused loudly. Never duck-types the backend.
2417
+ *
2418
+ * Exported at the package root for a host that mints its own checkpoint rows (e.g. a `task_done` wake card): it reads the
2419
+ * fidelity to stamp at from its store's own declaration instead of writing a constant —
2420
+ * `put(token, stampCheckpointRequirements(checkpointFrom({ ... }), resolveDeclaredFidelity(store, "checkpointStore")))`.
2406
2421
  */
2407
2422
  export declare function resolveDeclaredFidelity(store: {
2408
2423
  readonly fidelity?: StoreFidelity;
@@ -2432,18 +2447,24 @@ export interface CheckpointStore {
2432
2447
  */
2433
2448
  readonly fidelity?: StoreFidelity;
2434
2449
  /**
2435
- * The CLAIM-HOLDER declaration: this store judges {@link ResolveExpectation.holder} in the same atomic step as the resolve's flip.
2436
- * Same "declaration, never duck-typing" posture as the optional axes above ({@link durability}, {@link fidelity}) — what it
2437
- * declares happens inside {@link resolve}, so no verb's presence can say it: ABSENT reads as "does not judge holders", and a run handed a
2438
- * holder over such a store is refused at its store seat (`config.invalid_checkpoint_store`) — a holder the store would ignore would
2439
- * fence nothing while the deployment believed it fenced.
2450
+ * The GRANT-HOLDER declaration ({@link StoreHolderFence}, the one shape the session store declares too): `holder: "writes"` = this
2451
+ * store judges the holder of every write it is handed that carries one — `put` / `setPendingSteer` / `expire` (`opts.holder`),
2452
+ * `resolve` (`expect.holder`) and both arms of {@link claimTerminal} (`expect.holder`) — in that write's own atomic step, by the
2453
+ * deployment's one judge ({@link HolderJudge}). Same "declaration, never duck-typing" posture as the optional axes above
2454
+ * ({@link durability}, {@link fidelity}): ABSENT reads as "judges no holder", and a run handed a holder over such a store is refused at
2455
+ * its store seat (`config.invalid_checkpoint_store`) — a holder the store would ignore would fence nothing while the deployment
2456
+ * believed it fenced. The retired `{ holder: true }` (a promise about `resolve` alone) and every other form are refused at the seat
2457
+ * ({@link readStoreFence}). A wrapper store forwards this member and the holder of every verb it forwards; a wrapper that drops
2458
+ * either fences nothing — the store contract kit binds the COMPOSED store to catch exactly that.
2440
2459
  */
2441
- readonly fence?: {
2442
- readonly holder: true;
2443
- };
2460
+ readonly fence?: StoreHolderFence;
2444
2461
  /** Create-once. Throws {@link CheckpointError} `already_exists` on a token collision (never a silent
2445
- * overwrite — a reused token would clobber a live suspension). */
2446
- put(token: CheckpointToken, cp: Checkpoint): Promise<void>;
2462
+ * overwrite — a reused token would clobber a live suspension).
2463
+ * `opts.holder` (the run's grant holder, verbatim): judged first, in the same atomic step as the create — a holder the store's judge
2464
+ * does not hold current throws `holder.superseded` ({@link holderSupersededError}) with nothing written; no holder ⇒ as before. */
2465
+ put(token: CheckpointToken, cp: Checkpoint, opts?: CheckpointWriteOptions): Promise<void>;
2466
+ /** The row filed under `token` as stored, or `null` when none is; a held value that is no row throws `storedCheckpointRowRefusal`'s
2467
+ * refusal, bytes that do not decode `checkpointRowUnreadable`'s (both: checkpoint-queries.ts); every other row is answered as stored. */
2447
2468
  get(token: CheckpointToken): Promise<Checkpoint | null>;
2448
2469
  /**
2449
2470
  * Atomic CAS: `UPDATE … SET status='resolved' WHERE token=? AND scope=? AND status='pending'`.
@@ -2564,8 +2585,12 @@ export interface CheckpointStore {
2564
2585
  * persisted model-facing field on this row; rejected rather than truncated because cutting an
2565
2586
  * instruction can invert it). NOT an approval channel: this only writes the parked queue, never
2566
2587
  * touches status / the resolve path / any decision (§3 inv #4).
2588
+ *
2589
+ * `opts.holder` (a leg's own steer, carried verbatim): judged first, in the same atomic step as the append, before the row is
2590
+ * looked at — a holder the store's judge does not hold current throws `holder.superseded` ({@link holderSupersededError}), the queue
2591
+ * unchanged; no holder ⇒ as before (a person's steer onto a parked card carries none).
2567
2592
  */
2568
- setPendingSteer(token: CheckpointToken, scope: string, steer: PendingSteerInput): Promise<boolean>;
2593
+ setPendingSteer(token: CheckpointToken, scope: string, steer: PendingSteerInput, opts?: CheckpointWriteOptions): Promise<boolean>;
2569
2594
  /**
2570
2595
  * CAS-expire a **single** `pending` checkpoint by token: `UPDATE … SET status='expired' WHERE token=?
2571
2596
  * AND scope=? AND status='pending'`. Returns the CAS winner (`true` = was pending → now expired; `false`
@@ -2577,8 +2602,12 @@ export interface CheckpointStore {
2577
2602
  * goes through `resolve`); the paused env is destroyed only once the row is `expired` (this call won, or a loser
2578
2603
  * reads it so), so the same checkpoint is **never both reaped and resumed**. `scope` is in the WHERE for multi-tenant isolation, like
2579
2604
  * `resolve`/`reap`.
2605
+ *
2606
+ * `opts.holder` (an expire a run issues in its own name, carried verbatim): one more precondition of the same CAS — a holder the
2607
+ * store's judge does not hold current LOSES (`false`, the row untouched; never a throw, so a caller reading the row still sees that it
2608
+ * was expired by someone else when it was). No holder ⇒ as before (a host's reaper, cancel and cleanup carry none).
2580
2609
  */
2581
- expire(token: CheckpointToken, scope: string): Promise<boolean>;
2610
+ expire(token: CheckpointToken, scope: string, opts?: CheckpointWriteOptions): Promise<boolean>;
2582
2611
  /**
2583
2612
  * design/384 slice 2 / S-25-R1 — the ATOMIC terminal claim: "win the terminal race" and "read the
2584
2613
  * truth on a loss" as ONE store operation. OPTIONAL, probed by presence (the `listByScope`
@@ -2692,11 +2721,11 @@ export interface CheckpointStore {
2692
2721
  * **OPTIONAL** (unlike the required {@link listByScope}); the in-memory and file first-party impls provide it.
2693
2722
  */
2694
2723
  listScopes?(): Promise<string[]>;
2695
- /** The PENDING rows of every scope past their deadline, one facet per call ({@link CheckpointOverdueQuery}; read by
2724
+ /** The PENDING rows of every scope past their deadline (or age backstop), one facet per call ({@link CheckpointOverdueQuery}; read by
2696
2725
  * `readCheckpointOverdueQuery`, keyset-paged, bounded). OPTIONAL, probed by presence; both first-party stores provide it. */
2697
2726
  listOverdue?(query: CheckpointOverdueQuery): Promise<CheckpointPage<CheckpointSummary, CheckpointOverdueCursor>>;
2698
2727
  /** The rows of ONE session in any status ({@link CheckpointSessionQuery}; read by `readCheckpointSessionQuery`, keyset-paged,
2699
- * 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. */
2728
+ * 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). The query's `axis` says which session of a row it names: its own, or its run's (`checkpointRunSessionOf`). OPTIONAL, probed by presence; both first-party stores provide it. A store that offers it and cannot answer the run axis refuses `axis: "run"` (`config.invalid_argument`) — it never answers the row-session page in its place. */
2700
2729
  listBySession?(query: CheckpointSessionQuery): Promise<CheckpointPage<CheckpointRowRead, CheckpointSessionCursor>>;
2701
2730
  /** Delete the checkpoint rows of one session that exist when the call starts, in any status, when the guard admits it
2702
2731
  * ({@link CheckpointDeleteGuard}); answers the count. Present exactly when the store can judge the guard (a session head read). */
@@ -2866,10 +2895,9 @@ export declare class InMemoryCheckpointStore implements CheckpointStore {
2866
2895
  /** Honest declaration on the fidelity axis: `put`/`get` are `structuredClone`, so a row keeps the
2867
2896
  * whole structured-clone domain — a `Date` filed here is a `Date` when it comes back. */
2868
2897
  readonly fidelity: "structured-clone";
2869
- /** Declared exactly when the store was built with a `holderIsCurrent` judge ({@link CheckpointStore.fence}). */
2870
- readonly fence?: {
2871
- readonly holder: true;
2872
- };
2898
+ /** `{ holder: "writes" }`, declared exactly when the store was built with a `holderIsCurrent` judge ({@link CheckpointStore.fence}):
2899
+ * the judge is then asked on every write that carries a holder. */
2900
+ readonly fence?: StoreHolderFence;
2873
2901
  private cps;
2874
2902
  /** The listing's memo of each stored row object's verdict: a `put` stores a new object, so a replaced row is judged again. */
2875
2903
  private readonly rowVerdicts;
@@ -2890,7 +2918,7 @@ export declare class InMemoryCheckpointStore implements CheckpointStore {
2890
2918
  holderIsCurrent?: HolderJudge;
2891
2919
  retention?: RetentionDeclaration;
2892
2920
  });
2893
- put(token: CheckpointToken, cp: Checkpoint): Promise<void>;
2921
+ put(token: CheckpointToken, cp: Checkpoint, opts?: CheckpointWriteOptions): Promise<void>;
2894
2922
  get(token: CheckpointToken): Promise<Checkpoint | null>;
2895
2923
  /** The loser's single-round-trip reading (claim law 1): what the row IS, in its own vocabulary —
2896
2924
  * or `absent` for a missing row AND a wrong-scope row alike (the isolation rule: cross-scope truth
@@ -2912,7 +2940,7 @@ export declare class InMemoryCheckpointStore implements CheckpointStore {
2912
2940
  protected claimResolveCore(token: CheckpointToken, scope: string, outcome: ResumeOutcome, expect?: ResolveExpectation): TerminalClaimOutcome;
2913
2941
  /** The one protected write core for the terminal-expire claim — `expire` and
2914
2942
  * `claimTerminal({kind:"expire"})` both run exactly this (claim law 2, same as the resolve core). */
2915
- protected claimExpireCore(token: CheckpointToken, scope: string): TerminalClaimOutcome;
2943
+ protected claimExpireCore(token: CheckpointToken, scope: string, holder?: string): TerminalClaimOutcome;
2916
2944
  resolve(token: CheckpointToken, scope: string, outcome: ResumeOutcome, expect?: ResolveExpectation): Promise<boolean>;
2917
2945
  /** design/384 slice 2 — the atomic terminal claim (the interface JSDoc is the law's single
2918
2946
  * normative statement). Implemented OVER the same protected cores `resolve`/`expire` run, which is
@@ -2942,8 +2970,8 @@ export declare class InMemoryCheckpointStore implements CheckpointStore {
2942
2970
  claimTerminal(token: CheckpointToken, scope: string, intent: TerminalClaimIntent): Promise<TerminalClaimOutcome>;
2943
2971
  recordExecutionOutcome(token: CheckpointToken, scope: string, gate: GateOutcome): Promise<ExecutionOutcomeRecordWord>;
2944
2972
  reopen(token: CheckpointToken, scope: string, reason: ReopenReason, expect?: Pick<ResolveExpectation, "rev">): Promise<boolean>;
2945
- setPendingSteer(token: CheckpointToken, scope: string, steer: PendingSteerInput): Promise<boolean>;
2946
- expire(token: CheckpointToken, scope: string): Promise<boolean>;
2973
+ setPendingSteer(token: CheckpointToken, scope: string, steer: PendingSteerInput, opts?: CheckpointWriteOptions): Promise<boolean>;
2974
+ expire(token: CheckpointToken, scope: string, opts?: CheckpointWriteOptions): Promise<boolean>;
2947
2975
  reap(scope: string, cutoff: number): Promise<number>;
2948
2976
  listByScope(scope: string): Promise<CheckpointSummary[]>;
2949
2977
  listScopes(): Promise<string[]>;
@@ -16,9 +16,10 @@ import { isRunOrigin, RUN_ORIGINS } from "./run-origin.js";
16
16
  import { describeRejectedValue } from "./tool-search-setting.js";
17
17
  import { readBoundBinding } from "./skill-grant-binding.js";
18
18
  import { checkpointExecutionRecorded, executionRecordDisposition, ExecutionOutcomeConflictError, } from "./checkpoint-execution-record.js";
19
- import { checkpointHolderMatches, checkpointOccMatches, checkpointRevOf } from "./checkpoint-generation.js";
19
+ import { checkpointHolderMatches, checkpointOccMatches, checkpointRevOf, holderJudgedCurrent, readHolderJudge } from "./checkpoint-generation.js";
20
+ import { holderSupersededError } from "./grant-holder.js";
20
21
  import { isGateKind, parkedApprovalCardOf } from "./pause-registry.js";
21
- import { checkpointDeadlineColumn, checkpointDeadlinePassed, deleteSessionRowsAtStart, ownerSessionRowsDelete, unreadableSessionRowsDelete, readCheckpointOverdueQuery, readCheckpointSessionQuery, rowMemberProblem, selectOverduePage, selectSessionPage } from "./checkpoint-queries.js";
22
+ import { checkpointDeadlineColumn, checkpointDeadlinePassed, checkpointRunSessionOf, storedCheckpointRowRefusal, deleteSessionRowsAtStart, ownerSessionRowsDelete, unreadableSessionRowsDelete, readCheckpointOverdueQuery, readCheckpointSessionQuery, rowMemberProblem, selectOverduePage, selectSessionPage } from "./checkpoint-queries.js";
22
23
  import { renderUntrustedCommandText, stripFormatCharacters } from "./permission-rule-model.js";
23
24
  import { egressText } from "./untrusted-egress.js";
24
25
  import { steerReplayRefusal } from "./steer-replay.js";
@@ -29,7 +30,7 @@ import { isBlankInput, MAX_PENDING_STEER_CHARS, STEERING_CONTROL_CHARS_RE, steer
29
30
  import { oneStepRekeyAnswerOf, readIdentityRekeyInput } from "./identity-rekey.js";
30
31
  import { rekeyCheckpointRow } from "./checkpoint-rekey.js";
31
32
  export { MAX_PENDING_STEER_CHARS };
32
- export { BINDING_CHECKPOINT_VERSION, CHECKPOINT_CONFIG_REFUSAL_CODES, CHECKPOINT_ERROR_CODES, CHECKPOINT_FEATURES, CheckpointError, checkpointVersionOf, CURRENT_CHECKPOINT_VERSION, encodeAtFidelity, F012_CHECKPOINT_VERSION, FACE_CHECKPOINT_VERSION, isCheckpointConfigRefusalCode, isCheckpointErrorCode, isPlainRecord, MAX_SUPPORTED_CHECKPOINT_VERSION, normalizeProbeCause, ORG_ADMISSION_CHECKPOINT_VERSION, REAL_APPROVAL_CHECKPOINT_VERSION, RESOURCE_CHECKPOINT_VERSION, safeDataValue, SPAWN_RESUME_REFUSAL_CODES, TOKEN_CHECKPOINT_VERSION, } from "./checkpoint-features.js";
33
+ export { CHECKPOINT_CONFIG_REFUSAL_CODES, CHECKPOINT_ERROR_CODES, CHECKPOINT_FEATURES, CheckpointError, checkpointVersionOf, encodeAtFidelity, isCheckpointConfigRefusalCode, isCheckpointErrorCode, isPlainRecord, MAX_SUPPORTED_CHECKPOINT_VERSION, normalizeProbeCause, safeDataValue, SPAWN_RESUME_REFUSAL_CODES, } from "./checkpoint-features.js";
33
34
  export function mintCheckpointToken() {
34
35
  return randomBytes(16).toString("hex");
35
36
  }
@@ -226,12 +227,14 @@ export function checkpointIndexFacts(cp) {
226
227
  const refused = indexTreeRefusal("gate", gate) ?? indexTreeRefusal("pendingAction", pending);
227
228
  if (refused !== undefined)
228
229
  throw refused;
230
+ const runSessionId = checkpointRunSessionOf(cp) ?? null;
229
231
  const card = parkedApprovalCardOf(gate);
230
232
  const tool = pending.kind === "tool_approval" ? pending : undefined;
231
233
  return {
232
234
  token: cp.token,
233
235
  scope: cp.scope,
234
236
  sessionId: cp.sessionId,
237
+ runSessionId,
235
238
  version: checkpointVersionOf(cp),
236
239
  gateKind: gate.kind,
237
240
  approvalCard: card.kind === "card" ? card.card : card.kind === "unknown_word" && typeof card.word === "string" ? card.word : null,
@@ -673,9 +676,9 @@ export class InMemoryCheckpointStore {
673
676
  const opts = receiveOptions(options, "InMemoryCheckpointStore", IN_MEMORY_CHECKPOINT_STORE_OPTION_KEYS);
674
677
  this.retention = readRetentionDeclaration("InMemoryCheckpointStore.retention", opts.retention);
675
678
  this.disclose = opts.disclose;
676
- this.holderIsCurrent = opts.holderIsCurrent;
677
- if (opts.holderIsCurrent !== undefined)
678
- this.fence = Object.freeze({ holder: true });
679
+ this.holderIsCurrent = readHolderJudge("InMemoryCheckpointStore.holderIsCurrent", opts.holderIsCurrent);
680
+ if (this.holderIsCurrent !== undefined)
681
+ this.fence = Object.freeze({ holder: "writes" });
679
682
  const headOf = opts.sessionHeadOf;
680
683
  if (headOf !== undefined) {
681
684
  const remove = (token, row) => this.cps.get(token) === row && this.cps.delete(token);
@@ -683,15 +686,21 @@ export class InMemoryCheckpointStore {
683
686
  this.deleteUnreadableSessionCheckpoints = async (sessionId) => deleteSessionRowsAtStart(this.cps, unreadableSessionRowsDelete(sessionId, headOf), remove);
684
687
  }
685
688
  }
686
- async put(token, cp) {
689
+ async put(token, cp, opts) {
690
+ if (!holderJudgedCurrent(opts?.holder, this.holderIsCurrent, "checkpoint"))
691
+ throw holderSupersededError("put");
687
692
  if (this.cps.has(token)) {
688
693
  throw new CheckpointError("checkpoint.already_exists", `checkpoint token already exists`);
689
694
  }
690
695
  this.cps.set(token, structuredClone(cp));
691
696
  }
692
697
  async get(token) {
693
- const cp = this.cps.get(token);
694
- return cp ? structuredClone(cp) : null;
698
+ if (!this.cps.has(token))
699
+ return null;
700
+ const cp = this.cps.get(token), refused = storedCheckpointRowRefusal(token, cp);
701
+ if (refused !== undefined)
702
+ throw refused;
703
+ return structuredClone(cp);
695
704
  }
696
705
  claimLossFrom(cp, scope) {
697
706
  if (cp === undefined || cp.scope !== scope)
@@ -725,11 +734,14 @@ export class InMemoryCheckpointStore {
725
734
  delete cp.reopenReason;
726
735
  return { claimed: true };
727
736
  }
728
- claimExpireCore(token, scope) {
737
+ claimExpireCore(token, scope, holder) {
729
738
  const cp = this.cps.get(token);
730
739
  if (!checkpointRowMatches(cp, scope, "pending")) {
731
740
  return this.claimLossFrom(cp, scope);
732
741
  }
742
+ if (!holderJudgedCurrent(holder, this.holderIsCurrent, "checkpoint")) {
743
+ return this.claimLossFrom(cp, scope);
744
+ }
733
745
  cp.status = "expired";
734
746
  return { claimed: true };
735
747
  }
@@ -754,7 +766,7 @@ export class InMemoryCheckpointStore {
754
766
  this.fault = null;
755
767
  throw new Error(`injected fault: ${name} before commit`);
756
768
  }
757
- const out = intent.kind === "resolve" ? this.claimResolveCore(token, scope, intent.outcome, intent.expect) : this.claimExpireCore(token, scope);
769
+ const out = intent.kind === "resolve" ? this.claimResolveCore(token, scope, intent.outcome, intent.expect) : this.claimExpireCore(token, scope, intent.expect?.holder);
758
770
  if (out.claimed && (this.fault === "claim-after-commit" || (intent.kind === "resolve" && this.fault === "resolve-after-commit"))) {
759
771
  const name = this.fault === "claim-after-commit" ? "claim" : "resolve";
760
772
  this.fault = null;
@@ -784,8 +796,10 @@ export class InMemoryCheckpointStore {
784
796
  cp.reopenReason = reason;
785
797
  return true;
786
798
  }
787
- async setPendingSteer(token, scope, steer) {
799
+ async setPendingSteer(token, scope, steer, opts) {
788
800
  const clean = validatePendingSteer(steer);
801
+ if (!holderJudgedCurrent(opts?.holder, this.holderIsCurrent, "checkpoint"))
802
+ throw holderSupersededError("setPendingSteer");
789
803
  const cp = this.cps.get(token);
790
804
  if (!checkpointRowMatches(cp, scope, "pending")) {
791
805
  return false;
@@ -793,11 +807,11 @@ export class InMemoryCheckpointStore {
793
807
  cp.state.pendingSteerQueue = appendPendingSteer(cp.state, clean);
794
808
  return true;
795
809
  }
796
- async expire(token, scope) {
810
+ async expire(token, scope, opts) {
797
811
  if (!checkpointRowMatches(this.cps.get(token), scope, "pending")) {
798
812
  return false;
799
813
  }
800
- return this.claimExpireCore(token, scope).claimed;
814
+ return this.claimExpireCore(token, scope, opts?.holder).claimed;
801
815
  }
802
816
  async reap(scope, cutoff) {
803
817
  let n = 0;