@sema-agent/core 7.14.0 → 7.16.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 (136) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/core/ask-origin.d.ts +2 -2
  3. package/dist/core/checkpoint-store.d.ts +14 -15
  4. package/dist/core/governance-codes.js +2 -0
  5. package/dist/core/hooks.d.ts +4 -3
  6. package/dist/core/memory-engine/delegation-settlement.d.ts +37 -12
  7. package/dist/core/memory-engine/delegation-settlement.js +128 -39
  8. package/dist/core/memory-engine/engine.d.ts +9 -8
  9. package/dist/core/memory-engine/engine.js +115 -120
  10. package/dist/core/memory-engine/file-backend.d.ts +17 -5
  11. package/dist/core/memory-engine/file-backend.js +78 -34
  12. package/dist/core/memory-engine/index.d.ts +2 -2
  13. package/dist/core/memory-engine/index.js +2 -2
  14. package/dist/core/memory-engine/layout.d.ts +152 -54
  15. package/dist/core/memory-engine/layout.js +441 -104
  16. package/dist/core/memory-engine/types.d.ts +8 -3
  17. package/dist/core/memory-engine/types.js +5 -0
  18. package/dist/core/runner/abort-race.d.ts +3 -3
  19. package/dist/core/runner/active-skill-scope.d.ts +2 -2
  20. package/dist/core/runner/assemble-result.d.ts +29 -29
  21. package/dist/core/runner/checkpoint-scope.d.ts +4 -4
  22. package/dist/core/runner/clock-and-limits.d.ts +3 -3
  23. package/dist/core/runner/compaction-call-options.d.ts +11 -11
  24. package/dist/core/runner/compaction-knobs.d.ts +4 -4
  25. package/dist/core/runner/compaction-seams.d.ts +5 -5
  26. package/dist/core/runner/contracts.d.ts +224 -226
  27. package/dist/core/runner/decide-continuation.d.ts +6 -6
  28. package/dist/core/runner/denial-limit-arms.d.ts +8 -8
  29. package/dist/core/runner/derived-route-fallback.d.ts +2 -2
  30. package/dist/core/runner/gate-exit.d.ts +6 -6
  31. package/dist/core/runner/git-status-frame.d.ts +7 -7
  32. package/dist/core/runner/inherited-ask-grants.d.ts +6 -6
  33. package/dist/core/runner/memory-capture-optout.d.ts +1 -1
  34. package/dist/core/runner/memory-consolidation-driver.d.ts +4 -4
  35. package/dist/core/runner/memory-consolidation.d.ts +6 -6
  36. package/dist/core/runner/park-commit.d.ts +6 -6
  37. package/dist/core/runner/permission-rule-lanes.d.ts +22 -20
  38. package/dist/core/runner/permission-rule-lanes.js +1 -1
  39. package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -4
  40. package/dist/core/runner/prepare-ask-lane.d.ts +3 -3
  41. package/dist/core/runner/prepare-boundary-parks.d.ts +3 -3
  42. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -5
  43. package/dist/core/runner/prepare-config-doors.d.ts +21 -21
  44. package/dist/core/runner/prepare-context-lane.d.ts +6 -6
  45. package/dist/core/runner/prepare-defer-classify.d.ts +3 -3
  46. package/dist/core/runner/prepare-defer-classify.js +12 -10
  47. package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
  48. package/dist/core/runner/prepare-file-history.d.ts +2 -2
  49. package/dist/core/runner/prepare-gate-stations.d.ts +8 -9
  50. package/dist/core/runner/prepare-gate-stations.js +2 -2
  51. package/dist/core/runner/prepare-hands-readface.d.ts +41 -41
  52. package/dist/core/runner/prepare-hands-readface.js +27 -29
  53. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -6
  54. package/dist/core/runner/prepare-listings.d.ts +3 -3
  55. package/dist/core/runner/prepare-lsp.d.ts +3 -3
  56. package/dist/core/runner/prepare-memory-engine-session.d.ts +5 -5
  57. package/dist/core/runner/prepare-memory.js +6 -7
  58. package/dist/core/runner/prepare-offload-wrappers.d.ts +2 -2
  59. package/dist/core/runner/prepare-park-ask.d.ts +11 -12
  60. package/dist/core/runner/prepare-park-ask.js +3 -3
  61. package/dist/core/runner/prepare-policy-chain.d.ts +6 -6
  62. package/dist/core/runner/prepare-policy-chain.js +2 -2
  63. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -5
  64. package/dist/core/runner/prepare-protocol-tools.d.ts +1 -1
  65. package/dist/core/runner/prepare-question-face.d.ts +4 -4
  66. package/dist/core/runner/prepare-run-refs.d.ts +11 -11
  67. package/dist/core/runner/prepare-safety-scan.d.ts +1 -1
  68. package/dist/core/runner/prepare-suspend-saga.d.ts +4 -4
  69. package/dist/core/runner/prepare-task.d.ts +12 -12
  70. package/dist/core/runner/prepare-task.js +5 -7
  71. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +2 -3
  72. package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -4
  73. package/dist/core/runner/prepare-workspace-restore.d.ts +1 -1
  74. package/dist/core/runner/remote-env-retry.d.ts +3 -3
  75. package/dist/core/runner/resume-admission.d.ts +1 -1
  76. package/dist/core/runner/resume-claim.d.ts +1 -1
  77. package/dist/core/runner/resume-internals-and-config.d.ts +1 -1
  78. package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
  79. package/dist/core/runner/resume-preflight.d.ts +1 -1
  80. package/dist/core/runner/resume-review-outcome.d.ts +1 -1
  81. package/dist/core/runner/run-brain-sinks.d.ts +1 -1
  82. package/dist/core/runner/run-clock-and-content.d.ts +4 -4
  83. package/dist/core/runner/run-compaction-machinery.d.ts +3 -3
  84. package/dist/core/runner/run-git-lane.d.ts +1 -1
  85. package/dist/core/runner/run-harness-handlers.d.ts +2 -2
  86. package/dist/core/runner/run-identity-wiring.d.ts +4 -4
  87. package/dist/core/runner/run-leg.d.ts +3 -3
  88. package/dist/core/runner/run-notification-lane.d.ts +2 -2
  89. package/dist/core/runner/run-reasoning-seat.d.ts +2 -2
  90. package/dist/core/runner/run-settle-and-teardown.d.ts +4 -4
  91. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +2 -2
  92. package/dist/core/runner/run-terminal-adoption.d.ts +5 -5
  93. package/dist/core/runner/runtask.d.ts +14 -14
  94. package/dist/core/runner/session-file-state-replay.d.ts +3 -3
  95. package/dist/core/runner/session-rule-policy.d.ts +2 -2
  96. package/dist/core/runner/steer-admission.d.ts +2 -2
  97. package/dist/core/runner/stream-halt-verbs.d.ts +1 -1
  98. package/dist/core/runner/stream-reap.d.ts +1 -1
  99. package/dist/core/runner/synthetic-tools.d.ts +8 -8
  100. package/dist/core/runner/teardown-bounded.d.ts +2 -2
  101. package/dist/core/runner/tool-defer-gate.d.ts +86 -0
  102. package/dist/core/runner/tool-defer-gate.js +57 -0
  103. package/dist/core/runner/tool-disclosure.d.ts +33 -69
  104. package/dist/core/runner/tool-disclosure.js +0 -43
  105. package/dist/core/runner/tool-end-body.d.ts +3 -3
  106. package/dist/core/runner/tool-face-overlay.d.ts +2 -2
  107. package/dist/core/runner/tool-output-projection.d.ts +2 -2
  108. package/dist/core/runner/turn-attachments.d.ts +53 -53
  109. package/dist/core/runner/usage-accounting.d.ts +4 -4
  110. package/dist/core/runner/workspace-path.d.ts +1 -1
  111. package/dist/core/runner-deps.d.ts +16 -9
  112. package/dist/core/task-spec.d.ts +8 -2
  113. package/dist/core/tool-spec.d.ts +7 -4
  114. package/dist/core/types.d.ts +1 -1
  115. package/dist/engine/llm/types.d.ts +1 -1
  116. package/dist/index.d.ts +4 -4
  117. package/dist/index.js +3 -3
  118. package/dist/tools/fs/bash-readonly-classifier.d.ts +40 -40
  119. package/dist/tools/fs/encoding.d.ts +31 -40
  120. package/dist/tools/fs/fs-bash.d.ts +76 -35
  121. package/dist/tools/fs/fs-bash.js +86 -29
  122. package/dist/tools/fs/fs-pdf.d.ts +8 -8
  123. package/dist/tools/fs/fs-search-tools.d.ts +4 -4
  124. package/dist/tools/fs/fs-shared.d.ts +144 -158
  125. package/dist/tools/fs/fs-write.d.ts +8 -8
  126. package/dist/tools/fs/gh-rate-limit.d.ts +13 -14
  127. package/dist/tools/fs/index.d.ts +74 -78
  128. package/dist/tools/fs/notebook.d.ts +24 -25
  129. package/dist/tools/fs/pdf.d.ts +3 -3
  130. package/dist/tools/fs/read-deny.d.ts +22 -22
  131. package/dist/tools/fs/read-face.d.ts +21 -24
  132. package/dist/tools/fs/repo-map.d.ts +8 -8
  133. package/dist/tools/fs/safety.d.ts +116 -129
  134. package/dist/tools/fs/search.d.ts +63 -71
  135. package/package.json +5 -2
  136. package/test/export-surface.snapshot.json +9 -1
