@sema-agent/core 7.72.0 → 7.74.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 (375) hide show
  1. package/CHANGELOG.md +565 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/list-agents-tool.js +1 -1
  5. package/dist/agents/parked-resume-drive.d.ts +10 -0
  6. package/dist/agents/parked-resume-drive.js +9 -0
  7. package/dist/agents/retain-ledger.d.ts +3 -0
  8. package/dist/agents/retain-ledger.js +3 -3
  9. package/dist/agents/send-message-tool.js +5 -4
  10. package/dist/agents/send-user-message-tool.d.ts +12 -0
  11. package/dist/agents/send-user-message-tool.js +67 -0
  12. package/dist/agents/subagent-steps.d.ts +9 -0
  13. package/dist/agents/subagent-steps.js +38 -0
  14. package/dist/agents/subagent.d.ts +2 -0
  15. package/dist/agents/subagent.js +43 -12
  16. package/dist/agents/verify.js +23 -8
  17. package/dist/agents/yield-adoption.js +3 -1
  18. package/dist/brain/anthropic.d.ts +42 -1
  19. package/dist/brain/anthropic.js +68 -13
  20. package/dist/brain/failover.d.ts +5 -0
  21. package/dist/brain/failover.js +51 -22
  22. package/dist/brain/model-lane.d.ts +12 -3
  23. package/dist/brain/model-lane.js +5 -5
  24. package/dist/brain/open-responses.js +7 -8
  25. package/dist/brain/openai.js +31 -24
  26. package/dist/brain/route-adjudicator.d.ts +33 -4
  27. package/dist/brain/route-adjudicator.js +49 -12
  28. package/dist/brain/stream-engine.js +166 -156
  29. package/dist/brain/stream-shared.d.ts +4 -3
  30. package/dist/brain/stream-shared.js +2 -2
  31. package/dist/core/actions-digest.d.ts +43 -0
  32. package/dist/core/actions-digest.js +22 -0
  33. package/dist/core/allow-entry.js +4 -4
  34. package/dist/core/ask-class.d.ts +2 -2
  35. package/dist/core/ask-headline.d.ts +1 -1
  36. package/dist/core/ask-origin.d.ts +44 -4
  37. package/dist/core/ask-origin.js +29 -10
  38. package/dist/core/auto-mode.d.ts +7 -9
  39. package/dist/core/auto-mode.js +114 -8
  40. package/dist/core/background-agent-store.d.ts +1 -0
  41. package/dist/core/background-agent-store.js +49 -8
  42. package/dist/core/checkpoint-features.d.ts +3 -2
  43. package/dist/core/checkpoint-features.js +1 -1
  44. package/dist/core/checkpoint-rekey.d.ts +1 -1
  45. package/dist/core/checkpoint-rekey.js +6 -1
  46. package/dist/core/checkpoint-requirements.d.ts +23 -3
  47. package/dist/core/checkpoint-requirements.js +5 -1
  48. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  49. package/dist/core/checkpoint-row-verdict.js +9 -3
  50. package/dist/core/checkpoint-store.d.ts +26 -2
  51. package/dist/core/checkpoint-store.js +9 -2
  52. package/dist/core/child-clamp-seats.d.ts +15 -0
  53. package/dist/core/child-clamp-seats.js +15 -0
  54. package/dist/core/config-refusal-codes.d.ts +1 -1
  55. package/dist/core/config-refusal-codes.js +1 -0
  56. package/dist/core/cron.js +9 -1
  57. package/dist/core/delegation-frames.d.ts +1 -0
  58. package/dist/core/delegation-frames.js +1 -1
  59. package/dist/core/deployment-shape.d.ts +7 -0
  60. package/dist/core/deployment-shape.js +19 -0
  61. package/dist/core/engine-capabilities.d.ts +13 -1
  62. package/dist/core/engine-capabilities.js +1 -1
  63. package/dist/core/engine-notice.d.ts +41 -28
  64. package/dist/core/engine-version.js +1 -1
  65. package/dist/core/entries-not-applied.d.ts +19 -7
  66. package/dist/core/entries-not-applied.js +33 -1
  67. package/dist/core/gate-fold.js +5 -4
  68. package/dist/core/gate-lanes.js +8 -12
  69. package/dist/core/gate-outcome.d.ts +8 -2
  70. package/dist/core/gate-outcome.js +10 -3
  71. package/dist/core/governance-codes.d.ts +14 -2
  72. package/dist/core/governance-codes.js +22 -6
  73. package/dist/core/hook-condition.d.ts +37 -0
  74. package/dist/core/hook-condition.js +567 -0
  75. package/dist/core/hooks.d.ts +5 -0
  76. package/dist/core/hooks.js +1 -0
  77. package/dist/core/host-instance.d.ts +23 -0
  78. package/dist/core/host-instance.js +69 -0
  79. package/dist/core/instruction-preview.d.ts +63 -0
  80. package/dist/core/instruction-preview.js +406 -0
  81. package/dist/core/leg-budget.d.ts +26 -0
  82. package/dist/core/leg-budget.js +9 -0
  83. package/dist/core/leg-identity.d.ts +51 -1
  84. package/dist/core/leg-identity.js +45 -2
  85. package/dist/core/manager-launch-check.d.ts +48 -0
  86. package/dist/core/manager-launch-check.js +64 -0
  87. package/dist/core/mcp-call-meta.d.ts +2 -2
  88. package/dist/core/mcp-injection-drop.d.ts +20 -10
  89. package/dist/core/mcp-injection-drop.js +9 -3
  90. package/dist/core/mcp-server-spec.d.ts +2 -1
  91. package/dist/core/member-outcome.d.ts +3 -2
  92. package/dist/core/member-outcome.js +1 -1
  93. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  94. package/dist/core/memory-engine/deletion-record.js +96 -0
  95. package/dist/core/memory-engine/engine.js +24 -16
  96. package/dist/core/memory-engine/file-backend.js +7 -5
  97. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  98. package/dist/core/memory-engine/projection-ledger.js +1 -1
  99. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  100. package/dist/core/memory-engine/scope-contract.js +18 -18
  101. package/dist/core/memory-engine/sync-client.js +26 -6
  102. package/dist/core/memory-engine/sync.d.ts +20 -2
  103. package/dist/core/memory-engine/sync.js +18 -17
  104. package/dist/core/mode-policy.d.ts +25 -6
  105. package/dist/core/mode-policy.js +33 -8
  106. package/dist/core/model-seat.d.ts +8 -5
  107. package/dist/core/model-shell.d.ts +129 -0
  108. package/dist/core/model-shell.js +249 -0
  109. package/dist/core/mods/kernel/digest.d.ts +4 -0
  110. package/dist/core/mods/kernel/digest.js +5 -0
  111. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  112. package/dist/core/mods/kernel/dispatch.js +15 -6
  113. package/dist/core/mods/kernel/events.d.ts +21 -5
  114. package/dist/core/mods/kernel/events.js +19 -10
  115. package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
  116. package/dist/core/mods/kernel/hash-mirror.js +55 -0
  117. package/dist/core/mods/kernel/index.d.ts +1 -0
  118. package/dist/core/mods/kernel/index.js +1 -0
  119. package/dist/core/mods/kernel/package-reader.d.ts +48 -0
  120. package/dist/core/mods/kernel/package-reader.js +149 -0
  121. package/dist/core/mods/kernel/site-rules.d.ts +4 -0
  122. package/dist/core/mods/kernel/site-rules.js +13 -0
  123. package/dist/core/mods/package.d.ts +7 -3
  124. package/dist/core/mods/package.js +47 -80
  125. package/dist/core/own-property-receipt.js +11 -4
  126. package/dist/core/parent-spec-seat.d.ts +13 -11
  127. package/dist/core/parent-spec-seat.js +13 -9
  128. package/dist/core/peer-seat.js +3 -3
  129. package/dist/core/peer-task-store.d.ts +365 -0
  130. package/dist/core/peer-task-store.js +682 -0
  131. package/dist/core/permission-rule-consent.js +6 -11
  132. package/dist/core/permission-rule-model.d.ts +27 -0
  133. package/dist/core/permission-rule-model.js +33 -5
  134. package/dist/core/permission-rule-org.js +13 -3
  135. package/dist/core/permission-rule-provider.d.ts +35 -33
  136. package/dist/core/permission-rule-provider.js +38 -295
  137. package/dist/core/permission-rule-store.d.ts +181 -8
  138. package/dist/core/permission-rule-store.js +420 -17
  139. package/dist/core/permission-rule-sync.js +15 -1
  140. package/dist/core/permission-rules.js +4 -1
  141. package/dist/core/project-seat.d.ts +55 -0
  142. package/dist/core/project-seat.js +96 -0
  143. package/dist/core/protocol-http-auth.d.ts +3 -2
  144. package/dist/core/protocol-http-auth.js +26 -18
  145. package/dist/core/remote-env.d.ts +4 -4
  146. package/dist/core/retain-seat.d.ts +42 -0
  147. package/dist/core/retain-seat.js +76 -0
  148. package/dist/core/retired-keys.js +1 -0
  149. package/dist/core/rewind-refusal-codes.d.ts +8 -0
  150. package/dist/core/rewind-refusal-codes.js +12 -0
  151. package/dist/core/roles.d.ts +2 -2
  152. package/dist/core/roles.js +15 -1
  153. package/dist/core/rule-offer-read.d.ts +1 -1
  154. package/dist/core/rule-offer-read.js +32 -4
  155. package/dist/core/rule-store-fault.d.ts +9 -7
  156. package/dist/core/rule-store-fault.js +8 -3
  157. package/dist/core/run-ledger-seat.d.ts +66 -0
  158. package/dist/core/run-ledger-seat.js +70 -0
  159. package/dist/core/run-ledger.d.ts +332 -0
  160. package/dist/core/run-ledger.js +550 -0
  161. package/dist/core/runner/checkpoint-scope.d.ts +14 -3
  162. package/dist/core/runner/checkpoint-scope.js +16 -6
  163. package/dist/core/runner/compact-session.js +1 -1
  164. package/dist/core/runner/construction-doors.js +8 -0
  165. package/dist/core/runner/contracts.d.ts +21 -5
  166. package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
  167. package/dist/core/runner/cross-boundary-lane.js +4 -0
  168. package/dist/core/runner/delegation-owner.d.ts +30 -0
  169. package/dist/core/runner/delegation-owner.js +20 -4
  170. package/dist/core/runner/finish-reason-seat.js +4 -2
  171. package/dist/core/runner/gate-exit.d.ts +7 -0
  172. package/dist/core/runner/gate-exit.js +2 -1
  173. package/dist/core/runner/leg-frame.js +3 -0
  174. package/dist/core/runner/model-lane-seat.d.ts +3 -0
  175. package/dist/core/runner/model-lane-seat.js +4 -0
  176. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  177. package/dist/core/runner/nested-memory-lane.js +91 -30
  178. package/dist/core/runner/person-path-rows.d.ts +27 -16
  179. package/dist/core/runner/person-path-rows.js +93 -15
  180. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  181. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  182. package/dist/core/runner/prepare-config-doors.js +13 -7
  183. package/dist/core/runner/prepare-context-lane.js +1 -0
  184. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  185. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  186. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  187. package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
  188. package/dist/core/runner/prepare-gate-stations.js +3 -1
  189. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  190. package/dist/core/runner/prepare-hands-readface.js +15 -3
  191. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  192. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  193. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  194. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  195. package/dist/core/runner/prepare-run-refs.js +3 -2
  196. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  197. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  198. package/dist/core/runner/prepare-task.js +42 -30
  199. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  200. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  201. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  202. package/dist/core/runner/prepare-wiring-manifest.js +8 -6
  203. package/dist/core/runner/resume-apply.js +11 -5
  204. package/dist/core/runner/resume-policy-outcome.js +5 -2
  205. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  206. package/dist/core/runner/resume-review-outcome.js +24 -1
  207. package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
  208. package/dist/core/runner/role-seat-defaulted.js +1 -1
  209. package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
  210. package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
  211. package/dist/core/runner/run-harness-handlers.js +4 -1
  212. package/dist/core/runner/run-identity-wiring.js +3 -2
  213. package/dist/core/runner/run-leg.js +5 -2
  214. package/dist/core/runner/run-notification-lane.js +20 -1
  215. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  216. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  217. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  218. package/dist/core/runner/runtask.d.ts +6 -2
  219. package/dist/core/runner/runtask.js +21 -9
  220. package/dist/core/runner/shell-env-withheld.d.ts +6 -4
  221. package/dist/core/runner/shell-env-withheld.js +25 -3
  222. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  223. package/dist/core/runner/stop-tail-notice.js +9 -2
  224. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  225. package/dist/core/runner/stream-settle-backstop.js +1 -0
  226. package/dist/core/runner/sub-agent-deny-lists.js +9 -5
  227. package/dist/core/runner/task-start-doors.js +6 -3
  228. package/dist/core/runner/terminal-account.d.ts +6 -1
  229. package/dist/core/runner/terminal-account.js +16 -1
  230. package/dist/core/runner/tool-end-body.d.ts +1 -1
  231. package/dist/core/runner/tool-not-executed.d.ts +27 -8
  232. package/dist/core/runner/tool-not-executed.js +22 -11
  233. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  234. package/dist/core/runner/write-protection-station.d.ts +1 -1
  235. package/dist/core/runner/write-protection-station.js +1 -1
  236. package/dist/core/runner-deps.d.ts +17 -10
  237. package/dist/core/secret-env.d.ts +61 -37
  238. package/dist/core/secret-env.js +49 -49
  239. package/dist/core/session-checkout.d.ts +3 -0
  240. package/dist/core/session-checkout.js +1 -0
  241. package/dist/core/session-store.d.ts +12 -6
  242. package/dist/core/session-store.js +26 -6
  243. package/dist/core/session.d.ts +31 -8
  244. package/dist/core/shell-read-silence.d.ts +40 -2
  245. package/dist/core/shell-read-silence.js +23 -4
  246. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  247. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  248. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  249. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  250. package/dist/core/store-contracts/session-store-contract.js +87 -3
  251. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  252. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  253. package/dist/core/task-event.d.ts +14 -7
  254. package/dist/core/task-notification.d.ts +96 -10
  255. package/dist/core/task-notification.js +135 -6
  256. package/dist/core/task-registry-agent.d.ts +1 -0
  257. package/dist/core/task-registry-agent.js +1 -1
  258. package/dist/core/task-registry-shared.d.ts +12 -1
  259. package/dist/core/task-registry-shared.js +3 -1
  260. package/dist/core/task-registry-workflow.d.ts +1 -1
  261. package/dist/core/task-registry-workflow.js +9 -1
  262. package/dist/core/task-registry.d.ts +40 -2
  263. package/dist/core/task-registry.js +80 -15
  264. package/dist/core/task-result.d.ts +18 -3
  265. package/dist/core/task-spec-members.d.ts +3 -1
  266. package/dist/core/task-spec-members.js +19 -3
  267. package/dist/core/task-spec.d.ts +48 -22
  268. package/dist/core/tool-catalog-entries.js +2 -0
  269. package/dist/core/tool-gate-phase.d.ts +6 -3
  270. package/dist/core/tool-gate-phase.js +1 -0
  271. package/dist/core/tool-mount-facts.d.ts +8 -4
  272. package/dist/core/tool-mount-facts.js +7 -2
  273. package/dist/core/tool-mount-plan.d.ts +3 -1
  274. package/dist/core/tool-mount-plan.js +10 -3
  275. package/dist/core/tool-mount-static.d.ts +1 -1
  276. package/dist/core/tool-mount-static.js +4 -2
  277. package/dist/core/tool-result-store.d.ts +56 -3
  278. package/dist/core/tool-result-store.js +219 -25
  279. package/dist/core/tool-spec.d.ts +9 -2
  280. package/dist/core/trace.d.ts +3 -3
  281. package/dist/core/user-attachment.d.ts +5 -1
  282. package/dist/core/user-attachment.js +14 -7
  283. package/dist/core/wiring-manifest.d.ts +26 -20
  284. package/dist/core/wiring-manifest.js +7 -3
  285. package/dist/core/workflow-journal-store.d.ts +53 -10
  286. package/dist/core/workflow-journal-store.js +27 -4
  287. package/dist/core/workflow-run-store-contract.js +16 -0
  288. package/dist/core/workflow-run-store.d.ts +9 -7
  289. package/dist/core/workflow-run-store.js +4 -1
  290. package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
  291. package/dist/engine/execution-env/node-execution-env.js +227 -13
  292. package/dist/engine/harness/types.d.ts +49 -1
  293. package/dist/engine/harness/types.js +10 -0
  294. package/dist/engine/llm/types.d.ts +13 -7
  295. package/dist/engine/llm/validation.d.ts +8 -1
  296. package/dist/engine/llm/validation.js +31 -2
  297. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  298. package/dist/engine/session/import-validate.js +6 -1
  299. package/dist/engine/session/session.d.ts +15 -2
  300. package/dist/engine/session/session.js +34 -4
  301. package/dist/host-env.d.ts +10 -0
  302. package/dist/host-env.js +1 -0
  303. package/dist/index.d.ts +28 -9
  304. package/dist/index.js +22 -6
  305. package/dist/internal/harness-types.d.ts +1 -1
  306. package/dist/orchestration/goal.js +1 -1
  307. package/dist/orchestration/run-workflow-tool.js +40 -32
  308. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  309. package/dist/orchestration/workflow-park-adoption.js +47 -12
  310. package/dist/orchestration/workflow-primitives.js +10 -1
  311. package/dist/orchestration/workflow-script-runner.d.ts +2 -2
  312. package/dist/orchestration/workflow-stop.d.ts +128 -0
  313. package/dist/orchestration/workflow-stop.js +156 -0
  314. package/dist/orchestration/workflow.d.ts +31 -7
  315. package/dist/orchestration/workflow.js +119 -57
  316. package/dist/prompts/manager-recipe.d.ts +18 -0
  317. package/dist/prompts/manager-recipe.js +24 -0
  318. package/dist/shell/lex.d.ts +2 -2
  319. package/dist/shell/lex.js +1 -1
  320. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  321. package/dist/stores/file/permission-rule-store.js +0 -1
  322. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  323. package/dist/stores/file/workflow-journal-store.js +93 -5
  324. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  325. package/dist/tools/fs/bash-model-shell.d.ts +23 -0
  326. package/dist/tools/fs/bash-model-shell.js +25 -0
  327. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
  328. package/dist/tools/fs/bash-readonly-classifier.js +3 -0
  329. package/dist/tools/fs/file-write-check.js +9 -3
  330. package/dist/tools/fs/fs-bash.js +13 -11
  331. package/dist/tools/fs/index.d.ts +8 -7
  332. package/dist/tools/fs/index.js +4 -4
  333. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  334. package/dist/tools/fs/read-deny-home.js +5 -5
  335. package/dist/tools/fs/read-deny.d.ts +33 -8
  336. package/dist/tools/fs/read-deny.js +114 -25
  337. package/dist/tools/fs/safety.d.ts +4 -1
  338. package/dist/tools/fs/safety.js +4 -2
  339. package/dist/tools/fs/shell-read-argv.js +1 -0
  340. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  341. package/dist/tools/fs/shell-read-check.js +134 -22
  342. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  343. package/dist/tools/fs/shell-read-establish.js +21 -11
  344. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  345. package/dist/tools/fs/shell-read-judge.js +26 -7
  346. package/dist/tools/fs/shell-read-plan.d.ts +7 -3
  347. package/dist/tools/fs/shell-read-plan.js +8 -5
  348. package/dist/tools/fs/shell-read-word.d.ts +8 -0
  349. package/dist/tools/fs/shell-read-word.js +13 -4
  350. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  351. package/dist/tools/monitor.js +12 -8
  352. package/dist/tools/scheduler-tools.d.ts +1 -0
  353. package/dist/tools/scheduler-tools.js +5 -2
  354. package/package.json +3 -2
  355. package/test/export-surface.snapshot.json +192 -3
  356. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  357. package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
  358. package/wire-changes/answers/core@7.73.0.json +216 -0
  359. package/wire-changes/answers/core@7.74.0.json +68 -0
  360. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  361. package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
  362. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  363. package/wire-changes/answers/primitives@7.74.0.json +7 -0
  364. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  365. package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
  366. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  367. package/wire-changes/core-stores-sql@7.74.0.json +143 -0
  368. package/wire-changes/core@7.73.0.json +6480 -0
  369. package/wire-changes/core@7.74.0.json +2210 -0
  370. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  371. package/wire-changes/mods-kernel@7.74.0.json +421 -0
  372. package/wire-changes/primitives@7.73.0.json +227 -0
  373. package/wire-changes/primitives@7.74.0.json +174 -0
  374. package/wire-changes/wiki-gate@7.73.0.json +145 -0
  375. package/wire-changes/wiki-gate@7.74.0.json +145 -0
