@sema-agent/core 7.55.0 → 7.56.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 (418) hide show
  1. package/CHANGELOG.md +513 -0
  2. package/dist/agents/cascade.js +1 -1
  3. package/dist/agents/cc-peer-directory.js +1 -0
  4. package/dist/agents/child-model-seat.d.ts +0 -11
  5. package/dist/agents/child-model-seat.js +0 -3
  6. package/dist/agents/list-agents-tool.d.ts +3 -1
  7. package/dist/agents/list-agents-tool.js +7 -7
  8. package/dist/agents/peer-directory.d.ts +22 -4
  9. package/dist/agents/peer-directory.js +24 -2
  10. package/dist/agents/peer-session-drain.js +2 -2
  11. package/dist/agents/repair-loop.js +2 -2
  12. package/dist/agents/send-message-tool.js +4 -4
  13. package/dist/agents/subagent.d.ts +6 -4
  14. package/dist/agents/subagent.js +64 -60
  15. package/dist/agents/tool-filter.d.ts +7 -5
  16. package/dist/agents/tool-filter.js +12 -9
  17. package/dist/agents/verify.d.ts +3 -2
  18. package/dist/agents/verify.js +3 -3
  19. package/dist/brain/anthropic.js +30 -73
  20. package/dist/brain/media-degrade.d.ts +18 -7
  21. package/dist/brain/media-degrade.js +13 -2
  22. package/dist/brain/model-capability.d.ts +37 -0
  23. package/dist/brain/model-capability.js +34 -0
  24. package/dist/brain/model-presets.d.ts +2 -8
  25. package/dist/brain/model-presets.js +1 -6
  26. package/dist/brain/open-responses.js +13 -26
  27. package/dist/brain/openai.js +14 -87
  28. package/dist/brain/reasoning-request.d.ts +96 -0
  29. package/dist/brain/reasoning-request.js +174 -0
  30. package/dist/brain/reasoning.d.ts +11 -11
  31. package/dist/brain/reasoning.js +4 -3
  32. package/dist/brain/request-params.d.ts +7 -4
  33. package/dist/brain/request-params.js +7 -4
  34. package/dist/brain/status-sink.d.ts +20 -0
  35. package/dist/brain/status-sink.js +7 -0
  36. package/dist/core/a2a.d.ts +2 -1
  37. package/dist/core/a2a.js +19 -13
  38. package/dist/core/agent-definition.d.ts +10 -0
  39. package/dist/core/allow-entry.d.ts +20 -13
  40. package/dist/core/allow-entry.js +26 -22
  41. package/dist/core/allow-rule-shadow.d.ts +3 -3
  42. package/dist/core/ask-origin.d.ts +64 -18
  43. package/dist/core/ask-origin.js +63 -23
  44. package/dist/core/ask-question.d.ts +51 -8
  45. package/dist/core/ask-question.js +3 -4
  46. package/dist/core/ask-unresolvable-notice.d.ts +8 -3
  47. package/dist/core/ask-unresolvable-notice.js +16 -2
  48. package/dist/core/checkpoint-generation.d.ts +53 -0
  49. package/dist/core/checkpoint-generation.js +35 -0
  50. package/dist/core/checkpoint-queries.d.ts +180 -0
  51. package/dist/core/checkpoint-queries.js +272 -0
  52. package/dist/core/checkpoint-requirements.d.ts +13 -1
  53. package/dist/core/checkpoint-requirements.js +4 -0
  54. package/dist/core/checkpoint-store.d.ts +88 -24
  55. package/dist/core/checkpoint-store.js +24 -9
  56. package/dist/core/cross-boundary-taint.d.ts +6 -5
  57. package/dist/core/cross-boundary-taint.js +1 -3
  58. package/dist/core/decision-receipt.d.ts +37 -3
  59. package/dist/core/decision-receipt.js +17 -17
  60. package/dist/core/delegation-not-started.d.ts +6 -0
  61. package/dist/core/delegation-not-started.js +17 -0
  62. package/dist/core/engine-attestation.d.ts +93 -0
  63. package/dist/core/engine-attestation.js +70 -0
  64. package/dist/core/engine-capabilities.d.ts +4 -1
  65. package/dist/core/engine-capabilities.js +1 -1
  66. package/dist/core/engine-notice.d.ts +30 -11
  67. package/dist/core/file-history-store.d.ts +90 -14
  68. package/dist/core/file-history-store.js +23 -15
  69. package/dist/core/gate-fold.d.ts +1 -1
  70. package/dist/core/gate-fold.js +22 -10
  71. package/dist/core/gate-lanes.js +73 -64
  72. package/dist/core/gate-outcome.d.ts +26 -5
  73. package/dist/core/gate-outcome.js +26 -0
  74. package/dist/core/governance-codes.d.ts +5 -1
  75. package/dist/core/governance-codes.js +6 -0
  76. package/dist/core/hooks.d.ts +17 -16
  77. package/dist/core/hooks.js +3 -1
  78. package/dist/core/host-floor.d.ts +128 -0
  79. package/dist/core/host-floor.js +206 -0
  80. package/dist/core/host-target.d.ts +38 -3
  81. package/dist/core/host-target.js +38 -5
  82. package/dist/core/mcp.d.ts +5 -1
  83. package/dist/core/mcp.js +67 -41
  84. package/dist/core/memory-engine/delegation-settlement.js +15 -24
  85. package/dist/core/memory-engine/engine.js +4 -4
  86. package/dist/core/memory-engine/layout.d.ts +60 -8
  87. package/dist/core/memory-engine/layout.js +65 -6
  88. package/dist/core/model-seat.d.ts +10 -3
  89. package/dist/core/mods/classic-events.d.ts +67 -0
  90. package/dist/core/mods/classic-events.js +1 -0
  91. package/dist/core/mods/dollar.d.ts +13 -0
  92. package/dist/core/mods/extension-call.d.ts +31 -0
  93. package/dist/core/mods/extension-call.js +43 -0
  94. package/dist/core/mods/kernel/dispatch.d.ts +20 -3
  95. package/dist/core/mods/kernel/dispatch.js +140 -69
  96. package/dist/core/mods/kernel/events.d.ts +47 -11
  97. package/dist/core/mods/kernel/events.js +66 -42
  98. package/dist/core/mods/kernel/index.d.ts +4 -4
  99. package/dist/core/mods/kernel/index.js +2 -2
  100. package/dist/core/mods/kernel/receive.d.ts +39 -5
  101. package/dist/core/mods/kernel/receive.js +290 -17
  102. package/dist/core/mods/kernel/registration.d.ts +33 -2
  103. package/dist/core/mods/kernel/registration.js +6 -7
  104. package/dist/core/mods/kernel/site-rules.d.ts +44 -16
  105. package/dist/core/mods/kernel/site-rules.js +24 -42
  106. package/dist/core/mods/spec-seats.d.ts +69 -0
  107. package/dist/core/mods/spec-seats.js +114 -0
  108. package/dist/core/mods/stations.d.ts +28 -8
  109. package/dist/core/mods/stations.js +29 -13
  110. package/dist/core/mods/tool-call.d.ts +79 -0
  111. package/dist/core/mods/tool-call.js +152 -0
  112. package/dist/core/namespaced-rule-name.d.ts +32 -38
  113. package/dist/core/namespaced-rule-name.js +29 -36
  114. package/dist/core/parent-spec-seat.d.ts +6 -1
  115. package/dist/core/parent-spec-seat.js +2 -0
  116. package/dist/core/park-selfcheck.js +1 -0
  117. package/dist/core/permission-rule-consent.d.ts +19 -0
  118. package/dist/core/permission-rule-consent.js +116 -26
  119. package/dist/core/permission-rule-model.d.ts +14 -3
  120. package/dist/core/permission-rule-model.js +39 -24
  121. package/dist/core/permission-rule-org.d.ts +6 -2
  122. package/dist/core/permission-rule-org.js +7 -3
  123. package/dist/core/permission-rule-provider.d.ts +5 -2
  124. package/dist/core/permission-rule-provider.js +41 -11
  125. package/dist/core/permission-rule-store.d.ts +3 -2
  126. package/dist/core/permission-rule-store.js +11 -2
  127. package/dist/core/permission-rule-sync.js +3 -2
  128. package/dist/core/permission-rule-syntax.d.ts +5 -4
  129. package/dist/core/permission-rule-syntax.js +2 -2
  130. package/dist/core/permission-rules.d.ts +4 -4
  131. package/dist/core/permission-rules.js +11 -20
  132. package/dist/core/persisted-rule-arms.d.ts +2 -2
  133. package/dist/core/persisted-rule-arms.js +10 -12
  134. package/dist/core/principal-name.d.ts +20 -0
  135. package/dist/core/principal-name.js +22 -0
  136. package/dist/core/prompt-section-seat.js +4 -6
  137. package/dist/core/protocol-http-auth.d.ts +26 -5
  138. package/dist/core/protocol-http-auth.js +137 -4
  139. package/dist/core/retired-keys.d.ts +16 -0
  140. package/dist/core/retired-keys.js +16 -4
  141. package/dist/core/rewrite-rejudge.d.ts +60 -0
  142. package/dist/core/rewrite-rejudge.js +36 -0
  143. package/dist/core/roles.d.ts +28 -1
  144. package/dist/core/roles.js +31 -19
  145. package/dist/core/rule-lane-reads.d.ts +20 -15
  146. package/dist/core/rule-lane-reads.js +45 -17
  147. package/dist/core/rule-owner.d.ts +3 -3
  148. package/dist/core/rule-owner.js +3 -2
  149. package/dist/core/runner/announce-once-ledger.d.ts +14 -0
  150. package/dist/core/runner/announce-once-ledger.js +5 -0
  151. package/dist/core/runner/assemble-result.d.ts +1 -0
  152. package/dist/core/runner/assemble-result.js +1 -1
  153. package/dist/core/runner/call-hook-stations.d.ts +3 -2
  154. package/dist/core/runner/caller-roster.d.ts +16 -4
  155. package/dist/core/runner/caller-roster.js +33 -6
  156. package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
  157. package/dist/core/runner/capability-withheld-seat.js +24 -0
  158. package/dist/core/runner/classifier-ladder.d.ts +7 -9
  159. package/dist/core/runner/classifier-ladder.js +3 -3
  160. package/dist/core/runner/construction-doors.js +3 -0
  161. package/dist/core/runner/contracts.d.ts +28 -25
  162. package/dist/core/runner/cross-boundary-lane.d.ts +17 -13
  163. package/dist/core/runner/cross-boundary-lane.js +40 -27
  164. package/dist/core/runner/denial-limit-arms.d.ts +2 -2
  165. package/dist/core/runner/denial-limit-arms.js +1 -1
  166. package/dist/core/runner/file-history-request.d.ts +18 -0
  167. package/dist/core/runner/file-history-request.js +21 -13
  168. package/dist/core/runner/file-history-restore.d.ts +45 -0
  169. package/dist/core/runner/file-history-restore.js +46 -0
  170. package/dist/core/runner/gate-exit.d.ts +3 -3
  171. package/dist/core/runner/gate-exit.js +4 -3
  172. package/dist/core/runner/image.d.ts +7 -17
  173. package/dist/core/runner/image.js +9 -60
  174. package/dist/core/runner/permission-rule-lanes.d.ts +4 -4
  175. package/dist/core/runner/permission-rule-lanes.js +26 -10
  176. package/dist/core/runner/person-path-rows.d.ts +12 -9
  177. package/dist/core/runner/person-path-rows.js +18 -7
  178. package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
  179. package/dist/core/runner/prepare-ask-lane.js +5 -2
  180. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
  181. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  182. package/dist/core/runner/prepare-config-doors.d.ts +29 -38
  183. package/dist/core/runner/prepare-config-doors.js +42 -25
  184. package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
  185. package/dist/core/runner/prepare-defer-classify.js +7 -8
  186. package/dist/core/runner/prepare-file-history.d.ts +48 -8
  187. package/dist/core/runner/prepare-file-history.js +7 -39
  188. package/dist/core/runner/prepare-gate-stations.d.ts +1 -1
  189. package/dist/core/runner/prepare-gate-stations.js +10 -1
  190. package/dist/core/runner/prepare-hands-readface.d.ts +2 -8
  191. package/dist/core/runner/prepare-hands-readface.js +15 -14
  192. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  193. package/dist/core/runner/prepare-inherited-gate.js +5 -3
  194. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  195. package/dist/core/runner/prepare-park-ask.js +5 -5
  196. package/dist/core/runner/prepare-policy-chain.d.ts +6 -3
  197. package/dist/core/runner/prepare-policy-chain.js +65 -72
  198. package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
  199. package/dist/core/runner/prepare-prompt-assembly.js +10 -8
  200. package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
  201. package/dist/core/runner/prepare-prompt-inputs.js +3 -5
  202. package/dist/core/runner/prepare-protocol-tools.d.ts +2 -0
  203. package/dist/core/runner/prepare-protocol-tools.js +3 -3
  204. package/dist/core/runner/prepare-safety-scan.d.ts +1 -1
  205. package/dist/core/runner/prepare-safety-scan.js +0 -17
  206. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  207. package/dist/core/runner/prepare-suspend-saga.js +5 -6
  208. package/dist/core/runner/prepare-task.d.ts +1 -1
  209. package/dist/core/runner/prepare-task.js +29 -20
  210. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +7 -4
  211. package/dist/core/runner/prepare-tool-disclosure-mount.js +20 -16
  212. package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
  213. package/dist/core/runner/prepare-turn-wiring.js +2 -7
  214. package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -2
  215. package/dist/core/runner/prepare-wiring-manifest.js +3 -3
  216. package/dist/core/runner/resume-admission.js +1 -1
  217. package/dist/core/runner/resume-apply.js +11 -12
  218. package/dist/core/runner/resume-checkpoint-screen.js +3 -0
  219. package/dist/core/runner/resume-claim.d.ts +4 -2
  220. package/dist/core/runner/resume-claim.js +15 -8
  221. package/dist/core/runner/retired-runner-deps.js +1 -0
  222. package/dist/core/runner/rewind-files.d.ts +15 -0
  223. package/dist/core/runner/rewind-files.js +132 -0
  224. package/dist/core/runner/run-attachment-seats.js +2 -1
  225. package/dist/core/runner/run-brain-sinks.d.ts +4 -1
  226. package/dist/core/runner/run-brain-sinks.js +4 -2
  227. package/dist/core/runner/run-harness-handlers.js +12 -4
  228. package/dist/core/runner/run-leg.d.ts +1 -1
  229. package/dist/core/runner/run-leg.js +30 -18
  230. package/dist/core/runner/run-settle-and-teardown.js +2 -1
  231. package/dist/core/runner/run-turn-boundary.js +1 -10
  232. package/dist/core/runner/runtask.d.ts +3 -0
  233. package/dist/core/runner/runtask.js +8 -9
  234. package/dist/core/runner/session-read-file-states.d.ts +15 -0
  235. package/dist/core/runner/session-read-file-states.js +28 -0
  236. package/dist/core/runner/session-rule-policy.js +4 -3
  237. package/dist/core/runner/shell-env-withheld.d.ts +33 -0
  238. package/dist/core/runner/shell-env-withheld.js +51 -0
  239. package/dist/core/runner/skills-seat.js +6 -2
  240. package/dist/core/runner/stream-settle-backstop.js +1 -1
  241. package/dist/core/runner/sub-agent-deny-lists.js +4 -7
  242. package/dist/core/runner/synthetic-tools.d.ts +6 -0
  243. package/dist/core/runner/synthetic-tools.js +4 -1
  244. package/dist/core/runner/tool-disclosure.d.ts +10 -12
  245. package/dist/core/runner/tool-disclosure.js +1 -3
  246. package/dist/core/runner/tool-end-body.d.ts +1 -1
  247. package/dist/core/runner/tool-end-body.js +10 -9
  248. package/dist/core/runner/tool-not-executed.d.ts +5 -0
  249. package/dist/core/runner/tool-not-executed.js +11 -0
  250. package/dist/core/runner/tool-occurrence.d.ts +8 -0
  251. package/dist/core/runner/tool-occurrence.js +7 -0
  252. package/dist/core/runner/turn-attachments.d.ts +33 -15
  253. package/dist/core/runner/turn-attachments.js +62 -37
  254. package/dist/core/runner-deps.d.ts +5 -5
  255. package/dist/core/safety-axis-vocab.d.ts +6 -4
  256. package/dist/core/safety-axis-vocab.js +6 -5
  257. package/dist/core/safety-merge-corpus.js +11 -3
  258. package/dist/core/secret-env.d.ts +26 -3
  259. package/dist/core/secret-env.js +44 -8
  260. package/dist/core/select-model.js +3 -3
  261. package/dist/core/session-policy-store.d.ts +27 -15
  262. package/dist/core/session-policy-store.js +156 -36
  263. package/dist/core/session-store.d.ts +29 -10
  264. package/dist/core/session-store.js +51 -19
  265. package/dist/core/session.d.ts +82 -16
  266. package/dist/core/session.js +53 -0
  267. package/dist/core/shell-read-silence.d.ts +11 -12
  268. package/dist/core/shell-read-silence.js +9 -5
  269. package/dist/core/shell-run-candidates.js +3 -1
  270. package/dist/core/shell-wrapper-projection.js +1 -1
  271. package/dist/core/shell-wrapper-table.d.ts +14 -7
  272. package/dist/core/shell-wrapper-table.js +5 -4
  273. package/dist/core/side-query.js +10 -1
  274. package/dist/core/skill-grant.d.ts +7 -2
  275. package/dist/core/skill-grant.js +5 -0
  276. package/dist/core/skills-directory.js +6 -2
  277. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
  278. package/dist/core/store-contracts/checkpoint-store-contract.js +140 -2
  279. package/dist/core/store-contracts/file-history-store-contract.js +31 -1
  280. package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
  281. package/dist/core/store-contracts/peer-directory-contract.js +14 -2
  282. package/dist/core/store-contracts/session-repo-contract.js +51 -0
  283. package/dist/core/store-contracts/session-store-contract.d.ts +2 -1
  284. package/dist/core/store-contracts/session-store-contract.js +150 -14
  285. package/dist/core/stub-env.d.ts +2 -0
  286. package/dist/core/stub-env.js +1 -0
  287. package/dist/core/synthetic-read-verdict.js +3 -3
  288. package/dist/core/task-event.d.ts +32 -4
  289. package/dist/core/task-notification.d.ts +16 -12
  290. package/dist/core/task-registry.d.ts +9 -0
  291. package/dist/core/task-registry.js +11 -1
  292. package/dist/core/task-result.d.ts +18 -0
  293. package/dist/core/task-spec.d.ts +18 -13
  294. package/dist/core/tighten-task-spec.js +2 -1
  295. package/dist/core/tool-catalog-entries.d.ts +17 -0
  296. package/dist/core/tool-catalog-entries.js +13 -2
  297. package/dist/core/tool-check-reading.d.ts +11 -0
  298. package/dist/core/tool-check-reading.js +11 -6
  299. package/dist/core/tool-model-gate.d.ts +2 -2
  300. package/dist/core/tool-name-aliases.d.ts +16 -16
  301. package/dist/core/tool-name-aliases.js +13 -19
  302. package/dist/core/tool-name-readings.d.ts +5 -35
  303. package/dist/core/tool-name-readings.js +1 -9
  304. package/dist/core/tool-policy.d.ts +68 -198
  305. package/dist/core/tool-policy.js +149 -198
  306. package/dist/core/tool-result-store.js +3 -0
  307. package/dist/core/tool-roster.d.ts +14 -19
  308. package/dist/core/tool-roster.js +11 -44
  309. package/dist/core/tool-spec-members.js +7 -2
  310. package/dist/core/tool-spec.d.ts +19 -11
  311. package/dist/core/tools.js +49 -9
  312. package/dist/core/trace.d.ts +2 -2
  313. package/dist/core/types.d.ts +1 -1
  314. package/dist/core/user-attachment.d.ts +8 -1
  315. package/dist/core/user-attachment.js +64 -4
  316. package/dist/core/wiring-manifest.d.ts +9 -0
  317. package/dist/core/wiring-manifest.js +1 -0
  318. package/dist/core/workflow-journal-store.js +1 -1
  319. package/dist/engine/compaction/compaction.js +3 -2
  320. package/dist/engine/execution-env/node-execution-env.d.ts +7 -3
  321. package/dist/engine/execution-env/node-execution-env.js +11 -2
  322. package/dist/engine/harness/agent-harness.d.ts +25 -1
  323. package/dist/engine/harness/agent-harness.js +54 -7
  324. package/dist/engine/harness/types.d.ts +29 -2
  325. package/dist/engine/llm/types.d.ts +28 -11
  326. package/dist/engine/loop/agent-loop.d.ts +22 -0
  327. package/dist/engine/loop/agent-loop.js +16 -26
  328. package/dist/engine/loop/types.d.ts +16 -6
  329. package/dist/engine/session/memory-repo.d.ts +9 -2
  330. package/dist/engine/session/memory-repo.js +11 -1
  331. package/dist/engine/session/repo-utils.d.ts +6 -5
  332. package/dist/engine/session/repo-utils.js +14 -6
  333. package/dist/index.d.ts +22 -10
  334. package/dist/index.js +15 -7
  335. package/dist/internal/harness-types.d.ts +1 -1
  336. package/dist/internal/llm.d.ts +1 -1
  337. package/dist/orchestration/run-workflow-tool.d.ts +6 -4
  338. package/dist/orchestration/run-workflow-tool.js +5 -3
  339. package/dist/orchestration/workflow.d.ts +3 -0
  340. package/dist/orchestration/workflow.js +36 -18
  341. package/dist/prompt-assembly/artifact.d.ts +2 -2
  342. package/dist/prompt-assembly/artifact.js +5 -3
  343. package/dist/prompt-assembly/assemble.d.ts +3 -2
  344. package/dist/prompt-assembly/assemble.js +1 -1
  345. package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
  346. package/dist/prompt-assembly/catalog/schema.js +34 -2
  347. package/dist/prompt-assembly/catalog/sections.js +0 -1
  348. package/dist/prompt-assembly/composer.d.ts +3 -1
  349. package/dist/prompt-assembly/composer.js +1 -1
  350. package/dist/prompt-assembly/event-registry.js +1 -0
  351. package/dist/prompt-assembly/overlay.js +3 -3
  352. package/dist/prompt-assembly/renderers.d.ts +1 -1
  353. package/dist/prompt-assembly/renderers.js +0 -3
  354. package/dist/prompt-assembly/role-base.d.ts +15 -0
  355. package/dist/prompt-assembly/role-base.js +9 -0
  356. package/dist/prompt-assembly/select.d.ts +39 -14
  357. package/dist/prompt-assembly/select.js +47 -16
  358. package/dist/prompt-assembly/sugar.d.ts +17 -11
  359. package/dist/prompt-assembly/sugar.js +8 -3
  360. package/dist/prompt-assembly/tool-catalog.d.ts +37 -3
  361. package/dist/prompt-assembly/tool-catalog.js +114 -4
  362. package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
  363. package/dist/prompt-assembly/turn-snapshot.js +0 -3
  364. package/dist/prompt-assembly/types.d.ts +0 -7
  365. package/dist/scenarios/full-body.d.ts +11 -11
  366. package/dist/scenarios/full-body.js +4 -3
  367. package/dist/shell/lex.js +10 -1
  368. package/dist/stores/file/adoption/adopt.js +4 -3
  369. package/dist/stores/file/adoption/marker.js +3 -2
  370. package/dist/stores/file/checkpoint-store.d.ts +21 -0
  371. package/dist/stores/file/checkpoint-store.js +38 -6
  372. package/dist/stores/file/file-history-store.js +6 -7
  373. package/dist/stores/file/index.js +2 -1
  374. package/dist/stores/file/permission-rule-adopt.js +4 -3
  375. package/dist/stores/file/permission-rule-store.js +11 -5
  376. package/dist/stores/file/session-store.d.ts +29 -6
  377. package/dist/stores/file/session-store.js +42 -50
  378. package/dist/tools/artifact/artifact-tool.js +3 -2
  379. package/dist/tools/fs/bash-program-position.d.ts +19 -2
  380. package/dist/tools/fs/bash-program-position.js +56 -9
  381. package/dist/tools/fs/fs-bash.js +5 -5
  382. package/dist/tools/fs/fs-glob.d.ts +86 -0
  383. package/dist/tools/fs/fs-glob.js +226 -0
  384. package/dist/tools/fs/fs-read.js +14 -14
  385. package/dist/tools/fs/fs-search-tools.js +7 -7
  386. package/dist/tools/fs/pattern-kill-guard.d.ts +22 -0
  387. package/dist/tools/fs/pattern-kill-guard.js +397 -0
  388. package/dist/tools/fs/pdf.d.ts +9 -6
  389. package/dist/tools/fs/pdf.js +3 -3
  390. package/dist/tools/fs/program-read-model.d.ts +57 -7
  391. package/dist/tools/fs/program-read-model.js +11 -1
  392. package/dist/tools/fs/program-read-model.rows.js +78 -21
  393. package/dist/tools/fs/read-deny-home.js +3 -2
  394. package/dist/tools/fs/removal-targets.d.ts +17 -7
  395. package/dist/tools/fs/removal-targets.js +47 -20
  396. package/dist/tools/fs/search.d.ts +10 -0
  397. package/dist/tools/fs/search.js +20 -26
  398. package/dist/tools/fs/shell-read-argv.js +89 -12
  399. package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
  400. package/dist/tools/fs/shell-read-bindings.js +41 -0
  401. package/dist/tools/fs/shell-read-check.js +6 -19
  402. package/dist/tools/fs/shell-read-environment.d.ts +5 -1
  403. package/dist/tools/fs/shell-read-environment.js +3 -2
  404. package/dist/tools/fs/shell-read-establish.d.ts +15 -0
  405. package/dist/tools/fs/shell-read-establish.js +19 -20
  406. package/dist/tools/fs/shell-read-plan.js +24 -16
  407. package/dist/tools/fs/shell-read-start.d.ts +6 -1
  408. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
  409. package/dist/tools/fs/shell-read-write-targets.js +2 -3
  410. package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
  411. package/dist/tools/fs/shell-reentry-text.js +40 -2
  412. package/dist/tools/todo.js +63 -63
  413. package/dist/tools/web.d.ts +19 -14
  414. package/dist/tools/web.js +38 -55
  415. package/package.json +1 -1
  416. package/test/export-surface.snapshot.json +143 -5
  417. package/wire-changes/core@7.56.0.json +3891 -0
  418. package/wire-changes/mods-kernel@7.56.0.json +303 -0
