@sema-agent/core 7.15.0 → 7.17.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 (287) hide show
  1. package/CHANGELOG.md +202 -0
  2. package/dist/agents/builtin-agents.d.ts +3 -3
  3. package/dist/agents/cross-session-envelope.d.ts +0 -1
  4. package/dist/agents/cross-session-envelope.js +0 -1
  5. package/dist/agents/peer-notices.d.ts +0 -9
  6. package/dist/agents/peer-notices.js +0 -63
  7. package/dist/agents/subagent.js +7 -15
  8. package/dist/brain/request-params.d.ts +2 -2
  9. package/dist/config/defaults.d.ts +0 -7
  10. package/dist/config/defaults.js +0 -2
  11. package/dist/core/artifact-host.d.ts +218 -0
  12. package/dist/core/artifact-host.js +92 -0
  13. package/dist/core/ask-origin.d.ts +29 -3
  14. package/dist/core/ask-origin.js +17 -9
  15. package/dist/core/ask-question.d.ts +25 -0
  16. package/dist/core/ask-question.js +4 -0
  17. package/dist/core/ask-unresolvable-notice.d.ts +30 -21
  18. package/dist/core/ask-unresolvable-notice.js +16 -8
  19. package/dist/core/auto-compaction.d.ts +10 -10
  20. package/dist/core/auto-mode-arming.d.ts +2 -2
  21. package/dist/core/background-agent-store.d.ts +5 -5
  22. package/dist/core/background-shell.d.ts +1 -1
  23. package/dist/core/checkpoint-execution-record.d.ts +0 -3
  24. package/dist/core/checkpoint-execution-record.js +0 -4
  25. package/dist/core/checkpoint-store.d.ts +71 -99
  26. package/dist/core/checkpoint-store.js +9 -16
  27. package/dist/core/context-edit.d.ts +36 -104
  28. package/dist/core/context-edit.js +37 -60
  29. package/dist/core/effective-path-target.d.ts +68 -8
  30. package/dist/core/effective-path-target.js +42 -30
  31. package/dist/core/engine-notice.d.ts +46 -32
  32. package/dist/core/env-budget.d.ts +31 -0
  33. package/dist/core/env-budget.js +39 -0
  34. package/dist/core/exec-output-tail.d.ts +5 -5
  35. package/dist/core/file-history-store.js +3 -6
  36. package/dist/core/fs-write-gate-policy.d.ts +1 -1
  37. package/dist/core/fs-write-gate-policy.js +3 -3
  38. package/dist/core/gate-lanes.js +9 -15
  39. package/dist/core/governance-codes.d.ts +1 -1
  40. package/dist/core/governance-codes.js +4 -0
  41. package/dist/core/hands-band.d.ts +1 -1
  42. package/dist/core/hooks.d.ts +18 -17
  43. package/dist/core/lsp-session.d.ts +1 -1
  44. package/dist/core/lsp.d.ts +1 -1
  45. package/dist/core/lsp.js +5 -4
  46. package/dist/core/mcp.d.ts +5 -5
  47. package/dist/core/mcp.js +4 -48
  48. package/dist/core/memory-engine/delegation-settlement.d.ts +37 -12
  49. package/dist/core/memory-engine/delegation-settlement.js +128 -39
  50. package/dist/core/memory-engine/engine.d.ts +9 -8
  51. package/dist/core/memory-engine/engine.js +115 -120
  52. package/dist/core/memory-engine/file-backend.d.ts +17 -5
  53. package/dist/core/memory-engine/file-backend.js +78 -34
  54. package/dist/core/memory-engine/index.d.ts +2 -2
  55. package/dist/core/memory-engine/index.js +2 -2
  56. package/dist/core/memory-engine/layout.d.ts +152 -54
  57. package/dist/core/memory-engine/layout.js +441 -104
  58. package/dist/core/memory-engine/types.d.ts +8 -3
  59. package/dist/core/memory-engine/types.js +5 -0
  60. package/dist/core/memory-recall.d.ts +0 -8
  61. package/dist/core/memory.d.ts +1 -1
  62. package/dist/core/oracle-isolation.js +2 -2
  63. package/dist/core/parent-spec-seat.d.ts +66 -0
  64. package/dist/core/parent-spec-seat.js +47 -0
  65. package/dist/core/permission-rule-model.d.ts +11 -6
  66. package/dist/core/permission-rule-model.js +53 -37
  67. package/dist/core/permission-rules.js +8 -3
  68. package/dist/core/protocol-naming.d.ts +2 -2
  69. package/dist/core/remote-env.d.ts +1 -1
  70. package/dist/core/retired-keys.d.ts +19 -0
  71. package/dist/core/retired-keys.js +15 -0
  72. package/dist/core/runner/abort-race.d.ts +3 -3
  73. package/dist/core/runner/active-skill-scope.d.ts +2 -2
  74. package/dist/core/runner/active-skill-scope.js +3 -3
  75. package/dist/core/runner/assemble-result.d.ts +42 -40
  76. package/dist/core/runner/assemble-result.js +5 -4
  77. package/dist/core/runner/checkpoint-scope.d.ts +4 -4
  78. package/dist/core/runner/clock-and-limits.d.ts +3 -3
  79. package/dist/core/runner/compaction-call-options.d.ts +35 -99
  80. package/dist/core/runner/compaction-knobs.d.ts +4 -4
  81. package/dist/core/runner/compaction-seams.d.ts +5 -5
  82. package/dist/core/runner/contracts.d.ts +232 -233
  83. package/dist/core/runner/decide-continuation.d.ts +6 -6
  84. package/dist/core/runner/denial-limit-arms.d.ts +8 -8
  85. package/dist/core/runner/derived-route-fallback.d.ts +2 -2
  86. package/dist/core/runner/gate-exit.d.ts +6 -6
  87. package/dist/core/runner/gate-exit.js +15 -1
  88. package/dist/core/runner/git-status-frame.d.ts +7 -7
  89. package/dist/core/runner/halt-attribution.d.ts +35 -0
  90. package/dist/core/runner/halt-attribution.js +16 -0
  91. package/dist/core/runner/inherited-ask-grants.d.ts +6 -6
  92. package/dist/core/runner/memory-capture-optout.d.ts +1 -1
  93. package/dist/core/runner/memory-consolidation-driver.d.ts +4 -4
  94. package/dist/core/runner/memory-consolidation.d.ts +6 -8
  95. package/dist/core/runner/memory-consolidation.js +0 -1
  96. package/dist/core/runner/park-commit.d.ts +6 -6
  97. package/dist/core/runner/permission-rule-lanes.d.ts +19 -19
  98. package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -4
  99. package/dist/core/runner/prepare-artifact.d.ts +53 -0
  100. package/dist/core/runner/prepare-artifact.js +77 -0
  101. package/dist/core/runner/prepare-ask-lane.d.ts +3 -3
  102. package/dist/core/runner/prepare-boundary-parks.d.ts +3 -3
  103. package/dist/core/runner/prepare-caps-and-workflow.d.ts +9 -7
  104. package/dist/core/runner/prepare-caps-and-workflow.js +2 -3
  105. package/dist/core/runner/prepare-config-doors.d.ts +24 -24
  106. package/dist/core/runner/prepare-config-doors.js +5 -2
  107. package/dist/core/runner/prepare-context-lane.d.ts +8 -8
  108. package/dist/core/runner/prepare-context-lane.js +2 -13
  109. package/dist/core/runner/prepare-defer-classify.d.ts +2 -2
  110. package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
  111. package/dist/core/runner/prepare-file-history.d.ts +3 -3
  112. package/dist/core/runner/prepare-file-history.js +3 -52
  113. package/dist/core/runner/prepare-gate-stations.d.ts +5 -5
  114. package/dist/core/runner/prepare-hands-readface.d.ts +35 -38
  115. package/dist/core/runner/prepare-hands-readface.js +3 -2
  116. package/dist/core/runner/prepare-inherited-gate.d.ts +9 -6
  117. package/dist/core/runner/prepare-inherited-gate.js +7 -8
  118. package/dist/core/runner/prepare-listings.d.ts +3 -3
  119. package/dist/core/runner/prepare-lsp.d.ts +3 -3
  120. package/dist/core/runner/prepare-memory-engine-session.d.ts +5 -5
  121. package/dist/core/runner/prepare-memory.d.ts +4 -6
  122. package/dist/core/runner/prepare-memory.js +10 -9
  123. package/dist/core/runner/prepare-offload-wrappers.d.ts +2 -2
  124. package/dist/core/runner/prepare-park-ask.d.ts +6 -6
  125. package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
  126. package/dist/core/runner/prepare-policy-chain.js +15 -30
  127. package/dist/core/runner/prepare-prompt-assembly.js +1 -1
  128. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -5
  129. package/dist/core/runner/prepare-protocol-tools.d.ts +1 -1
  130. package/dist/core/runner/prepare-question-face.d.ts +4 -4
  131. package/dist/core/runner/prepare-run-refs.d.ts +11 -11
  132. package/dist/core/runner/prepare-safety-scan.d.ts +2 -2
  133. package/dist/core/runner/prepare-suspend-saga.d.ts +4 -4
  134. package/dist/core/runner/prepare-suspend-saga.js +0 -2
  135. package/dist/core/runner/prepare-task.d.ts +12 -12
  136. package/dist/core/runner/prepare-task.js +10 -9
  137. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +2 -3
  138. package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -4
  139. package/dist/core/runner/prepare-wiring-manifest.js +9 -7
  140. package/dist/core/runner/prepare-workspace-restore.d.ts +1 -1
  141. package/dist/core/runner/remote-env-retry.d.ts +3 -3
  142. package/dist/core/runner/resume-admission.d.ts +1 -1
  143. package/dist/core/runner/resume-admission.js +2 -1
  144. package/dist/core/runner/resume-claim.d.ts +1 -1
  145. package/dist/core/runner/resume-internals-and-config.d.ts +1 -1
  146. package/dist/core/runner/resume-internals-and-config.js +4 -0
  147. package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
  148. package/dist/core/runner/resume-preflight.d.ts +1 -1
  149. package/dist/core/runner/resume-review-outcome.d.ts +1 -1
  150. package/dist/core/runner/retired-runner-deps.d.ts +3 -0
  151. package/dist/core/runner/retired-runner-deps.js +7 -0
  152. package/dist/core/runner/run-brain-sinks.d.ts +1 -1
  153. package/dist/core/runner/run-clock-and-content.d.ts +4 -4
  154. package/dist/core/runner/run-compaction-machinery.d.ts +3 -3
  155. package/dist/core/runner/run-git-lane.d.ts +1 -1
  156. package/dist/core/runner/run-harness-handlers.d.ts +2 -2
  157. package/dist/core/runner/run-harness-handlers.js +2 -3
  158. package/dist/core/runner/run-identity-wiring.d.ts +4 -4
  159. package/dist/core/runner/run-leg.d.ts +3 -3
  160. package/dist/core/runner/run-notification-lane.d.ts +2 -2
  161. package/dist/core/runner/run-reasoning-seat.d.ts +2 -2
  162. package/dist/core/runner/run-settle-and-teardown.d.ts +5 -5
  163. package/dist/core/runner/run-settle-and-teardown.js +3 -1
  164. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +2 -2
  165. package/dist/core/runner/run-terminal-adoption.d.ts +5 -5
  166. package/dist/core/runner/runtask.d.ts +14 -14
  167. package/dist/core/runner/session-file-state-replay.d.ts +3 -3
  168. package/dist/core/runner/session-file-state-replay.js +3 -3
  169. package/dist/core/runner/session-rule-policy.d.ts +2 -2
  170. package/dist/core/runner/session-rule-policy.js +3 -4
  171. package/dist/core/runner/steer-admission.d.ts +2 -2
  172. package/dist/core/runner/stream-halt-verbs.d.ts +1 -1
  173. package/dist/core/runner/stream-halt-verbs.js +1 -1
  174. package/dist/core/runner/stream-reap.d.ts +1 -1
  175. package/dist/core/runner/stream-steer-verb.js +1 -4
  176. package/dist/core/runner/synthetic-tools.d.ts +8 -8
  177. package/dist/core/runner/teardown-bounded.d.ts +2 -2
  178. package/dist/core/runner/tool-defer-gate.d.ts +1 -1
  179. package/dist/core/runner/tool-disclosure.d.ts +33 -33
  180. package/dist/core/runner/tool-end-body.d.ts +3 -3
  181. package/dist/core/runner/tool-face-overlay.d.ts +2 -2
  182. package/dist/core/runner/tool-output-projection.d.ts +2 -2
  183. package/dist/core/runner/turn-attachments.d.ts +53 -53
  184. package/dist/core/runner/usage-accounting.d.ts +4 -4
  185. package/dist/core/runner/workspace-path.d.ts +1 -1
  186. package/dist/core/runner/workspace-path.js +3 -0
  187. package/dist/core/runner-deps.d.ts +30 -49
  188. package/dist/core/safe-notify.d.ts +1 -1
  189. package/dist/core/sensitive-path-policy.d.ts +1 -1
  190. package/dist/core/sensitive-path-policy.js +4 -4
  191. package/dist/core/session.d.ts +2 -2
  192. package/dist/core/skill-tool-specifier.d.ts +1 -1
  193. package/dist/core/skills-directory.d.ts +1 -1
  194. package/dist/core/store-contracts/checkpoint-store-contract.js +1 -1
  195. package/dist/core/strategy-store.d.ts +8 -11
  196. package/dist/core/task-event.d.ts +20 -17
  197. package/dist/core/task-limits.d.ts +1 -1
  198. package/dist/core/task-notification.d.ts +5 -5
  199. package/dist/core/task-registry-agent.d.ts +5 -5
  200. package/dist/core/task-registry-monitor.d.ts +2 -2
  201. package/dist/core/task-registry-shared.d.ts +27 -27
  202. package/dist/core/task-registry-shared.js +3 -13
  203. package/dist/core/task-registry.d.ts +8 -8
  204. package/dist/core/task-result.d.ts +37 -37
  205. package/dist/core/task-spec.d.ts +5 -5
  206. package/dist/core/task-stream.d.ts +16 -11
  207. package/dist/core/tool-catalog-entries.d.ts +1 -0
  208. package/dist/core/tool-catalog-entries.js +5 -0
  209. package/dist/core/tool-conformance.d.ts +0 -2
  210. package/dist/core/tool-conformance.js +1 -3
  211. package/dist/core/tool-errors.d.ts +5 -0
  212. package/dist/core/tool-errors.js +1 -0
  213. package/dist/core/tool-policy.d.ts +51 -22
  214. package/dist/core/tool-policy.js +28 -5
  215. package/dist/core/tool-result-budget.d.ts +1 -1
  216. package/dist/core/tool-result-store.d.ts +11 -11
  217. package/dist/core/tool-spec.d.ts +34 -38
  218. package/dist/core/tools.d.ts +2 -2
  219. package/dist/core/trace.d.ts +12 -15
  220. package/dist/core/untrusted-text.d.ts +1 -1
  221. package/dist/core/wiring-manifest.d.ts +4 -3
  222. package/dist/core/workflow-journal-store.d.ts +11 -11
  223. package/dist/engine/execution-env/node-execution-env.d.ts +3 -2
  224. package/dist/engine/execution-env/node-execution-env.js +4 -2
  225. package/dist/engine/harness/agent-harness.d.ts +47 -4
  226. package/dist/engine/harness/agent-harness.js +52 -9
  227. package/dist/engine/llm/types.d.ts +1 -1
  228. package/dist/engine/loop/agent-loop.js +15 -8
  229. package/dist/engine/loop/types.d.ts +5 -0
  230. package/dist/index.d.ts +21 -16
  231. package/dist/index.js +17 -12
  232. package/dist/internal/harness.d.ts +1 -0
  233. package/dist/orchestration/run-spec.d.ts +3 -0
  234. package/dist/orchestration/run-spec.js +3 -3
  235. package/dist/orchestration/run-workflow-tool.d.ts +12 -6
  236. package/dist/orchestration/run-workflow-tool.js +23 -5
  237. package/dist/orchestration/workflow-primitives.d.ts +4 -2
  238. package/dist/orchestration/workflow-primitives.js +1 -4
  239. package/dist/orchestration/workflow-types.d.ts +34 -4
  240. package/dist/orchestration/workflow-types.js +2 -0
  241. package/dist/orchestration/workflow.d.ts +39 -7
  242. package/dist/orchestration/workflow.js +234 -113
  243. package/dist/prompt-assembly/assemble.d.ts +2 -2
  244. package/dist/prompt-assembly/assemble.js +9 -9
  245. package/dist/prompt-assembly/composer.d.ts +6 -7
  246. package/dist/prompt-assembly/composer.js +10 -10
  247. package/dist/prompt-assembly/epoch.js +1 -1
  248. package/dist/prompt-assembly/event-registry.d.ts +0 -21
  249. package/dist/prompt-assembly/packs/sema-default.js +30 -30
  250. package/dist/prompt-assembly/types.d.ts +14 -14
  251. package/dist/prompts/coordinator.d.ts +0 -13
  252. package/dist/prompts/coordinator.js +0 -3
  253. package/dist/stores/file/checkpoint-store.js +1 -5
  254. package/dist/stores/file/file-history-store.js +2 -2
  255. package/dist/stores/file/permission-rule-store.d.ts +4 -35
  256. package/dist/stores/file/permission-rule-store.js +4 -148
  257. package/dist/tools/artifact/artifact-text.d.ts +62 -0
  258. package/dist/tools/artifact/artifact-text.js +68 -0
  259. package/dist/tools/artifact/artifact-tool.d.ts +52 -0
  260. package/dist/tools/artifact/artifact-tool.js +351 -0
  261. package/dist/tools/artifact/local-stub.d.ts +26 -0
  262. package/dist/tools/artifact/local-stub.js +296 -0
  263. package/dist/tools/fs/bash-readonly-classifier.d.ts +114 -48
  264. package/dist/tools/fs/bash-readonly-classifier.js +171 -60
  265. package/dist/tools/fs/encoding.d.ts +31 -40
  266. package/dist/tools/fs/fs-bash.d.ts +49 -45
  267. package/dist/tools/fs/fs-bash.js +19 -27
  268. package/dist/tools/fs/fs-pdf.d.ts +8 -8
  269. package/dist/tools/fs/fs-search-tools.d.ts +4 -4
  270. package/dist/tools/fs/fs-search-tools.js +5 -2
  271. package/dist/tools/fs/fs-shared.d.ts +146 -158
  272. package/dist/tools/fs/fs-shared.js +3 -11
  273. package/dist/tools/fs/fs-write.d.ts +8 -8
  274. package/dist/tools/fs/gh-rate-limit.d.ts +13 -14
  275. package/dist/tools/fs/index.d.ts +78 -78
  276. package/dist/tools/fs/index.js +4 -1
  277. package/dist/tools/fs/notebook.d.ts +24 -25
  278. package/dist/tools/fs/pdf.d.ts +3 -3
  279. package/dist/tools/fs/read-deny.d.ts +22 -22
  280. package/dist/tools/fs/read-face.d.ts +21 -24
  281. package/dist/tools/fs/repo-map.d.ts +8 -8
  282. package/dist/tools/fs/safety.d.ts +233 -130
  283. package/dist/tools/fs/safety.js +131 -31
  284. package/dist/tools/fs/search.d.ts +63 -71
  285. package/dist/tools/fs/search.js +8 -6
  286. package/package.json +6 -2
  287. package/test/export-surface.snapshot.json +119 -39