@@ -6,6 +6,7 @@ import { createEditedFilesLedger } from "./edited-files-ledger.js";
6
6
  import { createToolOccurrenceTable } from "./tool-occurrence.js";
7
7
  import { createHookProgressLane, createHookScreenSeat } from "./hook-progress-lane.js";
8
8
  import { reviewRefusalSentence } from "../park-resumability.js";
9
+ import { handsReadOnlyCarried } from "../child-clamp-seats.js";
9
10
  export function forwardsSubagentEvents(spec) {
10
11
  return spec.forwardSubagentEvents === true;
11
12
  }
@@ -27,7 +28,7 @@ export function prepareRunRefs(input) {
27
28
  if (e.type === "task_progress" || e.type === "task_started")
28
29
  forwardSafely(internals, e);
29
30
  else if (spec.forwardSubagentEvents === true &&
30
- (e.type === "text_delta" || e.type === "text_end" || e.type === "reasoning_delta" || e.type === "tool_start" || e.type === "tool_progress" || e.type === "hook_progress" || e.type === "tool_end")) {
31
+ (e.type === "text_delta" || e.type === "text_end" || e.type === "reasoning_delta" || e.type === "reasoning_end" || e.type === "tool_start" || e.type === "tool_progress" || e.type === "hook_progress" || e.type === "tool_end")) {
31
32
  forwardSafely(internals, e);
32
33
  }
33
34
  }
@@ -56,6 +57,6 @@ export function prepareRunRefs(input) {
56
57
  await permissionModeSeat.steer("plan");
57
58
  };
58
59
  const subagentRetain = spec.retainSubagentSessions ? new SubagentRetainLedger(spec.retainSubagentSessions) : undefined;
59
- const worktreeIsolation = spec.handsReadOnly !== true ? createSubagentWorktreeHelper(executionEnv, taskRootFinal, () => readFloor(undefined)) : undefined;
60
+ const worktreeIsolation = handsReadOnlyCarried(spec) !== true ? createSubagentWorktreeHelper(executionEnv, taskRootFinal, () => readFloor(undefined)) : undefined;
60
61
  return { noteFileEdited, editedFilesSnapshot, harnessRef, toolProgressRef, toolOccurrences, hookScreens, hookProgress, skillGrants, forwardEvent, reviewRequestRef, requestReview, stopRequestedRef, requestStopAfterTurn, bindPermissionModeSeat, enterPlanMode, subagentRetain, worktreeIsolation };
61
62
  }