@@ -7,7 +7,7 @@ import { deliverEngineNotice } from "../types.js";
7
7
  import { inlineUntrusted } from "../untrusted-text.js";
8
8
  import { fileArgPath } from "../tool-registry.js";
9
9
  import { RosterBuilder } from "../tool-roster.js";
10
- import { isNotStartedDelegationResult } from "../../agents/subagent.js";
10
+ import { isNotStartedDelegationResult } from "../delegation-not-started.js";
11
11
  import { thrownText } from "../thrown-value.js";
12
12
  export function prepareMemoryEngineSession(input) {
13
13
  const { memoryEngineSession, internals, memoryDelegationEvidence, externalContentTargetActive, lockedPreflight, mountedMcp, sessionId, runId, deps, provenanceForChildrenRef, delegationSettlementRef, spec, envHandToolNames, roster, contentOriginWrapRef } = input;
@@ -2,7 +2,7 @@ import { callTargetReadingOf } from "../effective-path-target.js";
2
2
  import { approvalTargetsOf } from "../approval-object.js";
3
3
  import { uuidv7 } from "../../engine/session/uuid.js";
4
4
  import { Value } from "typebox/value";
5
- import { classifyQuestionOutcome, validateAskQuestions } from "../ask-question.js";
5
+ import { classifyQuestionOutcome, isEngineQuestionFace, validateAskQuestions } from "../ask-question.js";
6
6
  import { hasBackgroundShell, sweepBackgroundShells, sweepRunBoundaryBackgroundShells } from "../background-shell.js";
7
7
  import { boundInputHashOf, exactBoundInputHashOf } from "../canonical-json.js";
8
8
  import { buildRiskDescriptor, debitLedger, encodeAtFidelity, mintCheckpointId, mintCheckpointToken, resolveDeclaredFidelity, } from "../checkpoint-store.js";
@@ -17,7 +17,7 @@ import { raceAbort, raceSettlementAgainstSignal } from "./abort-race.js";
17
17
  import { CONTENT_ASK_BINDING_CAP } from "./content-ask-bindings.js";
18
18
  import { DEFAULT_UNATTENDED_APPROVAL_TTL_MS, publishCommittedSuspend, sanitizedTtlMs } from "./park-commit.js";
19
19
  import { remoteEnvFailureNote } from "./remote-env-retry.js";
20
- import { approvalCardMemberOf, callFaceSeat, engineCardOf, parkedToolIdentity, parkedToolFace } from "../tool-roster.js";
20
+ import { approvalCardMemberOf, callFaceSeat, parkedToolIdentity, parkedToolFace } from "../tool-roster.js";
21
21
  import { seatOf } from "../tool-name-readings.js";
22
22
  class ParkRefusal extends Error {
23
23
  constructor(message, options) {
@@ -112,7 +112,7 @@ export function prepareParkAsk(input) {
112
112
  };
113
113
  const suspendAsk = parkLaneArmed && checkpointStore !== undefined
114
114
  ? async (req, postHookArgs, safety, liveFaceUnavailable, realApproval, allowRuleShadowed, askDecisionReason, probeReason, probeCause, segmentCoverage, matchedAskRule, probeMandated, carry) => {
115
- const contentAsk = engineCardOf(req) === "question";
115
+ const contentAsk = isEngineQuestionFace(req.face);
116
116
  const syncFirstEligible = contentAsk ? contentAskRoutable(req.toolCallId) : isLiveApproverSeat(onAsk);
117
117
  if (syncFirstEligible &&
118
118
  runtimeCaps?.forceDurableGate !== true &&
@@ -179,7 +179,7 @@ export function prepareParkAsk(input) {
179
179
  return undefined;
180
180
  if (reprojectedRaced.tag === "threw")
181
181
  throw reprojectedRaced.error;
182
- const reprojected = refuseOutOfContractDecision(reprojectedRaced.value);
182
+ const reprojected = refuseOutOfContractDecision(reprojectedRaced.value, { call: req });
183
183
  const filedAsHeld = ownArgs(parkedArgs);
184
184
  const rewroteTheFiledValue = reprojected.updatedInput !== undefined && !(filedAsHeld.ok && samePlainValue(reprojected.updatedInput, filedAsHeld.value));
185
185
  if (reprojected.action === "deny" || rewroteTheFiledValue) {
@@ -188,7 +188,7 @@ export function prepareParkAsk(input) {
188
188
  `refusing to file a row whose executable form nothing adjudicated`);
189
189
  }
190
190
  if (reprojected.action === "ask")
191
- storedShapeFacts = ownedClearanceFacts(reprojected);
191
+ storedShapeFacts = ownedClearanceFacts(reprojected, req);
192
192
  }
193
193
  const rowRealApproval = realApproval ?? (storedShapeFacts?.requiresRealApproval === true ? { origin: carry?.origin ?? wordlessDemand(req.toolName) } : undefined);
194
194
  if (offloadStore && isVolatileOffloadStore(offloadStore) && !offloadStore.isEmpty()) {
@@ -6,8 +6,8 @@
6
6
  * inherited-unavailable marker channel, the grant record, the sandbox-admission mode's arming and its three
7
7
  * sideband maps, the source-identity and risk-axes factories, the two permission-rule lanes and the rule-offer
8
8
  * factory, the approved-edit re-check, the inherited-constraint wrappers (the same-instance adapter and the true
9
- * wrapper), the rewrite-emitter index and the instrumented chain, the integrity guards, the fold, and the final-form
10
- * re-check that is the effective policy. The advised-names dedupe pair only this section reads moved with it.
9
+ * wrapper), the instrumented chain, the integrity guards, the fold, and the same-instance arbitration refresh that is the
10
+ * effective policy. The advised-names dedupe pair only this section reads moved with it.
11
11
  * The interface is the dependency list the segment had implicitly.
12
12
  *
13
13
  * ASYNC PHASE: the stretch awaits the session-policy store (the task's own rules and each ancestor's live re-read)
@@ -42,7 +42,10 @@ import { type ModeGateSeats, type PermissionModeController } from "../mode-polic
42
42
  import { type InheritedAskGrant } from "./inherited-ask-grants.js";
43
43
  import { createRuleOffersOf, type PermissionRuleLanes } from "./permission-rule-lanes.js";
44
44
  import type { ToolCallLike } from "../tool-registry.js";
45
+ import { type HostFloor } from "../host-floor.js";
45
46
  export interface PreparePolicyChainInput {
47
+ /** borrowed-readonly — the deployment's host floor as the config doors compiled it: the leading narrowing layer when declared. */
48
+ hostFloor: HostFloor | undefined;
46
49
  /** borrowed-readonly — the REBOUND spec. Read: `sessionId` / `principal` (the session-rule read and the lanes' identity),
47
50
  * `durableApproval` / `checkpointStore` (the mandate-park facility test and the sandbox arming's park prerequisites), `taskId` (the late-ask observer's detail),
48
51
  * `tools` (the names the caller mounted, for the name audit). Never mutated. */
@@ -202,7 +205,7 @@ export interface PreparePolicyChainResult {
202
205
  };
203
206
  /** owned — the caller-facing policy layers (the wiring manifest reads their COUNT). */
204
207
  policyLayers: ToolPolicy[];
205
- /** owned — THE effective policy the gate station adjudicates with (the fold plus its final-form re-check), or undefined. */
208
+ /** owned — THE effective policy the gate station adjudicates with (the fold, plus the same-instance arbitration refresh), or undefined. */
206
209
  effectivePolicy: ToolPolicy | undefined;
207
210
  /** borrowed-mutable — the inherited-unavailable marker channel. Writers: the inherited arms here (mark); the gate station
208
211
  * (the lifecycle-end sweep) and the park lane's consumers (delete on consumption). */
@@ -1,10 +1,11 @@
1
1
  import { argsAsTheToolReads, withArgsReading } from "../effective-path-target.js";
2
+ import { outletAsk, readRejudge, rewriteChasedSentence, sameBytes } from "../rewrite-rejudge.js";
2
3
  import { policyAskClassOf } from "../ask-class.js";
3
- import { ASK_USER_QUESTION_TOOL_NAME } from "../ask-question.js";
4
+ import { ASK_USER_QUESTION_TOOL_NAME, isEngineQuestionFace } from "../ask-question.js";
4
5
  import { classifierUnavailableSeat } from "./classifier-ladder.js";
5
6
  import { resolveCheckpointStore } from "../checkpoint-store.js";
6
7
  import { chainJudges, inheritedToolChecks, screeningInstallationsOf, standsInFor } from "../mods/stations.js";
7
- import { isNamespacedCoveringRuleName, namespacedRuleNameCovers } from "../permission-rules.js";
8
+ import { isCoveringRuleName, ruleNameCovers } from "../namespaced-rule-name.js";
8
9
  import { isIsolated } from "../remote-env.js";
9
10
  import { deliverEngineNotice } from "../engine-notice.js";
10
11
  import { earlierGrammarNotice } from "../session-policy-store.js";
@@ -29,8 +30,9 @@ import { createPermissionRuleLanes, inheritedAskRuleEvidence, createRuleOffersOf
29
30
  import { createLiveSessionRules, createSessionRulePolicy } from "./session-rule-policy.js";
30
31
  import { policyThrowLine, reportPolicyThrow } from "./policy-throw.js";
31
32
  import { heldBy, heldValues, seatOf, wireOf } from "../tool-name-readings.js";
33
+ import { hostFloorPolicy } from "../host-floor.js";
32
34
  export async function preparePolicyChain(input) {
33
- const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, executionEnv, lockedPreflight, pathRuleAnchors, headLeads, tools, harnessTools, selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus, ownModChain, autoModeDecider, readFace, permissionMode, scratchpadDir, toolRosterDeltas, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef } = input;
35
+ const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, executionEnv, lockedPreflight, pathRuleAnchors, headLeads, tools, harnessTools, selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus, ownModChain, autoModeDecider, readFace, permissionMode, scratchpadDir, toolRosterDeltas, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef, hostFloor } = input;
34
36
  const ancestorArbitrations = new Map();
35
37
  const arbitrateInherited = (ask, toolCallId, judged) => {
36
38
  const verdict = arbitrateByMode(permissionMode.current, judged.classification, { origin: judged.origin, ...askMandateMember(ancestorFacts(judged.ask.action === "ask" ? judged.ask : undefined)) });
@@ -85,7 +87,7 @@ export async function preparePolicyChain(input) {
85
87
  }
86
88
  if (known.has(n))
87
89
  continue;
88
- if (isNamespacedCoveringRuleName(n, kind) && [...known].some((k) => namespacedRuleNameCovers(n, k)))
90
+ if (isCoveringRuleName(n, kind) && [...known].some((k) => ruleNameCovers(n, k)))
89
91
  continue;
90
92
  unmatched.add(`"${n}" (${kind})`);
91
93
  }
@@ -102,7 +104,7 @@ export async function preparePolicyChain(input) {
102
104
  }
103
105
  advisedPolicyNames.set(deps, advised);
104
106
  try {
105
- const e = new Error(`toolPolicy name audit: ${[...unmatched].join(", ")} match(es) no tool mounted this run (primary or alias) — the rule cannot fire here. Often a typo or a self-report/wire name skew (e.g. TodoWrite vs the mounted TaskCreate family; "*" has no wildcard meaning in a name-keyed policy). Advisory only: enforcement is unchanged, and a name can be legitimate for another scenario or a per-spawn tool.`);
107
+ const e = new Error(`toolPolicy name audit: ${[...unmatched].join(", ")} match(es) no tool mounted this run (primary or alias) — the rule cannot fire here. Often a typo or a self-report/wire name skew (e.g. TodoWrite vs the mounted TaskCreate family; a "*" on a deny or ask list reaches every name its pattern matches). Advisory only: enforcement is unchanged, and a name can be legitimate for another scenario or a per-spawn tool.`);
106
108
  e.code = "config.toolpolicy.unmatched_names";
107
109
  deps.onError?.(e, { phase: "config", sessionId });
108
110
  }
@@ -159,7 +161,7 @@ export async function preparePolicyChain(input) {
159
161
  .map((entry) => ({
160
162
  check: (creq) => checkToolPolicyProjection(entry, creq) ?? { action: "allow" },
161
163
  }));
162
- const narrowingLayers = [sessionRulePolicy, ...ancestorRulePolicies, ...frozenConstraintLayers].filter((p) => p !== undefined);
164
+ const narrowingLayers = [hostFloor !== undefined ? hostFloorPolicy(hostFloor) : undefined, sessionRulePolicy, ...ancestorRulePolicies, ...frozenConstraintLayers].filter((p) => p !== undefined);
163
165
  auditPolicyNames(sessionRulePolicy);
164
166
  for (const layer of ancestorRulePolicies)
165
167
  auditPolicyNames(layer, true);
@@ -169,6 +171,16 @@ export async function preparePolicyChain(input) {
169
171
  const sameInstanceAncestorCount = policy === undefined ? 0 : (inheritedParentConstraints ?? []).reduce((n, pc) => (pc.policy === policy ? n + 1 : n), 0);
170
172
  const sharedFirstDecision = new Map();
171
173
  const SHARED_FIRST_DECISION_CAP = 256;
174
+ const staleArbitrations = new Map();
175
+ const noteArbitration = (toolCallId, arbitrate, stale) => {
176
+ const rest = (staleArbitrations.get(toolCallId) ?? []).filter((a) => a !== arbitrate);
177
+ if (stale)
178
+ rest.push(arbitrate);
179
+ if (rest.length > 0)
180
+ staleArbitrations.set(toolCallId, rest);
181
+ else
182
+ staleArbitrations.delete(toolCallId);
183
+ };
172
184
  const inheritedUnavailableAsks = new Set();
173
185
  const INHERITED_UNAVAILABLE_CAP = 256;
174
186
  const markInheritedUnavailable = (toolCallId) => {
@@ -229,7 +241,7 @@ export async function preparePolicyChain(input) {
229
241
  list.push({ cls, layer });
230
242
  foldAskClasses.set(toolCallId, list);
231
243
  };
232
- const isDelegatedQuestion = (creq) => wireOf("inherited.questionFloat", creq) === ASK_USER_QUESTION_TOOL_NAME;
244
+ const isDelegatedQuestion = (creq) => isEngineQuestionFace(creq.face);
233
245
  const sandboxBoundaryCapable = (call) => heldBy("gate.sandboxBoundary.egress", egressTools, call) || !envHandToolNames.has(wireOf("gate.sandboxBoundary.hand", call));
234
246
  const emitSandboxAdmitted = (info) => {
235
247
  emitTrace(deps.tracer, () => ({
@@ -255,8 +267,8 @@ export async function preparePolicyChain(input) {
255
267
  };
256
268
  const callerPolicyLayer = policy !== undefined && sameInstanceAncestorCount > 0
257
269
  ? wrapToolPolicy(policy, async (creq, csignal) => {
258
- const decision = refuseOutOfContractDecision(await policy.check(creq, csignal ?? abortController.signal));
259
- sharedFirstDecision.set(creq.toolCallId, decision);
270
+ const decision = refuseOutOfContractDecision(await policy.check(creq, csignal ?? abortController.signal), { call: creq });
271
+ sharedFirstDecision.set(creq.toolCallId, { decision, judged: creq.args });
260
272
  if (sharedFirstDecision.size > SHARED_FIRST_DECISION_CAP) {
261
273
  const oldest = sharedFirstDecision.keys().next().value;
262
274
  if (oldest !== undefined)
@@ -297,7 +309,7 @@ export async function preparePolicyChain(input) {
297
309
  const seat = seatMarksOf(call);
298
310
  const face = readFace();
299
311
  return {
300
- ...INHERITED_STATION_FACTS,
312
+ ...INHERITED_STATION_FACTS, call: { toolCallId: call.toolCallId, toolName: call.toolName },
301
313
  mandateMarks: { egress: seat.egress, shellGated: false, ...(seat.tier === "always" && !seat.shellGated ? { irreversibility: "always" } : {}) },
302
314
  ...(seat.sources.size > 0 ? { toolMarkSources: seat.sources } : {}),
303
315
  ...(deps.a2a?.isolatePeers === true ? { a2aIsolatePeers: true } : {}),
@@ -352,7 +364,7 @@ export async function preparePolicyChain(input) {
352
364
  }
353
365
  let re;
354
366
  try {
355
- re = refuseOutOfContractDecision(await pol.check(await withArgsReading(creq, editArgs, csignal ?? abortController.signal), csignal ?? abortController.signal));
367
+ re = refuseOutOfContractDecision(await pol.check(await withArgsReading(creq, editArgs, csignal ?? abortController.signal), csignal ?? abortController.signal), { call: creq });
356
368
  }
357
369
  catch (err) {
358
370
  reportPolicyThrow(notifyOwnHookCrash, "an inherited parent policy's re-check of the approved edit", creq, err, csignal ?? abortController.signal);
@@ -363,13 +375,16 @@ export async function preparePolicyChain(input) {
363
375
  }
364
376
  if (re.action === "deny")
365
377
  return vetoed(re);
366
- if (re.action === "allow") {
367
- const stated = re.updatedInput === undefined ? "mode" : re.decisionReason;
368
- return onApproval(withAttestation({ action: "allow", updatedInput: re.updatedInput !== undefined ? re.updatedInput : editArgs, ...(stated !== undefined ? { decisionReason: stated } : {}) }, re.attestation));
378
+ const read = readRejudge(creq, editArgs, re);
379
+ if (read.kind === "rewritten") {
380
+ editArgs = read.form;
381
+ const { updatedInput: _form, ...verdict } = re;
382
+ re = outletAsk(verdict, creq.toolName, editArgs);
369
383
  }
370
- if (re.updatedInput !== undefined)
371
- editArgs = argsAsTheToolReads(creq, re.updatedInput);
372
- const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: ancestorAutoMode, ask: re, req: { ...creq, args: editArgs }, signal: csignal ?? abortController.signal, subject: "the approved edit", allowRewrite: editArgs, facts: inheritedStationFacts(creq), unavailableSeat: classifierUnavailableSeat({ station: "ancestor", ...(ancestorDecider?.timeoutMs !== undefined ? { budgetMs: ancestorDecider.timeoutMs } : {}), route: frozenApproverRoute(onAskOf), onNotice: deps.onNotice, sessionId, runId }) });
384
+ else if (re.action === "allow") {
385
+ return onApproval(withAttestation({ action: "allow", updatedInput: editArgs, decisionReason: "mode" }, re.attestation));
386
+ }
387
+ const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: read.kind === "rewritten" ? undefined : ancestorAutoMode, ask: re, req: { ...creq, args: editArgs }, signal: csignal ?? abortController.signal, subject: "the approved edit", allowRewrite: editArgs, facts: inheritedStationFacts(creq), unavailableSeat: classifierUnavailableSeat({ station: "ancestor", ...(ancestorDecider?.timeoutMs !== undefined ? { budgetMs: ancestorDecider.timeoutMs } : {}), route: frozenApproverRoute(onAskOf), onNotice: deps.onNotice, sessionId, runId }) });
373
388
  if (judged.kind === "allow") {
374
389
  return onApproval(judged.result);
375
390
  }
@@ -378,7 +393,10 @@ export async function preparePolicyChain(input) {
378
393
  const { ask: editAsk } = judged;
379
394
  re = editAsk;
380
395
  const editArbitrated = arbitrateInherited(re, creq.toolCallId, judged);
381
- if (editArbitrated !== undefined) {
396
+ const outletReleased = read.kind === "rewritten" && editArbitrated?.action === "allow";
397
+ if (outletReleased)
398
+ ancestorArbitrations.delete(creq.toolCallId);
399
+ if (editArbitrated !== undefined && !outletReleased) {
382
400
  return onApproval(editArbitrated.action === "allow" ? { action: "allow", updatedInput: editArgs, decisionReason: "mode" } : editArbitrated);
383
401
  }
384
402
  const { resolved: rr, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAsk({
@@ -469,8 +487,14 @@ export async function preparePolicyChain(input) {
469
487
  ? { check: () => ({ action: "allow" }) }
470
488
  : policy !== undefined && pc.policy === policy
471
489
  ? {
472
- check: async (creq, csignal) => {
473
- const first = sharedFirstDecision.get(creq.toolCallId);
490
+ check: async function arbitrate(creq, csignal) {
491
+ const recorded = sharedFirstDecision.get(creq.toolCallId);
492
+ const first = recorded?.decision;
493
+ const stale = recorded !== undefined && !sameBytes(creq, recorded.decision.updatedInput !== undefined ? recorded.decision.updatedInput : recorded.judged, creq.args);
494
+ if (recorded !== undefined)
495
+ noteArbitration(creq.toolCallId, arbitrate, stale);
496
+ if (stale)
497
+ return { action: "allow" };
474
498
  if (first === undefined) {
475
499
  return {
476
500
  action: "deny",
@@ -546,7 +570,7 @@ export async function preparePolicyChain(input) {
546
570
  : wrapToolPolicy(pc.policy, async (creq, csignal) => {
547
571
  let decision;
548
572
  try {
549
- decision = refuseOutOfContractDecision(await pc.policy.check(creq, csignal ?? abortController.signal));
573
+ decision = refuseOutOfContractDecision(await pc.policy.check(creq, csignal ?? abortController.signal), { call: creq });
550
574
  }
551
575
  catch (err) {
552
576
  reportPolicyThrow(notifyOwnHookCrash, "an inherited parent policy", creq, err, csignal ?? abortController.signal);
@@ -575,88 +599,57 @@ export async function preparePolicyChain(input) {
575
599
  const settled = await settleInstallationAsk(pc, ask, creq, csignal);
576
600
  return settled.kind === "settled" ? settled.result : settled.resolved;
577
601
  });
578
- const rewriteCapableLayers = policy !== undefined || parentConstraintWrappers.length > 0;
579
- const rewriteEmitterIndex = new Map();
580
602
  const rewriteCapableChain = [
581
603
  ...(callerPolicyLayer !== undefined ? [callerPolicyLayer] : []),
582
604
  ...parentConstraintWrappers,
583
605
  ];
584
606
  const callerSlotOffset = callerPolicyLayer !== undefined ? 1 : 0;
585
- const sameInstanceAdapterIndices = new Set();
586
- (inheritedParentConstraints ?? []).forEach((pc, j) => {
587
- if (policy !== undefined && pc.policy === policy)
588
- sameInstanceAdapterIndices.add(j + callerSlotOffset);
589
- });
590
607
  const instrumentedChain = rewriteCapableChain.map((layer, idx) => wrapToolPolicy(layer, async (creq, csignal) => {
591
- const d = refuseOutOfContractDecision(await layer.check(creq, csignal));
592
- if (d.updatedInput !== undefined)
593
- rewriteEmitterIndex.set(creq.toolCallId, idx);
608
+ const d = refuseOutOfContractDecision(await layer.check(creq, csignal), { call: creq });
594
609
  if (d.action === "ask") {
595
610
  recordFoldAskClass(creq.toolCallId, idx < callerSlotOffset ? policyAskClassOf(policy) : "mandate", idx < callerSlotOffset ? "caller_policy" : "ancestor_constraint");
596
611
  }
597
612
  return d;
598
613
  }));
599
614
  const modeGateLayer = createModeGatePolicy(permissionMode, { env: executionEnv, rootPath: taskRootFinal, acceptDirs: [taskRootFinal, ...additionalRootsCanonical], roster: toolRosterDeltas, readOnlyDeclared: (name) => mountedToolDeclaresReadOnly(tools, name), ...(scratchpadDir !== undefined ? { exemptDirs: [scratchpadDir] } : {}) });
600
- const policyLayers = [
601
- ...narrowingLayers,
602
- ...instrumentedChain,
603
- ...(rewriteCapableLayers ? narrowingLayers : []),
604
- ];
615
+ const policyLayers = [...narrowingLayers, ...instrumentedChain, ...(rewriteCapableChain.length > 0 ? narrowingLayers : [])];
605
616
  const integrityGuardLayers = [createTranscriptIntegrityPolicy(), createUnverifiableDeletePolicy({ removalSeat: { env: executionEnv, additionalRoots: () => additionalRootsCanonical } })];
606
- const guardedPolicyLayers = rewriteCapableLayers
607
- ? [...integrityGuardLayers, ...policyLayers, modeGateLayer, ...integrityGuardLayers]
608
- : [...integrityGuardLayers, ...policyLayers, modeGateLayer];
617
+ const guardedPolicyLayers = [...integrityGuardLayers, ...policyLayers, modeGateLayer];
609
618
  const foldedPolicy = guardedPolicyLayers.length === 1 ? guardedPolicyLayers[0] : combinePolicies(...guardedPolicyLayers);
610
- const effectivePolicy = foldedPolicy !== undefined && rewriteCapableLayers
619
+ const effectivePolicy = foldedPolicy !== undefined && sameInstanceAncestorCount > 0
611
620
  ? wrapToolPolicy(foldedPolicy, async (req, signal) => {
612
621
  let decision;
622
+ let stale;
613
623
  try {
614
624
  decision = await foldedPolicy.check(req, signal);
615
625
  }
616
- catch (err) {
617
- rewriteEmitterIndex.delete(req.toolCallId);
618
- throw err;
626
+ finally {
627
+ stale = staleArbitrations.get(req.toolCallId) ?? [];
628
+ staleArbitrations.delete(req.toolCallId);
619
629
  }
620
- const emitterIdx = rewriteEmitterIndex.get(req.toolCallId);
621
- rewriteEmitterIndex.delete(req.toolCallId);
622
- if (decision.action === "deny" || decision.updatedInput === undefined)
630
+ if (decision.action === "deny" || stale.length === 0)
623
631
  return decision;
624
- const recheckPrefix = rewriteCapableChain.slice(0, emitterIdx ?? rewriteCapableChain.length);
625
- const postEmitterSameInstanceAdapters = [];
626
- if (emitterIdx !== undefined && emitterIdx > 0) {
627
- for (let i = emitterIdx + 1; i < rewriteCapableChain.length; i++) {
628
- if (sameInstanceAdapterIndices.has(i))
629
- postEmitterSameInstanceAdapters.push(rewriteCapableChain[i]);
630
- }
631
- }
632
- const recheckLayers = [...recheckPrefix, ...postEmitterSameInstanceAdapters];
633
- const finalReq = await withArgsReading(req, decision.updatedInput, signal);
632
+ const finalReq = decision.updatedInput !== undefined ? await withArgsReading(req, decision.updatedInput, signal) : req;
633
+ const carried = decision.updatedInput !== undefined ? { updatedInput: decision.updatedInput } : {};
634
634
  let asked;
635
635
  let revalidated;
636
636
  try {
637
- for (const layer of recheckLayers) {
638
- const d = refuseOutOfContractDecision(await layer.check(finalReq, signal));
639
- if (d.action === "deny") {
640
- return withAttestation({ ...d, updatedInput: decision.updatedInput }, mergeAttestation(req, attestationOf(decision, req), attestationOf(d, req), "answer"));
641
- }
642
- if (d.updatedInput !== undefined) {
643
- return {
644
- action: "deny",
645
- message: "policy required a rewrite during final-form re-check — the arguments that would execute were not accepted as-is (fail-closed; rewrite chains are not iterated to a fixpoint)",
646
- updatedInput: decision.updatedInput,
647
- };
648
- }
637
+ for (const arbitrate of stale) {
638
+ const d = refuseOutOfContractDecision(await arbitrate(finalReq, signal), { call: finalReq });
639
+ if (d.action === "deny")
640
+ return withAttestation({ ...d, ...carried }, mergeAttestation(req, attestationOf(decision, req), attestationOf(d, req), "answer"));
641
+ if (readRejudge(finalReq, finalReq.args, d).kind === "rewritten")
642
+ return { action: "deny", message: rewriteChasedSentence(req.toolName), ...carried };
649
643
  if (d.action === "ask" && asked === undefined)
650
644
  asked = d;
651
645
  revalidated = mergeAttestation(req, revalidated, d.attestation);
652
646
  }
653
647
  }
654
648
  finally {
655
- rewriteEmitterIndex.delete(req.toolCallId);
656
- }
657
- if (asked !== undefined && decision.action === "allow") {
658
- return { ...asked, updatedInput: decision.updatedInput };
649
+ staleArbitrations.delete(req.toolCallId);
659
650
  }
651
+ if (asked !== undefined && decision.action === "allow")
652
+ return { ...asked, ...carried };
660
653
  if (decision.action === "allow")
661
654
  return withAttestation(decision, mergeAttestation(req, attestationOf(decision, req), revalidated));
662
655
  return decision;
@@ -3,7 +3,7 @@ import type { Model } from "../../internal/llm.js";
3
3
  import { assemblePrompt, type AssembledPrompt } from "../../prompt-assembly/assemble.js";
4
4
  import { type CenterAdoption } from "../../prompt-assembly/artifact.js";
5
5
  import { type RunPromptIdentity } from "../../prompt-assembly/epoch.js";
6
- import type { HostForm, HostRole } from "../../prompt-assembly/catalog/schema.js";
6
+ import type { HostForm, HostRole, PromptTraitName } from "../../prompt-assembly/catalog/schema.js";
7
7
  import type { SourcedOverlay } from "../../prompt-assembly/overlay.js";
8
8
  import { type EnvironmentFacts } from "../../prompts/default.js";
9
9
  import { type LegModBus } from "../mods/stations.js";
@@ -47,15 +47,13 @@ export interface PreparePromptAssemblyInput {
47
47
  memoryBlock: string | undefined;
48
48
  /** borrowed-readonly — the environment facts; `date` is the assembly's date, the block builder re-renders on a date change. */
49
49
  envFacts: EnvironmentFacts;
50
- /** borrowed-readonly — the resolved prompt profile (a runtime fact of the assembly). */
51
- promptProfile: "simple" | "classic";
52
- /** borrowed-readonly — the fable mitigations switch (a runtime fact of the assembly). */
53
- fableMitigations: boolean;
50
+ /** borrowed-readonly — the run's effective prompt traits (a selector value of the assembly). */
51
+ promptTraits: ReadonlySet<PromptTraitName>;
54
52
  /** borrowed-readonly — the run's ONE tool roster, read only: the assembly receives DETACHED copies, the audit and the
55
53
  * manifest read it in place. Never mutated here. */
56
54
  tools: readonly AgentTool[];
57
- /** borrowed-readonly — the task model: `promptGuidance` (the model-guidance section) and `id` (the compose event's `model`). */
58
- model: Pick<Model, "id" | "promptGuidance">;
55
+ /** borrowed-readonly — the task model: `id` (the compose event's `model`). */
56
+ model: Pick<Model, "id">;
59
57
  /** borrowed-readonly — the acquired session id (every operator line's attribution). */
60
58
  sessionId: string;
61
59
  /** borrowed-readonly — the once-per-session ledger's operator sink (the collision audit's two lines). */
@@ -15,19 +15,23 @@ import { protocolOf } from "../protocol-table.js";
15
15
  import { hasConversationContent } from "../session.js";
16
16
  import { PROMPT_HASH_SALT } from "./prompt-hash-salt.js";
17
17
  const CATALOG_DIGEST = catalogDigestOf(SEMA_DEFAULT_CATALOG);
18
- function taskLayerOf(task) {
18
+ const TASK_TEXT_DIGEST_SCHEME = "sid-sha256:";
19
+ function taskLayerDigestOf(sessionId, text) {
20
+ return `${TASK_TEXT_DIGEST_SCHEME}${createHash("sha256").update(sessionId).update("\u0000").update(text).digest("hex")}`;
21
+ }
22
+ function taskLayerOf(task, sessionId) {
19
23
  return task.map(({ overlay: o, origin }) => ({
20
24
  by: origin.by,
21
25
  id: o.id,
22
26
  op: o.op,
23
27
  target: o.target,
24
- ...(o.text !== undefined ? { chars: o.text.length } : {}),
28
+ ...(o.text !== undefined ? { text: taskLayerDigestOf(sessionId, o.text) } : {}),
25
29
  ...(o.message !== undefined ? { message: o.message } : {}),
26
30
  ...(o.when !== undefined ? { when: o.when } : {}),
27
31
  }));
28
32
  }
29
33
  export async function preparePromptAssembly(input) {
30
- const { session, deps, internals, resume, sugar, host, binding, modBus, featureFlags, mcpInstructionsBlock, memoryBlock, envFacts, promptProfile, fableMitigations, tools, model, sessionId, onceLedger } = input;
34
+ const { session, deps, internals, resume, sugar, host, binding, modBus, featureFlags, mcpInstructionsBlock, memoryBlock, envFacts, promptTraits, tools, model, sessionId, onceLedger } = input;
31
35
  const topLevel = internals?.parentTaskId === undefined && internals?.parentSessionId === undefined && internals?.parentCenterArtifactDigest === undefined;
32
36
  const stored = await session.getPromptEpoch();
33
37
  let centerAdoption;
@@ -82,10 +86,8 @@ export async function preparePromptAssembly(input) {
82
86
  ...featureFlags,
83
87
  orchestrationEnabled: featureFlags.orchestrationEnabled && tools.some((t) => t.name === "Workflow"),
84
88
  orchestrationDeferred: featureFlags.orchestrationDeferred && tools.some((t) => t.name === "Workflow"),
85
- promptProfile,
86
- fableMitigations,
87
89
  };
88
- const selectorRecord = selectorRecordOf(selectorsOf(facts, host, binding));
90
+ const selectorRecord = selectorRecordOf(selectorsOf(facts, host, binding, promptTraits));
89
91
  const centerOverlays = centerOverlaysOf(centerAdoption);
90
92
  const lowerAdds = new Map();
91
93
  for (const { overlay } of [...sugar, ...centerOverlays])
@@ -105,6 +107,7 @@ export async function preparePromptAssembly(input) {
105
107
  deployOverlays: composed.deploy,
106
108
  host,
107
109
  ...(binding !== undefined ? { binding } : {}),
110
+ traits: promptTraits,
108
111
  tools,
109
112
  facts,
110
113
  ...(envFacts.cwd !== undefined ? { workspaceFolder: envFacts.cwd } : {}),
@@ -112,11 +115,10 @@ export async function preparePromptAssembly(input) {
112
115
  memoryBlock,
113
116
  buildEnvBlock: (date) => buildEnvironmentContext({ ...envFacts, date }) || undefined,
114
117
  date: envFacts.date,
115
- ...(model.promptGuidance && model.promptGuidance.length > 0 ? { modelGuidance: model.promptGuidance.join("\n\n") } : {}),
116
118
  onWarn: (message, phase) => deps.onError?.(new Error(message), { phase, sessionId }),
117
119
  });
118
120
  const deployLayer = composed.deploy.length > 0 ? digestOf(composed.deploy.map(({ overlay, origin }) => ({ by: origin.by, overlay }))) : undefined;
119
- const taskLayer = taskOverlays.length > 0 ? digestOf(taskLayerOf(taskOverlays)) : undefined;
121
+ const taskLayer = taskOverlays.length > 0 ? digestOf(taskLayerOf(taskOverlays, sessionId)) : undefined;
120
122
  const bindingLayer = digestOf(selectorRecord);
121
123
  const renderers = rendererVector();
122
124
  const identityFor = (center) => ({
@@ -23,7 +23,8 @@ import type { LegModBus } from "../mods/stations.js";
23
23
  import type { ExecutionEnv, ThinkingLevel } from "../../internal/harness.js";
24
24
  import type { Model } from "../../internal/llm.js";
25
25
  import { type EnvironmentFacts } from "../../prompts/default.js";
26
- import type { SourcedOverlay } from "../../prompt-assembly/overlay.js";
26
+ import type { HostRole } from "../../prompt-assembly/catalog/schema.js";
27
+ import { type RequestBodySugar } from "../../prompt-assembly/sugar.js";
27
28
  import type { ContainmentFace } from "../../tools/fs/index.js";
28
29
  import type { LockedPreflight } from "../locked-config.js";
29
30
  import type { MaterializedMcp } from "../mcp.js";
@@ -65,10 +66,6 @@ export interface PreparePromptInputsInput {
65
66
  /** borrowed-readonly — the frozen tool face; `defer` (the Workflow short-pointer flag) and `selector` (with the spec's whole-face
66
67
  * switch, the valve's reading that decides which servers' instructions are taught). */
67
68
  toolFaceSnapshot: Pick<ToolFaceSnapshot, "defer" | "selector">;
68
- /** borrowed-readonly — the resolved prompt profile (rides the flags to the legacy ctx). */
69
- promptProfile: "simple" | "classic";
70
- /** borrowed-readonly — the fable-mitigations profile axis (rides the flags with the profile). */
71
- fableMitigations: boolean;
72
69
  /** borrowed-readonly — trusted internals: `goalMode` (goal flag), `isolation` (worktree flag),
73
70
  * `defaultSystemPrompt` (the sugar's third source). `undefined` on a standalone prepare. */
74
71
  internals: Pick<RunInternals, "goalMode" | "isolation" | "defaultSystemPrompt"> | undefined;
@@ -81,8 +78,12 @@ export interface PreparePromptInputsInput {
81
78
  delegation: {
82
79
  readonly isNonForkChild: boolean;
83
80
  };
84
- /** borrowed-readonly — the resolved role; only its `systemPrompt` preset is read (second source). */
85
- resolvedRole: Pick<ResolvedRole, "systemPrompt">;
81
+ /** borrowed-readonly — the resolved role; only its role-base statement (`promptRole` / `systemPrompt`) is read (the
82
+ * role-base decision's second source). */
83
+ resolvedRole: Pick<ResolvedRole, "promptRole" | "systemPrompt">;
84
+ /** borrowed-readonly — the task seat's role word as its door judged it (`TaskSpec.promptRole`, `resolveHost`): the
85
+ * role-base decision's first source, beside the spec's own text. */
86
+ taskRole: HostRole | undefined;
86
87
  /** borrowed-mutable — the materialized MCP roster; `serverInstructions` (the disposed entries) and `tools` (each server's listing: did it list
87
88
  * any tool) are read, and the instructions lane's ledger is stated: the block is what the model is told at the run's start. */
88
89
  mcp: Pick<MaterializedMcp, "serverInstructions" | "tools" | "instructionsDelta">;
@@ -122,8 +123,9 @@ export interface PreparePromptInputsInput {
122
123
  export interface PreparePromptInputsResult {
123
124
  /** owned — the runtime feature flags (see {@link PromptFeatureFlags}). */
124
125
  featureFlags: PromptFeatureFlags;
125
- /** owned — the request-body sugar's overlays (the task class's first contributions), in application order. */
126
- sugar: readonly SourcedOverlay[];
126
+ /** owned — the request-body sugar: its overlays (the task class's first contributions, in application order) and the
127
+ * run's host role, from the one role-base decision. */
128
+ sugar: RequestBodySugar;
127
129
  /** owned — the fenced MCP server-instructions block, or undefined when no server declared any. */
128
130
  mcpInstructionsBlock: string | undefined;
129
131
  /** owned — the environment facts the env tail renders from. Filled here; no later phase writes it
@@ -1,5 +1,5 @@
1
1
  import { formatLocalDate, isValidTimeZone } from "../../prompts/default.js";
2
- import { sugarOverlays } from "../../prompt-assembly/sugar.js";
2
+ import { requestBodySugar } from "../../prompt-assembly/sugar.js";
3
3
  import { valveLeaves } from "../../agents/tool-filter.js";
4
4
  import { instructionsTaught, toldAtStart } from "../mounted-mcp.js";
5
5
  import { isIsolated } from "../remote-env.js";
@@ -9,7 +9,7 @@ import { renderMcpInstructionsEntry } from "./turn-attachments.js";
9
9
  const ULTRA_REASONING_TIERS = new Set(["xhigh", "max"]);
10
10
  import { compactionEnabled } from "../context-settings.js";
11
11
  export async function preparePromptInputs(input) {
12
- const { spec, deps, failClosedReason, lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, promptProfile, fableMitigations, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId, session, advertisedWritableDirs } = input;
12
+ const { spec, deps, failClosedReason, lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId, session, advertisedWritableDirs } = input;
13
13
  const promptPolicyEnabled = Boolean(lockedPreflight.toolPolicy);
14
14
  const promptHooksEnabled = input.modBus.hasHandlers("classic.PreToolUse") || input.modBus.hasHandlers("classic.PostToolUse");
15
15
  if (failClosedReason) {
@@ -24,15 +24,13 @@ export async function preparePromptInputs(input) {
24
24
  writeFaceOpen: resolvedWriteFace === "open",
25
25
  orchestrationEnabled: selfOrchestrationActive,
26
26
  orchestrationDeferred: selfOrchestrationActive && (toolFaceSnapshot.defer?.includes("Workflow") ?? false),
27
- promptProfile,
28
- fableMitigations,
29
27
  goalEnabled: internals?.goalMode === true,
30
28
  awarenessEnabled: thinking !== undefined && ULTRA_REASONING_TIERS.has(thinking),
31
29
  worktreeIsolated: internals?.isolation === "worktree" && ownedEnv !== undefined,
32
30
  withinTaskCompactionEnabled: compactionEnabled(spec.compaction?.enabled, input.contextOverlay) && (spec.compaction?.withinTask ?? true),
33
31
  isSubagent: delegation.isNonForkChild,
34
32
  };
35
- const sugar = sugarOverlays({ spec, resolvedRole, ...(internals !== undefined ? { internals } : {}) });
33
+ const sugar = requestBodySugar({ spec, resolvedRole, ...(input.taskRole !== undefined ? { taskRole: input.taskRole } : {}), ...(internals !== undefined ? { internals } : {}) });
36
34
  const valveLeft = valveLeaves(spec, toolFaceSnapshot.selector);
37
35
  const taught = mcp.serverInstructions.filter((entry) => instructionsTaught(valveLeft, entry.server, input.roster.tools, mcp.tools));
38
36
  toldAtStart(mcp.instructionsDelta, new Set(taught.map((entry) => entry.server)));
@@ -36,6 +36,8 @@ export interface PrepareProtocolToolsInput {
36
36
  * mount predicate, and whether a real client was acquired) and `a2a` (the declared peers the door judged: the materialize
37
37
  * input and whether a handle was acquired) are read. */
38
38
  lockedPreflight: Pick<LockedPreflight, "mcp" | "a2a">;
39
+ /** borrowed-readonly — the deployment's host floor as the config doors compiled it: each MCP http dial and every A2A request is judged by it. */
40
+ hostFloor: import("../host-floor.js").HostFloor | undefined;
39
41
  /** borrowed-readonly — the REBOUND spec. Read: `principal` (the MCP header / the A2A identity), `tools`
40
42
  * (the caller names both reserved-name guards check against), `excludeAllTools` (the valve's whole-face switch: the live roster lane's
41
43
  * reading, and the first-dial gate), `signal` (the host's abort, which stops an MCP dial). */
@@ -14,7 +14,7 @@ import { applyMcpToolFaces } from "./tool-face-overlay.js";
14
14
  import { sectionDisposerOf } from "../prompt-section-seat.js";
15
15
  import { thrownText } from "../thrown-value.js";
16
16
  export async function prepareProtocolTools(input) {
17
- const { lockedPreflight, spec, deps, mcpPool, reminderMark, reminderDisclosureCounts, runId, sessionId, onceLedger, roster, rosterSeat, remoteToolOffload, toolFaceSnapshot, toolEffects, axisExplicitNegatives, irreversibilityTier, irreversibleTools, egressTools, toolMarkSources, abortController, rollback } = input;
17
+ const { lockedPreflight, hostFloor, spec, deps, mcpPool, reminderMark, reminderDisclosureCounts, runId, sessionId, onceLedger, roster, rosterSeat, remoteToolOffload, toolFaceSnapshot, toolEffects, axisExplicitNegatives, irreversibilityTier, irreversibleTools, egressTools, toolMarkSources, abortController, rollback } = input;
18
18
  const markedBy = (name, source) => {
19
19
  const set = toolMarkSources.get(name);
20
20
  if (set !== undefined)
@@ -30,7 +30,7 @@ export async function prepareProtocolTools(input) {
30
30
  const leaves = valveLeaves(spec, toolFaceSnapshot.selector);
31
31
  const resourcesReached = resourceFacesLeft(leaves);
32
32
  const mcp = lockedPreflight.mcp?.length
33
- ? await materializeMcpTools(lockedPreflight.mcp, spec.principal, deps.onElicit, deps.mcpImageResizer, { reminderMark, counts: reminderDisclosureCounts }, mcpRevocationWiring(deps, runId), mcpPool === undefined ? undefined : { pool: mcpPool.pool, ownsPool: mcpPool.owned }, sectionDisposerOf(input.modBus, abortController.signal), (entry) => resourcesReached || serverReached(mintNamespacePrefix(MCP_NAMESPACE, entry.name)), AbortSignal.any([abortController.signal, ...(spec.signal !== undefined ? [spec.signal] : [])]))
33
+ ? await materializeMcpTools(lockedPreflight.mcp, spec.principal, deps.onElicit, deps.mcpImageResizer, { reminderMark, counts: reminderDisclosureCounts }, mcpRevocationWiring(deps, runId), mcpPool === undefined ? undefined : { pool: mcpPool.pool, ownsPool: mcpPool.owned }, sectionDisposerOf(input.modBus, abortController.signal), (entry) => resourcesReached || serverReached(mintNamespacePrefix(MCP_NAMESPACE, entry.name)), AbortSignal.any([abortController.signal, ...(spec.signal !== undefined ? [spec.signal] : [])]), hostFloor)
34
34
  :
35
35
  { tools: [], toolAxes: [], warnings: [], serverInstructions: [], instructionsDelta: { pendingAdds: [], pendingRemovals: [] }, droppedTools: [], statuses: [], refresh: async () => [], reconnect: async (server) => ({ server, prefix: mintNamespacePrefix(MCP_NAMESPACE, server), outcome: "not_declared", reason: "this task declared no MCP servers", toolCount: 0, added: [], removed: [] }), dispose: async () => { } };
36
36
  if (lockedPreflight.mcp?.length)
@@ -167,7 +167,7 @@ export async function prepareProtocolTools(input) {
167
167
  foldProtocolAxes(mcp.toolAxes, "MCP");
168
168
  const a2aDeclared = lockedPreflight.a2a;
169
169
  const a2a = a2aDeclared
170
- ? await materializeA2aTools(a2aDeclared, spec.principal, abortController.signal)
170
+ ? await materializeA2aTools(a2aDeclared, spec.principal, abortController.signal, hostFloor)
171
171
  : { tools: [], toolAxes: [], warnings: [], statuses: [], refresh: async () => [], dispose: async () => { } };
172
172
  if (a2aDeclared)
173
173
  rollback.push(function a2aDispose() { return a2a.dispose(); });
@@ -16,7 +16,7 @@ export interface PrepareSafetyScanInput {
16
16
  * The six collections are **borrowed-mutable**: the driver and later phases fold into them IN
17
17
  * PLACE (identity is part of the contract — closures alias these exact objects). Mutation owners
18
18
  * after this phase, in driver order:
19
- * · the roster builder (`toolEffects`: every mount and unmount; the aliases' axes on a non-caller mount and on an unmount);
19
+ * · the roster builder (`toolEffects`: every mount and unmount);
20
20
  * · the MCP/A2A materialize fold + the runtime refresh seam (protocol-axis tighten registration and a protocol tool's effect;
21
21
  * on refresh, `toolEffects.delete` resets a replaced tool's effect record for the fresh fold —
22
22
  * the irreversible/egress sets deliberately KEEP their entries, the tighten-only residue);
@@ -116,9 +116,7 @@ export function prepareSafetyScan(input) {
116
116
  }
117
117
  }
118
118
  const candidates = engineCandidatesOf(spec, deps);
119
- const engineNames = new Set(candidates.map(([n]) => n));
120
119
  for (const t of survivors.values()) {
121
- const tier = tierOf(t);
122
120
  for (const alias of t.aliases ?? []) {
123
121
  if (alias === t.name || survivors.has(alias))
124
122
  continue;
@@ -128,21 +126,6 @@ export function prepareSafetyScan(input) {
128
126
  claimedAliases.add(alias);
129
127
  if (t.effect)
130
128
  declared.set(alias, t.effect);
131
- if (engineNames.has(alias))
132
- continue;
133
- if (tier !== undefined) {
134
- irreversibilityTier.set(alias, tier);
135
- if (tier === "always" || tier === "maybe") {
136
- irreversibleTools.add(alias);
137
- markedBy(alias, "deployment");
138
- }
139
- }
140
- if (t.reversibilityProbe)
141
- reversibilityProbes.set(alias, t.reversibilityProbe);
142
- if (t.egress) {
143
- egressTools.add(alias);
144
- markedBy(alias, "deployment");
145
- }
146
129
  }
147
130
  }
148
131
  return {