@@ -22,7 +22,7 @@ class ParkRefusal extends Error {
22
22
  }
23
23
  }
24
24
  export function prepareParkAsk(input) {
25
- const { askLane, saga, spec, deps, sessionId, checkpointStore, toolRosterDeltas, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, offloadStore, ownedEnv, incompleteSuspendAdapter, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedBash, shellGatedMonitor, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, faceCheckpointState, f012CheckpointState, orgAdmissionCheckpointState, ruleOffersOf, now, humanReviewRef, abortController, harness, pausedRef } = input;
25
+ const { askLane, saga, spec, deps, sessionId, checkpointStore, toolRosterDeltas, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, offloadStore, ownedEnv, incompleteSuspendAdapter, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedTools, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, faceCheckpointState, f012CheckpointState, orgAdmissionCheckpointState, ruleOffersOf, now, humanReviewRef, abortController, harness, pausedRef } = input;
26
26
  if (askLane === undefined || saga === undefined)
27
27
  return { parkAsk: undefined };
28
28
  const { composedCallSignal, approvalPreviewOf } = askLane;
@@ -232,8 +232,8 @@ export function prepareParkAsk(input) {
232
232
  ...(shadowedRule !== undefined ? { shadowedRule } : {}),
233
233
  ...(probeReason !== undefined ? { probeReason } : {}),
234
234
  ...(probeCause !== undefined ? { probeCause } : {}),
235
- shellGated: (req.toolName === "Bash" && shellGatedBash) || (req.toolName === "Monitor" && shellGatedMonitor),
236
- ...(effectiveShellGate !== "off" ? { shellGateDoctrine: effectiveShellGate } : {}),
235
+ shellGated: shellGatedTools.has(req.toolName),
236
+ shellGateDoctrine: effectiveShellGate,
237
237
  });
238
238
  gate =
239
239
  safety !== undefined || realApproval !== undefined
@@ -1,14 +1,14 @@
1
1
  /**
2
- * design/390 §1.2 M17 (design/238 P21) — prepareTask's POLICY-CHAIN phase, verbatim from the driver: the caller policy
2
+ * PrepareTask's POLICY-CHAIN phase, verbatim from the driver: the caller policy
3
3
  * and its name audit (advisory once per deployment; the two hard refusals), the session / ancestor / frozen-projection /
4
4
  * skill-scope deny-narrowing layers and their fold, the resume-edit base policy, the hook record with its timeout seat
5
5
  * and observational half, the same-instance arbitration machinery (the caller slot's first-decision record), the
6
- * inherited-unavailable marker channel, the RB-40 grant record, the sandbox-admission mode's arming and its three
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
9
  * wrapper), the rewrite-emitter index and the instrumented chain, the integrity guards, the fold, and the final-form
10
10
  * re-check that is the effective policy. The advised-names dedupe pair only this section reads moved with it.
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
  * ASYNC PHASE: the stretch awaits the session-policy store (the task's own rules and each ancestor's live re-read)
14
14
  * exactly where the segment did; the closures it builds await at tool-call time. The phase boundary adds one
@@ -78,8 +78,8 @@ export interface PreparePolicyChainInput {
78
78
  /** borrowed-readonly — the caller tools' names, the first-await snapshot (the sandbox boundary predicate: a caller tool
79
79
  * is never contained by the hand tools' env). */
80
80
  ownToolNames: ReadonlySet<string>;
81
- /** borrowed-readonly — whether the shell tool is under an operator `shellGate:"always"` (the offer factory's mandate term). */
82
- shellGatedBash: boolean;
81
+ /** borrowed-readonly — the shell-seat provenance set (the offer factory's `shellGated` mandate term, read per call). */
82
+ shellGatedTools: ReadonlySet<string>;
83
83
  /** borrowed-readonly — the tracked-cwd seat, read per call by the lanes and the offer factory (never written here). */
84
84
  handsCwdRef: CwdRef | undefined;
85
85
  /** borrowed-readonly — the compiled read-deny judge, or undefined (the offer factory's directory negative control). */
