@sema-agent/core 7.60.0 → 7.62.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 (560) hide show
  1. package/CHANGELOG.md +917 -0
  2. package/README.md +2 -2
  3. package/dist/agents/agent-transcript-tool.d.ts +2 -2
  4. package/dist/agents/agent-transcript-tool.js +1 -1
  5. package/dist/agents/cascade.d.ts +71 -12
  6. package/dist/agents/cascade.js +61 -21
  7. package/dist/agents/composition-allowance.d.ts +53 -0
  8. package/dist/agents/composition-allowance.js +49 -0
  9. package/dist/agents/composition-placement.d.ts +29 -0
  10. package/dist/agents/composition-placement.js +24 -0
  11. package/dist/agents/cumulative-stats.d.ts +4 -0
  12. package/dist/agents/cumulative-stats.js +3 -0
  13. package/dist/agents/inherited-tool-pool.d.ts +5 -3
  14. package/dist/agents/inherited-tool-pool.js +2 -2
  15. package/dist/agents/list-agents-tool.d.ts +1 -1
  16. package/dist/agents/peer-held-queue.d.ts +27 -4
  17. package/dist/agents/peer-held-queue.js +81 -36
  18. package/dist/agents/peer-notice-route.d.ts +1 -1
  19. package/dist/agents/peer-notice-route.js +4 -3
  20. package/dist/agents/peer-notices.d.ts +4 -4
  21. package/dist/agents/peer-notices.js +8 -4
  22. package/dist/agents/peer-session-drain.d.ts +8 -1
  23. package/dist/agents/peer-session-drain.js +49 -10
  24. package/dist/agents/repair-loop.js +16 -6
  25. package/dist/agents/retain-ledger.js +3 -1
  26. package/dist/agents/roster-store.d.ts +1 -1
  27. package/dist/agents/roster-store.js +7 -4
  28. package/dist/agents/send-message-tool.d.ts +8 -10
  29. package/dist/agents/send-message-tool.js +43 -23
  30. package/dist/agents/subagent-completion-gate.d.ts +35 -0
  31. package/dist/agents/subagent-completion-gate.js +62 -0
  32. package/dist/agents/subagent-steps.d.ts +7 -6
  33. package/dist/agents/subagent.d.ts +36 -41
  34. package/dist/agents/subagent.js +245 -200
  35. package/dist/agents/suspend-guard.d.ts +47 -16
  36. package/dist/agents/suspend-guard.js +13 -4
  37. package/dist/agents/verify.d.ts +41 -14
  38. package/dist/agents/verify.js +41 -30
  39. package/dist/brain/anthropic.js +1 -0
  40. package/dist/brain/errors.d.ts +7 -1
  41. package/dist/brain/errors.js +6 -0
  42. package/dist/brain/failover.js +2 -1
  43. package/dist/brain/open-responses.js +1 -0
  44. package/dist/brain/openai.js +1 -0
  45. package/dist/brain/provider-dialect.d.ts +10 -0
  46. package/dist/brain/provider-dialect.js +13 -2
  47. package/dist/brain/stream-engine.d.ts +3 -0
  48. package/dist/brain/stream-engine.js +4 -0
  49. package/dist/core/agent-state.d.ts +1 -1
  50. package/dist/core/allow-entry.d.ts +59 -23
  51. package/dist/core/allow-entry.js +131 -38
  52. package/dist/core/ask-origin.d.ts +79 -0
  53. package/dist/core/ask-origin.js +76 -0
  54. package/dist/core/ask-question.d.ts +19 -13
  55. package/dist/core/ask-question.js +8 -2
  56. package/dist/core/auto-compaction.d.ts +2 -0
  57. package/dist/core/auto-compaction.js +2 -1
  58. package/dist/core/auto-mode.js +3 -5
  59. package/dist/core/background-agent-store.d.ts +7 -5
  60. package/dist/core/background-agent-store.js +12 -11
  61. package/dist/core/checkpoint-features.d.ts +722 -0
  62. package/dist/core/checkpoint-features.js +98 -0
  63. package/dist/core/checkpoint-requirements.d.ts +33 -5
  64. package/dist/core/checkpoint-requirements.js +18 -5
  65. package/dist/core/checkpoint-row-verdict.d.ts +99 -0
  66. package/dist/core/checkpoint-row-verdict.js +225 -0
  67. package/dist/core/checkpoint-store.d.ts +107 -738
  68. package/dist/core/checkpoint-store.js +45 -143
  69. package/dist/core/child-clamp-seats.d.ts +3 -2
  70. package/dist/core/child-clamp-seats.js +4 -3
  71. package/dist/core/closest-name.d.ts +13 -0
  72. package/dist/core/closest-name.js +35 -0
  73. package/dist/core/context-settings.js +3 -5
  74. package/dist/core/cross-boundary-taint.d.ts +1 -1
  75. package/dist/core/decision-receipt.d.ts +14 -1
  76. package/dist/core/decision-receipt.js +6 -3
  77. package/dist/core/delegation-frames.d.ts +13 -9
  78. package/dist/core/effective-path-target.js +2 -3
  79. package/dist/core/engine-attestation.d.ts +11 -1
  80. package/dist/core/engine-attestation.js +2 -0
  81. package/dist/core/engine-notice.d.ts +68 -21
  82. package/dist/core/engine-notice.js +9 -2
  83. package/dist/core/file-history-retention.d.ts +8 -0
  84. package/dist/core/file-history-retention.js +14 -11
  85. package/dist/core/file-history-store.d.ts +31 -1
  86. package/dist/core/file-history-store.js +31 -2
  87. package/dist/core/frame-settlement.d.ts +10 -0
  88. package/dist/core/frame-settlement.js +6 -1
  89. package/dist/core/fs-write-gate-policy.d.ts +3 -3
  90. package/dist/core/fs-write-gate-policy.js +8 -7
  91. package/dist/core/gate-fold.js +4 -3
  92. package/dist/core/gate-lanes.js +7 -4
  93. package/dist/core/gate-outcome.d.ts +40 -1
  94. package/dist/core/gate-outcome.js +10 -0
  95. package/dist/core/git-worktree-env.d.ts +7 -3
  96. package/dist/core/git-worktree-env.js +16 -13
  97. package/dist/core/governance-codes.d.ts +14 -4
  98. package/dist/core/governance-codes.js +19 -4
  99. package/dist/core/hooks.d.ts +25 -4
  100. package/dist/core/hooks.js +11 -4
  101. package/dist/core/host-floor.js +3 -5
  102. package/dist/core/human-input-projection.d.ts +1 -0
  103. package/dist/core/human-input-projection.js +3 -0
  104. package/dist/core/image-admission.d.ts +47 -7
  105. package/dist/core/image-admission.js +35 -4
  106. package/dist/core/input-author.d.ts +36 -0
  107. package/dist/core/input-author.js +39 -0
  108. package/dist/core/leg-identity.d.ts +62 -0
  109. package/dist/core/leg-identity.js +18 -0
  110. package/dist/core/locked-config.d.ts +4 -3
  111. package/dist/core/locked-config.js +5 -3
  112. package/dist/core/lsp.d.ts +5 -3
  113. package/dist/core/lsp.js +3 -2
  114. package/dist/core/mailbox-store.d.ts +85 -10
  115. package/dist/core/mailbox-store.js +31 -10
  116. package/dist/core/mcp-connection-pool.d.ts +6 -20
  117. package/dist/core/mcp-connection-pool.js +10 -28
  118. package/dist/core/mcp-failure.d.ts +76 -15
  119. package/dist/core/mcp-failure.js +60 -33
  120. package/dist/core/mcp-host-seat.d.ts +92 -53
  121. package/dist/core/mcp-host-seat.js +225 -46
  122. package/dist/core/mcp-probe.js +2 -2
  123. package/dist/core/mcp-server-link.d.ts +18 -6
  124. package/dist/core/mcp-server-link.js +19 -4
  125. package/dist/core/mcp-server-spec.d.ts +2 -1
  126. package/dist/core/mcp-session-end.d.ts +1 -2
  127. package/dist/core/mcp-session-end.js +1 -1
  128. package/dist/core/mcp.d.ts +6 -49
  129. package/dist/core/mcp.js +115 -111
  130. package/dist/core/media-byte-cap.d.ts +21 -46
  131. package/dist/core/media-byte-cap.js +55 -55
  132. package/dist/core/member-group.d.ts +7 -0
  133. package/dist/core/member-group.js +35 -0
  134. package/dist/core/memory-engine/consolidation-driver.d.ts +1 -1
  135. package/dist/core/memory-engine/consolidation.d.ts +1 -1
  136. package/dist/core/memory-engine/consolidation.js +7 -1
  137. package/dist/core/memory-engine/dual-root.d.ts +31 -0
  138. package/dist/core/memory-engine/dual-root.js +59 -11
  139. package/dist/core/memory-engine/engine.js +27 -24
  140. package/dist/core/memory-engine/file-backend.d.ts +13 -0
  141. package/dist/core/memory-engine/file-backend.js +35 -15
  142. package/dist/core/memory-engine/layout.d.ts +3 -0
  143. package/dist/core/memory-engine/layout.js +13 -3
  144. package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
  145. package/dist/core/memory-engine/memory-deployment.js +182 -0
  146. package/dist/core/memory-engine/sync-client.d.ts +39 -18
  147. package/dist/core/memory-engine/sync-client.js +72 -14
  148. package/dist/core/memory-engine/sync-report.d.ts +7 -4
  149. package/dist/core/memory-engine/sync.d.ts +9 -1
  150. package/dist/core/memory-vector.d.ts +1 -1
  151. package/dist/core/memory.d.ts +10 -10
  152. package/dist/core/mode-policy.d.ts +8 -8
  153. package/dist/core/mode-policy.js +8 -6
  154. package/dist/core/mods/agent-stations.d.ts +39 -4
  155. package/dist/core/mods/agent-stations.js +59 -10
  156. package/dist/core/mods/classic-events.d.ts +9 -1
  157. package/dist/core/mods/dollar.d.ts +94 -1
  158. package/dist/core/mods/dollar.js +13 -1
  159. package/dist/core/mods/extension-call.d.ts +15 -1
  160. package/dist/core/mods/extension-call.js +7 -2
  161. package/dist/core/mods/kernel/dispatch.d.ts +4 -3
  162. package/dist/core/mods/kernel/dispatch.js +4 -4
  163. package/dist/core/mods/kernel/events.d.ts +14 -3
  164. package/dist/core/mods/kernel/events.js +18 -15
  165. package/dist/core/mods/kernel/registration.d.ts +3 -0
  166. package/dist/core/mods/kernel/registration.js +5 -0
  167. package/dist/core/mods/kernel/site-rules.d.ts +6 -3
  168. package/dist/core/mods/kernel/site-rules.js +10 -2
  169. package/dist/core/mods/lifecycle-stations.d.ts +36 -4
  170. package/dist/core/mods/lifecycle-stations.js +44 -9
  171. package/dist/core/mods/session-append.d.ts +118 -0
  172. package/dist/core/mods/session-append.js +318 -0
  173. package/dist/core/mods/session-compact.d.ts +48 -0
  174. package/dist/core/mods/session-compact.js +194 -0
  175. package/dist/core/mods/session-receive.d.ts +93 -0
  176. package/dist/core/mods/session-receive.js +138 -0
  177. package/dist/core/mods/session-send.d.ts +72 -0
  178. package/dist/core/mods/session-send.js +88 -0
  179. package/dist/core/mods/stations.d.ts +88 -21
  180. package/dist/core/mods/stations.js +149 -11
  181. package/dist/core/mods/tool-call.d.ts +2 -0
  182. package/dist/core/mods/tool-call.js +4 -4
  183. package/dist/core/output-style.js +3 -4
  184. package/dist/core/own-property-receipt.d.ts +68 -2
  185. package/dist/core/own-property-receipt.js +45 -2
  186. package/dist/core/park-selfcheck.js +4 -2
  187. package/dist/core/path-identity.d.ts +11 -0
  188. package/dist/core/path-identity.js +4 -0
  189. package/dist/core/path-rule-binding.d.ts +3 -1
  190. package/dist/core/path-rule-binding.js +3 -1
  191. package/dist/core/peer-seat.d.ts +3 -3
  192. package/dist/core/peer-seat.js +20 -8
  193. package/dist/core/permission-rule-consent.d.ts +21 -5
  194. package/dist/core/permission-rule-consent.js +21 -1
  195. package/dist/core/permission-rule-model.d.ts +34 -11
  196. package/dist/core/permission-rule-model.js +47 -10
  197. package/dist/core/permission-rule-org.d.ts +1 -1
  198. package/dist/core/permission-rule-provider.js +4 -1
  199. package/dist/core/permission-rules.d.ts +4 -0
  200. package/dist/core/permission-rules.js +11 -16
  201. package/dist/core/read-root-candidate.js +1 -1
  202. package/dist/core/remote-env.d.ts +74 -26
  203. package/dist/core/remote-env.js +20 -0
  204. package/dist/core/resume-startup-cause.d.ts +5 -4
  205. package/dist/core/retention-policy.d.ts +24 -23
  206. package/dist/core/retention-policy.js +36 -2
  207. package/dist/core/retention.d.ts +4 -1
  208. package/dist/core/retired-keys.d.ts +4 -4
  209. package/dist/core/row-admission.d.ts +10 -0
  210. package/dist/core/row-admission.js +5 -0
  211. package/dist/core/runner/advisor-instructions.d.ts +2 -1
  212. package/dist/core/runner/advisor-instructions.js +2 -1
  213. package/dist/core/runner/announce-once-ledger.d.ts +4 -4
  214. package/dist/core/runner/assemble-result.d.ts +13 -3
  215. package/dist/core/runner/assemble-result.js +12 -7
  216. package/dist/core/runner/caller-roster.d.ts +12 -9
  217. package/dist/core/runner/caller-roster.js +5 -2
  218. package/dist/core/runner/checkpoint-scope.d.ts +16 -1
  219. package/dist/core/runner/checkpoint-scope.js +21 -0
  220. package/dist/core/runner/compact-session.js +18 -3
  221. package/dist/core/runner/compaction-call-options.d.ts +1 -1
  222. package/dist/core/runner/compaction-restate.d.ts +2 -2
  223. package/dist/core/runner/compaction-restate.js +4 -3
  224. package/dist/core/runner/construction-doors.d.ts +2 -2
  225. package/dist/core/runner/construction-doors.js +2 -2
  226. package/dist/core/runner/contracts.d.ts +116 -34
  227. package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
  228. package/dist/core/runner/decide-continuation.d.ts +4 -2
  229. package/dist/core/runner/decide-continuation.js +7 -4
  230. package/dist/core/runner/delegation-owner.d.ts +43 -0
  231. package/dist/core/runner/delegation-owner.js +59 -0
  232. package/dist/core/runner/denial-limit-arms.d.ts +15 -21
  233. package/dist/core/runner/denial-limit-arms.js +17 -10
  234. package/dist/core/runner/expire-settle.d.ts +44 -0
  235. package/dist/core/runner/expire-settle.js +55 -0
  236. package/dist/core/runner/git-status-frame.d.ts +3 -3
  237. package/dist/core/runner/git-status-frame.js +2 -1
  238. package/dist/core/runner/halt-attribution.d.ts +2 -1
  239. package/dist/core/runner/halt-attribution.js +2 -1
  240. package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
  241. package/dist/core/runner/lineage-reroot-view.js +108 -0
  242. package/dist/core/runner/local-claims.d.ts +17 -0
  243. package/dist/core/runner/local-claims.js +18 -0
  244. package/dist/core/runner/media-removed-seat.d.ts +46 -0
  245. package/dist/core/runner/media-removed-seat.js +88 -0
  246. package/dist/core/runner/park-commit.d.ts +2 -2
  247. package/dist/core/runner/permission-rule-lanes.d.ts +7 -2
  248. package/dist/core/runner/permission-rule-lanes.js +28 -9
  249. package/dist/core/runner/person-path-rows.d.ts +15 -0
  250. package/dist/core/runner/person-path-rows.js +27 -4
  251. package/dist/core/runner/placement-fence.d.ts +26 -0
  252. package/dist/core/runner/placement-fence.js +38 -0
  253. package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
  254. package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
  255. package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
  256. package/dist/core/runner/prepare-ask-lane.js +4 -4
  257. package/dist/core/runner/prepare-boundary-parks.d.ts +4 -1
  258. package/dist/core/runner/prepare-boundary-parks.js +2 -2
  259. package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -0
  260. package/dist/core/runner/prepare-caps-and-workflow.js +2 -1
  261. package/dist/core/runner/prepare-config-doors.d.ts +6 -6
  262. package/dist/core/runner/prepare-config-doors.js +19 -21
  263. package/dist/core/runner/prepare-context-lane.d.ts +6 -2
  264. package/dist/core/runner/prepare-context-lane.js +13 -13
  265. package/dist/core/runner/prepare-delegation-surface.d.ts +9 -9
  266. package/dist/core/runner/prepare-delegation-surface.js +4 -5
  267. package/dist/core/runner/prepare-execution-env.d.ts +5 -2
  268. package/dist/core/runner/prepare-execution-env.js +7 -4
  269. package/dist/core/runner/prepare-gate-stations.d.ts +19 -14
  270. package/dist/core/runner/prepare-gate-stations.js +6 -4
  271. package/dist/core/runner/prepare-hands-readface.d.ts +6 -6
  272. package/dist/core/runner/prepare-hands-readface.js +32 -11
  273. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -0
  274. package/dist/core/runner/prepare-inherited-gate.js +10 -3
  275. package/dist/core/runner/prepare-lsp.d.ts +3 -0
  276. package/dist/core/runner/prepare-lsp.js +2 -2
  277. package/dist/core/runner/prepare-park-ask.d.ts +5 -2
  278. package/dist/core/runner/prepare-park-ask.js +4 -5
  279. package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
  280. package/dist/core/runner/prepare-policy-chain.js +16 -25
  281. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  282. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
  283. package/dist/core/runner/prepare-prompt-inputs.js +3 -2
  284. package/dist/core/runner/prepare-question-face.d.ts +6 -4
  285. package/dist/core/runner/prepare-question-face.js +2 -2
  286. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  287. package/dist/core/runner/prepare-run-refs.js +2 -2
  288. package/dist/core/runner/prepare-suspend-saga.d.ts +11 -7
  289. package/dist/core/runner/prepare-suspend-saga.js +17 -7
  290. package/dist/core/runner/prepare-task.d.ts +1 -1
  291. package/dist/core/runner/prepare-task.js +61 -30
  292. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
  293. package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
  294. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -0
  295. package/dist/core/runner/prepare-wiring-manifest.js +2 -1
  296. package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
  297. package/dist/core/runner/prepare-workspace-restore.js +10 -6
  298. package/dist/core/runner/read-root-grant.d.ts +1 -1
  299. package/dist/core/runner/read-root-grant.js +2 -1
  300. package/dist/core/runner/resume-admission.d.ts +8 -6
  301. package/dist/core/runner/resume-admission.js +23 -6
  302. package/dist/core/runner/resume-apply.d.ts +4 -0
  303. package/dist/core/runner/resume-apply.js +14 -5
  304. package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
  305. package/dist/core/runner/resume-checkpoint-screen.js +4 -84
  306. package/dist/core/runner/resume-claim.d.ts +8 -3
  307. package/dist/core/runner/resume-claim.js +28 -12
  308. package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
  309. package/dist/core/runner/resume-internals-and-config.js +10 -1
  310. package/dist/core/runner/resume-preflight.d.ts +3 -2
  311. package/dist/core/runner/resume-preflight.js +13 -26
  312. package/dist/core/runner/retired-runner-deps.js +2 -0
  313. package/dist/core/runner/run-git-lane.d.ts +2 -0
  314. package/dist/core/runner/run-git-lane.js +6 -2
  315. package/dist/core/runner/run-harness-handlers.d.ts +2 -0
  316. package/dist/core/runner/run-harness-handlers.js +5 -4
  317. package/dist/core/runner/run-identity-wiring.d.ts +2 -2
  318. package/dist/core/runner/run-identity-wiring.js +14 -5
  319. package/dist/core/runner/run-leg.d.ts +3 -3
  320. package/dist/core/runner/run-leg.js +64 -36
  321. package/dist/core/runner/run-notification-lane.js +20 -2
  322. package/dist/core/runner/run-recovery-lanes.js +3 -2
  323. package/dist/core/runner/run-settle-and-teardown.js +12 -9
  324. package/dist/core/runner/run-stop-and-final-verify.js +2 -1
  325. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
  326. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  327. package/dist/core/runner/run-terminal-adoption.js +26 -17
  328. package/dist/core/runner/run-turn-boundary.js +34 -18
  329. package/dist/core/runner/runtask.d.ts +18 -3
  330. package/dist/core/runner/runtask.js +33 -17
  331. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  332. package/dist/core/runner/session-rule-policy.js +6 -1
  333. package/dist/core/runner/shell-env-withheld.d.ts +1 -1
  334. package/dist/core/runner/steering-preview.d.ts +9 -0
  335. package/dist/core/runner/steering-preview.js +5 -0
  336. package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
  337. package/dist/core/runner/stream-halt-verbs.js +4 -3
  338. package/dist/core/runner/stream-reap.d.ts +7 -6
  339. package/dist/core/runner/stream-reap.js +13 -16
  340. package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
  341. package/dist/core/runner/stream-settle-backstop.js +5 -3
  342. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  343. package/dist/core/runner/stream-steer-verb.js +16 -7
  344. package/dist/core/runner/terminal-account.d.ts +11 -1
  345. package/dist/core/runner/terminal-account.js +20 -0
  346. package/dist/core/runner/terminal-projection.d.ts +8 -2
  347. package/dist/core/runner/terminal-projection.js +2 -2
  348. package/dist/core/runner/tool-disclosure.d.ts +3 -0
  349. package/dist/core/runner/tool-disclosure.js +5 -2
  350. package/dist/core/runner/tool-end-body.d.ts +3 -3
  351. package/dist/core/runner/tool-end-body.js +1 -1
  352. package/dist/core/runner/tool-face-overlay.js +2 -0
  353. package/dist/core/runner/tool-output-projection.d.ts +3 -3
  354. package/dist/core/runner/tool-output-projection.js +7 -6
  355. package/dist/core/runner/tool-table-view.d.ts +56 -0
  356. package/dist/core/runner/tool-table-view.js +51 -0
  357. package/dist/core/runner/turn-attachments.d.ts +8 -2
  358. package/dist/core/runner/turn-attachments.js +2 -2
  359. package/dist/core/runner/void-verifier-pause.d.ts +33 -0
  360. package/dist/core/runner/void-verifier-pause.js +41 -0
  361. package/dist/core/runner-deps.d.ts +26 -27
  362. package/dist/core/secret-env.d.ts +19 -16
  363. package/dist/core/secret-env.js +45 -27
  364. package/dist/core/session-log-transfer.js +9 -10
  365. package/dist/core/session-policy-store.d.ts +1 -1
  366. package/dist/core/session-policy-store.js +5 -2
  367. package/dist/core/session-reconcile.d.ts +3 -2
  368. package/dist/core/session-reconcile.js +7 -4
  369. package/dist/core/session-store.d.ts +3 -1
  370. package/dist/core/session-store.js +10 -8
  371. package/dist/core/session.d.ts +16 -5
  372. package/dist/core/shell-confinement.d.ts +37 -0
  373. package/dist/core/shell-confinement.js +56 -0
  374. package/dist/core/skill-grant.js +1 -1
  375. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +8 -2
  376. package/dist/core/store-contracts/checkpoint-store-contract.js +83 -2
  377. package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
  378. package/dist/core/store-contracts/file-history-store-contract.js +25 -1
  379. package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
  380. package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
  381. package/dist/core/store-contracts/session-store-contract.js +22 -8
  382. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  383. package/dist/core/store-contracts/tool-result-store-contract.js +30 -0
  384. package/dist/core/task-event.d.ts +24 -9
  385. package/dist/core/task-limits.d.ts +5 -0
  386. package/dist/core/task-notification.d.ts +89 -12
  387. package/dist/core/task-notification.js +89 -14
  388. package/dist/core/task-registry-agent.d.ts +32 -50
  389. package/dist/core/task-registry-agent.js +36 -56
  390. package/dist/core/task-registry-monitor.d.ts +1 -1
  391. package/dist/core/task-registry-monitor.js +15 -60
  392. package/dist/core/task-registry-shared.d.ts +22 -112
  393. package/dist/core/task-registry-shared.js +3 -41
  394. package/dist/core/task-registry-workflow.js +5 -21
  395. package/dist/core/task-registry.d.ts +32 -62
  396. package/dist/core/task-registry.js +30 -110
  397. package/dist/core/task-result.d.ts +29 -12
  398. package/dist/core/task-spec-members.d.ts +39 -0
  399. package/dist/core/task-spec-members.js +92 -0
  400. package/dist/core/task-spec.d.ts +11 -11
  401. package/dist/core/task-tool-shape.d.ts +7 -57
  402. package/dist/core/task-tool-shape.js +7 -66
  403. package/dist/core/terminal-cause.d.ts +36 -6
  404. package/dist/core/terminal-cause.js +1 -0
  405. package/dist/core/tool-catalog-entries.js +2 -5
  406. package/dist/core/tool-check-reading.js +16 -10
  407. package/dist/core/tool-conformance.js +1 -2
  408. package/dist/core/tool-errors.d.ts +6 -3
  409. package/dist/core/tool-errors.js +2 -0
  410. package/dist/core/tool-face-reader.js +3 -2
  411. package/dist/core/tool-face.d.ts +8 -5
  412. package/dist/core/tool-face.js +1 -1
  413. package/dist/core/tool-name-aliases.d.ts +5 -29
  414. package/dist/core/tool-name-aliases.js +9 -5
  415. package/dist/core/tool-name-readings.d.ts +14 -3
  416. package/dist/core/tool-name-readings.js +2 -0
  417. package/dist/core/tool-policy.d.ts +109 -18
  418. package/dist/core/tool-policy.js +84 -14
  419. package/dist/core/tool-result-store.d.ts +23 -0
  420. package/dist/core/tool-result-store.js +3 -2
  421. package/dist/core/tool-roster.d.ts +4 -4
  422. package/dist/core/tool-spec.d.ts +23 -6
  423. package/dist/core/trace.d.ts +18 -1
  424. package/dist/core/types.d.ts +1 -1
  425. package/dist/core/types.js +1 -1
  426. package/dist/core/user-attachment.js +26 -21
  427. package/dist/core/workflow-journal-store.d.ts +1 -1
  428. package/dist/core/workflow-run-store.d.ts +2 -0
  429. package/dist/core/workflow-run-store.js +6 -5
  430. package/dist/core/workflow-settled-run.d.ts +5 -0
  431. package/dist/core/workflow-settled-run.js +7 -0
  432. package/dist/engine/execution-env/node-execution-env.d.ts +37 -9
  433. package/dist/engine/execution-env/node-execution-env.js +221 -22
  434. package/dist/engine/harness/agent-harness.d.ts +65 -18
  435. package/dist/engine/harness/agent-harness.js +90 -23
  436. package/dist/engine/harness/messages.d.ts +4 -3
  437. package/dist/engine/harness/messages.js +2 -2
  438. package/dist/engine/harness/types.d.ts +52 -7
  439. package/dist/engine/llm/media-removed.d.ts +14 -0
  440. package/dist/engine/llm/media-removed.js +9 -0
  441. package/dist/engine/llm/rejected-images.d.ts +35 -25
  442. package/dist/engine/llm/rejected-images.js +59 -10
  443. package/dist/engine/llm/types.d.ts +24 -3
  444. package/dist/engine/llm/types.js +7 -3
  445. package/dist/engine/loop/agent-loop.d.ts +6 -1
  446. package/dist/engine/loop/agent-loop.js +20 -11
  447. package/dist/engine/loop/types.d.ts +12 -3
  448. package/dist/engine/session/import-validate.js +7 -0
  449. package/dist/engine/session/parent-chain-guard.d.ts +3 -3
  450. package/dist/engine/session/parent-chain-guard.js +1 -1
  451. package/dist/engine/session/path-to-root.d.ts +18 -3
  452. package/dist/engine/session/path-to-root.js +15 -1
  453. package/dist/engine/session/repo-utils.d.ts +12 -1
  454. package/dist/engine/session/repo-utils.js +41 -0
  455. package/dist/engine/session/session.js +1 -1
  456. package/dist/engine/session/storage-base.d.ts +20 -0
  457. package/dist/engine/session/storage-base.js +28 -9
  458. package/dist/fixtures/index.d.ts +7 -5
  459. package/dist/fixtures/index.js +5 -3
  460. package/dist/index.d.ts +29 -18
  461. package/dist/index.js +19 -11
  462. package/dist/internal/harness-types.d.ts +2 -0
  463. package/dist/internal/harness.d.ts +4 -3
  464. package/dist/internal/harness.js +3 -2
  465. package/dist/internal/llm.d.ts +2 -1
  466. package/dist/internal/llm.js +1 -0
  467. package/dist/orchestration/goal.d.ts +6 -2
  468. package/dist/orchestration/goal.js +6 -3
  469. package/dist/orchestration/run-workflow-tool.d.ts +14 -17
  470. package/dist/orchestration/run-workflow-tool.js +43 -50
  471. package/dist/orchestration/workflow-types.d.ts +2 -2
  472. package/dist/orchestration/workflow.d.ts +7 -0
  473. package/dist/orchestration/workflow.js +10 -12
  474. package/dist/stores/file/background-agent-store.js +18 -15
  475. package/dist/stores/file/checkpoint-store.d.ts +2 -0
  476. package/dist/stores/file/checkpoint-store.js +13 -9
  477. package/dist/stores/file/file-history-store.js +3 -2
  478. package/dist/stores/file/fs-atomic.d.ts +0 -22
  479. package/dist/stores/file/fs-atomic.js +0 -17
  480. package/dist/stores/file/index.d.ts +7 -12
  481. package/dist/stores/file/index.js +25 -12
  482. package/dist/stores/file/ledger-tuning.d.ts +23 -0
  483. package/dist/stores/file/ledger-tuning.js +21 -0
  484. package/dist/stores/file/mailbox-store.js +42 -22
  485. package/dist/stores/file/memory-store.js +3 -2
  486. package/dist/stores/file/permission-rule-adopt.js +24 -21
  487. package/dist/stores/file/permission-rule-store.js +6 -3
  488. package/dist/stores/file/session-policy-store.js +3 -2
  489. package/dist/stores/file/session-store.d.ts +26 -7
  490. package/dist/stores/file/session-store.js +59 -35
  491. package/dist/stores/file/tool-result-store.d.ts +11 -0
  492. package/dist/stores/file/tool-result-store.js +57 -3
  493. package/dist/stores/file/usage-window-store.js +3 -2
  494. package/dist/stores/file/workflow-journal-store.d.ts +0 -2
  495. package/dist/stores/file/workflow-journal-store.js +3 -18
  496. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  497. package/dist/stores/file/workflow-run-store.js +15 -10
  498. package/dist/tools/fs/bash-program-position.d.ts +3 -2
  499. package/dist/tools/fs/bash-program-position.js +7 -7
  500. package/dist/tools/fs/dead-cwd.d.ts +5 -5
  501. package/dist/tools/fs/dead-cwd.js +4 -11
  502. package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
  503. package/dist/tools/fs/fs-bash-background-text.js +6 -0
  504. package/dist/tools/fs/fs-bash.d.ts +3 -18
  505. package/dist/tools/fs/fs-bash.js +37 -124
  506. package/dist/tools/fs/fs-pdf.js +8 -6
  507. package/dist/tools/fs/fs-read.js +2 -2
  508. package/dist/tools/fs/fs-shared.d.ts +28 -3
  509. package/dist/tools/fs/fs-shared.js +15 -0
  510. package/dist/tools/fs/index.d.ts +1 -1
  511. package/dist/tools/fs/index.js +4 -14
  512. package/dist/tools/fs/pdf.d.ts +4 -4
  513. package/dist/tools/fs/pdf.js +6 -6
  514. package/dist/tools/fs/read-deny-home.js +8 -1
  515. package/dist/tools/fs/read-deny.d.ts +26 -2
  516. package/dist/tools/fs/read-deny.js +9 -2
  517. package/dist/tools/fs/read-floor.d.ts +13 -5
  518. package/dist/tools/fs/read-floor.js +206 -2
  519. package/dist/tools/fs/removal-targets.js +2 -2
  520. package/dist/tools/fs/search.d.ts +3 -2
  521. package/dist/tools/fs/search.js +6 -6
  522. package/dist/tools/fs/shell-read-argv.d.ts +4 -2
  523. package/dist/tools/fs/shell-read-argv.js +14 -3
  524. package/dist/tools/fs/shell-read-bindings.d.ts +18 -2
  525. package/dist/tools/fs/shell-read-bindings.js +148 -68
  526. package/dist/tools/fs/shell-read-check.js +20 -4
  527. package/dist/tools/fs/shell-read-establish.js +25 -9
  528. package/dist/tools/fs/shell-read-functions.js +2 -2
  529. package/dist/tools/fs/shell-read-identity.d.ts +3 -1
  530. package/dist/tools/fs/shell-read-identity.js +4 -2
  531. package/dist/tools/fs/shell-read-judge.d.ts +7 -1
  532. package/dist/tools/fs/shell-read-judge.js +1 -1
  533. package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
  534. package/dist/tools/fs/shell-read-object-path.js +119 -0
  535. package/dist/tools/fs/shell-read-plan.d.ts +8 -0
  536. package/dist/tools/fs/shell-read-plan.js +47 -30
  537. package/dist/tools/fs/shell-read-start.d.ts +66 -13
  538. package/dist/tools/fs/shell-read-start.js +89 -17
  539. package/dist/tools/fs/shell-read-workdir.d.ts +29 -8
  540. package/dist/tools/fs/shell-read-workdir.js +31 -8
  541. package/dist/tools/monitor.d.ts +8 -7
  542. package/dist/tools/monitor.js +12 -10
  543. package/dist/tools/worktree.d.ts +5 -1
  544. package/dist/tools/worktree.js +20 -17
  545. package/package.json +6 -3
  546. package/test/export-surface.snapshot.json +112 -42
  547. package/wire-changes/core-stores-sql@7.61.0.json +480 -0
  548. package/wire-changes/core-stores-sql@7.62.0.json +30 -0
  549. package/wire-changes/core@7.61.0.json +4405 -0
  550. package/wire-changes/core@7.62.0.json +2181 -0
  551. package/wire-changes/mods-kernel@7.61.0.json +65 -0
  552. package/wire-changes/mods-kernel@7.62.0.json +42 -0
  553. package/wire-changes/primitives@7.61.0.json +30 -0
  554. package/wire-changes/primitives@7.62.0.json +30 -0
  555. package/dist/core/consolidate-scope.d.ts +0 -93
  556. package/dist/core/consolidate-scope.js +0 -98
  557. package/dist/core/runner/image-removed-seat.d.ts +0 -12
  558. package/dist/core/runner/image-removed-seat.js +0 -19
  559. package/dist/core/runner/memory-consolidation.d.ts +0 -109
  560. package/dist/core/runner/memory-consolidation.js +0 -251