@@ -105,8 +105,11 @@ export interface PrepareSuspendSagaInput {
105
105
  * onto the row. */
106
106
  nestedStats: Prepared["nestedStats"];
107
107
  /** borrowed-readonly — the trusted spawn-side channel (the driver's binding, the row id already restored into it):
108
- * `repairBundle` (the live bundle), `delegationProvenance` (the aggregate copied onto the row) and `rowTaskId` (stamped). */
109
- internals: Pick<RunInternals, "repairBundle" | "delegationProvenance" | "rowTaskId" | "holder" | "isDelegatedChild" | "observerLeg"> | undefined;
108
+ * `repairBundle` (the live bundle), `delegationProvenance` (the aggregate copied onto the row), `rowTaskId` (stamped) and the
109
+ * identity the row's `legIdentity` records (`parentTaskId`, the root pair, `explicitAgentName`). */
110
+ internals: Pick<RunInternals, "repairBundle" | "delegationProvenance" | "rowTaskId" | "holder" | "isDelegatedChild" | "observerLeg" | "parentTaskId" | "rootSessionId" | "rootSessionIncarnation" | "rootSessionScope" | "explicitAgentName"> | undefined;
111
+ /** borrowed-readonly — the task id the leg's host declared (`spec.taskId`, after a member ledger's rebind): the row's `legIdentity.declaredTaskId`. */
112
+ declaredTaskId: string | undefined;
110
113
  /** borrowed-readonly — the ToolSearch activation set (`Prepared.activeTools`); copied onto the row at mint time. */
111
114
  activeTools: Prepared["activeTools"];
112
115
  /** borrowed-readonly — the structured-output seat; `value`/`set` are copied onto the row at mint time. */
@@ -123,6 +126,7 @@ export interface PrepareSuspendSagaInput {
123
126
  readBlock: boolean;
124
127
  /** borrowed-readonly — the inherited-gate phase's SKILL-GRANT section builder (the row's `skillGrants`). */
125
128
  skillGrantCheckpointSection: () => SerializedCheckpointState["skillGrants"];
129
+ /** borrowed-readonly — the leg's member ledger book: the row's `runLedger`. */ runLedgerBook: import("../run-ledger.js").RunLedgerBook | undefined;
126
130
  /** borrowed-readonly — the leg's skill scopes (the mods admission's record): the row's `skillScopes`, read at the park. */
127
131
  skillScopesCheckpointSection: () => SerializedCheckpointState["skillScopes"];
128
132
  /** borrowed-readonly — the leg's reminder provenance mark (travels with the row). */
@@ -11,7 +11,7 @@ import { writeHolderOf } from "../park-resumability.js";
11
11
  import { holderSupersededError, isHolderSuperseded } from "../grant-holder.js";
12
12
  import { latchWriteRefusal } from "./branch-writeback.js";
13
13
  import { serializeAnnouncedListings } from "./announce-once-ledger.js";
14
- import { workflowMemberOf } from "../leg-identity.js";
14
+ import { legIdentityRecordOf, workflowMemberOf } from "../leg-identity.js";
15
15
  import { remoteEnvFailureNote, restoreWorkspaceWithRetry } from "./remote-env-retry.js";
16
16
  import { thrownText } from "../thrown-value.js";
17
17
  const PARK_COMPENSATION_TIMEOUT_MS = 30_000;
@@ -87,7 +87,7 @@ function stampPlacementRootSessionId(placementRootResolved) {
87
87
  return placementValueOrAbsent(placementRootResolved);
88
88
  }
89
89
  export function prepareSuspendSaga(input) {
90
- const { commandSandboxRequirement, callerPlaces, gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, readBlock, skillGrantCheckpointSection, skillScopesCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, inheritedRuleBuckets, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, askSource, placementRootResolved, compositionLegResolved, checkpointScope, runOrigin, toolCeiling, toolListsJudged, ownToolLists, externalContentTargetActive, crossBoundary, remoteEnvFailures, memoryEngineSession, suspendLoopRef, writeRefusal, ownedEnv, workspaceSync } = input;
90
+ const { commandSandboxRequirement, callerPlaces, gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, readBlock, skillGrantCheckpointSection, skillScopesCheckpointSection, runLedgerBook, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, inheritedRuleBuckets, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, askSource, placementRootResolved, compositionLegResolved, checkpointScope, runOrigin, toolCeiling, toolListsJudged, ownToolLists, externalContentTargetActive, crossBoundary, remoteEnvFailures, memoryEngineSession, suspendLoopRef, writeRefusal, ownedEnv, workspaceSync } = input;
91
91
  if (!gateMachineryActive)
92
92
  return { saga: undefined };
93
93
  const putHolder = writeHolderOf(internals);
@@ -197,6 +197,8 @@ export function prepareSuspendSaga(input) {
197
197
  toolListsJudged,
198
198
  ownToolLists: ownToolLists !== undefined ? { toolName: ownToolLists.toolName, ...(ownToolLists.definition !== undefined ? { definition: ownToolLists.definition } : {}), lists: ownToolLists.lists } : undefined,
199
199
  commandSandbox: commandSandboxRequirement, ...callerPlaces.recorded(),
200
+ runLedger: runLedgerBook?.parkSection(),
201
+ legIdentity: legIdentityRecordOf(input.declaredTaskId, internals),
200
202
  crossBoundaryRecorded: crossBoundary.recorded() ? true : undefined,
201
203
  });
202
204
  const compensatePausedVM = (remoteEnv, snapshotId) => compensateUnparkedPause(remoteEnv, snapshotId, {
@@ -20,12 +20,12 @@ import { isValidReminderMark, mintReminderMark } from "../reminder-mint.js";
20
20
  import { renderOutputStyle } from "../output-style.js";
21
21
  import { prepareLanguageSeat } from "./language-frame.js";
22
22
  import { emitTrace } from "../trace.js";
23
- import { personPathRowsOfTask, ruleRowsDroppedNotice } from "./person-path-rows.js";
23
+ import { confinedDenyRowsOf, personPathRowsOfTask, ruleRowsDroppedNotice } from "./person-path-rows.js";
24
24
  import { ruleStoreUnreadableNotice } from "./rule-store-unreadable-notice.js";
25
25
  import { STALL_FIRST_BYTE_MS, STALL_FIRST_TOKEN_MS, STALL_IDLE_MS, withBrainCallGuardrail } from "../../brain/timeout.js";
26
26
  import { createFastModeLeg, SessionFastModeSeats } from "./fast-mode-seat.js";
27
27
  import { preparePromptSeats } from "./session-prompt-seats.js";
28
- import { bindParentSpecSeatFastMode, bindParentSpecSeatProjectId } from "../parent-spec-seat.js";
28
+ import { bindParentSpecSeatFastMode, bindParentSpecSeatProject } from "../parent-spec-seat.js";
29
29
  import { rootSessionAddressKeyOf, rootSessionAddressOf, treeRootAddressOf } from "../../agents/root-session-lane.js";
30
30
  import { OFFLOAD_TOOL_NAME } from "../tool-result-store.js";
31
31
  import { saveToolResultReach } from "../tool-result-bytes.js";
@@ -38,7 +38,7 @@ import { compileOutputSchema } from "./strict-output-schema.js";
38
38
  import { MEMORY_ENGINE_TOOL_NAMES } from "../memory-engine/tools.js";
39
39
  import { foldAdmissionFreeze } from "../memory-admission.js";
40
40
  import { chainAnchorRecords, chainPolicyOnLeg, chainTopAnchors, deploymentCanRerootChild } from "./child-tree.js";
41
- import { delegatedTreeOwner, judgedOwnerSeat, ownRowDelegationOwner } from "./delegation-owner.js";
41
+ import { delegatedTreeOwner, judgedLegOf, judgedOwnerSeat, ownRowDelegationOwner } from "./delegation-owner.js";
42
42
  import { prepareMemory } from "./prepare-memory.js";
43
43
  import { prepareMemoryEngineSession } from "./prepare-memory-engine-session.js";
44
44
  import { cardsFollowModel, prepareDeferClassify } from "./prepare-defer-classify.js";
@@ -91,7 +91,7 @@ import { prepareParkAsk } from "./prepare-park-ask.js";
91
91
  import { prepareGateStations } from "./prepare-gate-stations.js";
92
92
  export { batchContextAt } from "./prepare-park-ask.js";
93
93
  export { compensateUnparkedPause } from "./prepare-suspend-saga.js";
94
- import { checkpointScopeOf, compositionLegRecord, placementValueOrAbsent, restoreRowTaskId, workSessionOfLeg } from "./checkpoint-scope.js";
94
+ import { checkpointScopeOf, compositionLegRecord, placementValueOrAbsent, workSessionOfLeg } from "./checkpoint-scope.js";
95
95
  import { ANONYMOUS_SCOPE, identityMembersOf, scopeKeyOf } from "../isolation-scope.js";
96
96
  export { checkpointScopeOf, placementValueOrAbsent } from "./checkpoint-scope.js";
97
97
  export { mcpManifestEntries } from "../wiring-manifest.js";
@@ -114,11 +114,14 @@ import { sessionAddressOf } from "../task-notification.js";
114
114
  import { createFrameSettlement } from "../frame-settlement.js";
115
115
  import { announceSchedulerStoreUnmoved, createSchedulerTools } from "../../tools/scheduler-tools.js";
116
116
  import { readSchedulerDeclaration } from "../scheduler.js";
117
+ import { announceModelShellUnmounted, readModelShell } from "../model-shell.js";
117
118
  import { selfOrchestrationFailClosedReason } from "../../orchestration/workflow-script-runner.js";
119
+ import { runLedgerBookFor, withRunLedgerTask } from "../run-ledger.js";
120
+ import { managerLaunchCheck, managerLaunchCheckSentence, managerLaunchFactsOf, managerLaunchNarrowedNotice } from "../manager-launch-check.js";
118
121
  import { valveLeaves, valveLeavesPeer } from "../../agents/tool-filter.js";
119
122
  import { backgroundAgentsFact, envMountFacts, legSeatMountFacts, seatMountFacts, specMountFacts } from "../tool-mount-facts.js";
120
123
  import { judgeRunToolLists } from "./sub-agent-deny-lists.js";
121
- import { remainingBudgetMicroUsd } from "../checkpoint-store.js";
124
+ import { legBudgetSnapshot, resourceTotalOf } from "../leg-budget.js";
122
125
  import { checkpointStoreOfSeat } from "../checkpoint-seat.js";
123
126
  import { readLegExecutionEnv } from "../tool-mount-static.js";
124
127
  import { handsWriteHalfMounts, pdfModelCapabilitiesOf } from "../../tools/fs/index.js";
@@ -147,7 +150,8 @@ import { createWorkspaceFrameSeat } from "../workspace-snapshot.js";
147
150
  import { ensureStand, forkHasOwnTree, openSessionCheckout, openStandingCheckout, readLegCheckout, readStandingCheckout, recordedRootOf, sessionFrameOf, withEffectiveDirectories } from "../session-checkout.js";
148
151
  import { createCardProjector } from "./tool-output-projection.js";
149
152
  import { imageUnprocessedSeat, toolResultMediaRefusedSeat } from "./tool-result-media-seat.js";
150
- import { asThrownError, readMember, thrownText } from "../thrown-value.js";
153
+ import { asThrownError, codedRefusal, readMember, thrownText } from "../thrown-value.js";
154
+ import { handedProjectSeat } from "../project-seat.js";
151
155
  import { createAttachmentDelivery, refuseUserAttachmentPathsWithoutWorkspace } from "../user-attachment.js";
152
156
  import { screenReadDenySeat } from "../read-face-seats.js";
153
157
  import { admitLegMods, legEventsOf, legFacadeSeats, listLegModSeats } from "../mods/stations.js";
@@ -305,6 +309,7 @@ function validateInputFaultNotice(onError, sessionId) {
305
309
  }
306
310
  export async function prepareTask(request, deps, sessions, resume, internals, runnerSelf, runIdSink, holdSessionLock, legWrites, noticeDestinations, promptSubmitRef, runEnd) {
307
311
  const runId = uuidv7();
312
+ const legStartedAt = Date.now();
308
313
  if (runIdSink !== undefined)
309
314
  runIdSink.runId = runId;
310
315
  const rewindOutcome = runIdSink?.rewind ?? rewindOutcomeOf(request);
@@ -314,6 +319,8 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
314
319
  const { callerRoster, mountsCallerTool, permissionModeSeat, doors, checkpointStore, checkpointSeat, outputStyleSeat, languageDeclared, allowedTools, userAttachmentsSeat } = start;
315
320
  let spec = start.spec;
316
321
  deps = start.deps;
322
+ const runLedgerBookOfLeg = internals?.runLedgerBook ?? runLedgerBookFor(spec, resume !== undefined ? { section: resume.seed.runLedger } : undefined, internals?.rowTaskId);
323
+ spec = withRunLedgerTask(spec, runLedgerBookOfLeg);
317
324
  try {
318
325
  internals?.reportAdmittedIdentity?.(identityMembersOf(spec));
319
326
  }
@@ -333,7 +340,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
333
340
  const { ownToolLists, delegation, approvalParkNotResumable, notResumableSays, toolLegs, toolCeiling, toolListsJudged, toolFaceSnapshot, toolCeilingRead, fileHistoryRequest, retiredNames } = start;
334
341
  const ownerSeat = judgedOwnerSeat(internals);
335
342
  const treeOwner = ownerSeat === undefined ? undefined : await delegatedTreeOwner(ownerSeat, spec.signal);
336
- const judgedLeg = treeOwner === undefined ? undefined : { owner: treeOwner.owner, minted: spec.requireExistingSession !== true && (spec.sessionId === undefined || internals?.sessionIdMintedBySpawner === true), ...(spec.signal !== undefined ? { signal: spec.signal } : {}) };
343
+ const judgedLeg = judgedLegOf(spec, internals, treeOwner);
337
344
  let told = false;
338
345
  const verified = (id) => { if (told)
339
346
  return; told = true; if (runIdSink !== undefined)
@@ -350,7 +357,6 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
350
357
  const delegationOwner = internals?.delegationOwner ?? ownRowDelegationOwner(sessions, sessionId, async () => (await session.getMetadata()).incarnation, declaredRoot);
351
358
  await holdSessionLock?.(sessionId);
352
359
  const onceLedger = await loadAnnounceOnceLedger(session, resume?.seed.announcedListings, deps.onError);
353
- internals = restoreRowTaskId(internals, resume?.seed.rowTaskId);
354
360
  const hostTaskId = legTaskIdOf(spec, internals, sessionId);
355
361
  const askSource = mintAskSourceIdentity({ principal: spec.principal, sessionId, taskId: hostTaskId, isDelegatedChild: delegation.isDelegatedChild, internals, recordedFromSubagent: resume?.seed.fromSubagent === true, ...(typeof resume?.seed.sourceAgentName === "string" ? { recordedSourceAgentName: resume.seed.sourceAgentName } : {}), ...(resume?.seed.workflowMember !== undefined ? { recordedWorkflowMember: resume.seed.workflowMember } : {}) });
356
362
  const legNotice = mintLegNotice(askSource, internals, noticeDestinations, onceLedger.told);
@@ -405,7 +411,6 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
405
411
  if (!handsEnabled)
406
412
  refuseUserAttachmentPathsWithoutWorkspace(userAttachmentsSeat);
407
413
  const schedulerReading = readSchedulerDeclaration(executionEnv);
408
- const mountFacts = { ...legMountFacts, ...envMountFacts(handsEnabled, executionEnv, schedulerReading) };
409
414
  const externalContentTargetActive = targetIsExternal(executionEnv) !== false || resume?.seed.externalContentTarget === true || internals?.externalContentTarget === true;
410
415
  const crossBoundaryTree = joinedCrossBoundaryTree(internals?.crossBoundaryTree, (m) => deps.onError?.(new Error(m), { phase: "config", sessionId }));
411
416
  const abortController = new AbortController();
@@ -478,6 +483,8 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
478
483
  }
479
484
  const ownedEnv = ownedEnvSeat.current;
480
485
  const { taskRootFinal: taskRootRestored, rebaseRestoredPath, remote: workspaceRemote, ownTarget } = await prepareWorkspaceRestore({ ownedEnv, deps, spec, resume, taskRootInitial, placementFence, abortController, sessionId });
486
+ const modelShellReading = handsEnabled ? await readModelShell(executionEnv) : { kind: "undeclared" };
487
+ const mountFacts = { ...legMountFacts, ...envMountFacts(handsEnabled, executionEnv, schedulerReading, modelShellReading.kind === "mounted") };
481
488
  const reportWorkspace = (cwd) => {
482
489
  if (internals?.onWorkspaceResolved === undefined)
483
490
  return;
@@ -557,11 +564,12 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
557
564
  let readDenyAdditionsNormalized = [];
558
565
  let handsLessResolvedFace;
559
566
  let handsLessResolvedWriteFace;
567
+ let carriedFaces;
560
568
  let legReadBlock = false;
561
569
  const pausedRef = {};
562
570
  const mcpHostSeats = internals?.mcpHostSeats;
563
571
  const mountedMcpNow = () => mountedMcpOf({ declared: installedPreflight.mcp, roster: roster.tools, aggregateNames: new Set(mcp.tools.filter((t) => t.mcpRemoteName === undefined).map((t) => t.name)), ...(mcpHostSeats !== undefined ? { hostSeats: mcpHostSeats } : {}) });
564
- const { sharedArtifactReadsCell, liveInheritedGate, seedInheritedGate, inheritedAncestorRules, inheritedShellGate, inheritedParentConstraints, permissionMode, commitModeSeats, endModeCeiling, inheritedAdmittedOrgScopes, inheritedRuleBuckets, priorOwnOrgVerdict, orgGovernedProvenance, effectiveShellGate, ownSessionRulesRef, ancestorSessionRulesRef, ancestorRulesNow, memoryAdmittedOrgScopesRef, ownOrgVerdictRef, runClampSource, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, frozenOnAsk, hookEnvSource, frozenOnQuestion, parentSpecSeat, provenanceForChildrenRef, delegationSettlementRef, inheritedGateForChildren, carrierReadFace, carrierWriteFace, fullShellReachable, gateStopRef, stopForDenialLimit, enrichSpecToolCtx } = prepareInheritedGate({ spec, deps, commandSandboxRequirement, callerPlaces, delegationOwner, delegated: delegation.isDelegatedChild, askSeat: doors.askSeat, hostFloor: doors.hostFloor, crossBoundaryTree, internals, resume, sessions, sessionId, runId, hostTaskId, taskRootFinal, delegationCwd, givenNoWorkspace, ownTarget, executionEnv, ownedEnv, lockedPreflight: installedPreflight, pathRuleAnchors: { chainTop, onLeg: onLeg.chained, siteOf: onLeg.siteOf }, checkpointSeat, checkpointScope, taskScope, pausedRef, toolFaceSnapshot, mountsCallerTool, mountedMcp: mountedMcpNow, promptLean, resolvedInteractionPosture, permissionModeSeat, mountFacts, spendSeat: spend, harnessRef, skillGrants, requestAllowedTools: allowedToolTables.request, forwardEvent, subagentRetain, taskArtifacts, worktreeIsolation, requestReview, requestStopAfterTurn, enterPlanMode, reminderMark, reminderDisclosureCounts, fileHistoryEnabled, historyScope, historyRoot, historyFs, abortRun: () => { abortController.abort(); void harness.abort(); }, runtimeCaps: () => runtimeCaps, approvalParkNotResumable, hostApprovalParksNotResumable: doors.hostApprovalParksNotResumable, modBus: legMods.standing, ownModChain, autoModeDecider: () => autoModeDeciderRef.current, legNotice, autoModeDenialTracking: () => autoModeDenialTrackingRef.current, autoModeArming: () => autoModeArmingRef.current, agentForkDenial: () => agentForkDenial, agentStations: () => agentStationsRef.current, sendStation: () => sendStationRef.current, taskStations: () => taskStationsRef.current, continuationReach, observersActive: () => observersActive, resolvedReadFace: () => resolvedReadFace, resolvedWriteFace: () => resolvedWriteFace, readDenyAdditionsNormalized: () => readDenyAdditionsNormalized, handsLessResolvedFace: () => handsLessResolvedFace, handsLessResolvedWriteFace: () => handsLessResolvedWriteFace, readBlock: () => legReadBlock, centerAdoption: () => centerAdoptionRef.current, memoryEngineSession: () => memoryEngineSession, sessionIncarnation: () => sessionIncarnation });
572
+ const { sharedArtifactReadsCell, liveInheritedGate, seedInheritedGate, inheritedAncestorRules, inheritedShellGate, inheritedParentConstraints, permissionMode, commitModeSeats, endModeCeiling, inheritedAdmittedOrgScopes, inheritedRuleBuckets, priorOwnOrgVerdict, orgGovernedProvenance, effectiveShellGate, ownSessionRulesRef, ancestorSessionRulesRef, ancestorRulesNow, memoryAdmittedOrgScopesRef, ownOrgVerdictRef, runClampSource, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, frozenOnAsk, hookEnvSource, frozenOnQuestion, parentSpecSeat, provenanceForChildrenRef, delegationSettlementRef, inheritedGateForChildren, carrierReadFace, carrierWriteFace, fullShellReachable, gateStopRef, stopForDenialLimit, enrichSpecToolCtx } = prepareInheritedGate({ spec, deps, commandSandboxRequirement, callerPlaces, delegationOwner, delegated: delegation.isDelegatedChild, askSeat: doors.askSeat, hostFloor: doors.hostFloor, crossBoundaryTree, internals, resume, sessions, sessionId, runId, hostTaskId, taskRootFinal, delegationCwd, givenNoWorkspace, ownTarget, executionEnv, ownedEnv, lockedPreflight: installedPreflight, pathRuleAnchors: { chainTop, onLeg: onLeg.chained, siteOf: onLeg.siteOf }, checkpointSeat, checkpointScope, taskScope, pausedRef, toolFaceSnapshot, mountsCallerTool, mountedMcp: mountedMcpNow, promptLean, resolvedInteractionPosture, permissionModeSeat, mountFacts, spendSeat: spend, harnessRef, skillGrants, requestAllowedTools: allowedToolTables.request, forwardEvent, subagentRetain, taskArtifacts, worktreeIsolation, requestReview, requestStopAfterTurn, enterPlanMode, reminderMark, reminderDisclosureCounts, fileHistoryEnabled, historyScope, historyRoot, historyFs, abortRun: () => { abortController.abort(); void harness.abort(); }, runtimeCaps: () => runtimeCaps, approvalParkNotResumable, hostApprovalParksNotResumable: doors.hostApprovalParksNotResumable, modBus: legMods.standing, ownModChain, autoModeDecider: () => autoModeDeciderRef.current, legNotice, autoModeDenialTracking: () => autoModeDenialTrackingRef.current, autoModeArming: () => autoModeArmingRef.current, agentForkDenial: () => agentForkDenial, agentStations: () => agentStationsRef.current, sendStation: () => sendStationRef.current, taskStations: () => taskStationsRef.current, continuationReach, observersActive: () => observersActive, resolvedReadFace: () => resolvedReadFace, resolvedWriteFace: () => resolvedWriteFace, readDenyAdditionsNormalized: () => readDenyAdditionsNormalized, handsLessResolvedFace: () => handsLessResolvedFace, handsLessResolvedWriteFace: () => handsLessResolvedWriteFace, carriedFaces: () => carriedFaces, readBlock: () => legReadBlock, centerAdoption: () => centerAdoptionRef.current, memoryEngineSession: () => memoryEngineSession, sessionIncarnation: () => sessionIncarnation });
565
573
  bindPermissionModeSeat(permissionMode);
566
574
  const personRowNotices = { onUnread: ruleStoreUnreadableNotice(deps.onNotice, { sessionId, runId }, onceLedger, permissionMode), onRowsDropped: ruleRowsDroppedNotice(deps.onNotice, { sessionId, runId }) };
567
575
  const sessionRulesRead = { unread: { own: () => true, ancestor: () => true } };
@@ -591,8 +599,11 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
591
599
  const forcedGateNotResumable = runtimeCaps?.forceDurableGate === true && notResumableSays;
592
600
  const legNotResumable = notResumableSays !== undefined ? { source: notResumableSays, mandated: forcedGateNotResumable !== false && forcedGateNotResumable !== undefined } : undefined;
593
601
  const crossBoundary = await prepareCrossBoundaryLane({ token: crossBoundaryTree, posture: doors.crossBoundaryPosture, externalContentTargetActive, env: executionEnv, session, resumeLeg: resume !== undefined, sessionId, runId, hostTaskId, noticeRoute: legNotice.route, deps });
594
- const sessionProject = await resolveSessionProject(projectMarkerFsOf(executionEnv), taskRootCanonical, spec.projectId, internals?.parentProjectId);
595
- bindParentSpecSeatProjectId(parentSpecSeat, sessionProject.project?.id);
602
+ const handed = handedProjectSeat(internals?.parentProject);
603
+ if (!handed.ok)
604
+ throw codedRefusal(handed.code, handed.message);
605
+ const sessionProject = await resolveSessionProject(projectMarkerFsOf(executionEnv), taskRootCanonical, spec.project, handed.seat);
606
+ bindParentSpecSeatProject(parentSpecSeat, sessionProject.seat);
596
607
  if (sessionProject.markerFault !== undefined)
597
608
  deps.onError?.(sessionProject.markerFault, { phase: "config", sessionId });
598
609
  const undeliveredContinuationRef = { current: { parkedSteers: [], orphanTasks: [] } };
@@ -615,19 +626,8 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
615
626
  const maxSuspends = spec.maxSuspends ?? deps.maxSuspends ?? DEFAULT_MAX_SUSPENDS;
616
627
  const maxSlices = spec.resourceSuspend?.maxSlices;
617
628
  const priorLedger = resume?.priorLedger;
618
- const resourceTotal = spec.resourceSuspend
619
- ? {
620
- totalBudgetMicroUsd: spec.resourceSuspend.totalBudgetUsd !== undefined ? Math.round(spec.resourceSuspend.totalBudgetUsd * 1e6) : undefined,
621
- totalTokens: spec.resourceSuspend.totalTokens,
622
- }
623
- : undefined;
624
- const budgetSnapshot = {
625
- resourceRemainingMicroUsd: priorLedger
626
- ? remainingBudgetMicroUsd(priorLedger)
627
- : resourceTotal?.totalBudgetMicroUsd,
628
- resourceSpentMicroUsd: priorLedger?.spentMicroUsd ?? 0,
629
- suspendCount: priorSuspendCount,
630
- };
629
+ const resourceTotal = resourceTotalOf(spec);
630
+ const budgetSnapshot = legBudgetSnapshot(resourceTotal, resume);
631
631
  const outputRef = {};
632
632
  if (resume?.seed.outputRef) {
633
633
  outputRef.value = resume.seed.outputRef.value;
@@ -758,12 +758,16 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
758
758
  readDenyAdditionsNormalized = handsReadFace.readDenyAdditionsNormalized;
759
759
  handsLessResolvedFace = handsReadFace.handsLessResolvedFace;
760
760
  handsLessResolvedWriteFace = handsReadFace.handsLessResolvedWriteFace;
761
+ carriedFaces = handsReadFace.carriedFaces;
761
762
  legReadBlock = handsReadFace.readBlock;
762
763
  shellGatedTools = handsReadFace.shellGatedTools;
763
764
  await armAutoMode();
764
- const { worktreeSessionRef, sendMessageTier } = prepareDelegationSurface({ spec, deps, internals, resume, sessionId, sessionAddress, legOccupant, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, shellReadAdmission, runReadFloor: runFloor, ...(commandSandboxStart !== undefined ? { commandSandbox: commandSandboxStart } : {}), peerLaneActive, peerLaneRefs, sessionBox, roster, toolEffects, axisExplicitNegatives, toolFaceSnapshot, firstPartyOffload, offloadStore, toolResultBytes, taskArtifacts, subagentRetain, continuationReach, enrichSpecToolCtx, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle, worktreeSeat });
765
+ const runLedgerBookNow = runLedgerBookOfLeg;
766
+ const runLedgerSeats = runLedgerBookNow === undefined ? undefined : { book: runLedgerBookNow, record: async (ledger) => void (await session.appendRunLedger?.(ledger)) };
767
+ const { worktreeSessionRef, sendMessageTier } = prepareDelegationSurface({ runLedger: runLedgerSeats, spec, deps, internals, resume, sessionId, sessionAddress, legOccupant, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, shellReadAdmission, runReadFloor: runFloor, ...(commandSandboxStart !== undefined ? { commandSandbox: commandSandboxStart } : {}), peerLaneActive, peerLaneRefs, sessionBox, roster, toolEffects, axisExplicitNegatives, toolFaceSnapshot, firstPartyOffload, offloadStore, toolResultBytes, taskArtifacts, subagentRetain, continuationReach, enrichSpecToolCtx, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle, worktreeSeat });
765
768
  const { liveQuestionFace, contentAskBindings, contentAskRoutable, strandLateAnswer, settleContentAskBindings, durableQuestionFace, questionToolMounted, mountedQuestionTool } = prepareQuestionFace({ frozenOnQuestion, spec, askSource, deps, checkpointStore, runtimeCaps, approvalParkNotResumable, resolvedInteractionPosture, resume, sessionId, roster, inheritedUnavailableAsks: () => inheritedUnavailableAsks });
766
769
  announceSchedulerStoreUnmoved(schedulerReading, deps.onNotice);
770
+ announceModelShellUnmounted(modelShellReading, mountFacts, deps.onNotice);
767
771
  if (roster.mounts.holds("cron-list")) {
768
772
  roster.mountAll(createSchedulerTools(executionEnv, {
769
773
  ...(spec.principal !== undefined ? { principal: spec.principal } : {}),
@@ -832,6 +836,14 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
832
836
  const rosterFacts = { effects: toolEffects, egress: egressTools, irreversibilityTier, reversibilityProbes, deferred, trustedTools: new Set(spec.memory?.trustedTools ?? []) };
833
837
  const toolRoster = roster.snapshot(rosterFacts);
834
838
  rosterSeat.arm(toolRoster, () => roster.snapshot(rosterFacts));
839
+ if (runLedgerSeats !== undefined) {
840
+ const launch = managerLaunchCheck(managerLaunchFactsOf({ names: new Set(toolRoster.entries.map((e) => e.name)), backgroundAgents: roster.mounts.factOf("leg.backgroundAgents"), completionLane: internals?.onTaskNotification !== undefined, approver: frozenOnAsk !== undefined, parkStore: checkpointStore !== undefined, oneShot: spec.oneShot === true }));
841
+ runLedgerSeats.book.setLaunch(launch);
842
+ if (launch.verdict === "refused")
843
+ throw Object.assign(new Error(managerLaunchCheckSentence(launch)), { code: "config.invalid_argument", detail: { reason: "run_ledger_unready", launch } });
844
+ if (launch.verdict === "narrowed")
845
+ deliverEngineNotice(deps.onNotice, managerLaunchNarrowedNotice(launch, { ...legNotice.route.address, runId }), legNotice.admission);
846
+ }
835
847
  const structuredProjector = createCardProjector({
836
848
  declaredCards: toolRoster.entries.flatMap((e) => e.renderHints?.resultCards ?? []),
837
849
  onUndeclared: (type) => deliverEngineNotice(deps.onNotice, { code: "config.tool_card_undeclared", message: `a tool minted a \`details.type\` card ${JSON.stringify(type)} its definition never declared — dropped from tool_end.structured (declare it on the definition's catalog row or the caller's renderHints.resultCards)`, detail: { type, sessionId, runId } }),
@@ -975,7 +987,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
975
987
  const { basePolicyForResumeEdit, denyNarrowingPolicy, skillGrantLane, sessionRulesUnread, allowEntryLanes, policyLayers, effectivePolicy, inheritedUnavailableAsks, deferredAskIdentities, inheritedAskGrants, riskAxesOf, ruleOffersOf, callGrantDoorOf, callBindingSeat, grantBindingOf, permissionRuleLane, permissionRuleGateLane, ruleLaneFacts, permissionRuleOrgLane, storedRuleWholeToolRefusals, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions, ancestorArbitrations, inheritedInstallations, hostPoliciesUnderView } = await preparePolicyChain({ retiredNames, commandSandboxSideOf: commandSandboxSideFor, destinationOf: destinationFor, sandboxPlanOf, hostFloor: doors.hostFloor, spec, deps, sessionId, runId, hostTaskId, approvalWords, engineText, taskRootFinal, additionalRootsCanonical, writeLocation, executionEnv, lockedPreflight: installedPreflight, pathRuleAnchors: { leg: legAnchors, chainTop }, headLeads, tools, harnessTools, selector: toolFaceSnapshot.selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, readBlockJudge: handsReadFace.readBlockJudge, personRows, questionToolMounted, runtimeCaps, approvalParkNotResumable, notResumableSays, forcedGateNotResumable, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, inheritedRuleBuckets, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus: legMods.bus, ownModChain, autoModeDecider: () => autoModeDeciderRef.current, whileHeld: toolOccurrences.whileHeld, readFace: () => resolvedReadFace, permissionMode, autoStripNotice, toolRosterDeltas: rosterSeat, stopForDenialLimit, askSource, parkRouteOf: (toolCallId) => ({ parkRoute: callParkRoute(legParkClosureSeat.built && !legParkClosureSeat.continuationCalls.has(toolCallId), legMods.bus, toolCallId), suspendTargetGap: legParkClosureSeat.suspendTargetGap }), abortController, now, ownSessionRulesRef, announced: { announcedListingsRef, frameReceipts } });
976
988
  sessionRulesRead.unread = sessionRulesUnread;
977
989
  toolTableViewRef.current = createToolTableView({ policy: effectivePolicy, stored: { wholeToolRefusals: storedRuleWholeToolRefusals }, roster: rosterSeat, verdicts: verdictLedger.verdicts, turnSnapshotRef });
978
- const { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked, suspendTargetGap, durableSuspendInfraReady, suspendLaneGap, resourceSuspendEligible, usageGovernance, durableApproval, wiringManifest, askSeatWord, writeProtection, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound } = prepareWiringManifest({ spec, deps, callerPlaces, askSeat: doors.askSeat, hostFloorPosture: doors.hostFloor?.posture, sessionProject, crossBoundaryStationEngaged: crossBoundary.stationEngaged, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus: legMods.bus, standingModBus: legMods.standing, policyLayers, effectivePolicy, handsEnabled, skippedFactory, taskRootFinal, legWriteGuard: advertisedWritableDirs?.planFile !== undefined ? { ...legWriteGuard, exemptFiles: [advertisedWritableDirs.planFile] } : legWriteGuard, mcp, a2a, irreversibleTools, egressTools, shellReadStationArmed: handsReadFace.shellReadStationArmed, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, fastMode: fastModeLeg, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, harness, pausedRef, liveInheritedGate, delegation, approvalParkNotResumable, forcedGateNotResumable, toolRoster, toolPlan, readDenyBuiltinTiersActive: handsReadFace.readDenyBuiltinTiersActive, readFloorUnkept: handsReadFace.readFloorUnkept.current, lspManagerWired, lspDiagnosticsLive: lspDiagnostics !== undefined, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive: ownSessionRulesRef.current !== undefined, sessionBox, sessionAddress, runEnd, checkpointScope, memoryPollution: () => memoryEngineSession?.pollution, advisorFact: advisor.manifest, runOrigin: doors.runOrigin, commandSandboxFact: commandSandboxRun.state === "unavailable" ? { state: "unavailable", reason: commandSandboxRun.reason } : { state: commandSandboxRun.state } });
990
+ const { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked, suspendTargetGap, durableSuspendInfraReady, suspendLaneGap, resourceSuspendEligible, usageGovernance, durableApproval, wiringManifest, askSeatWord, writeProtection, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound } = prepareWiringManifest({ spec, deps, callerPlaces, askSeat: doors.askSeat, hostFloorPosture: doors.hostFloor?.posture, sessionProject, crossBoundaryStationEngaged: crossBoundary.stationEngaged, internals, resume, sessionId, runId, legStartedAt, hostTaskId, taskScope, modBus: legMods.bus, standingModBus: legMods.standing, policyLayers, effectivePolicy, handsEnabled, skippedFactory, taskRootFinal, legWriteGuard: advertisedWritableDirs?.planFile !== undefined ? { ...legWriteGuard, exemptFiles: [advertisedWritableDirs.planFile] } : legWriteGuard, mcp, a2a, irreversibleTools, egressTools, shellReadStationArmed: handsReadFace.shellReadStationArmed, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, fastMode: fastModeLeg, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, harness, pausedRef, liveInheritedGate, delegation, approvalParkNotResumable, forcedGateNotResumable, toolRoster, toolPlan, readDenyBuiltinTiersActive: handsReadFace.readDenyBuiltinTiersActive, readFloorUnkept: handsReadFace.readFloorUnkept.current, lspManagerWired, lspDiagnosticsLive: lspDiagnostics !== undefined, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive: ownSessionRulesRef.current !== undefined, sessionBox, sessionAddress, runEnd, checkpointScope, memoryPollution: () => memoryEngineSession?.pollution, advisorFact: advisor.manifest, runOrigin: doors.runOrigin, commandSandboxFact: commandSandboxRun.state === "unavailable" ? { state: "unavailable", reason: commandSandboxRun.reason } : { state: commandSandboxRun.state } });
979
991
  refuseDisplayWithoutSentences(legMods.bus, legEventsOf(hookIdentity));
980
992
  agentStationsRef.current = createAgentStations({ bus: legMods.bus, identity: hookIdentity, permissionMode: () => permissionMode.observed });
981
993
  sendStationRef.current = createSessionSendStation({ bus: legMods.bus, identity: hookIdentity });
@@ -1002,13 +1014,13 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
1002
1014
  const { askLane } = prepareAskLane({ commandSandboxSideOf: commandSandboxSideFor, destinationOf: destinationFor, gateMachineryActive, abortController, effectivePolicy, budgetSnapshot, handsCwdRef, handsRoot: attachmentRootCanonical, stampCallTarget, advertisedWritableDirs, exemptRoots: legExemptRoots, tools, inheritedUnavailableAsks, deferredAskIdentities, inheritedAskGrants, onAsk, humanReviewRef, now, ruleOffersOf, grantBindingOf, askSource, riskAxesOf, autoModeDenialTracking: autoModeDenialTrackingRef, hostTaskId, deps, sessionId, runId, modBus: legMods.bus, notifyOwnHookCrash, grantReadRoot: handsReadFace.grantReadRoot, approvalWords, toolRosterDeltas: rosterSeat, existingTargetSeat, forcedGateNotResumable, engineText, ...(sessionCallGrants !== undefined ? { sessionCallGrants } : {}) });
1003
1015
  const inheritedAnchorRecords = chainAnchorRecords(chainTop, inheritedParentConstraints ?? [], onLeg.siteOf);
1004
1016
  const workspaceSync = legWorkspaceSync({ env: ownedEnv ?? deps.executionEnv, sessionId, runId, onNotice: deps.onNotice, remoteEnvFailures, runSignal: abortController.signal });
1005
- const { saga } = prepareSuspendSaga({ legOccupant, commandSandboxRequirement, callerPlaces, gateMachineryActive, crossBoundary, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, readBlock: handsReadFace.readBlock, skillGrantCheckpointSection, skillScopesCheckpointSection: () => legMods.skillScopes.frozen(), reminderMark, handsCwdRef, handsRoot: attachmentRootCanonical, handsHome: attachmentRootCanonical !== undefined ? legAnchors.home : undefined, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors: chainTop !== legAnchors ? inheritedAnchorRecords.pathRuleAnchors : undefined, inheritedPathRuleInstallations: inheritedAnchorRecords.pathRuleInstallations, inheritedRuleBuckets, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, askSource, placementRootResolved, compositionLegResolved, checkpointScope, runOrigin: doors.runOrigin, toolCeiling: toolCeilingRead, toolListsJudged, ownToolLists, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, writeRefusal, ownedEnv, workspaceSync });
1017
+ const { saga } = prepareSuspendSaga({ legOccupant, commandSandboxRequirement, callerPlaces, gateMachineryActive, crossBoundary, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, declaredTaskId: spec.taskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, readBlock: handsReadFace.readBlock, skillGrantCheckpointSection, skillScopesCheckpointSection: () => legMods.skillScopes.frozen(), runLedgerBook: runLedgerSeats?.book, reminderMark, handsCwdRef, handsRoot: attachmentRootCanonical, handsHome: attachmentRootCanonical !== undefined ? legAnchors.home : undefined, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors: chainTop !== legAnchors ? inheritedAnchorRecords.pathRuleAnchors : undefined, inheritedPathRuleInstallations: inheritedAnchorRecords.pathRuleInstallations, inheritedRuleBuckets, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, askSource, placementRootResolved, compositionLegResolved, checkpointScope, runOrigin: doors.runOrigin, toolCeiling: toolCeilingRead, toolListsJudged, ownToolLists, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, writeRefusal, ownedEnv, workspaceSync });
1006
1018
  const { suspendForResource, suspendForPlatformLimit, suspendForReview } = prepareBoundaryParks({ saga, spec, checkpointStore, checkpointScope, approvalParkNotResumable, abortController, harness, session, sessions, sessionId, askSource, deps, priorLedger, maxSlices, maxSuspends, resourceTotal, priorSuspendCount, suspendChainBase, humanReviewRef, liveSpendRef, now, pausedRef, remoteEnvFailures, resourceSuspendEligible, durableSuspendInfraReady, suspendTargetGap });
1007
1019
  const { parkAsk } = prepareParkAsk({ commandSandboxSideOf: commandSandboxSideFor, destinationOf: destinationFor, askLane, saga, spec, deps, sessionId, askSource, checkpointStore, checkpointScope, toolRosterDeltas: rosterSeat, existingTargetSeat, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, strandLateAnswer, onAsk, runtimeCaps, inheritedUnavailableAsks, deferredAskIdentities, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, handsRoot: attachmentRootCanonical, stampCallTarget, shellReadLandings, advertisedWritableDirs, exemptRoots: legExemptRoots, offloadStore, suspendTargetGap, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedTools, irreversibilityTier, toolMarkSources, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, ruleOffersOf, riskAxesOf, grantBindingOf, now, humanReviewRef, abortController, harness, pausedRef, engineText });
1008
1020
  legParkClosureSeat.built = parkAsk?.suspendAsk !== undefined;
1009
1021
  legParkClosureSeat.suspendTargetGap = suspendTargetGap;
1010
1022
  const seatInputsFor = skillGateWiring({ tools, skillToolName: SKILL_TOOL_NAME, seatOf: skillSeatOf, mode: () => permissionMode.current, lane: skillGrantLane, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.skill_allowed", version: 1, taskId: hostTaskId, ...info, entries: [...info.entries], ts: Date.now() })), allowEntries: { deploymentAllows: { ...allowEntryLanes.deployment, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.allowed_tools_allowed", version: 1, taskId: hostTaskId, source: "deployment", ...info, entries: [...info.entries], ts: Date.now() })) }, requestAllows: { ...allowEntryLanes.request, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.allowed_tools_allowed", version: 1, taskId: hostTaskId, source: "request", ...info, entries: [...info.entries], ts: Date.now() })) } } });
1011
- const { approvedCallScreen, continuationGate } = prepareGateStations({ askLane, parkAsk, tools, refusedAsks, toolRosterDeltas: rosterSeat, crossBoundaryCheck: crossBoundary.seat({ tools, roster: rosterSeat }), deps, toolCallGateArmedRef, effectivePolicy, modBus: legMods.bus, inheritedInstallations, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, deferredAskIdentities, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, hookScreens, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, legNotice, handsCwdRef, stampCallTarget, readDenyInForce: (toolCallId) => ({ tiers: handsReadFace.readDenyBuiltinTiersActive, rows: [...readDenyAdditionsNormalized.map((e) => e.pattern), ...(pathTables?.forCall(toolCallId).ruleRows ?? handsReadFaceInput.denyRuleRows).filter((r) => r.faces.includes("read")).map((r) => r.rule)] }), hookEnvFace, writeProtectionCheck, shellReadCheck, readFace: () => resolvedReadFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider: autoModeDeciderRef, autoModeDenialTracking: autoModeDenialTrackingRef, askRoute: { ...wiringManifest.ask, effective: askSeatWord }, notResumable: legNotResumable, permissionMode, toolMarkSources, ...(deps.a2a?.isolatePeers === true ? { a2aIsolatePeers: true } : {}), a2aInsidePeerOf: a2aInsidePeerReader(lockedPreflight.a2a, deps.a2a?.isolatePeers === true), ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane: permissionRuleGateLane, seatInputsFor, permissionRuleOrgLane, questionToolMounted, durableQuestionFace, suspendTargetGap, continuationCalls: legParkClosureSeat.continuationCalls, workflowParkGap: internals?.workflowParkGap, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, commandSandboxArmed: commandSandboxRun.state === "armed", sandboxPlanOf });
1023
+ const { approvedCallScreen, continuationGate } = prepareGateStations({ askLane, parkAsk, tools, refusedAsks, toolRosterDeltas: rosterSeat, crossBoundaryCheck: crossBoundary.seat({ tools, roster: rosterSeat }), ...(deps.deploymentShape !== undefined ? { confinedLeg: { legsOf: (call) => crossBoundary.legsOf({ tools, roster: rosterSeat }, call), denyRows: (toolCallId) => confinedDenyRowsOf(pathTables, (id) => personRows.unreadFor(id), toolCallId) } } : {}), deps, toolCallGateArmedRef, effectivePolicy, modBus: legMods.bus, inheritedInstallations, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, deferredAskIdentities, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, hookScreens, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, legNotice, handsCwdRef, stampCallTarget, readDenyInForce: (toolCallId) => ({ tiers: handsReadFace.readDenyBuiltinTiersActive, rows: [...readDenyAdditionsNormalized.map((e) => e.pattern), ...(pathTables?.forCall(toolCallId).ruleRows ?? handsReadFaceInput.denyRuleRows).filter((r) => r.faces.includes("read")).map((r) => r.rule)] }), hookEnvFace, writeProtectionCheck, shellReadCheck, readFace: () => resolvedReadFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider: autoModeDeciderRef, autoModeDenialTracking: autoModeDenialTrackingRef, askRoute: { ...wiringManifest.ask, effective: askSeatWord }, notResumable: legNotResumable, permissionMode, toolMarkSources, ...(deps.a2a?.isolatePeers === true ? { a2aIsolatePeers: true } : {}), a2aInsidePeerOf: a2aInsidePeerReader(lockedPreflight.a2a, deps.a2a?.isolatePeers === true), ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane: permissionRuleGateLane, seatInputsFor, permissionRuleOrgLane, questionToolMounted, durableQuestionFace, suspendTargetGap, continuationCalls: legParkClosureSeat.continuationCalls, workflowParkGap: internals?.workflowParkGap, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, commandSandboxArmed: commandSandboxRun.state === "armed", sandboxPlanOf });
1012
1024
  const postureFrameRef = { report: (err) => deps.onError?.(err, { phase: "degraded", sessionId }) };
1013
1025
  const limitApproachRef = {};
1014
1026
  const renderTurnStartRequest = async (view, signal) => {
@@ -1036,7 +1048,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
1036
1048
  ...(commandSandboxRequirement !== undefined ? { effectiveSandbox: commandSandboxRequirement } : {}),
1037
1049
  ...(externalContentTargetActive ? { effectiveExternalContentTarget: true } : {}),
1038
1050
  };
1039
- const buildPrepared = () => ({ harness, session, sessionId, ...(rewindOutcome !== undefined ? { rewindOutcome } : {}), ...(captureLineage.own !== undefined ? { sessionIncarnation: captureLineage.own } : {}), ...(captureLineage.fault ? { sessionIncarnationUnread: true } : {}), taskId: hostTaskId, runId, crossBoundary, ...(doors.hostFloor !== undefined ? { hostFloor: doors.hostFloor } : {}), registryAccess: { owner: hostTaskId, scope: taskScope }, reminderMark, seededCopies, reminderDisclosureCounts, fullShellReachable, approvalPosture: { get mode() { return permissionMode.current; }, askEffective: askSeatWord }, ...(outputStyleSeat !== undefined ? { outputStyleFrame: renderOutputStyle(outputStyleSeat, engineText) } : {}), runTimeReminders, permissionMode, editedFilesSnapshot, taskRootPath: taskRootFinal, model, thinking, fastMode: fastModeLeg, mcp, ...(mcpRedial !== undefined ? { mcpRedial } : {}), ...(a2a.tools.length > 0 ? { a2a } : {}), blockedRef, outputRef, abortController, writeRefusal, blockedToolCalls, toolOccurrences, hookScreens, hookProgress, batchHaltRef, nestedStats, spend, laneDeps: deps, ...(rewindNotes.length > 0 ? { rewindNotes } : {}), ...(fileHistoryBoundary !== undefined ? { fileHistoryBoundary } : {}), ...(effectiveReadFaceObserved !== undefined ? { effectiveReadFace: effectiveReadFaceObserved, effectiveWriteFace: effectiveWriteFaceObserved } : {}), ...(effectiveReadDenyObserved !== undefined ? { effectiveReadDenyPatterns: effectiveReadDenyObserved } : {}), ...legPostureSeats, callerPlaces, effectiveMemoryScopes: memoryEffectiveScopes, readFloorUnkept: handsReadFace.readFloorUnkept, ...(placementValueOrAbsent(placementRootResolved) !== undefined ? { placementRoot: placementRootResolved } : {}), cwdRef: handsCwdRef, ...(attachmentRootCanonical !== undefined ? { handsRoot: attachmentRootCanonical } : {}), ...(stampCallTarget !== undefined ? { stampCallTarget } : {}), toolProgressRef, turnAbortRef, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), exemptRoots: legExemptRoots, ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), workspaceFrame: createWorkspaceFrameSeat(givenNoWorkspace ? undefined : { root: taskRootCanonical, ...(handsCwdRef !== undefined ? { cwdRef: handsCwdRef } : {}), ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), ...sessionFrameOf(sessionCheckout.record), ...(sessionCheckout.directories !== undefined ? { directories: sessionCheckout.directories } : {}), ...(sessionProject.project !== undefined ? { project: sessionProject.project } : {}), remote: workspaceRemote }), ...(workspaceStateSettle !== undefined ? { workspaceStateSettle } : {}), ...(sealReadStateSeat !== undefined ? { sealReadStateSeat } : {}), denyNarrowingPolicy, skillGrants: skillGrantLane, skillSpecs, ...(permissionRuleLane !== undefined ? { persistedRuleLane: permissionRuleLane } : {}), ...(basePolicyForResumeEdit !== undefined ? { basePolicyForResumeEdit } : {}), consolidationWriteJudge, ...(permissionRuleOrgLane !== undefined ? { permissionRuleOrg: permissionRuleOrgLane } : {}), releaseSignal, endModeCeiling, settleContentAskBindings, prefixChanges: legPrefix.changes, endPrefixLeg: () => endPrefixLeg(legPrefix.ledger, prefixLeg.number, limitApproachRef, session), observeSideRequest: legPrefix.observeSide, prefixAnchor, wiringManifest, promptManifest, promptIdentity, activeTools, ...(deferred.size > 0 ? { deferredToolNames: deferred } : {}), toolMaterializeStatic, deferDirectCall, ...(staticFaceForRef.current !== undefined ? { staticFaceFor: staticFaceForRef.current } : {}), ownedEnv, ...(workspaceSync !== undefined ? { workspaceSync } : {}), pausedRef, undeliveredContinuationRef, suspendProgressRef, remoteEnvFailures, refusedAsks, verdictLedger, reviewRequestRef, suspendLoopRef, suspendForResource, ...(suspendForPlatformLimit !== undefined ? { suspendForPlatformLimit } : {}), ...(suspendLaneGap !== undefined ? { suspendLaneGap } : {}), ...(envLifetimeSuspendAt !== undefined ? { envLifetimeSuspendAt } : {}), ...(usageGovernance !== undefined ? { usageGovernance } : {}), callIssuedAtRef, workCutRef, loopTerminalRef, loopReasksRef, brainCallGuardrailRef, gateStopRef, stopForDenialLimit, suspendForReview, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}), resourceLedger: priorLedger, liveSpendRef, humanReviewRef, now, tools, toolRoster, toolRosterDeltas: rosterSeat, structuredProjector, toolEffects, wakeRecovered, promptOverheadTokens, lastBrainContext, lastSentRequest: () => lastBrainContextRef.current, ...(advisor.instruction !== undefined ? { advisorInstruction: advisor.instruction } : {}), ...(languageSeat !== undefined ? { languageSeat } : {}), ...(sandboxFrameSeat !== undefined ? { sandboxFrameSeat } : {}), ...(memoryNoticesFrame !== undefined ? { memoryNoticesFrame } : {}), ...(compactionRestore !== undefined ? { compactionRestore } : {}), recentlyReadFiles, normalizeAttachmentPath, ...(onCompactionApplied ? { onCompactionApplied } : {}), compactionReuseRef, trimPressureRef, microCompact, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit && withheldDiagnosticsOf ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit, runIdent: lspRunIdent, withheldOf: withheldDiagnosticsOf } } : {}), stopRequestedRef, announcedSnapshotRecovered: onceLedger.recovered, ...(dateChange ? { dateChange } : {}), ...(workflowSizeGuideline ? { workflowSizeGuideline } : {}), ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(nestedMemory !== undefined ? { nestedMemory } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(mcpUnavailable ? { mcpUnavailable } : {}), ...(agentListing ? { agentListing } : {}), ...(skillsListing ? { skillsListing } : {}), announcedListingsRef, frameReceipts, engineText, frameSettlement, ...(userAttachmentsSeat !== undefined ? { userAttachments: userAttachmentsSeat } : {}), attachmentDelivery: createAttachmentDelivery(), imageUnprocessed, ...(modelFileReaderSeat.current !== undefined ? { modelFileReader: modelFileReaderSeat.current } : {}), syntheticReadVerdict, ...(peerLaneRefs.boundaryRound !== undefined ? { peerBoundaryRound: peerLaneRefs.boundaryRound } : {}), gitStatusRef, postureFrameRef, requestCoreRef, limitApproachRef, listBackgroundTasks, taskReadHandleOf, hookIdentity, legNotice, modBus: legMods.bus, endModLife: legMods.end, admitRows: rowSeat.admitRows, receiveSeat, turnOpenRedelivery: {}, compactStation, sessionMeasure, sideCallBookRef, ...(sessionBoxBound !== undefined ? { sessionBox: sessionBoxBound } : {}), ...(turnSnapshotRef.current !== undefined ? { turnSnapshot: turnSnapshotRef.current } : {}), ...(centerCompactionCandidate !== undefined ? { centerCompactionCandidate } : {}), ...(shellReadCheck !== undefined ? { shellReadCheck } : {}), ...(shellReadLandings !== undefined ? { shellReadLandings } : {}), commandSandboxPlanOf: sandboxPlanOf, ...(toolDisclosureSeat !== undefined ? { toolDisclosure: toolDisclosureSeat } : {}), ...(approvedCallScreen !== undefined ? { approvedCallScreen } : {}), ...(toolCallStationRef.current !== undefined ? { toolCallStation: toolCallStationRef.current } : {}), legAdoption, declaredReadKeys: (id, call) => (declaredReadSlotOf(call) === undefined ? undefined : (judgedReadsSeat.current?.(id)?.map((t) => t.key) ?? "unjudged")) });
1051
+ const buildPrepared = () => ({ harness, session, sessionId, ...(rewindOutcome !== undefined ? { rewindOutcome } : {}), ...(captureLineage.own !== undefined ? { sessionIncarnation: captureLineage.own } : {}), ...(captureLineage.fault ? { sessionIncarnationUnread: true } : {}), taskId: hostTaskId, runId, legStartedAt, crossBoundary, ...(doors.hostFloor !== undefined ? { hostFloor: doors.hostFloor } : {}), registryAccess: { owner: hostTaskId, scope: taskScope }, ...(runLedgerSeats !== undefined ? { runLedgerBook: runLedgerSeats.book } : {}), reminderMark, seededCopies, reminderDisclosureCounts, fullShellReachable, approvalPosture: { get mode() { return permissionMode.current; }, askEffective: askSeatWord }, ...(outputStyleSeat !== undefined ? { outputStyleFrame: renderOutputStyle(outputStyleSeat, engineText) } : {}), runTimeReminders, permissionMode, editedFilesSnapshot, taskRootPath: taskRootFinal, model, thinking, fastMode: fastModeLeg, mcp, ...(mcpRedial !== undefined ? { mcpRedial } : {}), ...(a2a.tools.length > 0 ? { a2a } : {}), blockedRef, outputRef, abortController, writeRefusal, blockedToolCalls, toolOccurrences, hookScreens, hookProgress, batchHaltRef, nestedStats, spend, laneDeps: deps, ...(rewindNotes.length > 0 ? { rewindNotes } : {}), ...(fileHistoryBoundary !== undefined ? { fileHistoryBoundary } : {}), ...(effectiveReadFaceObserved !== undefined ? { effectiveReadFace: effectiveReadFaceObserved, effectiveWriteFace: effectiveWriteFaceObserved } : {}), ...(effectiveReadDenyObserved !== undefined ? { effectiveReadDenyPatterns: effectiveReadDenyObserved } : {}), ...legPostureSeats, callerPlaces, effectiveMemoryScopes: memoryEffectiveScopes, readFloorUnkept: handsReadFace.readFloorUnkept, ...(placementValueOrAbsent(placementRootResolved) !== undefined ? { placementRoot: placementRootResolved } : {}), cwdRef: handsCwdRef, ...(attachmentRootCanonical !== undefined ? { handsRoot: attachmentRootCanonical } : {}), ...(stampCallTarget !== undefined ? { stampCallTarget } : {}), toolProgressRef, turnAbortRef, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), exemptRoots: legExemptRoots, ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), workspaceFrame: createWorkspaceFrameSeat(givenNoWorkspace ? undefined : { root: taskRootCanonical, ...(handsCwdRef !== undefined ? { cwdRef: handsCwdRef } : {}), ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), ...sessionFrameOf(sessionCheckout.record), ...(sessionCheckout.directories !== undefined ? { directories: sessionCheckout.directories } : {}), ...(sessionProject.project !== undefined ? { project: sessionProject.project } : {}), remote: workspaceRemote }), ...(workspaceStateSettle !== undefined ? { workspaceStateSettle } : {}), ...(sealReadStateSeat !== undefined ? { sealReadStateSeat } : {}), denyNarrowingPolicy, skillGrants: skillGrantLane, skillSpecs, ...(permissionRuleLane !== undefined ? { persistedRuleLane: permissionRuleLane } : {}), ...(basePolicyForResumeEdit !== undefined ? { basePolicyForResumeEdit } : {}), consolidationWriteJudge, ...(permissionRuleOrgLane !== undefined ? { permissionRuleOrg: permissionRuleOrgLane } : {}), releaseSignal, endModeCeiling, settleContentAskBindings, prefixChanges: legPrefix.changes, endPrefixLeg: () => endPrefixLeg(legPrefix.ledger, prefixLeg.number, limitApproachRef, session), observeSideRequest: legPrefix.observeSide, prefixAnchor, wiringManifest, promptManifest, promptIdentity, activeTools, ...(deferred.size > 0 ? { deferredToolNames: deferred } : {}), toolMaterializeStatic, deferDirectCall, ...(staticFaceForRef.current !== undefined ? { staticFaceFor: staticFaceForRef.current } : {}), ownedEnv, ...(workspaceSync !== undefined ? { workspaceSync } : {}), pausedRef, undeliveredContinuationRef, suspendProgressRef, remoteEnvFailures, refusedAsks, verdictLedger, reviewRequestRef, suspendLoopRef, suspendForResource, ...(suspendForPlatformLimit !== undefined ? { suspendForPlatformLimit } : {}), ...(suspendLaneGap !== undefined ? { suspendLaneGap } : {}), ...(envLifetimeSuspendAt !== undefined ? { envLifetimeSuspendAt } : {}), ...(usageGovernance !== undefined ? { usageGovernance } : {}), callIssuedAtRef, workCutRef, loopTerminalRef, loopReasksRef, brainCallGuardrailRef, gateStopRef, stopForDenialLimit, suspendForReview, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}), resourceLedger: priorLedger, liveSpendRef, humanReviewRef, now, tools, toolRoster, toolRosterDeltas: rosterSeat, structuredProjector, toolEffects, wakeRecovered, promptOverheadTokens, lastBrainContext, lastSentRequest: () => lastBrainContextRef.current, ...(advisor.instruction !== undefined ? { advisorInstruction: advisor.instruction } : {}), ...(languageSeat !== undefined ? { languageSeat } : {}), ...(sandboxFrameSeat !== undefined ? { sandboxFrameSeat } : {}), ...(memoryNoticesFrame !== undefined ? { memoryNoticesFrame } : {}), ...(compactionRestore !== undefined ? { compactionRestore } : {}), recentlyReadFiles, normalizeAttachmentPath, ...(onCompactionApplied ? { onCompactionApplied } : {}), compactionReuseRef, trimPressureRef, microCompact, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit && withheldDiagnosticsOf ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit, runIdent: lspRunIdent, withheldOf: withheldDiagnosticsOf } } : {}), stopRequestedRef, announcedSnapshotRecovered: onceLedger.recovered, ...(dateChange ? { dateChange } : {}), ...(workflowSizeGuideline ? { workflowSizeGuideline } : {}), ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(nestedMemory !== undefined ? { nestedMemory } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(mcpUnavailable ? { mcpUnavailable } : {}), ...(agentListing ? { agentListing } : {}), ...(skillsListing ? { skillsListing } : {}), announcedListingsRef, frameReceipts, engineText, frameSettlement, ...(userAttachmentsSeat !== undefined ? { userAttachments: userAttachmentsSeat } : {}), attachmentDelivery: createAttachmentDelivery(), imageUnprocessed, ...(modelFileReaderSeat.current !== undefined ? { modelFileReader: modelFileReaderSeat.current } : {}), syntheticReadVerdict, ...(peerLaneRefs.boundaryRound !== undefined ? { peerBoundaryRound: peerLaneRefs.boundaryRound } : {}), gitStatusRef, postureFrameRef, requestCoreRef, limitApproachRef, listBackgroundTasks, taskReadHandleOf, hookIdentity, legNotice, modBus: legMods.bus, endModLife: legMods.end, admitRows: rowSeat.admitRows, receiveSeat, turnOpenRedelivery: {}, compactStation, sessionMeasure, sideCallBookRef, ...(sessionBoxBound !== undefined ? { sessionBox: sessionBoxBound } : {}), ...(turnSnapshotRef.current !== undefined ? { turnSnapshot: turnSnapshotRef.current } : {}), ...(centerCompactionCandidate !== undefined ? { centerCompactionCandidate } : {}), ...(shellReadCheck !== undefined ? { shellReadCheck } : {}), ...(shellReadLandings !== undefined ? { shellReadLandings } : {}), commandSandboxPlanOf: sandboxPlanOf, ...(toolDisclosureSeat !== undefined ? { toolDisclosure: toolDisclosureSeat } : {}), ...(approvedCallScreen !== undefined ? { approvedCallScreen } : {}), ...(toolCallStationRef.current !== undefined ? { toolCallStation: toolCallStationRef.current } : {}), legAdoption, declaredReadKeys: (id, call) => (declaredReadSlotOf(call) === undefined ? undefined : (judgedReadsSeat.current?.(id)?.map((t) => t.key) ?? "unjudged")) });
1040
1052
  refuseLateRosterChanges(callerRoster.roster);