@@ -148,7 +148,7 @@ export interface PreparePolicyChainResult {
148
148
  /** borrowed-mutable — the inherited-unavailable marker channel. Writers: the inherited arms here (mark); the gate station
149
149
  * (the lifecycle-end sweep) and the park lane's consumers (delete on consumption). */
150
150
  inheritedUnavailableAsks: Set<string>;
151
- /** borrowed-mutable — the RB-40 grant record. Writers: the inherited arms here (record a clean allow at a live approver);
151
+ /** borrowed-mutable — the grant record. Writers: the inherited arms here (record a clean allow at a live approver);
152
152
  * the gate station (consume on reuse, sweep at settlement). */
153
153
  inheritedAskGrants: Map<string, {
154
154
  approver: unknown;
@@ -16,7 +16,7 @@ import { askGrantShapeOf } from "./inherited-ask-grants.js";
16
16
  import { createPermissionRuleLanes, inheritedAskRuleEvidence, createRuleOffersOf } from "./permission-rule-lanes.js";
17
17
  import { createSessionRulePolicy } from "./session-rule-policy.js";
18
18
  export async function preparePolicyChain(input) {
19
- const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, executionEnv, lockedPreflight, tools, harnessTools, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, ownToolNames, shellGatedBash, handsCwdRef, readDenyMatcher, questionToolMounted, runtimeCaps, inheritedAncestorRules, inheritedParentConstraints, seedInheritedGate, hasSkillManifest, skillScope, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, autoModeDecider, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef } = input;
19
+ const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, executionEnv, lockedPreflight, tools, harnessTools, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, ownToolNames, shellGatedTools, handsCwdRef, readDenyMatcher, questionToolMounted, runtimeCaps, inheritedAncestorRules, inheritedParentConstraints, seedInheritedGate, hasSkillManifest, skillScope, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, autoModeDecider, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef } = input;
20
20
  const policy = lockedPreflight.toolPolicy;
21
21
  const auditPolicyNames = (auditee) => {
22
22
  const nameGroups = toolPolicyNameSets(auditee);
@@ -265,7 +265,7 @@ export async function preparePolicyChain(input) {
265
265
  localOwnerDeclared: deps.localOwnerRules === true,
266
266
  egressTools,
267
267
  irreversibilityTier,
268
- shellGatedBash,
268
+ shellGatedTools,
269
269
  taskRoot: taskRootFinal,
270
270
  cwdRef: handsCwdRef,
271
271
  deniesDirectoryRead: readDenyMatcher !== undefined ? (d) => readDenyMatcher.matchPath(d) !== null : undefined,
@@ -1,11 +1,11 @@
1
1
  /**
2
- * design/390 M10 — prepareTask's PROMPT-INPUTS phase: the prompt provider selection, the runtime
2
+ * PrepareTask's PROMPT-INPUTS phase: the prompt provider selection, the runtime
3
3
  * feature flags the harness-context block gates on (so it never claims a mechanism the task lacks),
4
4
  * the three-source user system prompt + the caller's append block, the fenced MCP server-instructions
5
5
  * block, the environment facts (client zone + date basis, knowledge cutoff, the deployment's sandbox
6
6
  * axes, resume-continuity facts on a durable-resume leg only, the hands facts + the one batched env
7
- * probe with its cwd/pwd alignment guard) and the git-status lane probe. The body is the driver's
8
- * stretch moved verbatim; the interface is the dependency list it had implicitly (design/238 R-1).
7
+ * probe with its cwd/pwd alignment guard) and the git-status lane probe. The body is moved verbatim
8
+ * from the driver's own stretch; its interface is the dependency list that stretch had implicitly.
9
9
  *
10
10
  * ASYNC BY CONTENT: the stretch awaits the env probe (hands) and the git-status lane probe (always).
11
11
  * It sits past prepareTask's first await, so the driver's `await` adds no window a caller could reach.
@@ -13,7 +13,7 @@
13
13
  * The one input computed by the DRIVER rather than read here: `failClosedReason` — the
14
14
  * self-orchestration fail-closed advisory's text. Its helper takes the whole `TaskSpec`/`RunnerDeps`
15
15
  * (it audits several deployment seats), which this phase's narrow `spec`/`deps` seats cannot satisfy
16
- * (design/238 R-4); the driver evaluates the helper in the Input literal and this phase only announces
16
+ * The driver evaluates the helper in the Input literal and this phase only announces
17
17
  * the result on the operator lane, exactly where the stretch always did.
18
18
  *
19
19
  * Nothing here throws on its own: the env probe and the alignment guard are best-effort (a stub/odd env
@@ -91,7 +91,7 @@ export interface PreparePromptInputsInput {
91
91
  additionalRootsCanonical: readonly string[];
92
92
  /** borrowed-readonly — the canonical extra read-only roots (copied into the env facts). */
93
93
  additionalReadRootsCanonical: readonly string[];
94
- /** borrowed-readonly — #691: the advertised-writable-directory seat (hands only). The scratchpad section is
94
+ /** borrowed-readonly — the advertised-writable-directory seat (hands only). The scratchpad section is
95
95
  * rendered only when the seat did not SKIP the scratchpad — a directory the fence refused is not advertised. */
96
96
  advertisedWritableDirs?: AdvertisedWritableDirs;
97
97
  /** borrowed-readonly — the acquired session's id (operator-line context). */
@@ -36,7 +36,7 @@ export interface PrepareProtocolToolsInput {
36
36
  * wrapper) and, at RUN time, the refresh closure's splice within a server's name-prefix domain. Later
37
37
  * phases push their own mounts; the roster's full writer table is the delegation-surface phase's. */
38
38
  roster: RosterBuilder;
39
- /** borrowed-mutable — the run-time delta seat (design/388 §2.5): the refresh closure re-mints the roster through it after
39
+ /** borrowed-mutable — the run-time delta seat: the refresh closure re-mints the roster through it after
40
40
  * every re-splice so the stream learns of the change. Armed by the driver after the roster is minted. */
41
41
  rosterSeat: ToolRosterDeltaSeat;
42
42
  /** borrowed-readonly — the large-result wrapper for protocol tools (per-tool `_meta` bar, 50K default). */
@@ -1,17 +1,17 @@
1
1
  /**
2
- * design/390 §1.2 M7 — prepareTask's QUESTION-FACE phase, verbatim from the driver: the leg's ONE checkpoint-store
2
+ * PrepareTask's QUESTION-FACE phase, verbatim from the driver: the leg's ONE checkpoint-store
3
3
  * read, the durable mandate as it binds at the question seat, the content-ask binding table (with the leak
4
4
  * bound the routing lane checks against — the constant below), the stranded-answer disclosure and the leg-end
5
5
  * settle, the three-way mount decision (live face / durable face / override), and the AskUserQuestion mount
6
6
  * with its redeemed-approval, posture, fallback and synthetic-continuation arms. The interface is the
7
- * dependency list the segment had implicitly (design/238 R-1).
7
+ * dependency list the segment had implicitly.
8
8
  *
9
9
  * SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await, so the phase adds no yield between the
10
- * offload-reader mount before it and the scheduler mount after it (design/390 §1.5 S1: a stretch with no await
10
+ * offload-reader mount before it and the scheduler mount after it (a stretch with no await
11
11
  * is extracted as a sync function — an `async` wrapper would open a microtask window). Read-stability of the
12
12
  * host handles for the call: {@link RunInternals} (`@contract prepare.deps-read-stable`).
13
13
  *
14
- * One seat is a LIVE GETTER (design/238 D-3): the inherited-unavailable marker set is declared by the driver's
14
+ * One seat is a LIVE GETTER: the inherited-unavailable marker set is declared by the driver's
15
15
  * gate-fold section AFTER this phase and read per call at RUN time, so it enters as `() => ReadonlySet` — a
16
16
  * read before the driver declares it throws (temporal dead zone), which is the fail-loud an uninitialized
17
17
  * live read owes.
@@ -1,17 +1,17 @@
1
1
  /**
2
- * design/390 §1.2 M3a — prepareTask's RUN-REFS phase, verbatim from the driver: the run's own edited-files
2
+ * PrepareTask's RUN-REFS phase, verbatim from the driver: the run's own edited-files
3
3
  * ledger, the harness ref, the per-task skill scope, the display-forwarding wrapper, the three run-local refs
4
4
  * (review request / stop-after-turn / plan mode) with the ctx primitives that write them, the subagent-retain
5
5
  * ledger and the worktree-isolation helper. Nothing here has behavior of its own: the phase MINTS SEATS —
6
6
  * mutable cells and the closures bound to them — that later phases, the tool ctx and the run loop read and
7
- * write. The interface is the dependency list the segment had implicitly (design/238 R-1).
7
+ * write. The interface is the dependency list the segment had implicitly.
8
8
  *
9
9
  * SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await, so the phase adds no yield between the
10
- * file-history phase before it and the inherited-gate fold after it (design/390 §1.5 S1: a stretch with no
10
+ * file-history phase before it and the inherited-gate fold after it (a stretch with no
11
11
  * await is extracted as a sync function — an `async` wrapper would open a microtask window).
12
12
  *
13
- * Every cell that leaves here as `borrowed-mutable` carries its writer table on the Result member (design/238
14
- * R-3): the closures minted here, the driver's harness build, the project-context phase's inherited-skill
13
+ * Every cell that leaves here as `borrowed-mutable` carries its writer table on the Result member:
14
+ * the closures minted here, the driver's harness build, the project-context phase's inherited-skill
15
15
  * seed, the skill tool, and the run loop's two writes — nothing else writes them. Read-stability of the host
16
16
  * handles for the call: {@link RunInternals} (`@contract prepare.deps-read-stable`).
17
17
  */
@@ -43,8 +43,8 @@ export interface PrepareRunRefsResult {
43
43
  /** owned — the ledger's LIVE read face (`Prepared.editedFilesSnapshot`, read at result assembly). */
44
44
  editedFilesSnapshot: EditedFilesLedger["snapshot"];
45
45
  /** borrowed-mutable — the harness seat: holds the harness once built, so a tool's execute can read the model
46
- * the parent is CURRENTLY on (design/38 1B: the `ToolExecuteContext.model` snapshot a delegation tool uses
47
- * for `inherit`), and breaks the harness↔tool_search build cycle (design/36 rematerialize). Writers (R-3):
46
+ * the parent is CURRENTLY on (the `ToolExecuteContext.model` snapshot a delegation tool uses
47
+ * for `inherit`), and breaks the harness↔tool_search build cycle (rematerialize). Writers (R-3):
48
48
  * the driver, ONCE, when the harness is built (`harnessRef.current = harness`) — before any run. Readers:
49
49
  * `requestStopAfterTurn` here (mirrors the stop onto the harness's one-way flag), the tool ctx's model
50
50
  * snapshot, the rebuild seam and the delegation mounts. Identity is the contract: every closure minted
@@ -63,7 +63,7 @@ export interface PrepareRunRefsResult {
63
63
  * (the first request wins) and the run loop's turn-boundary consumer, which clears `pending` once the
64
64
  * `plan_review` checkpoint is minted. */
65
65
  reviewRequestRef: Prepared["reviewRequestRef"];
66
- /** owned — the ctx primitive that arms `reviewRequestRef` (design/80 D-B). */
66
+ /** owned — the ctx primitive that arms `reviewRequestRef`. */
67
67
  requestReview: (opts?: {
68
68
  reason?: string;
69
69
  }) => void;
@@ -79,7 +79,7 @@ export interface PrepareRunRefsResult {
79
79
  /** owned — the ctx primitive (mounted on the ctx only under `enablePlanMode`). */
80
80
  enterPlanMode: () => void;
81
81
  /** ownership-ref — the parent-run subagent-retain ledger, or undefined when the spec did not opt in. Its
82
- * lifecycle protocol belongs to the Runner (disposed in the task's terminal finally, design/122 D4); a
82
+ * lifecycle protocol belongs to the Runner (disposed in the task's terminal finally); a
83
83
  * prepare that throws has nothing to release here — the ledger is empty until a delegation retains. */
84
84
  subagentRetain: SubagentRetainLedger | undefined;
85
85
  /** owned — the Agent tool's worktree-isolation helper (lazy; write-capable runs only), or undefined. */
@@ -90,8 +90,8 @@ export interface PrepareRunRefsResult {
90
90
  * A run that opted into `forwardSubagentEvents` may have BACKGROUND children whose frames are forwarded to the
91
91
  * deployment's sink from the child's own run. Those forwards are scheduled on later microtasks than the parent's
92
92
  * turn, so "the parent stream ended" and "the child's already-emitted frames reached the sink" are two different
93
- * moments — the gap is one microtask ladder deep and moves whenever the gate's station structure changes (design/393
94
- * / #594: the three-layer gate added three async frames to a child's gated call, and a consumer that read the parent
93
+ * moments — the gap is one microtask ladder deep and moves whenever the gate's station structure changes
94
+ * (the three-layer gate added three async frames to a child's gated call, and a consumer that read the parent
95
95
  * to `done` then inspected the sink lost the child's `tool_end`). The rule is not a tick count: **before the parent
96
96
  * says `done`, every frame a child had already handed to the forward channel is delivered.** One macrotask turn is
97
97
  * the smallest boundary that strictly orders after all pending microtasks; it is taken only on the opted-in run,
@@ -9,7 +9,7 @@ export interface PrepareSafetyScanInput {
9
9
  deps: RunnerDeps;
10
10
  }
11
11
  /**
12
- * The scan's outputs. Ownership annotations (design/238 §4.2 four-class form):
12
+ * The scan's outputs. Ownership annotations (four-class form):
13
13
  *
14
14
  * `ownToolNames` is **borrowed-readonly** — a first-await snapshot with no mutation anywhere after
15
15
  * the scan; its one later read is the sandbox-boundary predicate's `.has()`.
@@ -1,16 +1,16 @@
1
1
  /**
2
- * design/390 §1.2 M19 (suspend saga) — prepareTask's DURABLE SETTLEMENT machinery, verbatim from the driver's
2
+ * PrepareTask's DURABLE SETTLEMENT machinery, verbatim from the driver's
3
3
  * gate-machinery block: the in-flight spend and repair-bundle folds, the §4.bis correctness-state serializer, the shared
4
4
  * paused-VM compensation bound to this task's failure ledger, the put-commit + put-failure saga (the pre-put cut
5
5
  * checkpoint, the screening-park disclosure, the rejection read-back with its three answers), the suspend-loop cap, the
6
6
  * env capability split (suspendable / park-only / neither) and the park-only handle. The module-scope helpers only this
7
7
  * segment called moved with it (the compensation's bound and body, the auto-mode latch reading, the placement stamp).
8
- * The interface is the dependency list the segment had implicitly (design/238 R-1) — every seat below used to be
8
+ * The interface is the dependency list the segment had implicitly — every seat below used to be
9
9
  * captured off the driver's scope.
10
10
  *
11
11
  * SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await of its own (every await lives inside the closures it
12
12
  * builds, which run at park time), so the phase adds no yield between the ask lane before it and the boundary parks
13
- * after it (design/390 §1.5). Read-stability of the host handles for the call: {@link RunInternals}
13
+ * after it. Read-stability of the host handles for the call: {@link RunInternals}
14
14
  * (`@contract prepare.deps-read-stable`).
15
15
  *
16
16
  * The saga exists exactly when the wiring-manifest phase's `gateMachineryActive` holds (the ask lane's presence law) —
@@ -27,7 +27,7 @@ import type { OutputRef } from "./synthetic-tools.js";
27
27
  import type { HookInvocationIdentity } from "../hooks.js";
28
28
  import type { InheritedGate, Prepared, PrepareResume, RunInternals, SuspendSaga } from "./contracts.js";
29
29
  /**
30
- * design/384 slice 2 — the ONE compensation for a paused-but-unparked VM, shared by the fence's
30
+ * The ONE compensation for a paused-but-unparked VM, shared by the fence's
31
31
  * post-pause checkpoints (③ in the park closure, ④ in the saga) and the saga's put-failure absent
32
32
  * arm (previously inline there: same two hops, one implementation now, so the three sites cannot
33
33
  * drift). Restores the workspace (bounded transient retry) then re-establishes consistency
@@ -26,7 +26,7 @@ export declare function __resetToolModelGateAnnouncements(): void;
26
26
  export declare const TOOL_MODEL_GATE_RESTORE_SENTENCE = "restore via TaskSpec.restoreGatedTools, SEMA_TOOL_MODEL_GATE=off, or RunnerDeps.toolModelGate: false";
27
27
  export { __resetReadFaceClampAnnouncement } from "./prepare-hands-readface.js";
28
28
  /**
29
- * design/164 件四 — how long before an execution environment's declared `lifetimeMs` expires the engine
29
+ * How long before an execution environment's declared `lifetimeMs` expires the engine
30
30
  * stops the run and checkpoints it. The margin has to cover ONE suspend: pausing/snapshotting the
31
31
  * workspace, minting the checkpoint, committing it durably, and letting the loop stop cleanly — with
32
32
  * room for a slow durable store. 60s is generous for that work and small next to any real sandbox
@@ -39,7 +39,7 @@ export { __resetReadFaceClampAnnouncement } from "./prepare-hands-readface.js";
39
39
  */
40
40
  export declare const ENV_LIFETIME_SUSPEND_MARGIN_MS = 60000;
41
41
  /**
42
- * design/164 件四 — resolve the moment an env's lifetime EXPIRES (epoch ms), or `undefined` when the env
42
+ * Resolve the moment an env's lifetime EXPIRES (epoch ms), or `undefined` when the env
43
43
  * declares none / cannot be aged. Split out as a pure function so the anchor rules are testable and
44
44
  * stated once.
45
45
  *
@@ -66,7 +66,7 @@ export { isFableFamilyModelId, resolveAttachmentsConfig, resolveModelPromptTrait
66
66
  export { rebaseWorkspacePath, rebaseWorkspacePathAcross } from "./workspace-path.js";
67
67
  /** Everything the run loop needs, built once by {@link prepareTask} (task setup, isolated from the loop). */
68
68
  /**
69
- * RB-330 + 5.38 r2 件2 — the SINGLE effective-delegation derivation for a leg, minted once per prepare
69
+ * The SINGLE effective-delegation derivation for a leg, minted once per prepare
70
70
  * and read by EVERY consumer face; two facets, one source:
71
71
  *
72
72
  * - `isDelegatedChild` — the raw delegation fact, forks included. Trusted internals first; on a
@@ -79,10 +79,10 @@ export { rebaseWorkspacePath, rebaseWorkspacePathAcross } from "./workspace-path
79
79
  * the `hookIdentity` mint.
80
80
  * - `isNonForkChild` — the fact minus forks, for the authority/context faces: the `loadProjectMemory`
81
81
  * ctx flag ({@link RunnerDeps.loadProjectMemory} `isSubagent`) and the prompt runtime fact
82
- * `isSubagent` (RB-204's `SUBAGENT_CONSENT_NOTICE` gate). A FORK is excluded on both, deliberately:
83
- * a fork IS the parent continuing (design/110), so it inherits the parent's authority — and, on the
82
+ * `isSubagent` (the `SUBAGENT_CONSENT_NOTICE` gate). A FORK is excluded on both, deliberately:
83
+ * a fork IS the parent continuing, so it inherits the parent's authority — and, on the
84
84
  * memory face, the parent's own project context; trimming a fork's CLAUDE.md would hand the
85
- * continuation LESS context than the run it continues. (RB-330 history: the memory face once used
85
+ * continuation LESS context than the run it continues. (The memory face must not use
86
86
  * `parentTaskId !== undefined` alone, which {@link RunInternals.isDelegatedChild}'s own docstring
87
87
  * forbids — a directly-started workflow's children have no nameable parent.)
88
88
  *
@@ -95,7 +95,7 @@ export declare function effectiveDelegationFacts(internals: Pick<RunInternals, "
95
95
  isNonForkChild: boolean;
96
96
  };
97
97
  /**
98
- * Build everything a task run needs (council design/34 ②: a free function with EXPLICIT deps, not a
98
+ * Build everything a task run needs (a free function with EXPLICIT deps, not a
99
99
  * Runner method — testable and decoupled). Resolves the model/role/thinking, acquires + reconciles the
100
100
  * session (with the conflict-detecting Proxy + bounded re-wake on a lost CAS), assembles the tool set
101
101
  * (caller tools + offload wrap + report_blocked + submit_output + MCP + memory + read_tool_result),
@@ -104,19 +104,19 @@ export declare function effectiveDelegationFacts(internals: Pick<RunInternals, "
104
104
  * flow** lives here — that stays in the Runner loop.
105
105
  */
106
106
  export declare function prepareTask(spec: TaskSpec, deps: RunnerDeps, sessions: SessionStore, resume?: PrepareResume, internals?: RunInternals,
107
- /** design/98 §3.1 (S8c): a TRUSTED self-reference to the Runner, passed by the Runner itself (never a
107
+ /** A TRUSTED self-reference to the Runner, passed by the Runner itself (never a
108
108
  * TaskSpec field) so the `run_workflow` tool can execute child tasks via `runner.runTask`. Undefined when
109
109
  * prepareTask is exercised standalone (then run_workflow is simply not mounted). */
110
110
  runnerSelf?: RunnerSelfSeat,
111
- /** #499 — carrier for the id minted below, so a prepare that THROWS still lets its caller name the
111
+ /** Carrier for the id minted below, so a prepare that THROWS still lets its caller name the
112
112
  * run (prepare emits run-scoped notices of its own; each needs a terminal that names it). Same seat
113
113
  * shape the Runner uses for the generated taskId/sessionId. */
114
114
  runIdSink?: {
115
115
  runId?: string;
116
116
  }): Promise<Prepared>;
117
- /** design/393 S7 (#675) — the entry IS the contract the notification lane's seat names ({@link PrepareTaskFn}, contracts.ts):
118
- * a signature change reds HERE, at the declaration, as `false` failing the `true` bound. IDENTITY, not assignability (review
119
- * round 1): the parameter tuple (arity, optionality, each type) and the return type must be the SAME type in both directions —
117
+ /** The entry IS the contract the notification lane's seat names ({@link PrepareTaskFn}, contracts.ts):
118
+ * a signature change reds HERE, at the declaration, as `false` failing the `true` bound. IDENTITY, not assignability:
119
+ * the parameter tuple (arity, optionality, each type) and the return type must be the SAME type in both directions —
120
120
  * one-way `extends` let a dropped trailing parameter, an added optional one or a narrowed return slip through. Type-level only —
121
121
  * nothing is emitted. */
122
122
  type Holds<T extends true> = T;
@@ -265,8 +265,7 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
265
265
  announceToolModelGate(deps.onNotice, model.id, doors.modelGate);
266
266
  const modelGateManifest = toolModelGateManifest(doors.modelGate);
267
267
  const { toolEffects, egressTools, irreversibleTools, irreversibilityTier, axisExplicitNegatives, reversibilityProbes, ownToolNames } = prepareSafetyScan({ spec, deps });
268
- let shellGatedBash = false;
269
- let shellGatedMonitor = false;
268
+ let shellGatedTools = new Set();
270
269
  refuseRequireExistingWithoutSession(spec);
271
270
  const { acquired, session, conflictRef, wakeRecovered, resumeAtBeforeParentId } = await prepareAcquireReconcile({ sessions, spec, resume, toolEffects, ...(internals?.sessionPlacement !== undefined ? { placement: internals.sessionPlacement } : {}), ...(() => { const g = durableParkGapFor(deps, spec); return g !== undefined ? { durableParkGap: g } : {}; })() });
272
271
  const sessionId = acquired.sessionId;
@@ -512,8 +511,7 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
512
511
  resolvedReadFace = handsReadFace.resolvedReadFace;
513
512
  readDenyAdditionsNormalized = handsReadFace.readDenyAdditionsNormalized;
514
513
  handsLessResolvedFace = handsReadFace.handsLessResolvedFace;
515
- shellGatedBash = handsReadFace.shellGatedBash;
516
- shellGatedMonitor = handsReadFace.shellGatedMonitor;
514
+ shellGatedTools = handsReadFace.shellGatedTools;
517
515
  const { worktreeSessionRef } = prepareDelegationSurface({ spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, roster, toolEffects, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, subagentRetain, enrichSpecToolCtx, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle });
518
516
  const { liveQuestionFace, contentAskBindings, contentAskRoutable, lateStrandedAnswers, discloseStrandedAnswers, settleContentAskBindings, durableQuestionFace, questionToolMounted, mountedQuestionTool } = prepareQuestionFace({ frozenOnQuestion, spec, deps, checkpointStore, runtimeCaps, resolvedInteractionPosture, resume, sessionId, roster, inheritedUnavailableAsks: () => inheritedUnavailableAsks });
519
517
  if (spec.handsReadOnly !== true) {
@@ -683,7 +681,7 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
683
681
  releaseSignal = () => sig.removeEventListener("abort", onExternalAbort);
684
682
  }
685
683
  }
686
- const { hooks, hookTimeoutMs, preToolUseObservational, ownGatePreToolUse, basePolicyForResumeEdit, denyNarrowingPolicy, policyLayers, effectivePolicy, inheritedUnavailableAsks, inheritedAskGrants, askSourceIdentity, riskAxesOf, ruleOffersOf, permissionRuleLane, permissionRuleOrgLane, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions } = await preparePolicyChain({ spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, executionEnv, lockedPreflight, tools, harnessTools, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, ownToolNames, shellGatedBash, handsCwdRef, readDenyMatcher, questionToolMounted, runtimeCaps, inheritedAncestorRules, inheritedParentConstraints, seedInheritedGate, hasSkillManifest, skillScope, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, autoModeDecider, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef });
684
+ const { hooks, hookTimeoutMs, preToolUseObservational, ownGatePreToolUse, basePolicyForResumeEdit, denyNarrowingPolicy, policyLayers, effectivePolicy, inheritedUnavailableAsks, inheritedAskGrants, askSourceIdentity, riskAxesOf, ruleOffersOf, permissionRuleLane, permissionRuleOrgLane, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions } = await preparePolicyChain({ spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, executionEnv, lockedPreflight, tools, harnessTools, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, ownToolNames, shellGatedTools, handsCwdRef, readDenyMatcher, questionToolMounted, runtimeCaps, inheritedAncestorRules, inheritedParentConstraints, seedInheritedGate, hasSkillManifest, skillScope, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, autoModeDecider, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef });
687
685
  const { onAsk, preToolContexts, blockedToolCalls, gateOutcomes, batchHaltRef, blockedTracked, incompleteSuspendAdapter, durableSuspendInfraReady, resourceSuspendEligible, usageGovernance, durableApproval, wiringManifest, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace } = prepareWiringManifest({ spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, hooks, preToolUseObservational, policyLayers, effectivePolicy, handsEnabled, mcp, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, lockedPreflight, peerLaneRefs, peerLaneActive, harness, pausedRef, frozenOnAsk, liveInheritedGate, delegation, toolRoster });
688
686
  if (fileHistoryBoundary !== undefined) {
689
687
  harness.on("tool_call", async () => {
@@ -694,8 +692,8 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
694
692
  const { askLane } = prepareAskLane({ gateMachineryActive, abortController, effectivePolicy, budgetSnapshot, handsCwdRef, tools, inheritedUnavailableAsks, inheritedAskGrants, onAsk, humanReviewRef, now, ruleOffersOf, askSourceIdentity, riskAxesOf, autoModeDenialTracking, spec, deps, sessionId, runId, hooks, hookTimeoutMs, notifyOwnHookCrash });
695
693
  const { saga } = prepareSuspendSaga({ gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, reminderMark, handsCwdRef, worktreeSessionRef, inheritedParentConstraints, seedInheritedGate, inheritedAncestorRules, inheritedShellGate, autoModeIntent, inheritedAdmittedOrgScopes, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter });
696
694
  const { suspendForResource, suspendForPlatformLimit, suspendForReview } = prepareBoundaryParks({ saga, spec, checkpointStore, abortController, harness, session, sessions, sessionId, deps, priorLedger, maxSlices, maxSuspends, resourceTotal, priorSuspendCount, suspendChainBase, humanReviewRef, liveSpendRef, now, faceCheckpointState, f012CheckpointState, orgAdmissionCheckpointState, pausedRef, remoteEnvFailures, resourceSuspendEligible, durableSuspendInfraReady, incompleteSuspendAdapter });
697
- const { parkAsk } = prepareParkAsk({ askLane, saga, spec, deps, sessionId, checkpointStore, toolRosterDeltas: rosterSeat, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, offloadStore, ownedEnv, incompleteSuspendAdapter, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedBash, shellGatedMonitor, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, faceCheckpointState, f012CheckpointState, orgAdmissionCheckpointState, ruleOffersOf, now, humanReviewRef, abortController, harness, pausedRef });
698
- prepareGateStations({ askLane, parkAsk, tools, toolRosterDeltas: rosterSeat, toolEffects, deps, toolCallGateArmedRef, effectivePolicy, hooks, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, gateOutcomes, batchHaltRef, blockedTracked, hookIdentity, reminderMark, planModeRef, hostTaskId, sessionId, ownGatePreToolUse, hookTimeoutMs, handsCwdRef, hookEnvFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedBash, shellGatedMonitor, autoModeDecider, autoModeDenialTracking, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, notifyOwnHookCrash });
695
+ const { parkAsk } = prepareParkAsk({ askLane, saga, spec, deps, sessionId, checkpointStore, toolRosterDeltas: rosterSeat, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, offloadStore, ownedEnv, incompleteSuspendAdapter, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedTools, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, faceCheckpointState, f012CheckpointState, orgAdmissionCheckpointState, ruleOffersOf, now, humanReviewRef, abortController, harness, pausedRef });
696
+ prepareGateStations({ askLane, parkAsk, tools, toolRosterDeltas: rosterSeat, toolEffects, deps, toolCallGateArmedRef, effectivePolicy, hooks, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, gateOutcomes, batchHaltRef, blockedTracked, hookIdentity, reminderMark, planModeRef, hostTaskId, sessionId, ownGatePreToolUse, hookTimeoutMs, handsCwdRef, hookEnvFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, notifyOwnHookCrash });
699
697
  const { microCompact, charsPerToken } = prepareContextLane({ model, deps, sessionId, runId, hostTaskId, offloadStore, microCompactKnob, harness, batchHaltRef, gitStatusRef, requestLossyRef, trimPressureRef });
700
698
  const preparedHolder = {};
701
699
  const { cacheBreakDetector, cacheFingerprint, promptOverheadTokens, readTaskFile, normalizeAttachmentPath, isDedupStubResult, recentlyReadFiles, onCompactionApplied, detectExternalChanges, listBackgroundTasks, centerCompactionCandidate, effectiveReadFaceObserved, effectiveReadDenyObserved } = prepareTurnWiring({ deps, systemPromptSeat, harnessTools, fpRef, model, epochArtifactDigestForSnapshot, promptProfile, fableMitigations, systemBlocks, thinking, spec, sessionId, turnSnapshotRef, promptManifest, charsPerToken, handsEnabled, executionEnv, attachmentRootCanonical, additionalRootsCanonical, additionalReadRootsCanonical, readDenyMatcher, resolvedReadFace, handsCwdRef, readFileStateForCheckpoint, denyNarrowingPolicy, abortController, hostTaskId, taskScope, buildAssembleInputs, centerAdoptionRef, harnessRef, epochDeclaredSections, carrierReadFace, readDenyAdditionsNormalized, preparedHolder });
@@ -1,12 +1,11 @@
1
1
  /**
2
- * design/390 §1.2 M14 — prepareTask's TOOL-DISCLOSURE-MOUNT phase, verbatim from the driver: the deferred registry
2
+ * PrepareTask's TOOL-DISCLOSURE-MOUNT phase, verbatim from the driver: the deferred registry
3
3
  * and its placeholders, the ToolSearch mount with its serialized activation section, the materialize strategy's
4
4
  * two-layer resolution (spec over the env channel, the safety interlock, the loud arms for a discarded env value), the
5
5
  * per-tool static exemption with its monotone ledger, the activation seed from the transcript / compaction snapshots /
6
6
  * checkpoint, the callable-names accessor the offload preview and ToolSearch share, the delta ref with its failed-server
7
7
  * arm, and the RefreshMcpTools rebuild seam's two arms. The env-channel announce ledger (per sink, per line) moved with
8
- * the segment — only this phase announces through it. The interface is the dependency list the segment had implicitly
9
- * (design/238 R-1).
8
+ * the segment — only this phase announces through it. The interface is the dependency list the segment had implicitly.
10
9
  *
11
10
  * ASYNC PHASE: with deferred names present the segment awaits the session's context and branch (the activation seed),
12
11
  * exactly where the driver awaited them; with nothing deferred the body has no await of its own. The phase adds no yield
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/390 §1.2 M18 — prepareTask's WIRING-MANIFEST phase, verbatim from the driver: the run's own frozen approver
2
+ * PrepareTask's WIRING-MANIFEST phase, verbatim from the driver: the run's own frozen approver
3
3
  * seat, the loud ungated-write warning (hand band / destructive MCP / first-party write tools with no effect-aware gate,
4
4
  * deduped per deployment and tool-set shape), the PreToolUse context stash and the blocked-call set, the settlement and
5
5
  * bare-rejection sidebands, the turn halt fact, the suspend infrastructure predicates (restore surface gap, durable
@@ -7,10 +7,10 @@
7
7
  * durableApproval, the effective wiring manifest, the peer lane's ask fold and drain binding, the park predicate as ONE
8
8
  * named const, the durable-gate-unavailable notice, the hook identity mint and the hook env face. The four helpers only
9
9
  * this segment called moved with it (usage governance, the per-deployment warn ledger, the MCP manifest projection, the
10
- * durable-gate notice). The interface is the dependency list the segment had implicitly (design/238 R-1).
10
+ * durable-gate notice). The interface is the dependency list the segment had implicitly.
11
11
  *
12
12
  * SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await, so the phase adds no yield between the policy-chain
13
- * station before it and the gate registration after it (design/390 §1.5: a stretch with no await is extracted as a sync
13
+ * station before it and the gate registration after it (a stretch with no await is extracted as a sync
14
14
  * function). Read-stability of the host handles for the call: {@link RunInternals} (`@contract prepare.deps-read-stable`).
15
15
  *
16
16
  * One read changed spelling and nothing else: the manifest's MCP face read `mcp?.statuses ?? []` while `mcp` had long
@@ -103,7 +103,7 @@ export interface PrepareWiringManifestInput {
103
103
  sessions: SessionStore;
104
104
  /** borrowed-readonly — the model gate's per-leg read face, or undefined. */
105
105
  modelGateManifest: WiringManifest["modelGate"];
106
- /** borrowed-readonly — the leg's minted tool roster (design/388): rides the manifest's `tools` section and is the
106
+ /** borrowed-readonly — the leg's minted tool roster: rides the manifest's `tools` section and is the
107
107
  * source of the hand band's write-capable names for the ungated-write warning (what actually MOUNTED). */
108
108
  toolRoster: ToolRoster;
109
109
  /** borrowed-readonly — the arming outcome the caps phase minted (the manifest's auto-mode face). */
@@ -45,7 +45,7 @@ export interface PrepareWorkspaceRestoreResult {
45
45
  * phases, so a consumer moved ahead of this call is a lexical error. */
46
46
  taskRootFinal: string;
47
47
  /** owned (pure function; closes over the phase-armed rebase state) — migrates one checkpointed
48
- * absolute path from the OLD workspace root onto the restored one (RB-439-c: any accepted
48
+ * absolute path from the OLD workspace root onto the restored one (any accepted
49
49
  * spelling of the old root); the identity function when no divergence was armed. Consumers (T7):
50
50
  * the readFileState checkpoint seed, the handsCwd seed, the activeWorktree restore. */
51
51
  rebaseRestoredPath: (p: string) => string;
@@ -1,13 +1,13 @@
1
1
  import type { RemoteExecutionEnv, RemoteExecutionError, SnapshotId, VmLifecycleOptions } from "../remote-env.js";
2
2
  import type { RemoteEnvFailureNote } from "../types.js";
3
3
  /**
4
- * RB-439-a — project one failed remote lifecycle call onto the caller-facing note. ONE builder for all
4
+ * Project one failed remote lifecycle call onto the caller-facing note. ONE builder for all
5
5
  * three ops so the `retryable` classification can never drift between the lane that reports a `suspendVM`
6
6
  * refusal and the lane that reports a failed restore.
7
7
  */
8
8
  export declare function remoteEnvFailureNote(op: RemoteEnvFailureNote["op"], error: RemoteExecutionError, attempts: number): RemoteEnvFailureNote;
9
9
  /**
10
- * RB-439-a — `resumeVM` with a bounded retry on the TRANSIENT codes, plus the attempt count for the
10
+ * `resumeVM` with a bounded retry on the TRANSIENT codes, plus the attempt count for the
11
11
  * caller-facing note.
12
12
  *
13
13
  * Why this op and no other: `resumeVM` is the one lifecycle call the seam documents as "idempotent +
@@ -19,7 +19,7 @@ export declare function remoteEnvFailureNote(op: RemoteEnvFailureNote["op"], err
19
19
  * attempt — `withRetry` will not spend a second call on a permanent refusal.
20
20
  */
21
21
  export declare function restoreWorkspaceWithRetry(env: RemoteExecutionEnv, snapshotId: SnapshotId, options: VmLifecycleOptions,
22
- /** design/384 slice 2 (additive): observe each attempt AS IT STARTS. The returned `attempts` is
22
+ /** Observe each attempt AS IT STARTS. The returned `attempts` is
23
23
  * only readable after settlement, and a caller whose wait on this promise is BOUNDED (the park
24
24
  * compensation) must report the live attempt count when its bound fires mid-call — without this
25
25
  * seat a deaf second attempt was reported as `attempts: 1`. */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/393 S3 — the resume ladder's ADMISSION rung (E1) and the wake's shaping (E2), verbatim from
2
+ * The resume ladder's ADMISSION rung (E1) and the wake's shaping (E2), verbatim from
3
3
  * `Runner.resumeStream`: the outcome container's domain, the one-read snapshots of the caller's config and
4
4
  * the trusted internals bag, the store resolution, the row read and its terminal-status confirm, the
5
5
  * same-process parent-constraint re-supply, then the wake pre-ladder (gate purity, pendingAction purity,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/393 S3 — the resume ladder's CLAIM rung (E10), verbatim from `Runner.resumeStream`: the atomic
2
+ * The resume ladder's CLAIM rung (E10), verbatim from `Runner.resumeStream`: the atomic
3
3
  * CAS (`claimTerminal` when the store provides it — one round trip carrying the loser's truth — else the
4
4
  * two-step `resolve` + diagnostic read), the same-Runner claim mark around it, and the loss classification
5
5
  * (`reopened_concurrently` for a live row whose rev moved, `already_resolved` for a consumed one, with the
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/393 S3 — the resume ladder's INTERNALS-AND-CONFIG rung (E7), verbatim from `Runner.resumeStream`:
2
+ * The resume ladder's INTERNALS-AND-CONFIG rung (E7), verbatim from `Runner.resumeStream`:
3
3
  * the locked-policy guard on the resume-edit seat, the principal and placement identity-continuity rungs,
4
4
  * and the governance-window ENTRANCE check for a row that still owes a delivery.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/393 S3 — the resume ladder's APPROVAL-LANE capture and binding rung (E4), verbatim from
2
+ * The resume ladder's APPROVAL-LANE capture and binding rung (E4), verbatim from
3
3
  * `Runner.resumeStream`: on a human / irreversible_ask row every deployment-supplied field of the
4
4
  * `policy_ask` decide is read exactly once into a plain twin (answer canonicalized, updatedInput cloned to the
5
5
  * JSON domain, the decision word, the refused keys, the host's decision facts and attribution, the deny note),
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/393 S3 — the resume ladder's deployment PREFLIGHT rung (E9), verbatim from `Runner.resumeStream`:
2
+ * The resume ladder's deployment PREFLIGHT rung (E9), verbatim from `Runner.resumeStream`:
3
3
  * the LAST rung before the CAS. The deployment's `resumePreflight` screens the resume off the persisted row's
4
4
  * facts under its own validated deadline; every non-answer arm refuses retry-later (the row stays pending);
5
5
  * only an explicit, fully readable `terminal` verdict settles the row through the single-shot expire CAS
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/393 S3 — the resume ladder's gate-match rung and the review / park TWINS (E3), verbatim from
2
+ * The resume ladder's gate-match rung and the review / park TWINS (E3), verbatim from
3
3
  * `Runner.resumeStream`: the outcome arm must match the persisted gate kind; a review-gate outcome
4
4
  * (plan_review / dry_run_review) is captured into a plain twin with its domain and text-payload checks, the
5
5
  * break-out-tag hygiene and the env_failed replay guard; the two tool-less park lanes (wake / resource_limit)
@@ -21,7 +21,7 @@ export interface RunBrainSinksInput {
21
21
  observeReasoningWireFacts: (facts: ReasoningWireFacts) => void;
22
22
  }
23
23
  export interface RunBrainSinksResult {
24
- /** design/99 BC-2: the subagent's human display name for its `task_progress` ticks, or undefined. */
24
+ /** The subagent's human display name for its `task_progress` ticks, or undefined. */
25
25
  subagentName: string | undefined;
26
26
  /** Compose the three brain ALS sinks around a brain-driving call. */
27
27
  withBrainSinks: <T>(fn: () => Promise<T>) => Promise<T>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/393 S5 — the run body's CLOCK and CONTENT seats (R6), verbatim from `Runner.runLocked`: the per-slice
2
+ * The run body's CLOCK and CONTENT seats (R6), verbatim from `Runner.runLocked`: the per-slice
3
3
  * walltime window and its MONOTONIC deadline anchored at task start, the hard-abort timer armed against that same
4
4
  * deadline (a suspendable task gets the backstop grace), the content-event push that also forwards a sub-agent's
5
5
  * events to the parent's display sink, the run's own committed-tail ref and the `message_committed` mint that
@@ -34,15 +34,15 @@ export interface RunClockAndContentInput {
34
34
  startedToolCallIds: Set<string>;
35
35
  }
36
36
  export interface RunClockAndContentResult {
37
- /** design/164: the PER-SLICE active clock, or undefined (0 is a valid, exhausted window). */
37
+ /** The PER-SLICE active clock, or undefined (0 is a valid, exhausted window). */
38
38
  effectiveTimeoutMs: number | undefined;
39
- /** RB-20: the monotonic deadline every walltime enforcement decision reads, or undefined. */
39
+ /** The monotonic deadline every walltime enforcement decision reads, or undefined. */
40
40
  walltimeMonotonicDeadline: number | undefined;
41
41
  /** The hard walltime backstop: its fired flag / lateness, and the clear the teardown calls. */
42
42
  timeout: ReturnType<typeof startTimeout>;
43
43
  /** Push a content event to the run's queue and, for a sub-agent, to the parent's display sink. */
44
44
  pushContent: (e: TaskEvent) => void;
45
- /** #483: the id of the LAST entry this run committed — the settle-time seal's provenance anchor. */
45
+ /** The id of the LAST entry this run committed — the settle-time seal's provenance anchor. */
46
46
  ownCommittedTailRef: {
47
47
  current: string | undefined;
48
48
  };
@@ -15,7 +15,7 @@ export interface RunCompactionMachineryInput {
15
15
  /** borrowed-mutable — the run's usage counters: every accounted summary call adds to them (compaction spend
16
16
  * tracked separately too). */
17
17
  stats: Stats;
18
- /** borrowed-readonly — the telemetry lane's price-table door (#462), consulted for every summarizer table adopted. */
18
+ /** borrowed-readonly — the telemetry lane's price-table door, consulted for every summarizer table adopted. */
19
19
  noteUnevaluablePriceTable: (p: ModelPricing) => void;
20
20
  /** borrowed-readonly — the Runner's deployment deps, read LIVE (`brain`, `pricing`, `onError`). */
21
21
  runner: RunnerDepsSeat;
@@ -23,13 +23,13 @@ export interface RunCompactionMachineryInput {
23
23
  export interface RunCompactionMachineryResult {
24
24
  /** The accounted compaction brain — `complete` always provided, usage recorded inline. */
25
25
  compactionBrain: Brain;
26
- /** design/64 §25 (A): whether ROUTINE turn-boundary compaction runs for this task. */
26
+ /** Whether ROUTINE turn-boundary compaction runs for this task. */
27
27
  withinTaskCompaction: boolean;
28
28
  /** §17.4: the consecutive-failure circuit breaker shared by every compaction lane of the run. */
29
29
  compactionBreaker: {
30
30
  failures: number;
31
31
  };
32
- /** design/145 门A/§3: the window-safety wiring (per call — a mid-task degrade moves the fallback target). */
32
+ /** The window-safety wiring (per call — a mid-task degrade moves the fallback target). */
33
33
  windowSafetyOptions: (mainModel: Model) => Pick<MaybeCompactOptions, "fallbackBudget" | "onWindowSafety">;
34
34
  }
35
35
  export declare function runCompactionMachinery(input: RunCompactionMachineryInput): RunCompactionMachineryResult;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/393 S5 — the run body's GIT LANE (R12), verbatim from `Runner.runLocked`: the git-status re-assert closure
2
+ * The run body's GIT LANE (R12), verbatim from `Runner.runLocked`: the git-status re-assert closure
3
3
  * installed on `prepared.gitStatusRef` (compaction landing hook + owed-frame retry — an engine-minted standalone
4
4
  * append with the receipt in hand, the announced mirror written only then), the parked mirror flush (F4), the
5
5
  * owed-frame retry subscription registered BEFORE the boundary handler, the boundary subscription itself and the