@@ -6,40 +6,43 @@ import { principalNameOf } from "../../core/principal-name.js";
6
6
  import { createPermissionRuleStoreProvider } from "../../core/permission-rule-provider.js";
7
7
  import { syncPermissionRules } from "../../core/permission-rule-sync.js";
8
8
  import { thrownText } from "../../core/thrown-value.js";
9
+ import { optionKeys, receiveMembers } from "../../core/own-property-receipt.js";
9
10
  import { FileStoreLockError } from "./fs-atomic.js";
10
11
  import { FileDurableRulePartitionProvider, LOCAL_OWNER_FILE, principalRuleFileName, readRuleAdoptionFile, writeRuleAdoptionFile, } from "./permission-rule-store.js";
12
+ const ADOPT_OPTION_KEYS = optionKeys()({ dir: 0, from: 0, toPrincipal: 0, transport: 0, now: 0, onError: 0 });
11
13
  export async function adoptFilePermissionRuleStore(opts) {
12
- if (principalNameOf(opts.toPrincipal) === undefined) {
14
+ const o = receiveMembers(opts, { subject: "adoptFilePermissionRuleStore options", unit: "option", moment: "at adoptFilePermissionRuleStore" }, ADOPT_OPTION_KEYS);
15
+ if (principalNameOf(o.toPrincipal) === undefined) {
13
16
  throw new Error("adoptFilePermissionRuleStore requires the adopting principal, a principal name — adoption is the act of giving this bucket an identity");
14
17
  }
15
- const from = readRuleOwner(opts.from);
18
+ const from = readRuleOwner(o.from);
16
19
  if (from === undefined) {
17
20
  throw new Error("adoptFilePermissionRuleStore requires a source owner — a principal owner whose principal is a principal name, or the local owner");
18
21
  }
19
- if (from.kind === "principal" && from.principal === opts.toPrincipal) {
20
- throw new Error(`the bucket already belongs to "${opts.toPrincipal}" — there is nothing to adopt`);
22
+ if (from.kind === "principal" && from.principal === o.toPrincipal) {
23
+ throw new Error(`the bucket already belongs to "${o.toPrincipal}" — there is nothing to adopt`);
21
24
  }
22
- const sourceFile = join(opts.dir, from.kind === "local-owner" ? LOCAL_OWNER_FILE : principalRuleFileName(from.principal));
23
- const targetFile = join(opts.dir, principalRuleFileName(opts.toPrincipal));
24
- const existing = readRuleAdoptionFile(opts.dir);
25
+ const sourceFile = join(o.dir, from.kind === "local-owner" ? LOCAL_OWNER_FILE : principalRuleFileName(from.principal));
26
+ const targetFile = join(o.dir, principalRuleFileName(o.toPrincipal));
27
+ const existing = readRuleAdoptionFile(o.dir);
25
28
  if (existing !== undefined) {
26
29
  if ("adopted" in existing) {
27
- if (existing.adopted.toPrincipal === opts.toPrincipal && sameRuleOwner(existing.adopted.from, from))
30
+ if (existing.adopted.toPrincipal === o.toPrincipal && sameRuleOwner(existing.adopted.from, from))
28
31
  return { status: "adopted" };
29
32
  throw new Error(`this directory already carries a completed adoption (${ruleOwnerText(existing.adopted.from)} → "${existing.adopted.toPrincipal}") — a second adoption of the same directory is not a shape this helper supports`);
30
33
  }
31
- if (existing.marker.toPrincipal !== opts.toPrincipal || !sameRuleOwner(existing.marker.from, from)) {
34
+ if (existing.marker.toPrincipal !== o.toPrincipal || !sameRuleOwner(existing.marker.from, from)) {
32
35
  throw new Error(`an adoption toward "${existing.marker.toPrincipal}" is already in flight in this directory — refusing to start a different one (resume the original, or repair the marker by hand)`);
33
36
  }
34
37
  }
35
38
  else if (existsSync(targetFile)) {
36
- throw new Error(`the target bucket for "${opts.toPrincipal}" already exists — merging two existing buckets goes through an explicit sync join, not a rename`);
39
+ throw new Error(`the target bucket for "${o.toPrincipal}" already exists — merging two existing buckets goes through an explicit sync join, not a rename`);
37
40
  }
38
- const provider = new FileDurableRulePartitionProvider(opts.dir, opts.onError);
41
+ const provider = new FileDurableRulePartitionProvider(o.dir, o.onError);
39
42
  try {
40
43
  let lockProbe;
41
44
  try {
42
- lockProbe = writerOf(provider.forPrincipal(opts.toPrincipal));
45
+ lockProbe = writerOf(provider.forPrincipal(o.toPrincipal));
43
46
  }
44
47
  catch (err) {
45
48
  if (!(err instanceof FileStoreLockError))
@@ -50,7 +53,7 @@ export async function adoptFilePermissionRuleStore(opts) {
50
53
  throw new Error("the target store refused a write face");
51
54
  let phase = existing !== undefined && "marker" in existing ? existing.marker.phase : 2;
52
55
  if (existing === undefined) {
53
- writeRuleAdoptionFile(opts.dir, marker(from, opts.toPrincipal, 2));
56
+ writeRuleAdoptionFile(o.dir, marker(from, o.toPrincipal, 2));
54
57
  phase = 2;
55
58
  }
56
59
  if (phase < 3) {
@@ -61,11 +64,11 @@ export async function adoptFilePermissionRuleStore(opts) {
61
64
  }
62
65
  if (sourcePresent)
63
66
  renameSync(sourceFile, targetFile);
64
- writeRuleAdoptionFile(opts.dir, marker(from, opts.toPrincipal, 3));
67
+ writeRuleAdoptionFile(o.dir, marker(from, o.toPrincipal, 3));
65
68
  phase = 3;
66
69
  }
67
70
  if (phase < 4) {
68
- writeRuleAdoptionFile(opts.dir, marker(from, opts.toPrincipal, 4));
71
+ writeRuleAdoptionFile(o.dir, marker(from, o.toPrincipal, 4));
69
72
  phase = 4;
70
73
  }
71
74
  let syncResult;
@@ -73,9 +76,9 @@ export async function adoptFilePermissionRuleStore(opts) {
73
76
  try {
74
77
  syncResult = await syncPermissionRules({
75
78
  provider: createPermissionRuleStoreProvider({ durable: provider }),
76
- principal: opts.toPrincipal,
77
- transport: opts.transport,
78
- ...(opts.now !== undefined ? { now: opts.now } : {}),
79
+ principal: o.toPrincipal,
80
+ transport: o.transport,
81
+ ...(o.now !== undefined ? { now: o.now } : {}),
79
82
  });
80
83
  }
81
84
  catch (err) {
@@ -88,12 +91,12 @@ export async function adoptFilePermissionRuleStore(opts) {
88
91
  error: `the first sync round did not land clean (${(syncResult.warnings ?? []).join("; ") || `${syncResult.dropped.length} drop(s)`}) — resume when the endpoint is healthy`,
89
92
  };
90
93
  }
91
- writeRuleAdoptionFile(opts.dir, marker(from, opts.toPrincipal, 5));
94
+ writeRuleAdoptionFile(o.dir, marker(from, o.toPrincipal, 5));
92
95
  phase = 5;
93
96
  }
94
- writeRuleAdoptionFile(opts.dir, {
97
+ writeRuleAdoptionFile(o.dir, {
95
98
  schemaVersion: 1,
96
- adopted: { from, toPrincipal: opts.toPrincipal, atMs: (opts.now ?? Date.now)() },
99
+ adopted: { from, toPrincipal: o.toPrincipal, atMs: (o.now ?? Date.now)() },
97
100
  });
98
101
  return { status: "adopted", ...(syncResult !== undefined ? { syncResult } : {}) };
99
102
  }
@@ -11,6 +11,7 @@ import { SESSION_RULES_GRAMMAR, readRuleGrammarStamp } from "../../core/session-
11
11
  import { canonicalize } from "../../core/canonical-json.js";
12
12
  import { BootLock, FileStoreLockError } from "./fs-atomic.js";
13
13
  import { assertAdoptionBootGate } from "./adoption/marker.js";
14
+ import { optionKeys, receiveOptions } from "../../core/own-property-receipt.js";
14
15
  import { thrownText } from "../../core/thrown-value.js";
15
16
  function isRuleFile(v) {
16
17
  const p = v;
@@ -402,6 +403,7 @@ class FileDurableRulePartition {
402
403
  }),
403
404
  };
404
405
  }
406
+ const FILE_DURABLE_RULE_PARTITION_PROVIDER_OPTION_KEYS = optionKeys()({ dataRoot: 0, platform: 0 });
405
407
  export class FileDurableRulePartitionProvider {
406
408
  dir;
407
409
  onError;
@@ -411,11 +413,12 @@ export class FileDurableRulePartitionProvider {
411
413
  constructor(dir, onError, opts) {
412
414
  this.dir = dir;
413
415
  this.onError = onError;
414
- if (opts?.dataRoot !== undefined)
415
- assertAdoptionBootGate(opts.dataRoot, "FileDurableRulePartitionProvider");
416
+ const options = receiveOptions(opts, "FileDurableRulePartitionProvider", FILE_DURABLE_RULE_PARTITION_PROVIDER_OPTION_KEYS);
417
+ if (options.dataRoot !== undefined)
418
+ assertAdoptionBootGate(options.dataRoot, "FileDurableRulePartitionProvider");
416
419
  let said = false;
417
420
  this.vetting = {
418
- platform: opts?.platform,
421
+ platform: options.platform,
419
422
  modeBitsUnjudged: (where) => {
420
423
  if (said)
421
424
  return;
@@ -4,7 +4,8 @@ import { judgeSessionRulesWrite, readMountedToolNames, readSessionRulesShape, Se
4
4
  import { atomicWriteFile, ensureDir, sanitizeScope } from "./fs-atomic.js";
5
5
  import { guardCorruptSink } from "./corrupt-read-sink.js";
6
6
  import { assertAdoptionBootGate, readRootAdoptionFile } from "./adoption/marker.js";
7
- import { receiveOptions } from "../../core/own-property-receipt.js";
7
+ import { optionKeys, receiveOptions } from "../../core/own-property-receipt.js";
8
+ const FILE_SESSION_POLICY_STORE_OPTION_KEYS = optionKeys()({ mountedToolNames: 0, onCorruptRead: 0 });
8
9
  export const SESSION_POLICY_MARK_SUFFIX = ".hwm.json";
9
10
  const MARK_SUFFIX = SESSION_POLICY_MARK_SUFFIX;
10
11
  export function readSessionPolicyMark(path) {
@@ -75,7 +76,7 @@ export class FileSessionPolicyStore {
75
76
  mountedToolNames;
76
77
  anonymousAlias;
77
78
  constructor(root, options) {
78
- const opts = receiveOptions(options, "FileSessionPolicyStore");
79
+ const opts = receiveOptions(options, "FileSessionPolicyStore", FILE_SESSION_POLICY_STORE_OPTION_KEYS);
79
80
  assertAdoptionBootGate(root, "FileSessionPolicyStore");
80
81
  this.mountedToolNames = readMountedToolNames(opts?.mountedToolNames);
81
82
  this.dir = join(root, "session-policy");
@@ -9,7 +9,8 @@ export interface FileSessionRepoOptions {
9
9
  *
10
10
  * Fires for: an unreadable sessions DIRECTORY (the listing degrades to "no sessions"), a session log
11
11
  * whose header could not be read during a listing (skipped from the result — a listing reads headers,
12
- * it never replays a log), and each corrupt interior JSONL record dropped on replay plus that replay's
12
+ * it never replays a log; a PLACED row whose owner cell alone is unreadable is not skipped — the placed listing lists it — and is
13
+ * disclosed as that), and each corrupt interior JSONL record dropped on replay plus that replay's
13
14
  * tally (turns missing from an otherwise healthy session).
14
15
  *
15
16
  * Never fires on plain ENOENT / `not_found` — that is honest absence, and the torn TAIL stays silent
@@ -41,7 +42,7 @@ export declare class FileSessionRepo implements SessionRepo {
41
42
  * file whose first record is not a meta header → `corrupt_session`, even when every other record is intact
42
43
  * (every write path here lays the header down first and the header alone carries `createdAt` / fork /
43
44
  * placement / owner, so the file is not a session this store wrote, or its header line is damaged);
44
- * otherwise the session, each skipped record disclosed.
45
+ * otherwise the session, each skipped record disclosed, and `loss` = what the replay dropped (absent = nothing).
45
46
  */
46
47
  private read;
47
48
  /**
@@ -51,6 +52,16 @@ export declare class FileSessionRepo implements SessionRepo {
51
52
  * the row). `skipped` words the corrupt-header refusal's reading of the records around it, where the caller has one.
52
53
  */
53
54
  private headerOf;
55
+ /** The header's cells but its owner — what a reader of the row's lane, lineage and occupant needs, each cell through its decoder. */
56
+ private cellsOf;
57
+ /**
58
+ * The row's header record, where the log has one: its FIRST record, which must be the meta header every write path lays down. A log whose
59
+ * first record is anything else is no row this store wrote — `corrupt_session`, said once here for every reader of the row — and so is one
60
+ * whose placement cell is no placement tuple ({@link readPlacementCell}): the placement is the cell that says which lane the row lives
61
+ * in, so every reader of the row, of any other cell, goes through its judge. The other cells are each read by their own reader
62
+ * ({@link headerOf} for the whole header, `placementOf` for the placement tuple alone): a reader of one cell does not answer for the others.
63
+ */
64
+ private metaLineOf;
54
65
  /**
55
66
  * The row's head in one read, without replaying the log: ONE descriptor on the session file, its first record for the owner and
56
67
  * occupant cells, and walking back from its end to the last entry record for the leaf. The three come from one inode — a file
@@ -70,12 +81,17 @@ export declare class FileSessionRepo implements SessionRepo {
70
81
  /**
71
82
  * The row's {@link SessionRow} — its header cells and the newest write it holds, the log's modification time (every write to a row
72
83
  * is an append to its log; the placed listing's age reads the same time) — in one read of the header, never a replay of the log.
73
- * `undefined` = no row; a row whose header cannot be read rejects (`corrupt_session`).
84
+ * `undefined` = no row; a row whose header cannot be read rejects (`corrupt_session`) — except a PLACED row whose only unreadable cell
85
+ * is the owner's, which is {@link OwnerlessPlacedRow}: a listing asks where a row lives and how old it is, not who owns it.
74
86
  */
75
87
  private rowOf;
76
- /** The one descriptor a by-id read of the row takes: its size and modification time and its header, from one inode (a file replaced
77
- * or removed while this reads is still the inode this descriptor opened); `undefined` = no file. */
88
+ /** The one descriptor a by-id read of the row takes: its size and modification time and its header decoded whole, from one inode (a
89
+ * file replaced or removed while this reads is still the inode this descriptor opened); `undefined` = no file. A reader of one cell
90
+ * alone takes {@link atFirstRecord}, which this is built on. */
78
91
  private atRow;
92
+ /** The descriptor under every by-id header read: the file's size and modification time and its first record, undecoded — the bytes
93
+ * each cell's reader decodes. One inode, bounded by the lines before the first record, never by the log; `undefined` = no file. */
94
+ private atFirstRecord;
79
95
  private storage;
80
96
  /**
81
97
  * RB-437 — release every shared authority this repo joined (LAST holder ⇒ evict + close the append fd).
@@ -103,7 +119,8 @@ export declare class FileSessionRepo implements SessionRepo {
103
119
  * browse face never throws — but "I could not read the directory" and "there are none" are different facts, and only the sink can
104
120
  * tell them apart (ENOENT is honest absence: the constructor creates the directory, so it was removed underneath us). A session
105
121
  * whose header cannot be read is skipped and disclosed — it exists and is missing from the listing — while a file that vanished
106
- * between the directory read and its own is honest absence.
122
+ * between the directory read and its own is honest absence. A placed row whose owner alone is unreadable is neither skipped nor
123
+ * silent: it is kept (the placed listing lists it) and disclosed, once per listing, in the same sentence whichever listing reads it.
107
124
  */
108
125
  private rows;
109
126
  /**
@@ -119,7 +136,9 @@ export declare class FileSessionRepo implements SessionRepo {
119
136
  scope?: string;
120
137
  }): Promise<PlacedSessionRow[]>;
121
138
  /** Cheap placement probe for one id (the TtlSessionStore's cold-cache release consults it so the
122
- * placed real-deletion obligation holds after a restart). `undefined` = missing file OR unplaced; a row that cannot be read rejects. */
139
+ * placed real-deletion obligation holds after a restart), answered from the row's header record alone — never a replay of its log —
140
+ * and from the placement cell alone: a row whose owner cell cannot be read still says whether it is placed (the readers of the owner
141
+ * refuse that row; this probe is not one of them). `undefined` = missing file OR unplaced; a log with no header record rejects. */
123
142
  placementOf(sessionId: string): Promise<SessionPlacementRecord | undefined>;
124
143
  delete(metadata: SessionMetadata, expect?: SessionRowExpectation): Promise<void>;
125
144
  fork(sourceMetadata: SessionMetadata, options?: SessionForkOptions & SessionCreateOptions): Promise<Session>;
@@ -1,10 +1,10 @@
1
1
  import { closeSync, existsSync, fstatSync, openSync, readdirSync, rmSync, utimesSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { BaseSessionStorage, StoredSession, SessionError, assertForkTarget, compareOccupants, forkRowCells, frozenRow, getEntriesToFork, importRowCells, incarnationCell, leafIdAfterEntry, ownerCell, readIncarnationCell, readOwnerCell, resolveLeafId, rowExpectationMissed, sessionLogMarkOf, sessionRowMatches, uuidv7, validateEntriesForImport, } from "../../internal/harness.js";
3
+ import { BaseSessionStorage, StoredSession, SessionError, assertForkTarget, compareOccupants, forkRowCells, frozenRow, getEntriesToFork, importRowCells, incarnationCell, leafIdAfterEntry, ownerCell, placementCellToWrite, readIncarnationCell, readOwnerCell, readPlacementCell, replayLossText, resolveLeafId, rowExpectationMissed, sessionLogMarkOf, sessionRowMatches, uuidv7, validateEntriesForImport, } from "../../internal/harness.js";
4
4
  import { canonicalStoreKey, AppendLog, atomicWriteFile, ensureDir, firstJsonlRecord, lastJsonlRecord, readJsonlRecords, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
5
5
  import { guardCorruptSink } from "./corrupt-read-sink.js";
6
6
  import { assertAdoptionBootGate } from "./adoption/marker.js";
7
- import { receiveOptions } from "../../core/own-property-receipt.js";
7
+ import { optionKeys, receiveOptions } from "../../core/own-property-receipt.js";
8
8
  import { thrownText } from "../../core/thrown-value.js";
9
9
  const SUFFIX = ".jsonl";
10
10
  const SESSION_LINE_JUDGE = {
@@ -38,8 +38,8 @@ class FileSessionStorage extends BaseSessionStorage {
38
38
  canonicalPath;
39
39
  holders = new Set();
40
40
  occupant;
41
- constructor(log, meta, entries, canonicalPath) {
42
- super(meta, entries);
41
+ constructor(log, meta, entries, canonicalPath, replayLoss) {
42
+ super(meta, entries, undefined, replayLoss !== undefined ? { replayLoss } : undefined);
43
43
  this.log = log;
44
44
  this.canonicalPath = canonicalPath;
45
45
  this.occupant = { incarnation: meta.incarnation };
@@ -72,13 +72,14 @@ class FileSessionStorage extends BaseSessionStorage {
72
72
  this.recordEntry(entry);
73
73
  }
74
74
  }
75
+ const FILE_SESSION_REPO_OPTION_KEYS = optionKeys()({ onCorruptRead: 0 });
75
76
  export class FileSessionRepo {
76
77
  dir;
77
78
  tmpDir;
78
79
  onCorruptRead;
79
80
  joined = new Map();
80
81
  constructor(root, options) {
81
- const opts = receiveOptions(options, "FileSessionRepo");
82
+ const opts = receiveOptions(options, "FileSessionRepo", FILE_SESSION_REPO_OPTION_KEYS);
82
83
  assertAdoptionBootGate(root, "FileSessionRepo");
83
84
  this.dir = join(root, "sessions");
84
85
  this.tmpDir = join(root, "tmp");
@@ -103,29 +104,38 @@ export class FileSessionRepo {
103
104
  tally = info;
104
105
  this.onCorruptRead?.({ ...info, sessionId: id });
105
106
  }, SESSION_LINE_JUDGE);
106
- const meta = this.headerOf(id, path, lines[0], () => ` (${tally?.dropped ?? 0} of ${tally?.total ?? lines.length} records skipped as corrupt)`);
107
+ const loss = tally !== undefined ? { dropped: tally.dropped, total: tally.total } : undefined;
108
+ const meta = this.headerOf(id, path, lines[0], () => ` (${replayLossText(loss ?? { dropped: 0, total: lines.length })})`);
107
109
  const entries = [];
108
110
  for (const line of lines)
109
111
  if (line.kind === "entry")
110
112
  entries.push(line.entry);
111
- return { meta, entries };
113
+ return { meta, entries, ...(loss !== undefined ? { loss } : {}) };
112
114
  }
113
115
  headerOf(id, path, first, skipped = () => "") {
114
- if (first === undefined || first.kind !== "meta")
115
- throw new SessionError("corrupt_session", `Session ${id} is unreadable: its log has no meta header${skipped()}`);
116
+ const head = this.metaLineOf(id, first, skipped);
117
+ return { ...this.cellsOf(id, path, head), owner: readOwnerCell(head.owner, id) };
118
+ }
119
+ cellsOf(id, path, head) {
116
120
  const said = (key) => (detail) => this.disclose(path, `session header ${key}: ${detail}`, id);
117
- const incarnation = readIncarnationCell(first.incarnation, said("incarnation"));
118
- const forkedFromIncarnation = readIncarnationCell(first.forkedFromIncarnation, said("forkedFromIncarnation"));
121
+ const incarnation = readIncarnationCell(head.incarnation, said("incarnation"));
122
+ const forkedFromIncarnation = readIncarnationCell(head.forkedFromIncarnation, said("forkedFromIncarnation"));
119
123
  return {
120
124
  id,
121
- createdAt: first.createdAt,
122
- ...(first.forkedFrom !== undefined ? { forkedFrom: first.forkedFrom } : {}),
123
- ...(first.placement !== undefined ? { placement: first.placement } : {}),
125
+ createdAt: head.createdAt,
126
+ ...(head.forkedFrom !== undefined ? { forkedFrom: head.forkedFrom } : {}),
127
+ ...(head.placement !== undefined ? { placement: head.placement } : {}),
124
128
  ...(incarnation !== undefined ? { incarnation } : {}),
125
129
  ...(forkedFromIncarnation !== undefined ? { forkedFromIncarnation } : {}),
126
- owner: readOwnerCell(first.owner, id),
127
130
  };
128
131
  }
132
+ metaLineOf(id, first, skipped = () => "") {
133
+ if (first === undefined || first.kind !== "meta")
134
+ throw new SessionError("corrupt_session", `Session ${id} is unreadable: its log has no meta header${skipped()}`);
135
+ const { placement: raw, ...cells } = first;
136
+ const placement = readPlacementCell(raw, id);
137
+ return { ...cells, ...(placement !== undefined ? { placement } : {}) };
138
+ }
129
139
  async headOf(sessionId) {
130
140
  return this.headNow(sessionId);
131
141
  }
@@ -152,13 +162,31 @@ export class FileSessionRepo {
152
162
  return { metadata: meta, head: { owner: meta.owner ?? null, incarnation: meta.incarnation, leafId: resolveLeafId(entries) }, entries };
153
163
  }
154
164
  rowOf(sessionId) {
155
- return this.atRow(sessionId, (_fd, _size, meta, mtimeMs) => ({ ...meta, lastActiveAt: Math.trunc(mtimeMs) }));
165
+ const path = this.pathFor(sessionId);
166
+ return this.atFirstRecord(sessionId, (_fd, _size, first, mtimeMs) => {
167
+ const head = this.metaLineOf(sessionId, first);
168
+ const cells = this.cellsOf(sessionId, path, head);
169
+ const lastActiveAt = Math.trunc(mtimeMs);
170
+ let owner;
171
+ try {
172
+ owner = readOwnerCell(head.owner, sessionId);
173
+ }
174
+ catch (err) {
175
+ if (head.placement === undefined || !(err instanceof SessionError))
176
+ throw err;
177
+ return { id: sessionId, placement: head.placement, lastActiveAt, ownerFault: thrownText(err) };
178
+ }
179
+ return { ...cells, owner, lastActiveAt };
180
+ });
156
181
  }
157
182
  atRow(sessionId, read) {
158
183
  const path = this.pathFor(sessionId);
184
+ return this.atFirstRecord(sessionId, (fd, size, first, mtimeMs) => read(fd, size, this.headerOf(sessionId, path, first), mtimeMs));
185
+ }
186
+ atFirstRecord(sessionId, read) {
159
187
  let fd;
160
188
  try {
161
- fd = openSync(path, "r");
189
+ fd = openSync(this.pathFor(sessionId), "r");
162
190
  }
163
191
  catch (err) {
164
192
  if (err.code === "ENOENT")
@@ -167,13 +195,13 @@ export class FileSessionRepo {
167
195
  }
168
196
  try {
169
197
  const { size, mtimeMs } = fstatSync(fd);
170
- return read(fd, size, this.headerOf(sessionId, path, firstJsonlRecord(fd, size, SESSION_LINE_JUDGE)), mtimeMs);
198
+ return read(fd, size, firstJsonlRecord(fd, size, SESSION_LINE_JUDGE), mtimeMs);
171
199
  }
172
200
  finally {
173
201
  closeSync(fd);
174
202
  }
175
203
  }
176
- storage(meta, entries) {
204
+ storage(meta, entries, loss) {
177
205
  const { id } = meta;
178
206
  const canonical = canonicalStoreKey(this.pathFor(id));
179
207
  const live = sharedSessionStorages.get(canonical)?.deref();
@@ -185,7 +213,7 @@ export class FileSessionRepo {
185
213
  if (live !== undefined)
186
214
  evictSharedSessionStorage(canonical);
187
215
  const log = new AppendLog(this.pathFor(id));
188
- const created = new FileSessionStorage(log, frozenRow({ ...meta, ...(meta.placement !== undefined ? { placement: { ...meta.placement } } : {}) }), entries, canonical);
216
+ const created = new FileSessionStorage(log, frozenRow({ ...meta, ...(meta.placement !== undefined ? { placement: { ...meta.placement } } : {}) }), entries, canonical, loss);
189
217
  sharedSessionStorages.set(canonical, new WeakRef(created));
190
218
  created.addHolder(this);
191
219
  this.joined.set(canonical, new WeakRef(created));
@@ -210,7 +238,7 @@ export class FileSessionRepo {
210
238
  const path = this.pathFor(id);
211
239
  if (!existsSync(path)) {
212
240
  const owner = ownerCell(options.owner);
213
- const placement = options.placement !== undefined ? { ...options.placement, placedAt: options.placement.placedAt ?? Date.now() } : undefined;
241
+ const placement = placementCellToWrite(options.placement, id, Date.now());
214
242
  const meta = { id, createdAt, ...(placement !== undefined ? { placement } : {}), ...incarnationCell(undefined), ...owner };
215
243
  try {
216
244
  writeThenLink(path, `${JSON.stringify({ kind: "meta", ...meta })}\n`);
@@ -222,12 +250,12 @@ export class FileSessionRepo {
222
250
  }
223
251
  return new StoredSession(this.storage(meta, []));
224
252
  }
225
- const { meta, entries } = this.read(id);
226
- return new StoredSession(this.storage({ ...meta, createdAt: meta.createdAt || createdAt }, entries));
253
+ const { meta, entries, loss } = this.read(id);
254
+ return new StoredSession(this.storage({ ...meta, createdAt: meta.createdAt || createdAt }, entries, loss));
227
255
  }
228
256
  async open(metadata) {
229
- const { meta, entries } = this.read(metadata.id);
230
- return new StoredSession(this.storage(meta, entries));
257
+ const { meta, entries, loss } = this.read(metadata.id);
258
+ return new StoredSession(this.storage(meta, entries, loss));
231
259
  }
232
260
  async touch(sessionId) {
233
261
  const now = new Date();
@@ -269,8 +297,11 @@ export class FileSessionRepo {
269
297
  this.disclose(this.pathFor(id), `session log unreadable (${thrownText(err)}) — skipped from ${listing}`, id);
270
298
  continue;
271
299
  }
272
- if (row !== undefined)
273
- out.push(row);
300
+ if (row === undefined)
301
+ continue;
302
+ if ("ownerFault" in row)
303
+ this.disclose(this.pathFor(id), `session log is a placed row whose owner cell is unreadable (${row.ownerFault}) — the placed listing lists it, the host listing never does`, id);
304
+ out.push(row);
274
305
  }
275
306
  return out;
276
307
  }
@@ -292,14 +323,7 @@ export class FileSessionRepo {
292
323
  return out;
293
324
  }
294
325
  async placementOf(sessionId) {
295
- try {
296
- return this.read(sessionId).meta.placement;
297
- }
298
- catch (err) {
299
- if (err instanceof SessionError && err.code === "not_found")
300
- return undefined;
301
- throw err;
302
- }
326
+ return this.atFirstRecord(sessionId, (_fd, _size, first) => this.metaLineOf(sessionId, first).placement);
303
327
  }
304
328
  async delete(metadata, expect) {
305
329
  if (expect !== undefined && !sessionRowMatches(expect, this.headNow(metadata.id), () => sessionLogMarkOf(this.read(metadata.id).entries)))
@@ -105,6 +105,17 @@ export declare class FileToolResultStore implements ToolResultStore {
105
105
  * even with a damaged owner record, so removing one on a guess would destroy another session's output.
106
106
  */
107
107
  deleteBySession(sessionId: string): ToolResultDeletionReport;
108
+ /**
109
+ * Age out the entries stored more than `maxAgeMs` before `now` (interface: {@link ToolResultStore.reap}). An entry's
110
+ * age is its content file's modification time: the write-once publication sets it and nothing rewrites the file.
111
+ * Both namespaces are swept, and only names this store writes are judged. Removal is content then owner record, the order {@link deleteBySession} keeps; an owner
112
+ * record whose content is already gone — the leftover of an interrupted pass, or of a session sweep — is removed
113
+ * once it is past the cutoff too, and is not counted (it was not an entry). Synchronous: under the data root's single
114
+ * writer nothing interleaves with it.
115
+ */
116
+ reap(now: number, opts?: {
117
+ maxAgeMs?: number;
118
+ }): number;
108
119
  /**
109
120
  * The entries `sessionId` owns, as ref + recorded owner (interface: {@link ToolResultStore.listBySession}). The selection is
110
121
  * {@link deleteBySession}'s own: it walks the same two namespaces and matches on the SIDECAR's `sessionId`, never on a file name; a
@@ -1,16 +1,18 @@
1
1
  import { createHash } from "node:crypto";
2
- import { readFileSync, readdirSync, unlinkSync } from "node:fs";
2
+ import { readFileSync, readdirSync, statSync, unlinkSync } from "node:fs";
3
3
  import { join } from "node:path";
4
+ import { ageCutoff } from "../../core/retention-policy.js";
4
5
  import { assertSafeToolResultRef, assertToolResultProvenanceMatch, normalizeToolResultProvenance, ToolResultRefConflictError, } from "../../core/tool-result-store.js";
5
6
  import { ensureDir, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
6
7
  import { guardCorruptSink } from "./corrupt-read-sink.js";
7
8
  import { assertAdoptionBootGate } from "./adoption/marker.js";
8
- import { receiveOptions } from "../../core/own-property-receipt.js";
9
+ import { optionKeys, receiveOptions } from "../../core/own-property-receipt.js";
10
+ const FILE_TOOL_RESULT_STORE_OPTION_KEYS = optionKeys()({ onCorruptRead: 0 });
9
11
  export class FileToolResultStore {
10
12
  dir;
11
13
  discloseCorrupt;
12
14
  constructor(root, options) {
13
- const opts = receiveOptions(options, "FileToolResultStore");
15
+ const opts = receiveOptions(options, "FileToolResultStore", FILE_TOOL_RESULT_STORE_OPTION_KEYS);
14
16
  assertAdoptionBootGate(root, "FileToolResultStore");
15
17
  this.dir = join(root, "tool-results");
16
18
  this.discloseCorrupt = guardCorruptSink(opts?.onCorruptRead);
@@ -181,6 +183,44 @@ export class FileToolResultStore {
181
183
  }
182
184
  return { deleted, unattributable };
183
185
  }
186
+ reap(now, opts) {
187
+ const cutoff = ageCutoff("FileToolResultStore.reap", now, opts);
188
+ if (cutoff === undefined)
189
+ return 0;
190
+ let removed = 0;
191
+ for (const [dir, folded] of [[this.dir, false], [join(this.dir, FOLDED_SUBDIR), true]]) {
192
+ let names;
193
+ try {
194
+ names = readdirSync(dir);
195
+ }
196
+ catch (err) {
197
+ if (err.code === "ENOENT")
198
+ continue;
199
+ throw err;
200
+ }
201
+ const listed = new Set(names);
202
+ for (const name of names) {
203
+ const content = name.endsWith(CONTENT_SUFFIX);
204
+ if (!content && !name.endsWith(OWNER_SUFFIX))
205
+ continue;
206
+ const stem = name.slice(0, -(content ? CONTENT_SUFFIX : OWNER_SUFFIX).length);
207
+ if (!isEncodedStem(stem, folded))
208
+ continue;
209
+ if (!content && listed.has(`${stem}${CONTENT_SUFFIX}`))
210
+ continue;
211
+ const path = join(dir, name);
212
+ const modified = modifiedAt(path);
213
+ if (modified === undefined || modified >= cutoff)
214
+ continue;
215
+ unlinkIfAbsentOk(path);
216
+ if (content) {
217
+ unlinkIfAbsentOk(join(dir, `${stem}${OWNER_SUFFIX}`));
218
+ removed++;
219
+ }
220
+ }
221
+ }
222
+ return removed;
223
+ }
184
224
  listBySession(sessionId) {
185
225
  const entries = [];
186
226
  let unattributable = 0;
@@ -277,6 +317,16 @@ function readOwnerAt(path) {
277
317
  const read = readOwnerFileAt(path);
278
318
  return typeof read === "string" ? read : read.provenance;
279
319
  }
320
+ function modifiedAt(path) {
321
+ try {
322
+ return statSync(path).mtimeMs;
323
+ }
324
+ catch (err) {
325
+ if (err.code === "ENOENT")
326
+ return undefined;
327
+ throw err;
328
+ }
329
+ }
280
330
  function unlinkIfAbsentOk(path) {
281
331
  try {
282
332
  unlinkSync(path);
@@ -295,6 +345,10 @@ function encodeRefFilename(ref) {
295
345
  const base = ref.replace(/[^A-Za-z0-9_.-]/g, "-").slice(0, 64);
296
346
  return { folded: true, stem: `${base || "ref"}-${createHash("sha256").update(Buffer.from(ref, "utf16le")).digest("hex")}` };
297
347
  }
348
+ const FOLDED_STEM = /^[A-Za-z0-9_.-]{1,64}-[0-9a-f]{64}$/;
349
+ function isEncodedStem(stem, folded) {
350
+ return folded ? FOLDED_STEM.test(stem) : stem.length <= MAX_FILENAME_CHARS && NATIVE_FILENAME_CHARSET.test(stem);
351
+ }
298
352
  function intOr(x, fallback) {
299
353
  return Number.isFinite(x) ? Math.floor(x) : fallback;
300
354
  }
@@ -3,13 +3,14 @@ import { join } from "node:path";
3
3
  import { chargeUsageRecord, readUsageRecord, EMPTY_USAGE_WINDOW_RECORD, } from "../../core/usage-window-store.js";
4
4
  import { atomicWriteFile, ensureDir, sanitizeScope } from "./fs-atomic.js";
5
5
  import { assertAdoptionBootGate } from "./adoption/marker.js";
6
- import { receiveOptions } from "../../core/own-property-receipt.js";
6
+ import { optionKeys, receiveOptions } from "../../core/own-property-receipt.js";
7
7
  import { guardCorruptSink } from "./corrupt-read-sink.js";
8
+ const FILE_USAGE_WINDOW_STORE_OPTION_KEYS = optionKeys()({ onCorruptRead: 0 });
8
9
  export class FileUsageWindowStore {
9
10
  dir;
10
11
  onCorruptRead;
11
12
  constructor(root, options) {
12
- const opts = receiveOptions(options, "FileUsageWindowStore");
13
+ const opts = receiveOptions(options, "FileUsageWindowStore", FILE_USAGE_WINDOW_STORE_OPTION_KEYS);
13
14
  assertAdoptionBootGate(root, "FileUsageWindowStore");
14
15
  this.dir = join(root, "usage-windows");
15
16
  ensureDir(this.dir);
@@ -126,8 +126,6 @@ export declare class FileWorkflowJournalStore implements WorkflowJournalStore {
126
126
  /** RB-242 — release ONLY a claim this `newRunId` still holds. A claim that is already gone (TTL-reaped
127
127
  * and possibly taken over) is a no-op: unlinking a successor's claim would re-open the very fork this prevents. */
128
128
  releaseResumeClaim(input: ResumeClaimArgs): Promise<void>;
129
- /** GC (service extra, mirrors the SQL twins): drop the run's ledger once the run is terminal + retained. */
130
- deleteByRun(runId: string): Promise<number>;
131
129
  /** Release ledger fds (graceful shutdown; parity with the other file stores' dispose).
132
130
  * Refcounted: the fds are shared with any other instance on the same directory, so the LAST holder
133
131
  * closes them. Idempotent — a second dispose() on the same instance must not decrement twice and pull
@@ -6,7 +6,7 @@ import { AppendLog, readJsonlRecords } from "./fs-atomic.js";
6
6
  import { guardCorruptSink } from "./corrupt-read-sink.js";
7
7
  import { canonicalStoreKey, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
8
8
  import { assertAdoptionBootGate } from "./adoption/marker.js";
9
- import { receiveOptions } from "../../core/own-property-receipt.js";
9
+ import { optionKeys, receiveOptions } from "../../core/own-property-receipt.js";
10
10
  import { assertJournalEntryFits } from "../../core/workflow-journal-store.js";
11
11
  export const RESUME_CLAIM_TTL_MS = 60 * 60 * 1000;
12
12
  export const RESUME_CLAIM_RELEASE_GRACE_MS = 5_000;
@@ -18,6 +18,7 @@ function isJournalLine(r) {
18
18
  const rec = r;
19
19
  return typeof rec.scope === "string" && Number.isFinite(rec.ordinal);
20
20
  }
21
+ const FILE_WORKFLOW_JOURNAL_STORE_OPTION_KEYS = optionKeys()({ onCorruptRead: 0 });
21
22
  export class FileWorkflowJournalStore {
22
23
  fsyncEnabled;
23
24
  dir;
@@ -35,7 +36,7 @@ export class FileWorkflowJournalStore {
35
36
  discloseCorrupt;
36
37
  constructor(root, fsyncEnabled = true, options) {
37
38
  this.fsyncEnabled = fsyncEnabled;
38
- const opts = receiveOptions(options, "FileWorkflowJournalStore");
39
+ const opts = receiveOptions(options, "FileWorkflowJournalStore", FILE_WORKFLOW_JOURNAL_STORE_OPTION_KEYS);
39
40
  this.discloseCorrupt = guardCorruptSink(opts?.onCorruptRead);
40
41
  assertAdoptionBootGate(root, "FileWorkflowJournalStore");
41
42
  this.dir = join(root, "workflow-journal");
@@ -259,22 +260,6 @@ export class FileWorkflowJournalStore {
259
260
  return;
260
261
  this.unlinkIfUnchanged(path, existing.raw);
261
262
  }
262
- async deleteByRun(runId) {
263
- const log = this.logs.get(runId);
264
- if (log !== undefined) {
265
- try {
266
- log.close();
267
- }
268
- catch { }
269
- this.logs.delete(runId);
270
- }
271
- this.scopes.delete(runId);
272
- const path = this.pathFor(runId);
273
- if (!existsSync(path))
274
- return 0;
275
- unlinkSync(path);
276
- return 1;
277
- }
278
263
  dispose() {
279
264
  if (this.closed)
280
265
  return;
@@ -17,7 +17,7 @@ export declare class FileWorkflowRunStore implements WorkflowRunStore {
17
17
  /** RB-145: this instance's own close latch — the refcount belongs to the DIRECTORY, not to callers. */
18
18
  private closed;
19
19
  private get runs();
20
- constructor(root: string, opts?: FileWorkflowRunStoreOptions);
20
+ constructor(root: string, options?: FileWorkflowRunStoreOptions);
21
21
  /** Serialize an op behind any in-flight op on the same id (the in-process per-id async mutex). */
22
22
  private withLock;
23
23
  /** Commit one ledger event (append + fsync) THEN flip the in-memory map (crash-safe ordering), then