@@ -1,5 +1,7 @@
1
1
  import { resolveBrainCallGuardrailMs } from "../../brain/timeout.js";
2
2
  import { assertReadFaceValue } from "../../tools/fs/index.js";
3
+ import { MICRO_COMPACT_MACHINES } from "../context-edit.js";
4
+ import { assertNoRetiredRunnerDeps } from "./retired-runner-deps.js";
3
5
  import { resolveCheckpointStore } from "../checkpoint-store.js";
4
6
  import { isModelPriced, malformedPricingField, modelCostToPricing } from "../pricing.js";
5
7
  import { preflightLockedConfig } from "../locked-config.js";
@@ -133,8 +135,8 @@ export function resolveMicroCompactKnob(bag) {
133
135
  throw microCompactConfigError(undefined, bag, "an object carrying optional machine/clearOnRejection keys");
134
136
  }
135
137
  const declaredMachine = bag?.machine;
136
- if (declaredMachine !== undefined && declaredMachine !== "off" && declaredMachine !== "legacy" && declaredMachine !== "cc") {
137
- throw microCompactConfigError("machine", declaredMachine, `"off" | "legacy" | "cc"`);
138
+ if (declaredMachine !== undefined && !MICRO_COMPACT_MACHINES.includes(declaredMachine)) {
139
+ throw microCompactConfigError("machine", declaredMachine, MICRO_COMPACT_MACHINES.map((m) => `"${m}"`).join(" | "));
138
140
  }
139
141
  return { machine: declaredMachine ?? "cc", clearOnRejection: resolveClearOnRejection(bag) };
140
142
  }