1041
1053
  rollback.commit();
1042
1054
  prefixLeg.number = await legPrefix.ledger.openLeg(() => session.getBranch(), (id) => session.getBranch(id));
@@ -16,7 +16,9 @@ import { type ContainmentFace } from "../../tools/fs/index.js";
16
16
  import type { ReadRootsSeat } from "./person-path-rows.js";
17
17
  import { type ReadFileState } from "../../tools/fs/safety.js";
18
18
  import type { DateAnchorRead, MemoryTailSnapshot, Prepared } from "./contracts.js";
19
- import { type DeclaredRoot, type ScreenedNestedMemory } from "./nested-memory-lane.js";
19
+ import { type DeclaredRoot, type NestedMemoryLane, type NestedMemoryLaneSeat, type ScreenedNestedMemory } from "./nested-memory-lane.js";
20
+ /** Single construction site for the instruction-file lane (live legs and `Runner.previewInstructions`). */
21
+ export declare const seatInstructionLane: (seat: NestedMemoryLaneSeat) => NestedMemoryLane;
20
22
  import type { ModelFileReader } from "../../tools/fs/fs-read.js";
21
23
  import type { ReminderDisclosureCounts } from "../reminder-disclosure.js";
22
24
  export interface PrepareTurnWiringInput {
@@ -155,8 +157,7 @@ export interface PrepareTurnWiringInput {
155
157
  /** owned — the instruction-file family as the config door read it (its one reading); absent ⇒ no lane. */
156
158
  nestedDeclaration: ScreenedNestedMemory | undefined;
157
159
  /** borrowed-readonly — the additional working directories the spec declared, as the hands resolved them (the lane's further roots under the family's opt-in). */
158
- declaredAdditionalRoots: readonly DeclaredRoot[];
159
- /** borrowed-readonly — the leg's budget snapshot the live gate stamps on every request (the card's probe carries it too). */
160
+ declaredAdditionalRoots: readonly DeclaredRoot[]; /** borrowed-readonly — the leg's budget snapshot the live gate stamps on every request (the card's probe carries it too). */
160
161
  budgetSnapshot: NonNullable<ToolCallRequest["budget"]>;
161
162
  }
162
163
  export interface PrepareTurnWiringResult {
@@ -17,6 +17,7 @@ import { headSegmentsChanged } from "./conversation-segment.js";
17
17
  import { CHANGED_FILES_MTIME_EPS_MS } from "./turn-attachments.js";
18
18
  import { frameFileToolsOf, isInstructionLaneEntry, readCompactionRestore } from "../user-attachment.js";
19
19
  import { createNestedMemoryLane } from "./nested-memory-lane.js";
20
+ export const seatInstructionLane = (seat) => createNestedMemoryLane(seat);
20
21
  export function declaringCallPolicy(turnSnapshotRef, stream) {
21
22
  return (model, context, options) => {
22
23
  turnSnapshotRef.current?.refreshRequestPolicy({ thinkingLevel: options?.reasoning ?? null, maxTokens: options?.maxTokens ?? model.maxTokens ?? null, fastSpeed: options?.fastMode?.requested === true && fastModeUnavailableFor(model) === undefined });
@@ -99,7 +100,7 @@ export function prepareTurnWiring(input) {
99
100
  const laneHands = handsEnabled && modelFileReader !== undefined && readFileStateForCheckpoint !== undefined && attachmentRootCanonical !== undefined ? { env: executionEnv, reader: modelFileReader, judge: servedReadVerdict, readFace: rosterReadFace, state: readFileStateForCheckpoint, root: attachmentRootCanonical, additionalRoots: input.declaredAdditionalRoots } : undefined;
100
101
  const rosterFileTools = () => frameFileToolsOf(preparedHolder.current?.toolRoster);
101
102
  const laneCommon = nestedDeclaration === undefined ? undefined : { declaration: nestedDeclaration, signal: abortController.signal, mark: reminderMark, counts: reminderDisclosureCounts, deps, leg: () => preparedHolder.current, fileTools: rosterFileTools };
102
- const nestedMemory = laneCommon === undefined ? undefined : createNestedMemoryLane(laneHands !== undefined ? { ...laneCommon, ...laneHands } : laneCommon);
103
+ const nestedMemory = laneCommon === undefined ? undefined : seatInstructionLane(laneHands !== undefined ? { ...laneCommon, ...laneHands } : laneCommon);
103
104
  const announceRestoreSkip = (path, reason) => {
104
105
  deps.onError?.(new Error(`compaction restore did not deliver ${path}: ${reason}`), { phase: "degraded", sessionId, classification: "attachment-read" });
105
106
  };
@@ -54,13 +54,15 @@ export interface PrepareWiringManifestInput {
54
54
  deps: RunnerDeps;
55
55
  /** borrowed-readonly — the trusted spawn-side channel: `questionFaceStripped`, `isDelegatedChild`, `onTaskNotification`,
56
56
  * `peerSelfRef`, `explicitAgentName`, `principalInboxAssistant` (the drain + the identity), `insideFork` / `agentName` / `spawnAgentType` / `parentToolCallId` (the identity). */
57
- internals: Pick<RunInternals, "questionFaceStripped" | "isDelegatedChild" | "observerLeg" | "onTaskNotification" | "peerSelfRef" | "explicitAgentName" | "principalInboxAssistant" | "spawnAgentType" | "insideFork" | "agentName" | "parentToolCallId"> | undefined;
57
+ internals: Pick<RunInternals, "questionFaceStripped" | "isDelegatedChild" | "observerLeg" | "onTaskNotification" | "peerSelfRef" | "explicitAgentName" | "principalInboxAssistant" | "spawnAgentType" | "insideFork" | "agentName" | "parentToolCallId" | "rootSessionId"> | undefined;
58
58
  /** borrowed-readonly — the resume leg, or undefined (the manifest's leg derivation reads presence only). */
59
59
  resume: Pick<PrepareResume, "seed"> | undefined;
60
60
  /** borrowed-readonly — the acquired session id. */
61
61
  sessionId: string;
62
62
  /** borrowed-readonly — the run's invocation id. */
63
63
  runId: string;
64
+ /** borrowed-readonly — epoch ms minted once beside {@link runId} at prepare entry; stamped on `manifest.leg.instance.startedAt`. */
65
+ legStartedAt: number;
64
66
  /** borrowed-readonly — the per-task identity (the hook identity's taskId). */
65
67
  hostTaskId: string;
66
68
  /** borrowed-readonly — the registry scope the peer drain binds under. */
@@ -2,6 +2,7 @@ import { bindPeerLaneDrain, peerDrainLanesOf } from "../../agents/peer-session-d
2
2
  import { teamRoleOf } from "../../agents/team-role.js";
3
3
  import { resolveCheckpointStore } from "../checkpoint-store.js";
4
4
  import { createHookEnvCapabilities, mintHookInvocationIdentity } from "../hooks.js";
5
+ import { hookRootSessionIdOf } from "../leg-identity.js";
5
6
  import { chainJudges } from "../mods/stations.js";
6
7
  import { MOD_EVENTS_HANDING_ENV } from "../mods/kernel/events.js";
7
8
  import { suspendTargetGapRowOf } from "../remote-env.js";
@@ -139,7 +140,7 @@ export function durableSuspendInfraGaps(facts) {
139
140
  return gaps;
140
141
  }
141
142
  export function prepareWiringManifest(input) {
142
- const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus, standingModBus, checkpointScope, policyLayers, effectivePolicy, handsEnabled, skippedFactory, taskRootFinal, legWriteGuard, mcp, a2a, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, fastMode, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, sessionBox, sessionAddress, runEnd, harness, pausedRef, askSeat, liveInheritedGate, delegation, approvalParkNotResumable, forcedGateNotResumable, toolRoster, toolPlan, readDenyBuiltinTiersActive, readFloorUnkept, lspManagerWired, shellReadStationArmed, crossBoundaryStationEngaged, lspDiagnosticsLive, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive, memoryPollution, advisorFact, hostFloorPosture, sessionProject, runOrigin, commandSandboxFact, callerPlaces } = input;
143
+ const { spec, deps, internals, resume, sessionId, runId, legStartedAt, hostTaskId, taskScope, modBus, standingModBus, checkpointScope, policyLayers, effectivePolicy, handsEnabled, skippedFactory, taskRootFinal, legWriteGuard, mcp, a2a, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, fastMode, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, sessionBox, sessionAddress, runEnd, harness, pausedRef, askSeat, liveInheritedGate, delegation, approvalParkNotResumable, forcedGateNotResumable, toolRoster, toolPlan, readDenyBuiltinTiersActive, readFloorUnkept, lspManagerWired, shellReadStationArmed, crossBoundaryStationEngaged, lspDiagnosticsLive, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive, memoryPollution, advisorFact, hostFloorPosture, sessionProject, runOrigin, commandSandboxFact, callerPlaces } = input;
143
144
  const onAsk = askSeat.value;
144
145
  const handWriteTools = toolRoster.entries.filter((e) => e.mountedBy === "hands" && (e.effect === "write" || e.effect === "idempotent")).map((e) => e.name);
145
146
  const hasEffectAwareGate = policyLayers.length > 0 || chainJudges(standingModBus);
@@ -172,10 +173,9 @@ export function prepareWiringManifest(input) {
172
173
  ungatedWarnedShapes.set(deployment, shapes);
173
174
  }
174
175
  shapes.add(what);
175
- deps.onError?.(new Error(`write-capable ${what} are present but UNGATED — ` +
176
- (hasEffectAwareGate
177
- ? `no question of the ${permissionMode.current} mode reaches their calls. `
178
- : `wire an effect-aware tool policy (or a PreToolUse hook). bash/MCP irreversible actions are otherwise unadjudicated; the deployment sandbox/egress boundary is the only protection. `) +
176
+ deps.onError?.(new Error((hasEffectAwareGate
177
+ ? `write-capable ${what} are present and no question of the ${permissionMode.current} mode reaches their calls — a tool policy the deployment wired may still ask about a call; this warning does not see what it decides. `
178
+ : `write-capable ${what} are present but UNGATED — wire an effect-aware tool policy (or a PreToolUse hook). bash/MCP irreversible actions are otherwise unadjudicated; the deployment sandbox/egress boundary is the only protection. `) +
179
179
  (peerWriteUngated.length > 0 ? `Under ${permissionMode.current} a server's tools run with nobody stating them; a deny or ask rule naming them still gates them. ` : "") +
180
180
  (callerWriteUnasked.length > 0
181
181
  ? `Under ${permissionMode.current} a caller's tool that declares no permission seat answers for itself: the mode's question never reaches its calls (in auto, the classifier rules only on what a rule or a policy asks); declare permissionSeat: "passthrough" on it to put each call to the mode's question. A deny or ask rule naming it still gates it, and a read target it declares (pathTarget access "read") is judged by the read station whatever its seat. `
@@ -212,7 +212,7 @@ export function prepareWiringManifest(input) {
212
212
  const wiringQuestionStripped = internals?.questionFaceStripped === true;
213
213
  const wiringFacts = {
214
214
  half: "effective",
215
- leg: wiringLegKindOf(resume !== undefined, internals), ...(runOrigin !== undefined ? { runOrigin } : {}),
215
+ leg: wiringLegKindOf(resume !== undefined, internals), legInstance: { runId, startedAt: legStartedAt }, ...(runOrigin !== undefined ? { runOrigin } : {}), ...(deps.host !== undefined ? { host: deps.host } : {}),
216
216
  teamRole: teamRoleOf({ isDelegatedChild: delegation.isDelegatedChild, ...(internals?.explicitAgentName !== undefined ? { spawnName: internals.explicitAgentName } : {}) }),
217
217
  ...(spec.peerPresence !== undefined ? { peerPresence: spec.peerPresence } : {}),
218
218
  askForm: askSeat.form,
@@ -307,8 +307,10 @@ export function prepareWiringManifest(input) {
307
307
  spec.enablePlanMode === true ||
308
308
  commandSandboxFact.state === "armed";
309
309
  announceDurableGateUnavailable({ onNotice: deps.onNotice, mandate: durableMandateSourceOf({ forceDurableGate: runtimeCaps?.forceDurableGate === true, durableApprovalDeclared: spec.durableApproval !== undefined, onAsk }), storeWired: checkpointStore !== undefined, taskStoreDisabled: spec.checkpointStore === "disabled", notResumable: forcedGateNotResumable, liveApprover: isAnsweringSeat(onAsk), seatForm: askSeat.form, declaredNone: askSeat.reach === "none", liveQuestionFace: liveQuestionFace !== undefined, parentConstraints: liveInheritedGate?.parentConstraints, sessionId, runId, principal: spec.principal });
310
+ const rootSessionId = hookRootSessionIdOf(internals, sessionId, delegation.isDelegatedChild);
310
311
  const hookIdentity = mintHookInvocationIdentity({
311
312
  sessionId,
313
+ ...(rootSessionId !== undefined ? { rootSessionId } : {}),
312
314
  taskId: hostTaskId,
313
315
  legKind: wiringManifest.leg.kind,
314
316
  isDelegatedChild: delegation.isDelegatedChild,
@@ -5,8 +5,9 @@ import { chainPolicyOnLeg, chainTopAnchors } from "./child-tree.js";
5
5
  import { mintHookInvocationIdentity } from "../hooks.js";
6
6
  import { admitLegMods, listLegModSeats, classicEventBase, failedHandlerClause, promptScreenHasHandlers, screenUserPrompt } from "../mods/stations.js";
7
7
  import { inputSourceOf } from "../steer-replay.js";
8
- import { legTaskIdOf } from "../leg-identity.js";
9
- import { restoreRowTaskId } from "./checkpoint-scope.js";
8
+ import { hookRootSessionIdOf, legTaskIdOf } from "../leg-identity.js";
9
+ import { restoreRowIdentity, resumedDeclaredTaskId } from "./checkpoint-scope.js";
10
+ import { runLedgerIdentityOf } from "../run-ledger.js";
10
11
  import { bindableArgsOf, callFactsSeat, checkToolPolicyProjection, policyCannotAnswer, refuseOutOfContractDecision } from "../tool-policy.js";
11
12
  import { editRecheckUnanswered } from "../real-approval.js";
12
13
  import { requestGrantBinding } from "../skill-grant-binding.js";
@@ -36,8 +37,10 @@ export async function resumeApply(input) {
36
37
  }
37
38
  }
38
39
  async function applyRungs(input, admitted) {
39
- const { cp, config, internals, outcomeGate, wakeMessage, resumeSignal, recheckGovernanceWindow, plainReviewOutcome, plainParkOutcome, runner, effectiveDelegationFacts } = input;
40
+ const { cp, config, outcomeGate, wakeMessage, resumeSignal, recheckGovernanceWindow, plainReviewOutcome, plainParkOutcome, runner, effectiveDelegationFacts } = input;
41
+ const internals = restoreRowIdentity(input.internals, cp.state);
40
42
  let plainPolicyOutcome = input.plainPolicyOutcome;
43
+ const ledgerTask = runLedgerIdentityOf(config, { section: cp.state.runLedger }, undefined);
41
44
  let wakeHookContext;
42
45
  let wakeDelivered = wakeMessage;
43
46
  let wakeRewrittenBy;
@@ -49,11 +52,14 @@ async function applyRungs(input, admitted) {
49
52
  }
50
53
  if (legMods !== undefined && promptScreenHasHandlers(legMods.bus)) {
51
54
  const screenedMessage = wakeMessage;
55
+ const isDelegatedChild = effectiveDelegationFacts(internals, cp.state.isDelegatedChild).isDelegatedChild;
56
+ const rootSessionId = hookRootSessionIdOf(internals, cp.sessionId, isDelegatedChild);
52
57
  const identity = mintHookInvocationIdentity({
53
58
  sessionId: cp.sessionId,
54
- taskId: legTaskIdOf(config, restoreRowTaskId(internals, cp.state.rowTaskId), cp.sessionId),
59
+ ...(rootSessionId !== undefined ? { rootSessionId } : {}),
60
+ taskId: legTaskIdOf(ledgerTask !== undefined && "taskId" in ledgerTask ? { taskId: ledgerTask.taskId } : { taskId: resumedDeclaredTaskId(config, cp.state) }, internals, cp.sessionId),
55
61
  legKind: "resume",
56
- isDelegatedChild: effectiveDelegationFacts(internals, cp.state.isDelegatedChild).isDelegatedChild,
62
+ isDelegatedChild,
57
63
  ...(internals?.insideFork === true ? { insideFork: true } : {}),
58
64
  ...(internals?.agentName !== undefined ? { agentName: internals.agentName } : {}),
59
65
  ...(internals?.explicitAgentName !== undefined ? { spawnName: internals.explicitAgentName } : {}),
@@ -1,4 +1,4 @@
1
- import { classifyQuestionOutcome, isLiveQuestionFace } from "../ask-question.js";
1
+ import { classifyQuestionOutcome, isLiveQuestionFace, QUESTION_OUTCOME_FAULT_TEXT } from "../ask-question.js";
2
2
  import { capturedJsonOf, editOfAnswer, exactBoundInputHashOf } from "../canonical-json.js";
3
3
  import { bindingRefusalOf } from "../tool-policy.js";
4
4
  import { CheckpointError, checkpointVersionOf, winnerFromOutcome } from "../checkpoint-store.js";
@@ -23,7 +23,10 @@ export function resumePolicyOutcome(input) {
23
23
  if (suppliedAnswer !== undefined) {
24
24
  const reading = classifyQuestionOutcome(suppliedAnswer);
25
25
  if (reading.shape !== "answered") {
26
- throw new CheckpointError("checkpoint.invalid_outcome", "resume carried a content-ask `answer` that does not read as an answer (malformed, sparse, or not capturable as plain data) — " +
26
+ const why = reading.shape === "contradictory"
27
+ ? QUESTION_OUTCOME_FAULT_TEXT[reading.fault]
28
+ : 'the value claims "unavailable", which is not an answer';
29
+ throw new CheckpointError("checkpoint.invalid_outcome", `resume carried a content-ask \`answer\` that does not read as an answer (${why}) — ` +
27
30
  "refusing pre-CAS rather than fabricating an empty human response; the checkpoint stays pending", { field: "answer" });
28
31
  }
29
32
  redeemedAnswer = reading.answer;
@@ -7,6 +7,7 @@
7
7
  * pre-CAS.
8
8
  */
9
9
  import { type Checkpoint, type PendingSteerEntry, type ResumeOutcome } from "../checkpoint-store.js";
10
+ import type { PermissionMode } from "../types.js";
10
11
  export interface ResumeReviewOutcomeInput {
11
12
  /** borrowed-readonly — the pending row (the lane is keyed on the STORED gate kind). */
12
13
  cp: Checkpoint;
@@ -16,6 +17,8 @@ export interface ResumeReviewOutcomeInput {
16
17
  outcomeGate: ResumeOutcome["gate"];
17
18
  /** borrowed-readonly — the validated wake message, carried into the wake twin. */
18
19
  wakeMessage: Omit<PendingSteerEntry, "seq"> | undefined;
20
+ /** borrowed-readonly — the resume config's mode as its door read it: a plan approval's mode may not contradict it. */
21
+ configPermissionMode: PermissionMode | undefined;
19
22
  }
20
23
  export interface ResumeReviewOutcomeResult {
21
24
  /** The review lane's plain twin (a plan_review / needs_review row), else undefined. */