@@ -148,6 +150,7 @@ function resolveClearOnRejection(bag) {
148
150
  export function prepareConfigDoors(input) {
149
151
  const { deps, sessions, resume, internals } = input;
150
152
  let spec = input.spec;
153
+ assertNoRetiredRunnerDeps(deps);
151
154
  assertRestoreGatedToolsValue(spec.restoreGatedTools);
152
155
  const microCompactKnob = resolveMicroCompactKnob(deps.microCompact);
153
156
  const assertToolNameListValue = (value, seat) => {
@@ -1,15 +1,15 @@
1
1
  /**
2
- * design/390 §1.2 M21 — prepareTask's CONTEXT-LANE phase, verbatim from the driver: the edit/guard budgets, the
2
+ * PrepareTask's CONTEXT-LANE phase, verbatim from the driver: the edit/guard budgets, the
3
3
  * microCompact machine state with the trigger-window clamp's one loud outlet, the model's chars-per-token coordinate,
4
4
  * and the `context` handler registered on the harness — heal → ledger replay → aggregate tool-result and media caps →
5
5
  * frontier clear → the guard chain (arms A/B/C) → the git-frame guard → the orphan belt → the lossy-projection flag →
6
6
  * the projection seat. The four module-level helpers only this lane called moved with it (the machine-state builder,
7
7
  * the frontier-clear recorder, the observation-buffer flush, the guard chain with its two types). The interface is the
8
- * dependency list the segment had implicitly (design/238 R-1).
8
+ * dependency list the segment had implicitly.
9
9
  *
10
10
  * SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await of its own (the handler it registers is async and
11
11
  * runs per provider request), so the phase adds no yield between the gate stations before it and the turn wiring after
12
- * it (design/390 §1.5). Read-stability of the host handles: {@link RunInternals} (`@contract prepare.deps-read-stable`).
12
+ * it. Read-stability of the host handles: {@link RunInternals} (`@contract prepare.deps-read-stable`).
13
13
  *
14
14
  * REGISTRATION SIDE EFFECT, OWNED: this phase registers the ONE `context` handler on the harness; the harness owns the
15
15
  * listener for the run's life (it is never unregistered — the harness is per prepare). No other station registers on
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import { type AgentHarness, type AgentMessage } from "../../internal/harness.js";
19
19
  import type { Model } from "../../internal/llm.js";
20
- import { type ContextEditMachine, type OccurrenceIndex } from "../context-edit.js";
20
+ import { type MicroCompactMachine, type OccurrenceIndex } from "../context-edit.js";
21
21
  import { type ToolResultStore } from "../tool-result-store.js";
22
22
  import { type RunnerDeps } from "../types.js";
23
23
  import type { Prepared, PreparedMicroCompact } from "./contracts.js";
@@ -39,7 +39,7 @@ export interface PrepareContextLaneInput {
39
39
  offloadStore: ToolResultStore | undefined;
40
40
  /** borrowed-readonly — the doors' RESOLVED microCompact knob (immutable values, never the deps bag). */
41
41
  microCompactKnob: {
42
- machine: "off" | ContextEditMachine;
42
+ machine: MicroCompactMachine;
43
43
  clearOnRejection: boolean;
44
44
  };
45
45
  /** borrowed-mutable — the built harness. Writer here: `on("context", …)` — the ONE registration of the request-build
@@ -76,7 +76,7 @@ export declare function prepareContextLane(input: PrepareContextLaneInput): Prep
76
76
  export interface GuardChainArgs {
77
77
  /** The post-frontier view the chain starts from. */
78
78
  edited: AgentMessage[];
79
- /** The pre-cap counterpart view (arm A's clearSource — RB-212 durable composition seat). */
79
+ /** The pre-cap counterpart view (arm A's clearSource — durable composition seat). */
80
80
  replayed: AgentMessage[];
81
81
  index: OccurrenceIndex;
82
82
  microCompact: PreparedMicroCompact;
@@ -106,8 +106,8 @@ export type GuardChainOutcome = {
106
106
  trimDroppedMessages: boolean;
107
107
  };
108
108
  /**
109
- * design/374 slice 3 — the GUARD CHAIN over one request build (D-7 case-ii transfer table),
110
- * module-level per the design/238 body-span bank. design/123 D3: the chain reads the anchored
109
+ * The GUARD CHAIN over one request build (D-7 case-ii transfer table),
110
+ * the chain reads the anchored
111
111
  * coordinate re-estimated on the EDITED array (pre-anchor clears don't lower it — deliberately;
112
112
  * trimToBudget doc). The opt-out machine = the pre-374 backstop order byte-identical
113
113
  * (trim as the ordinary second line); otherwise arm A (blocking machine run, only when the
@@ -44,14 +44,8 @@ export function prepareContextLane(input) {
44
44
  let ccPass;
45
45
  const edited = microCompact.machine === "off" ? mediaCapped : clearStaleToolResults(mediaCapped, {
46
46
  budgetTokens: editAt,
47
- machine: microCompact.machine,
48
- ...(microCompact.machine === "cc" || microCompact.clearOnRejection ? { recognizeCcMarkers: true } : {}),
49
- ...(microCompact.machine === "cc"
50
- ? {
51
- clearSource: replayed,
52
- onCleared: (pass) => { ccPass = pass; },
53
- }
54
- : {}),
47
+ clearSource: replayed,
48
+ onCleared: (pass) => { ccPass = pass; },
55
49
  anchoredTotalTokens: estimateContextTokens(mediaCapped, charsPerToken).tokens,
56
50
  charsPerToken,
57
51
  ...(offloadStore
@@ -193,15 +187,10 @@ export async function runGuardChain(args) {
193
187
  };
194
188
  let working = edited;
195
189
  let anchoredWorking = estimateContextTokens(working, charsPerToken).tokens;
196
- if (microCompact.machine === "legacy") {
197
- const t = applyGuardTrim(working, anchoredWorking);
198
- return { working, trimmed: t.trimmed, trimDroppedMessages: t.dropped };
199
- }
200
190
  if (microCompact.machine === "off" && anchoredWorking > guardAt) {
201
191
  let blockingPass;
202
192
  const blockingEdited = clearStaleToolResults(working, {
203
193
  budgetTokens: guardAt,
204
- machine: "cc",
205
194
  clearSource: args.replayed,
206
195
  onCleared: (pass) => { blockingPass = pass; },
207
196
  anchoredTotalTokens: anchoredWorking,
@@ -15,7 +15,7 @@ export interface PrepareDeferClassifyInput {
15
15
  * shallow copy for the classic-profile description swap (the caller's ToolSpec object is never
16
16
  * mutated); `splice` of a retracted memory group. After this phase: the content-origin wrap
17
17
  * (element replacement with the wrapped object), the disclosure mount, the MCP refresh re-splice. Since
18
- * design/388 every one of those writes is a builder verb (`unmountWhere` / `replaceAt`). */
18
+ * Every one of those writes is a builder verb (`unmountWhere` / `replaceAt`). */
19
19
  roster: RosterBuilder;
20
20
  /** borrowed-readonly — the frozen task-start tool face: `exclude` (the valve), `defer` (operator
21
21
  * defers, exact wire names), `alwaysLoad` (the inline pins). */
@@ -24,7 +24,7 @@ export interface PrepareDeferClassifyInput {
24
24
  * where a shell could be on the roster). */
25
25
  handsEnabled: boolean;
26
26
  /** borrowed-readonly — the spec-time precomputation the invariant checks the post-exclusion roster
27
- * against (design/199 D-6): a mismatch is an engine bug, thrown. */
27
+ * against: a mismatch is an engine bug, thrown. */
28
28
  fullShellReachable: boolean;
29
29
  /** borrowed-readonly — the resolved prompt profile (`classic` swaps in `descriptionClassic`). */
30
30
  promptProfile: "simple" | "classic";
@@ -74,7 +74,7 @@ export interface PrepareDelegationSurfaceInput {
74
74
  * the SendMessage / AgentTranscript mounts activate their ctx-first arms with it. */
75
75
  enrichSpecToolCtx: (ctx: ToolExecuteContext) => ToolExecuteContext;
76
76
  /** borrowed-mutable — the hands mount's tracked-cwd seat: present ⇔ real shell + write hands; the worktree pair's mount
77
- * predicate. Not written by this phase, but the tools it mounts over it ARE its writers (design/238 R-3): EnterWorktree and
77
+ * predicate. Not written by this phase, but the tools it mounts over it ARE its writers: EnterWorktree and
78
78
  * ExitWorktree assign `current` at run time (the hands band's shared cwd then points at the worktree, and back); the
79
79
  * Monitor only reads it. The cell must stay the hands mount's own object — a copy would strand those writes. */
80
80
  handsCwdRef: CwdRef | undefined;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/390 §1.2 M2 — prepareTask's file-history phase, verbatim from the driver: the DV-14 first-touch
2
+ * PrepareTask's file-history phase, verbatim from the driver: the DV-14 first-touch
3
3
  * policy door, the `RunnerDeps.fileHistoryStore` bad-value door, the retired `rewindFiles` two-sense
4
4
  * split, the restoreFiles / resumeAt / rewindFilesTo combination gates, the run's history coordinates
5
5
  * (canonical root, recording scope, filesystem identity), the fork carry, the child-scope refusal, the
@@ -25,7 +25,7 @@ import type { FileHistoryBoundarySeat, RunInternals } from "./contracts.js";
25
25
  export interface PrepareFileHistoryInput {
26
26
  /** borrowed-readonly — the deployment seats this phase reads: the first-touch failure policy and the
27
27
  * history store (both validated HERE, once), the incident sink, and the retired-epoch diagnostic probe. */
28
- deps: Pick<RunnerDeps, "onTrackFailure" | "fileHistoryStore" | "onError" | "legacyRewindBoundaryProbe">;
28
+ deps: Pick<RunnerDeps, "onTrackFailure" | "fileHistoryStore" | "onError">;
29
29
  /** borrowed-readonly — the REBOUND spec's rewind request fields (the retired `rewindFiles` spelling is
30
30
  * read off the same object as an unknown key) and the caller's cancel signal for the restore. */
31
31
  spec: Pick<TaskSpec, "resumeAt" | "resumeAtMode" | "restoreFiles" | "rewindFilesTo" | "acceptPartialRestore" | "signal">;
@@ -84,7 +84,7 @@ export declare function resolveFileHistoryScope(lineage: RunInternals["fileHisto
84
84
  * · a remote workspace names itself through its {@link WorkspaceHandle} (provider + sandbox, and the
85
85
  * device lane's id when stamped) — two runs on one sandbox share a tree, two sandboxes never do;
86
86
  * · an env that DECLARES its paths host-local (`hostLocalPaths: true`), or is the host adapter itself
87
- * (a {@link NodeExecutionEnv}, which the #211 seam names as the host-local default), is the
87
+ * (a {@link NodeExecutionEnv}, which the seam names as the host-local default), is the
88
88
  * control-plane host's filesystem — every such env is one tree;
89
89
  * · anything else — an env declaring `hostLocalPaths: false`, or an undeclared custom adapter — is
90
90
  * attested to nothing, so it is its OWN tree: a per-instance token, which still matches when the
@@ -63,7 +63,6 @@ export async function prepareFileHistory(input) {
63
63
  });
64
64
  }
65
65
  }
66
- const legacyEpochTail = (entryId, form = "at-or-above") => legacyRewindEpochTail(deps, sessionId, entryId, form);
67
66
  let restoredFilePaths = [];
68
67
  if (rewindTarget !== undefined && fileHistoryStore !== undefined && handsEnabled) {
69
68
  const historyStore = fileHistoryStore;
@@ -85,7 +84,7 @@ export async function prepareFileHistory(input) {
85
84
  }
86
85
  }
87
86
  if (anchor === undefined) {
88
- const e = new Error(`rewind-files: no file-history boundary exists at or above the "before" branch point on session "${sessionId}" — cannot restore files consistent with the rewound context. ${await legacyEpochTail(rewindTarget)}`);
87
+ const e = new Error(`rewind-files: no file-history boundary exists at or above the "before" branch point on session "${sessionId}" — cannot restore files consistent with the rewound context. ${rewindRefusalTail("at-or-above")}`);
89
88
  e.code = "rewind_snapshot.unresolvable";
90
89
  throw e;
91
90
  }
@@ -99,7 +98,7 @@ export async function prepareFileHistory(input) {
99
98
  if (restored.error?.code === "not_found") {
100
99
  const e = new Error(rewindBefore
101
100
  ? `rewind-files: the resolved "before" history anchor "${rewindTarget}" disappeared before restore — files were NOT rewound`
102
- : `rewind-files: no file-history boundary exists for entry "${rewindTarget}" on session "${sessionId}" — the working tree was NOT rewound. ${await legacyEpochTail(rewindTarget, "keyed")}`);
101
+ : `rewind-files: no file-history boundary exists for entry "${rewindTarget}" on session "${sessionId}" — the working tree was NOT rewound. ${rewindRefusalTail("keyed")}`);
103
102
  e.code = "rewind_snapshot.unresolvable";
104
103
  throw e;
105
104
  }
@@ -192,55 +191,7 @@ function resolveWiredFileHistoryStore(candidate) {
192
191
  }
193
192
  return candidate;
194
193
  }
195
- const LEGACY_PROBE_TIMEOUT_MS = 2_000;
196
- const LEGACY_PROBE_TIMED_OUT = Symbol("legacy-rewind-probe-timeout");
197
- async function legacyRewindEpochTail(deps, sessionId, entryId, form) {
198
- const probe = deps.legacyRewindBoundaryProbe;
199
- let verdict;
200
- if (probe !== undefined) {
201
- try {
202
- let timer;
203
- const timeout = new Promise((resolve) => {
204
- timer = setTimeout(() => resolve(LEGACY_PROBE_TIMED_OUT), LEGACY_PROBE_TIMEOUT_MS);
205
- });
206
- try {
207
- verdict = await Promise.race([Promise.resolve(probe({ sessionId, entryId })), timeout]);
208
- }
209
- finally {
210
- clearTimeout(timer);
211
- }
212
- if (verdict === LEGACY_PROBE_TIMED_OUT) {
213
- verdict = undefined;
214
- try {
215
- deps.onError?.(new Error(`RunnerDeps.legacyRewindBoundaryProbe did not answer within ${LEGACY_PROBE_TIMEOUT_MS}ms while explaining a rewind refusal — the refusal stands and names both possibilities`), { phase: "rewind", sessionId });
216
- }
217
- catch {
218
- }
219
- }
220
- }
221
- catch (err) {
222
- verdict = undefined;
223
- try {
224
- deps.onError?.(new Error(`RunnerDeps.legacyRewindBoundaryProbe threw while explaining a rewind refusal (${err.message}) — the refusal stands and names both possibilities`), { phase: "rewind", sessionId });
225
- }
226
- catch {
227
- }
228
- }
229
- if (verdict !== undefined && typeof verdict !== "boolean") {
230
- try {
231
- deps.onError?.(new Error(`RunnerDeps.legacyRewindBoundaryProbe answered ${JSON.stringify(String(verdict))} for entry "${entryId}" — only true/false/undefined are meaningful, so the refusal names both possibilities instead of trusting it`), { phase: "rewind", sessionId });
232
- }
233
- catch {
234
- }
235
- verdict = undefined;
236
- }
237
- }
238
- if (verdict === true) {
239
- return `This deployment's legacy-epoch probe reports that entry "${entryId}" DOES carry a boundary from the retired whole-tree snapshot era, which this engine's per-edited-file seat does not restore — the two epochs are not interchangeable (a whole-tree manifest carries no tracked-set provenance, so replaying it here would converge files this session never edited). Restore it with the whole-tree-era tooling this deployment kept, or re-run the turns under the current engine.`;
240
- }
241
- if (verdict === false) {
242
- return `This deployment's legacy-epoch probe reports no whole-tree-era boundary for entry "${entryId}" either, so the boundary simply does not exist: its turns ran without a RunnerDeps.fileHistoryStore wired, or it was reaped.`;
243
- }
194
+ function rewindRefusalTail(form) {
244
195
  return form === "keyed"
245
196
  ? `Boundaries are keyed by a turn's INITIAL entry and exist only for turns that ran with a RunnerDeps.fileHistoryStore wired; a boundary from the retired whole-tree snapshot era is not restorable by this seat, and reaped boundaries have none.`
246
197
  : `Either the boundary does not exist (its turns ran without a RunnerDeps.fileHistoryStore, or it was reaped), or it was produced in the retired whole-tree snapshot era, which this engine's per-edited-file seat does not restore.`;
@@ -1,18 +1,18 @@
1
1
  /**
2
- * design/390 §1.2 M20 — prepareTask's two GATE STATIONS, verbatim from the driver: the `tool_call` station (the final-roster
2
+ * PrepareTask's two GATE STATIONS, verbatim from the driver: the `tool_call` station (the final-roster
3
3
  * effect sync, the write-protection judge compiled once per task, the arming predicate, the compliance and plan-mode
4
4
  * short-circuits, the `runToolGate` call with every seat it is handed, the lifecycle sweep, the deferred sandbox-admission
5
5
  * disclosure, the PreToolUse context stash, the settlement sideband write and the bare-human-rejection boundary) and the
6
6
  * `tool_result` station (the PostToolUse / PostToolUseFailure seats and the PreToolUse context drain). The two module-scope
7
7
  * helpers only these stations called moved with them (the settlement screen, the rejection-boundary judgment). The
8
- * interface is the dependency list the stations had implicitly (design/238 R-1).
8
+ * interface is the dependency list the stations had implicitly.
9
9
  *
10
10
  * The stations REGISTER handlers on the harness (the side effect this phase exists for) and report only two observation
11
11
  * seats back; the order they register in — after the file-history boundary lease the driver registers, and in this order
12
12
  * (call before result) — is the order handlers run in.
13
13
  *
14
14
  * SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await of its own (the handlers run per tool call / per tool
15
- * result), so the phase adds no yield between the park closure before it and the context lane after it (design/390 §1.5).
15
+ * result), so the phase adds no yield between the park closure before it and the context lane after it.
16
16
  * Read-stability of the host handles for the call: {@link RunInternals} (`@contract prepare.deps-read-stable`).
17
17
  *
18
18
  * The `tool_call` station is built exactly when the ask lane and the park closure are (the same predicate as the whole
@@ -43,14 +43,14 @@ export interface PrepareGateStationsInput {
43
43
  /** borrowed-readonly — the FINAL mount roster: iterated once for the effect sync and the write-protection arming. Never
44
44
  * mutated here. */
45
45
  tools: readonly AgentTool[];
46
- /** borrowed-readonly — the leg's delta seat (design/388): its current roster is the face source for every gated call. */
46
+ /** borrowed-readonly — the leg's delta seat: its current roster is the face source for every gated call. */
47
47
  toolRosterDeltas: ToolRosterDeltaSeat;
48
48
  /** borrowed-mutable — the effect collection. Writer here: the final-roster sync fills MISSING entries from each
49
49
  * first-party tool's declared effect (never overrides a scanned one); the plan-mode deny reads it per call. */
50
50
  toolEffects: Map<string, ToolEffect>;
51
51
  /** borrowed-readonly — the deployment seats these stations read, as a Pick over the SAME `deps` object (receiver
52
52
  * preserved for `deps.onError?.()`): the write-protection table and its data root, the tracer, the error face, and
53
- * the notice sink (#648: the gate's unresolvable-ask exit delivers `delegation.ask_unresolvable` through it). */
53
+ * the notice sink (the gate's unresolvable-ask exit delivers `delegation.ask_unresolvable` through it). */
54
54
  deps: Pick<RunnerDeps, "writeProtectedPaths" | "memoryEngineDir" | "tracer" | "onError" | "onNotice">;
55
55
  /** borrowed-mutable — the protocol-tools phase's arming belt. Writer here: `armed` ← the registration predicate, the
56
56
  * one write; the refresh seam reads it. */
@@ -11,10 +11,10 @@ import { RosterBuilder } from "../tool-roster.js";
11
11
  * Deliberately asymmetric — it resets only the console latch: the WeakSet arm needs no seam
12
12
  * because a test resets it by minting a fresh sink function (identity IS the ledger key), while
13
13
  * the console arm's key is the process itself, which only this seam can refresh. Moved WITH the
14
- * phase (design/238 B-5); prepare-task.ts keeps a re-export so the existing import sites stand. */
14
+ * phase; prepare-task.ts keeps a re-export so the existing import sites stand. */
15
15
  export declare function __resetReadFaceClampAnnouncement(): void;
16
16
  /**
17
- * #483 rung-1 — the Runner's per-session read-file-state seats (CC parity: readFileState is minted
17
+ * The Runner's per-session read-file-state seats (CC parity: readFileState is minted
18
18
  * once per REPL session and mutated across turns; it has NO turn-boundary and NO abort clear site —
19
19
  * its only clears are compaction/fork/subagent-cleanup/dispose). sema's map stays per-task (the §11
20
20
  * ruling-A closure wiring), so the SESSION scope lives here instead: prepare adopts each task's live
@@ -30,17 +30,17 @@ export declare function __resetReadFaceClampAnnouncement(): void;
30
30
  * Bounded: an LRU over sessionIds (insertion-order refresh on read), because the SessionStore's own
31
31
  * eviction is not observable from here — a dropped seat costs one transcript replay, nothing else.
32
32
  * The stored value is the task's LIVE map (object identity), so in-turn mutations — tool write-backs,
33
- * and above all the RB-197 compaction clear — are the seat's truth by construction; a snapshot copy
33
+ * and above all the compaction clear — are the seat's truth by construction; a snapshot copy
34
34
  * here would resurrect summarized-away reads on the next turn.
35
35
  *
36
- * BRANCH BINDING (codex r1+r2, adopted): a sessionId alone does not name a transcript — the same id
36
+ * BRANCH BINDING: a sessionId alone does not name a transcript — the same id
37
37
  * can be rebranched (`resumeAt`), rewound out-of-band, or DELETED and re-created (`release()` + the
38
38
  * default create-on-miss acquire), and the seat's map would then vouch for reads the CURRENT branch
39
39
  * never saw. Each seat therefore records `anchorLeafId` — a leaf on the lineage its task produced —
40
40
  * and inheritance must first prove the CURRENT branch still descends from that anchor
41
41
  * (see {@link sessionSeatAnchorHolds}). The anchor is written twice: at ADOPT (the leaf at prepare;
42
42
  * `null` when the branch was still empty) and SEALED at the task's settle to the task's own tail
43
- * (`reanchor`). A `null` anchor is NEVER inheritable (codex r2: "the branch is non-empty now" proves
43
+ * (`reanchor`). A `null` anchor is NEVER inheritable ("the branch is non-empty now" proves
44
44
  * nothing about WHOSE messages those are — another Runner repopulating a released id, or a session
45
45
  * import, makes a non-empty branch that never contained this seat's reads). An unprovable anchor
46
46
  * falls back to the transcript replay, which reads the current branch by construction — cost, never
@@ -59,14 +59,14 @@ export declare class SessionReadFileStates {
59
59
  * `anchorLeafId` = the session's leaf as read at THIS prepare (null = the branch was empty; a
60
60
  * null-anchored seat is not inheritable until the settle-time {@link reanchor} names a real leaf). */
61
61
  adopt(sessionId: string, state: ReadFileState, anchorLeafId: string | null): void;
62
- /** #483 codex r2 — the settle-time SEAL: re-anchor the seat to the finished task's own tail, so a
62
+ /** The settle-time SEAL: re-anchor the seat to the finished task's own tail, so a
63
63
  * first-task (null-anchor) seat becomes inheritable only through a leaf its task provably wrote.
64
64
  * Identity-guarded: touches the row only while it still holds THIS task's map (a later prepare on
65
65
  * the same session has already replaced the seat and owns its own anchor). */
66
66
  reanchor(sessionId: string, state: ReadFileState, anchorLeafId: string): void;
67
67
  }
68
68
  /**
69
- * #483 (codex r1+r2) — does the session's CURRENT branch still descend from the seat's anchor?
69
+ * Does the session's CURRENT branch still descend from the seat's anchor?
70
70
  * TRUE is the licence to inherit; anything unprovable answers FALSE (the caller then replays the
71
71
  * transcript — the fail-closed direction costs a rebuild, never admits a wrong entry).
72
72
  *
@@ -82,17 +82,17 @@ export declare class SessionReadFileStates {
82
82
  * - a COMPACTION on the walked segment (A-082 idx2): refuses, even though the branch is perfectly
83
83
  * intact. The walked segment is exactly what landed AFTER this seat was anchored, and a
84
84
  * compaction there summarized older Read results OUT of the context the model will be shown —
85
- * the very state RB-197 clears from the live map at the landing site. That clear reaches the seat
85
+ * the very state the compaction clear removes from the live map at the landing site. That clear reaches the seat
86
86
  * only when the SAME Runner did both (the seat IS that map, by object identity); a second Runner
87
87
  * on the shared durable session clears its own map and commits the compaction as an ORDINARY
88
88
  * LINEAR APPEND, which every other test here passes. Inheriting across it would let requireRead
89
89
  * and checkStale both pass on a read whose card the model no longer has — a blind edit from a
90
- * summarized-away recollection, the exact failure the RB-197 clear exists to prevent. Refusing
90
+ * summarized-away recollection, the exact failure the compaction clear exists to prevent. Refusing
91
91
  * costs one transcript replay, and the replay reads the POST-compaction branch by construction,
92
92
  * so the fail-closed direction is also the CORRECT state. A compaction at or ABOVE the anchor is
93
93
  * not on the walked segment and does not refuse: the seat that observed it already carries its
94
94
  * clear (P-483-4), and an ordinary foreign turn with no compaction still inherits (G-483-5) —
95
- * dropping every seat a foreign Runner touched would restore the cross-turn amnesia #483 ended.
95
+ * dropping every seat a foreign Runner touched would restore the cross-turn read-state amnesia this seat-anchor check already ended.
96
96
  */
97
97
  export declare function sessionSeatAnchorHolds(getEntry: (id: string) => Promise<{
98
98
  parentId: string | null;
@@ -118,8 +118,8 @@ export interface PrepareHandsReadFaceInput {
118
118
  * resume; the workspace_state rung is skipped; the face fold goes stricter-wins). */
119
119
  resume: Pick<PrepareResume, "seed"> | undefined;
120
120
  /** borrowed-readonly — the acquired session (B-3 output), as a Pick (相 API 规则件 R-4: receiver
121
- * preserved): `getWorkspaceState` feeds the design/155 continuation rung; `buildContext` feeds
122
- * the transcript replay; `getStorage`/`getEntry` feed the #483 seat-anchor verification (one
121
+ * preserved): `getWorkspaceState` feeds the continuation rung; `buildContext` feeds
122
+ * the transcript replay; `getStorage`/`getEntry` feed the seat-anchor verification (one
123
123
  * leaf read per prepare + a bounded parent walk on the inherit leg only). */
124
124
  session: Pick<StoredSession, "getWorkspaceState" | "buildContext" | "getStorage" | "getEntry">;
125
125
  /** borrowed-readonly — the acquired session's id, for error/notice tags and the band's session
@@ -138,7 +138,7 @@ export interface PrepareHandsReadFaceInput {
138
138
  * (computed in the driver's inherited-gate block); the shellGate fold's doctrine value. */
139
139
  effectiveShellGate: ShellGateDoctrine;
140
140
  /** borrowed-readonly — B-1's frozen task-start face snapshot; only `.exclude` is read here (the
141
- * Monitor-mount honesty bit for the gh rate-limit hint, #181-F6). */
141
+ * Monitor-mount honesty bit for the gh rate-limit hint). */
142
142
  toolFaceSnapshot: ToolFaceSnapshot;
143
143
  /** borrowed-readonly — B-1's resolved main model; read ONLY for its pdf capability profile
144
144
  * (the Read tool's document-degradation fork). */
@@ -149,39 +149,36 @@ export interface PrepareHandsReadFaceInput {
149
149
  /** borrowed-readonly — the deployment seats this phase reads, as a Pick over the SAME deps
150
150
  * object (R-4: `deps.onError?.()` keeps its receiver; a new deps read must widen this Pick).
151
151
  * `readDenyBuiltinTiers`/`readDenyBuiltinExclude` are SNAPSHOTTED before the first await that
152
- * precedes the toolkit compile (#245/#244 — the caller retains these arrays by reference). */
152
+ * precedes the toolkit compile (the caller retains these arrays by reference). */
153
153
  deps: Pick<RunnerDeps, "onError" | "onNotice" | "tracer" | "readDenyPatterns" | "readDenyBuiltinTiers" | "readDenyBuiltinExclude" | "readFace" | "permissionRuleStore" | "hands">;
154
154
  /** borrowed-readonly — the trusted spawn-side seats the band forwards: the finished-command
155
- * notification lane, the mid-flight detach hub, and (#483 rung-1) the Runner's per-session
155
+ * notification lane, the mid-flight detach hub, and the Runner's per-session
156
156
  * read-state seats (absent on a standalone prepare ⇒ the transcript-replay rung covers alone). */
157
157
  internals: Pick<RunInternals, "onTaskNotification" | "detachHub" | "sessionReadStates"> | undefined;
158
- /** borrowed-readonly (A-082 idx7) — ABSOLUTE paths this prepare's design/381 restore wrote, deleted,
158
+ /** borrowed-readonly — ABSOLUTE paths this prepare's restore wrote, deleted,
159
159
  * or failed to write. Every read-state seed above describes the PRE-restore tree, so these keys are
160
160
  * dropped from the map: the engine replaced those bytes itself, and a surviving entry makes the
161
161
  * next refusal blame "the user or a linter" for the engine's own write. Absent (the common case)
162
162
  * when no file restore ran. Fail-closed by construction — dropping a read record only ever
163
163
  * produces refusals. */
164
164
  restoredFilePaths?: readonly string[];
165
- /** borrowed-readonly — (ref cell; the REF itself is never replaced) design/138 S2-C memory write gate:
166
- * the band's beforeWrite closure reads `.current` call-time; prepareMemory (driver, BEFORE this phase
167
- * since #691 — the memory root must be known before the toolkit compiles) installs the gate — the one
168
- * writer; this phase only reads. Declared in the driver because the SAME ref feeds prepareMemory. */
169
- memoryWriteGateRef: {
170
- current?: BeforeWriteHook;
171
- };
172
- /** borrowed-mutable — #691: the advertised-writable-directory seat (see its module header for the one
165
+ /** borrowed-readonly — the memory write gate the memory phase minted (it runs BEFORE this phase: the memory root
166
+ * must be known before the toolkit compiles), composed into the band's beforeWrite below; undefined for a
167
+ * memory-less run (every write passes the engine half). */
168
+ memoryWriteGate: BeforeWriteHook | undefined;
169
+ /** borrowed-mutable — the advertised-writable-directory seat (see its module header for the one
173
170
  * rule). Present on the hands leg only (a fence exists). The memory phase, which runs BEFORE this one,
174
171
  * has already admitted its write root through it; this phase admits the deployment's scratchpad and
175
172
  * folds `roots` into the write-capable containment allowlist before the toolkit compiles. */
176
173
  advertisedWritableDirs?: AdvertisedWritableDirs;
177
- /** borrowed-readonly — the driver's per-tool offload wrapper (design/158 posture + policy); the
174
+ /** borrowed-readonly — the driver's per-tool offload wrapper (posture + policy); the
178
175
  * band rides through it exactly as caller/MCP tools do. */
179
176
  firstPartyOffload: (tool: AgentTool) => AgentTool;
180
177
  /** borrowed-mutable — the SHARED mount array (§4.4: later refs alias it; identity is the
181
178
  * contract, never map/copy). This phase pushes the hands band IN PLACE (after caller tools /
182
179
  * built-ins / MCP / A2A, before the background-task mounts — T22 order). Mutation owners after
183
180
  * this phase: P11 background/Monitor/worktree pushes, the driver's excludeTools splice, the
184
- * refresh seam's runtime splice/push. Since design/388 the array is builder-private: this phase `mountAll`s the band. */
181
+ * refresh seam's runtime splice/push. The array is builder-private: this phase `mountAll`s the band. */
185
182
  roster: RosterBuilder;
186
183
  /** borrowed-readonly HERE (census divergence #5 vs the design row): this phase only reads
187
184
  * `.has("Bash")`/`.has("Monitor")` for the provenance bits — its mutation owners are B-2/P8/P9
@@ -197,16 +194,16 @@ export interface PrepareHandsReadFaceInput {
197
194
  /** borrowed-mutable — the classify doctrine's probe installs (`.set`, only where the doctrine
198
195
  * owns the seat). Same-object contract as above. */
199
196
  reversibilityProbes: ReversibilityProbes;
200
- /** borrowed-readonly — design/319 (A ticket): the run's reminder provenance mark (minted/adopted
197
+ /** borrowed-readonly — the run's reminder provenance mark (minted/adopted
201
198
  * by the driver's adoption ladder); threaded into the hands band so the fs-side engine mints
202
199
  * (the Read cyber/dedup/offset/empty reminders, the gh rate-limit hint) stamp the same mark the
203
200
  * system-prompt declaration names. */
204
201
  reminderMark: string;
205
- /** borrowed-mutable — design/319 (B ticket): the leg's disclosure trigger counters; the hands
202
+ /** borrowed-mutable — the leg's disclosure trigger counters; the hands
206
203
  * band's Read/notebook/PDF trailer outlets bump keys on it at tool-execute time (the driver owns
207
204
  * the object and folds it into result stats). */
208
205
  reminderDisclosureCounts: import("../reminder-disclosure.js").ReminderDisclosureCounts;
209
- /** borrowed-readonly — design/381: the first-touch history hook prepare built (present iff a fileHistoryStore is
206
+ /** borrowed-readonly — the first-touch history hook prepare built (present iff a fileHistoryStore is
210
207
  * wired and the run mounts a real fs env); threaded to the write band's trackFileEdit seat. */
211
208
  trackFileEdit?: import("../types.js").TrackFileEditHook;
212
209
  /** borrowed-readonly — the mutation lane's LANDED observation seat (the accumulator behind
@@ -233,11 +230,11 @@ export interface PrepareHandsReadFaceResult {
233
230
  path: string;
234
231
  content: string;
235
232
  }>) => Promise<void>) | undefined;
236
- /** owned — design/99 §E13: the per-task logical cwd ref (observable `cd`), minted when a real
233
+ /** owned — the per-task logical cwd ref (observable `cd`), minted when a real
237
234
  * writable shell mounts. The driver stamps it into checkpoints, threads it into worktree tools
238
235
  * and gate cwd reads; tools mutate `.current` at run time. Undefined when no shell / readOnly. */
239
236
  handsCwdRef: CwdRef | undefined;
240
- /** owned — design/155: the settle-side snapshot base (what the cwd/worktree refs were RESTORED
237
+ /** owned — the settle-side snapshot base (what the cwd/worktree refs were RESTORED
241
238
  * to), so runtask's settle write diffs against it. The driver's G4 worktree mount writes
242
239
  * `.restoredWorktreeDir` after this phase — object identity carried. */
243
240
  workspaceStateSettle: {
@@ -246,7 +243,7 @@ export interface PrepareHandsReadFaceResult {
246
243
  restoredWorktreeDir?: string;
247
244
  baselineUnknown?: boolean;
248
245
  } | undefined;
249
- /** owned — design/155: the branch-nearest `workspace_state` entry, fetched ONCE here and shared
246
+ /** owned — the branch-nearest `workspace_state` entry, fetched ONCE here and shared
250
247
  * with the driver's worktree seed (the G4 mount reads `.activeWorktree` through it). */
251
248
  wsSnapshot: WorkspaceState | undefined;
252
249
  /** owned — the wsSnapshot path rebaser (identity when no snapshot / same root); the G4 worktree
@@ -266,7 +263,7 @@ export interface PrepareHandsReadFaceResult {
266
263
  pattern: string;
267
264
  caseSensitive: boolean;
268
265
  }>;
269
- /** write-back (D-3 hold) — the hands-LESS legs' resolved face (#242: the read posture is a
266
+ /** write-back (D-3 hold) — the hands-LESS legs' resolved face (the read posture is a
270
267
  * property of the RUN, not the mount). Driver assigns onto its outer `let`. */
271
268
  handsLessResolvedFace: ReadFace | undefined;
272
269
  /** owned — the canonicalized write-capable extra roots (additionalDirectories + the advertised
@@ -276,10 +273,10 @@ export interface PrepareHandsReadFaceResult {
276
273
  /** owned — the read-only arm of the fence widening (2026-08-05 both-arms ruling); same identity
277
274
  * contract as above. */
278
275
  additionalReadRootsCanonical: string[];
279
- /** owned — RB-159: the canonical containment root, published so the working-file ATTACHMENT
276
+ /** owned — the canonical containment root, published so the working-file ATTACHMENT
280
277
  * reader applies the same containment the hands tools do. Undefined ⇔ hands-less. */
281
278
  attachmentRootCanonical: string | undefined;
282
- /** owned — design/199 件B: the ONE compiled deny judge per prepare (built-ins ∪ deployment ∪
279
+ /** owned — the ONE compiled deny judge per prepare (built-ins ∪ deployment ∪
283
280
  * task additions). Undefined ⇔ hands-less (its consumers only exist with hands). */
284
281
  readDenyMatcher: ReadDenyMatcher | undefined;
285
282
  /** owned — the shell-seat PROVENANCE set: the shell-running tools whose tier the engine's shell seat (read
@@ -288,7 +285,7 @@ export interface PrepareHandsReadFaceResult {
288
285
  * boundary): `shellGatedTools.has(toolName)`. Minted here, never grown afterwards; empty when the seat fold
289
286
  * did not run (no real writable shell). */
290
287
  shellGatedTools: ReadonlySet<string>;
291
- /** owned (design/380 rescan C4) — the ENV-HAND tool names, minted AT THE MOUNT: every tool this
288
+ /** owned — the ENV-HAND tool names, minted AT THE MOUNT: every tool this
292
289
  * phase mounted over the ExecutionEnv (the fs/bash band), later grown by the driver's own env
293
290
  * mounts (Monitor, the worktree pair — the SAME Set identity, mutated at those mount sites).
294
291
  * Consumed by the O9a external-content-target fold: these are the tools whose RESULTS are the
@@ -297,12 +294,12 @@ export interface PrepareHandsReadFaceResult {
297
294
  * misses Monitor/worktree, which are hands — both directions wrong for this consumer). Empty on
298
295
  * a hands-less leg (nothing mounts on the env; the driver's env mounts are hands-gated too). */
299
296
  envHandToolNames: Set<string>;
300
- /** owned (#483 codex r2+r3) — the settle-time SEAT SEAL: re-anchors the session seat to the
297
+ /** owned — the settle-time SEAT SEAL: re-anchors the session seat to the
301
298
  * task's OWN last-committed entry (see {@link SessionReadFileStates.reanchor}). The driver calls
302
299
  * it once at the run's settle (every terminal, suspend included), under the session lock, passing
303
300
  * the last entryId ITS OWN run committed (the message_committed lane) — never a re-read of the
304
301
  * shared session leaf, which a concurrent writer on another Runner could have moved onto a branch
305
- * this task's reads were never on (codex r3). No commits observed ⇒ no-op (the adopt-time anchor
302
+ * this task's reads were never on. No commits observed ⇒ no-op (the adopt-time anchor
306
303
  * stands). Synchronous, never throws. Undefined ⇔ hands-less / no seat channel. */
307
304
  sealReadStateSeat: ((ownCommittedTailEntryId: string | undefined) => void) | undefined;
308
305
  }
@@ -123,7 +123,7 @@ export function resolveHandsLessReadFace(input) {
123
123
  }
124
124
  export async function prepareHandsMount(input) {
125
125
  const envHandToolNames = new Set();
126
- const { handsEnabled, executionEnv, taskRootFinal, rebaseRestoredPath, resume, session, sessionId, hostTaskId, taskScope, fullShellReachable, effectiveShellGate, toolFaceSnapshot, model, spec, deps, internals, memoryWriteGateRef, advertisedWritableDirs, firstPartyOffload, roster, egressTools, irreversibilityTier, irreversibleTools, reversibilityProbes } = input;
126
+ const { handsEnabled, executionEnv, taskRootFinal, rebaseRestoredPath, resume, session, sessionId, hostTaskId, taskScope, fullShellReachable, effectiveShellGate, toolFaceSnapshot, model, spec, deps, internals, memoryWriteGate, advertisedWritableDirs, firstPartyOffload, roster, egressTools, irreversibilityTier, irreversibleTools, reversibilityProbes } = input;
127
127
  assertStringArraySeat(spec.additionalDirectories, "TaskSpec.additionalDirectories", "strings");
128
128
  assertStringArraySeat(spec.additionalReadDirectories, "TaskSpec.additionalReadDirectories", "strings");
129
129
  assertStringArraySeat(deps.readDenyPatterns, "RunnerDeps.readDenyPatterns", "compiler-owned");
@@ -328,7 +328,7 @@ export async function prepareHandsMount(input) {
328
328
  if (verdict !== undefined && verdict.ok === false)
329
329
  return verdict;
330
330
  }
331
- return memoryWriteGateRef.current?.(w);
331
+ return memoryWriteGate?.(w);
332
332
  },
333
333
  mountBackgroundTaskTools: false,
334
334
  monitorToolActive: backgroundTaskToolsActive && !(toolFaceSnapshot.exclude?.includes("Monitor") ?? false),
@@ -354,6 +354,7 @@ export async function prepareHandsMount(input) {
354
354
  const shellReadBoundary = () => ({
355
355
  roots: [rootCanonical, ...additionalRootsCanonical, ...additionalReadRootsCanonical],
356
356
  ...(handsCwdRef?.current !== undefined ? { cwd: handsCwdRef.current } : {}),
357
+ ...(executionEnv.homeDir !== undefined ? { homeDir: executionEnv.homeDir } : {}),
357
358
  denyMatch: (p) => readDenyMatcher?.matchPath(p)?.pattern ?? null,
358
359
  ...(resolvedReadFace !== undefined ? { face: resolvedReadFace } : {}),
359
360
  });
@@ -1,18 +1,18 @@
1
1
  /**
2
- * design/390 §1.2 M3b — prepareTask's INHERITED-GATE phase, verbatim from the driver: the live/seed fold of the
2
+ * PrepareTask's INHERITED-GATE phase, verbatim from the driver: the live/seed fold of the
3
3
  * chain this run inherits (ancestor rules rev-monotonic per (session, principal), shellGate by max rank, the
4
4
  * re-supplied parent constraints with their rebuilt denial trackers, the auto-mode intent, the org-admission
5
5
  * freeze with its tighten-only intersection and the monotonic governed bit), the effective shellGate against the
6
6
  * spec, the three cells later phases fill for the children's chain (own session rules, own admitted org scopes,
7
7
  * own org verdict), the checkpoint-section closures the suspend serializer reads (face / org / F-012 stamps), the
8
- * FROZEN ask and question seats (spec over deps), the two delegation refs the memory phase binds late, the ONE
8
+ * FROZEN ask and question seats (spec over deps), the parent SPEC seat the children inherit, the two delegation refs the memory phase binds late, the ONE
9
9
  * child-chain assembly `inheritedGateForChildren`, the caller-tool ctx enrichment `enrichSpecToolCtx` shared by
10
10
  * the roster wrap and the revival spawner, the denial-limit stop seat, and the full-shell reachability predicate.
11
- * The interface is the dependency list the segment had implicitly (design/238 R-1).
11
+ * The interface is the dependency list the segment had implicitly.
12
12
  *
13
13
  * SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await (the one `await` in it sits inside the
14
14
  * `hostSessionFork` closure a tool calls later), so the phase adds no yield between the run-refs phase before it
15
- * and the caps phase after it (design/390 §1.5: a stretch with no await is extracted as a sync function).
15
+ * and the caps phase after it (a stretch with no await is extracted as a sync function).
16
16
  *
17
17
  * LATE-BOUND SEATS. The closures minted here run long after this phase returns — at spawn time, at tool-call
18
18
  * time, at suspend time — and several of the facts they read are resolved by LATER stations of the same prepare:
@@ -25,7 +25,7 @@
25
25
  * sat behind a short-circuit). Read-stability of the host handles for the call: {@link RunInternals}
26
26
  * (`@contract prepare.deps-read-stable`).
27
27
  *
28
- * Every cell that leaves here as `borrowed-mutable` carries its writer table on the Result member (design/238 R-3).
28
+ * Every cell that leaves here as `borrowed-mutable` carries its writer table on the Result member.
29
29
  */
30
30
  import type { AgentHarness, ExecutionEnv } from "../../internal/harness.js";
31
31
  import type { SubagentWorktreeIsolation } from "../../agents/subagent.js";
@@ -36,6 +36,7 @@ import type { ReadFace } from "../../tools/fs/index.js";
36
36
  import type { AutoModeArmingRecipe } from "../auto-mode-arming.js";
37
37
  import type { AutoModeDecider, AutoModeDenialTracker } from "../auto-mode.js";
38
38
  import { type OnQuestion } from "../ask-question.js";
39
+ import { type ParentSpecSeat } from "../parent-spec-seat.js";
39
40
  import { type HookEnvCapabilities, type Hooks } from "../hooks.js";
40
41
  import type { LockedPreflight } from "../locked-config.js";
41
42
  import type { OwnOrgAdmissionVerdict } from "../memory-admission.js";
@@ -65,7 +66,7 @@ export interface PrepareInheritedGateInput {
65
66
  /** borrowed-readonly — the trusted spawn-side channel: `inheritedGate` (the LIVE half of the chain fold), `ownOrgAdmissionRef`
66
67
  * (the same-session continuation's freeze), `delegationProvenance` (the F-012 stamp), and the identity / peer / notification
67
68
  * seats the ctx enrichment forwards. Never mutated. */
68
- internals: Pick<RunInternals, "inheritedGate" | "ownOrgAdmissionRef" | "delegationProvenance" | "memoryCaptureAncestors" | "parentTaskId" | "parentSessionId" | "rootSessionId" | "placementRoot" | "explicitAgentName" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn" | "insideFork"> | undefined;
69
+ internals: Pick<RunInternals, "inheritedGate" | "ownOrgAdmissionRef" | "delegationProvenance" | "memoryCaptureAncestors" | "parentTaskId" | "parentSessionId" | "rootSessionId" | "placementRoot" | "explicitAgentName" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn" | "insideFork" | "questionFaceStripped"> | undefined;
69
70
  /** borrowed-readonly — the resume leg, or undefined on a fresh one: `seed.inheritedGate` is the CHECKPOINT half of the chain
70
71
  * fold (the trust floor the live half may only tighten), `seed.readFace` the hands-less re-park's carried section. */
71
72
  resume: Pick<PrepareResume, "seed"> | undefined;
@@ -240,6 +241,8 @@ export interface PrepareInheritedGateResult {
240
241
  notifyOwnHookCrash: (err: unknown) => void;
241
242
  /** owned — the FROZEN question seat (spec over deps), the content-ask twin of `frozenOnAsk`. */
242
243
  frozenOnQuestion: OnQuestion | undefined;
244
+ /** owned — the parent SPEC seat this run hands its children (`parentSpecSeatOf(spec, frozenOnQuestion)`): the ctx seat and the Workflow mount dep are this one value; both lanes apply it with `applyParentSpecSeat` (one law). */
245
+ parentSpecSeat: ParentSpecSeat;
243
246
  /** borrowed-mutable — the delegation runtime-provenance arming face. Writer: the memory-engine-session phase
244
247
  * (prepareMemoryEngineSession), once per leg when it arms. Read lazily by delegation tools through the ctx. */
245
248
  provenanceForChildrenRef: {