@sema-agent/core 7.73.0 → 7.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/CHANGELOG.md +246 -0
  2. package/dist/agents/list-agents-tool.js +1 -1
  3. package/dist/agents/retain-ledger.js +3 -3
  4. package/dist/agents/send-message-tool.js +4 -4
  5. package/dist/brain/anthropic.d.ts +42 -1
  6. package/dist/brain/anthropic.js +54 -4
  7. package/dist/brain/failover.d.ts +5 -0
  8. package/dist/brain/failover.js +51 -22
  9. package/dist/brain/model-lane.d.ts +12 -3
  10. package/dist/brain/model-lane.js +5 -5
  11. package/dist/brain/open-responses.js +3 -3
  12. package/dist/brain/openai.js +1 -1
  13. package/dist/brain/route-adjudicator.d.ts +33 -4
  14. package/dist/brain/route-adjudicator.js +49 -12
  15. package/dist/brain/stream-engine.js +9 -7
  16. package/dist/brain/stream-shared.d.ts +4 -3
  17. package/dist/brain/stream-shared.js +2 -2
  18. package/dist/core/allow-entry.js +1 -1
  19. package/dist/core/ask-class.d.ts +2 -2
  20. package/dist/core/ask-headline.d.ts +1 -1
  21. package/dist/core/ask-origin.d.ts +44 -4
  22. package/dist/core/ask-origin.js +29 -10
  23. package/dist/core/background-agent-store.d.ts +1 -0
  24. package/dist/core/background-agent-store.js +49 -8
  25. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  26. package/dist/core/checkpoint-row-verdict.js +2 -2
  27. package/dist/core/checkpoint-store.d.ts +2 -0
  28. package/dist/core/checkpoint-store.js +8 -2
  29. package/dist/core/config-refusal-codes.d.ts +1 -1
  30. package/dist/core/config-refusal-codes.js +1 -0
  31. package/dist/core/cron.js +9 -1
  32. package/dist/core/deployment-shape.d.ts +7 -0
  33. package/dist/core/deployment-shape.js +19 -0
  34. package/dist/core/engine-capabilities.d.ts +9 -1
  35. package/dist/core/engine-capabilities.js +1 -1
  36. package/dist/core/engine-notice.d.ts +14 -9
  37. package/dist/core/engine-version.js +1 -1
  38. package/dist/core/gate-fold.js +5 -4
  39. package/dist/core/gate-lanes.js +8 -12
  40. package/dist/core/gate-outcome.d.ts +8 -2
  41. package/dist/core/gate-outcome.js +10 -3
  42. package/dist/core/governance-codes.d.ts +8 -2
  43. package/dist/core/governance-codes.js +9 -1
  44. package/dist/core/hook-condition.d.ts +37 -0
  45. package/dist/core/hook-condition.js +567 -0
  46. package/dist/core/hooks.d.ts +2 -0
  47. package/dist/core/mode-policy.d.ts +4 -0
  48. package/dist/core/mode-policy.js +18 -2
  49. package/dist/core/model-seat.d.ts +8 -5
  50. package/dist/core/model-shell.d.ts +129 -0
  51. package/dist/core/model-shell.js +249 -0
  52. package/dist/core/mods/kernel/digest.d.ts +4 -0
  53. package/dist/core/mods/kernel/digest.js +5 -0
  54. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  55. package/dist/core/mods/kernel/dispatch.js +15 -6
  56. package/dist/core/mods/kernel/events.d.ts +21 -5
  57. package/dist/core/mods/kernel/events.js +19 -10
  58. package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
  59. package/dist/core/mods/kernel/hash-mirror.js +55 -0
  60. package/dist/core/mods/kernel/index.d.ts +1 -0
  61. package/dist/core/mods/kernel/index.js +1 -0
  62. package/dist/core/mods/kernel/package-reader.d.ts +48 -0
  63. package/dist/core/mods/kernel/package-reader.js +149 -0
  64. package/dist/core/mods/kernel/site-rules.d.ts +4 -0
  65. package/dist/core/mods/kernel/site-rules.js +13 -0
  66. package/dist/core/mods/package.d.ts +7 -3
  67. package/dist/core/mods/package.js +47 -80
  68. package/dist/core/permission-rule-org.js +13 -3
  69. package/dist/core/permission-rules.js +4 -1
  70. package/dist/core/retain-seat.d.ts +42 -0
  71. package/dist/core/retain-seat.js +76 -0
  72. package/dist/core/rewind-refusal-codes.d.ts +8 -0
  73. package/dist/core/rewind-refusal-codes.js +12 -0
  74. package/dist/core/roles.d.ts +2 -2
  75. package/dist/core/roles.js +15 -1
  76. package/dist/core/rule-store-fault.d.ts +9 -7
  77. package/dist/core/rule-store-fault.js +8 -3
  78. package/dist/core/runner/checkpoint-scope.d.ts +1 -0
  79. package/dist/core/runner/checkpoint-scope.js +4 -2
  80. package/dist/core/runner/compact-session.js +1 -1
  81. package/dist/core/runner/construction-doors.js +2 -0
  82. package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
  83. package/dist/core/runner/cross-boundary-lane.js +4 -0
  84. package/dist/core/runner/gate-exit.d.ts +7 -0
  85. package/dist/core/runner/gate-exit.js +2 -1
  86. package/dist/core/runner/model-lane-seat.d.ts +3 -0
  87. package/dist/core/runner/model-lane-seat.js +4 -0
  88. package/dist/core/runner/person-path-rows.d.ts +6 -0
  89. package/dist/core/runner/person-path-rows.js +13 -0
  90. package/dist/core/runner/prepare-config-doors.js +9 -5
  91. package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
  92. package/dist/core/runner/prepare-gate-stations.js +3 -1
  93. package/dist/core/runner/prepare-hands-readface.js +3 -2
  94. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  95. package/dist/core/runner/prepare-task.js +6 -3
  96. package/dist/core/runner/prepare-wiring-manifest.js +3 -4
  97. package/dist/core/runner/resume-policy-outcome.js +5 -2
  98. package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
  99. package/dist/core/runner/role-seat-defaulted.js +1 -1
  100. package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
  101. package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
  102. package/dist/core/runner/run-harness-handlers.js +1 -1
  103. package/dist/core/runner/run-leg.js +2 -2
  104. package/dist/core/runner/shell-env-withheld.d.ts +3 -2
  105. package/dist/core/runner/shell-env-withheld.js +24 -1
  106. package/dist/core/runner/sub-agent-deny-lists.js +9 -5
  107. package/dist/core/runner/tool-end-body.d.ts +1 -1
  108. package/dist/core/runner/tool-not-executed.d.ts +27 -8
  109. package/dist/core/runner/tool-not-executed.js +22 -11
  110. package/dist/core/runner/write-protection-station.d.ts +1 -1
  111. package/dist/core/runner/write-protection-station.js +1 -1
  112. package/dist/core/runner-deps.d.ts +4 -0
  113. package/dist/core/secret-env.d.ts +8 -0
  114. package/dist/core/secret-env.js +5 -2
  115. package/dist/core/shell-read-silence.d.ts +40 -2
  116. package/dist/core/shell-read-silence.js +23 -4
  117. package/dist/core/task-event.d.ts +4 -4
  118. package/dist/core/task-notification.js +6 -1
  119. package/dist/core/task-registry-agent.d.ts +1 -0
  120. package/dist/core/task-registry-agent.js +1 -1
  121. package/dist/core/task-registry.d.ts +1 -0
  122. package/dist/core/task-registry.js +4 -3
  123. package/dist/core/task-result.d.ts +5 -3
  124. package/dist/core/task-spec-members.js +8 -0
  125. package/dist/core/tool-gate-phase.d.ts +6 -3
  126. package/dist/core/tool-gate-phase.js +1 -0
  127. package/dist/core/tool-mount-facts.d.ts +7 -3
  128. package/dist/core/tool-mount-facts.js +6 -2
  129. package/dist/core/tool-mount-plan.d.ts +1 -1
  130. package/dist/core/tool-mount-plan.js +4 -3
  131. package/dist/core/tool-result-store.d.ts +37 -1
  132. package/dist/core/tool-result-store.js +168 -23
  133. package/dist/core/trace.d.ts +3 -3
  134. package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
  135. package/dist/engine/execution-env/node-execution-env.js +225 -13
  136. package/dist/engine/harness/types.d.ts +25 -0
  137. package/dist/engine/llm/types.d.ts +8 -0
  138. package/dist/engine/llm/validation.d.ts +8 -1
  139. package/dist/engine/llm/validation.js +31 -2
  140. package/dist/host-env.d.ts +10 -0
  141. package/dist/host-env.js +1 -0
  142. package/dist/index.d.ts +10 -2
  143. package/dist/index.js +9 -2
  144. package/dist/internal/harness-types.d.ts +1 -1
  145. package/dist/orchestration/goal.js +1 -1
  146. package/dist/orchestration/workflow-primitives.js +10 -1
  147. package/dist/orchestration/workflow-script-runner.d.ts +2 -2
  148. package/dist/orchestration/workflow.d.ts +1 -1
  149. package/dist/orchestration/workflow.js +2 -2
  150. package/dist/shell/lex.d.ts +2 -2
  151. package/dist/shell/lex.js +1 -1
  152. package/dist/tools/fs/bash-model-shell.d.ts +23 -0
  153. package/dist/tools/fs/bash-model-shell.js +25 -0
  154. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
  155. package/dist/tools/fs/bash-readonly-classifier.js +3 -0
  156. package/dist/tools/fs/fs-bash.js +13 -11
  157. package/dist/tools/fs/shell-read-argv.js +1 -0
  158. package/dist/tools/fs/shell-read-check.js +39 -9
  159. package/dist/tools/fs/shell-read-plan.d.ts +2 -3
  160. package/dist/tools/fs/shell-read-plan.js +8 -5
  161. package/dist/tools/fs/shell-read-word.d.ts +8 -0
  162. package/dist/tools/fs/shell-read-word.js +13 -4
  163. package/dist/tools/monitor.js +12 -8
  164. package/dist/tools/scheduler-tools.d.ts +1 -0
  165. package/dist/tools/scheduler-tools.js +5 -2
  166. package/package.json +3 -2
  167. package/test/export-surface.snapshot.json +62 -3
  168. package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
  169. package/wire-changes/answers/core@7.74.0.json +68 -0
  170. package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
  171. package/wire-changes/answers/primitives@7.74.0.json +7 -0
  172. package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
  173. package/wire-changes/core-stores-sql@7.74.0.json +143 -0
  174. package/wire-changes/core@7.74.0.json +2210 -0
  175. package/wire-changes/mods-kernel@7.74.0.json +421 -0
  176. package/wire-changes/primitives@7.74.0.json +174 -0
  177. package/wire-changes/wiki-gate@7.74.0.json +145 -0
@@ -0,0 +1,76 @@
1
+ import { types } from "node:util";
2
+ import { optionKeys, receiveMembers } from "./own-property-receipt.js";
3
+ export const RETAIN_SEAT_FIELD = "TaskSpec.retainSubagentSessions";
4
+ const RETAIN_SEAT_MEMBERS = optionKeys()({ ttlMs: 0, max: 0 });
5
+ const refuse = (field, why) => ({
6
+ ok: false,
7
+ code: "config.invalid_argument",
8
+ field,
9
+ message: `${field}: ${why} — the run is refused rather than retained under a setting nobody chose.`,
10
+ });
11
+ function kindOf(v) {
12
+ if (v === null)
13
+ return "null";
14
+ if (types.isProxy(v))
15
+ return "a Proxy";
16
+ if (Array.isArray(v))
17
+ return "an array";
18
+ if (typeof v === "number") {
19
+ if (!Number.isFinite(v))
20
+ return "a number that is not finite";
21
+ if (!Number.isInteger(v))
22
+ return "a number that is not a whole number";
23
+ return v > Number.MAX_SAFE_INTEGER ? "a whole number above that" : "a whole number below 1";
24
+ }
25
+ if (typeof v === "object")
26
+ return "an object";
27
+ return `${/^[aeiou]/.test(typeof v) ? "an" : "a"} ${typeof v}`;
28
+ }
29
+ export function screenRetainSeat(value, at = RETAIN_SEAT_FIELD) {
30
+ try {
31
+ return screenRead(value, at);
32
+ }
33
+ catch {
34
+ return refuse(at, "could not be read: reading it threw — a value whose read throws is refused rather than read as off");
35
+ }
36
+ }
37
+ function screenRead(value, at) {
38
+ if (value === undefined || value === false)
39
+ return { ok: true };
40
+ if (value === true)
41
+ return { ok: true, seat: true };
42
+ if (value === null || typeof value !== "object" || (!types.isProxy(value) && Array.isArray(value))) {
43
+ return refuse(at, `must be \`true\`, \`false\` or a record { ttlMs?, max? } (got ${kindOf(value)})`);
44
+ }
45
+ let record;
46
+ try {
47
+ record = receiveMembers(value, { subject: at, unit: "member", moment: "when the run's spec is read" }, RETAIN_SEAT_MEMBERS);
48
+ }
49
+ catch (e) {
50
+ if (!(e instanceof Error) || !("code" in e) || e.code !== "config.invalid_argument")
51
+ throw e;
52
+ const member = "member" in e ? e.member : undefined;
53
+ return { ok: false, code: "config.invalid_argument", field: typeof member === "string" ? `${at}.${member}` : at, message: e.message };
54
+ }
55
+ const seat = {};
56
+ for (const key of ["ttlMs", "max"]) {
57
+ const v = Reflect.get(record, key);
58
+ if (v === undefined)
59
+ continue;
60
+ if (typeof v !== "number" || !Number.isSafeInteger(v) || v < 1)
61
+ return refuse(`${at}.${key}`, `must be a whole number from 1 to ${Number.MAX_SAFE_INTEGER} (got ${kindOf(v)})`);
62
+ seat[key] = v;
63
+ }
64
+ return { ok: true, seat: Object.freeze(seat) };
65
+ }
66
+ export function retainSeatError(refusal) {
67
+ return Object.assign(new Error(refusal.message), { code: refusal.code, detail: { field: refusal.field } });
68
+ }
69
+ export function retainSeatToBuild(value) {
70
+ const screened = screenRetainSeat(value);
71
+ if (!screened.ok)
72
+ throw retainSeatError(screened);
73
+ if (screened.seat === undefined)
74
+ throw retainSeatError(refuse(RETAIN_SEAT_FIELD, "asks for no retention, and a retain ledger is made only for `true` or a record"));
75
+ return screened.seat;
76
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The rewind verbs' refusals that happen before any work — the request or the session refused, nothing written: the closed set a host
3
+ * maps to a 4xx by family. Not in it: `rewind.restore_failed` (the restore itself failed — before writing, e.g. an unreadable
4
+ * session row, or after touching the disk where it may be partial; its `detail.permanence` says whether a retry can help) and the two rewind notices (`rewind.boundary_unrecorded`, `rewind.file_left_as_is`:
5
+ * notice codes, in ENGINE_NOTICE_CODES).
6
+ */
7
+ export declare const REWIND_REFUSAL_CODES: readonly ["rewind.invalid_spec", "rewind.conflicting_targets", "rewind.store_unconfigured", "rewind.capture_disabled", "rewind.files_env_unsupported", "rewind.session_busy", "rewind.session_parked", "rewind.target_off_branch", "rewind.unseen_later_turn", "rewind.child_scope_unsupported"];
8
+ export type RewindRefusalCode = (typeof REWIND_REFUSAL_CODES)[number];
@@ -0,0 +1,12 @@
1
+ export const REWIND_REFUSAL_CODES = Object.freeze([
2
+ "rewind.invalid_spec",
3
+ "rewind.conflicting_targets",
4
+ "rewind.store_unconfigured",
5
+ "rewind.capture_disabled",
6
+ "rewind.files_env_unsupported",
7
+ "rewind.session_busy",
8
+ "rewind.session_parked",
9
+ "rewind.target_off_branch",
10
+ "rewind.unseen_later_turn",
11
+ "rewind.child_scope_unsupported",
12
+ ]);
@@ -194,13 +194,13 @@ export declare function screenRoleMap(roles: ModelRoles | undefined, field: "Run
194
194
  export declare const ROLE_SEAT_STAND_IN_CAUSES: readonly ["unknown_model_ref", "tier_unbound"];
195
195
  export type RoleSeatStandInCause = (typeof ROLE_SEAT_STAND_IN_CAUSES)[number];
196
196
  /** A role seat whose word the catalog does not hold: the role, the seat as the refusal names it, the word written there, why it is not held,
197
- * and whether the role's OWN tier default is absent in that catalog too (then the walk's tier step supplies this role nothing either). */
197
+ * and whether the role's OWN tier default is bound in that catalog (the walk's tier step then supplies this role a model: {@link roleTierModel}). */
198
198
  export interface UnheldRoleSeat {
199
199
  role: ModelRole;
200
200
  seat: string;
201
201
  word: string;
202
202
  cause: RoleSeatStandInCause;
203
- ownTierAbsent: boolean;
203
+ ownTierBound: boolean;
204
204
  }
205
205
  /**
206
206
  * The ONE test of "this seat names a word the deployment's catalog does not declare": the word a role entry writes — the string
@@ -508,8 +508,22 @@ function partsModel(parts, models, seat = "a role seat") {
508
508
  return undefined;
509
509
  }
510
510
  export const ROLE_SEAT_STAND_IN_CAUSES = Object.freeze(["unknown_model_ref", "tier_unbound"]);
511
+ function ownTierBoundOf(role, models) {
512
+ const tier = ROLE_TIER_DEFAULTS[role];
513
+ if (tier === undefined)
514
+ return false;
515
+ try {
516
+ if (!tiersActive(models))
517
+ return false;
518
+ const entry = catalogEntry(tier, models);
519
+ return typeof entry === "object" && entry !== null;
520
+ }
521
+ catch {
522
+ return false;
523
+ }
524
+ }
511
525
  function unheldSeatOf(role, seat, word, models) {
512
- return { role, seat, word, cause: isFixedTierWord(word) && tiersActive(models) ? "tier_unbound" : "unknown_model_ref", ownTierAbsent: absentTierDefault(role, models) !== undefined };
526
+ return { role, seat, word, cause: isFixedTierWord(word) && tiersActive(models) ? "tier_unbound" : "unknown_model_ref", ownTierBound: ownTierBoundOf(role, models) };
513
527
  }
514
528
  export function unheldSeatWord(spec, models) {
515
529
  const named = typeof spec === "string" ? spec : isBindingObject(spec) && !("id" in spec && "api" in spec) ? spec.model : undefined;
@@ -49,16 +49,18 @@ export declare function ruleStoreFaultReasonOf(err: unknown): RuleStoreFaultReas
49
49
  export declare function ruleStoreSourcesWord(sources: readonly RuleStoreSource[]): string;
50
50
  /**
51
51
  * The run's `permission.rule_store_unavailable` sentence (audience: the person): which partition, why, what it costs meanwhile, and
52
- * what to repair. No path, no permission mode: it is told only where the mode puts such a call to a person
53
- * (`rule-store-unreadable-notice.ts`), so until a read succeeds every call asks a person.
52
+ * what to repair. No path. `relaxedMode` names the leg's mode when it answers the class unasked (so the cost clause states only what
53
+ * that mode does — the unread rules by themselves do not make the engine ask, under `auto` the classifier judges such a call, retained
54
+ * deny/ask rows still apply, and a deny rule saved since may not be in force); `undefined` otherwise (every call asks a person until a
55
+ * read succeeds).
54
56
  */
55
- export declare function ruleStoreUnreadableNoticeSentence(at: "prepare" | "call", faults: readonly RuleStoreFault[] | undefined): string;
57
+ export declare function ruleStoreUnreadableNoticeSentence(at: "prepare" | "call", faults: readonly RuleStoreFault[] | undefined, relaxedMode: string | undefined): string;
56
58
  /**
57
59
  * The `permission.rule_store_unreadable_relaxed` sentence (audience: the operator): the same partition, cause and repair, where the leg's
58
- * permission mode answers the class of the unread rules with nobody asked — so the person is told nothing and no deny or ask row of the
59
- * unread rules stops a call beyond the rows of the last read that succeeded. (Another class on a call may still put it to a person.) With
60
- * `rows`, the fact is that many rows of the rules whose rule itself could not be read: the calls they may reach are released alike, while
61
- * every other row applies as read.
60
+ * permission mode answers the class of the unread rules with nobody asked — the person is told by their own notice, and until a read
61
+ * succeeds only the deny and ask rows of the last read that succeeded apply (under `auto` the classifier judges such a call, and a
62
+ * no-ruling result or a retained ask row may still put it to a person). With `rows`, the fact is that many rows of the rules whose rule
63
+ * itself could not be read: the calls they may reach are released alike, while every other row applies as read.
62
64
  */
63
65
  export declare function ruleStoreUnreadableRelaxedSentence(mode: string, at: "prepare" | "call", faults: readonly RuleStoreFault[] | undefined, rows?: number): string;
64
66
  /**
@@ -63,10 +63,14 @@ function waysOut(faults) {
63
63
  return [...new Set([...acts, ...logs])].join(" ");
64
64
  }
65
65
  const UNSAID = Object.freeze([Object.freeze({ sources: Object.freeze([]), reason: "unclassified" })]);
66
- export function ruleStoreUnreadableNoticeSentence(at, faults) {
66
+ export function ruleStoreUnreadableNoticeSentence(at, faults, relaxedMode) {
67
67
  const { head, clause } = faultsClause(faults !== undefined && faults.length > 0 ? faults : UNSAID);
68
68
  const fixes = waysOut(faults !== undefined && faults.length > 0 ? faults : UNSAID);
69
- return `Your saved permission rules${head} could not be read ${at === "prepare" ? "when this run started" : "for a call on this run"}: ${clause}. Until a read of them succeeds, none of their allow rows (Read directory rows included) applies, while the deny and ask rows most recently read from them this run still apply — a deny row you removed since that read keeps refusing until then. While they cannot be read, every call is asked about rather than allowed, whatever its tool (rules nobody can read may name any), until a read of them succeeds. ${fixes} Every later check reads them again.`;
69
+ const modeNote = relaxedMode === "auto" ? " (the classifier judges such a call)" : "";
70
+ const cost = relaxedMode !== undefined
71
+ ? `Under this run's permission mode (${relaxedMode}), the unread rules by themselves do not make the engine ask${modeNote}: until a read of them succeeds, only the deny and ask rows most recently read from them this run apply (none, if no read has succeeded) — a deny rule you saved since may not be in force.`
72
+ : "Until a read of them succeeds, none of their allow rows (Read directory rows included) applies, while the deny and ask rows most recently read from them this run still apply — a deny row you removed since that read keeps refusing until then. While they cannot be read, every call is asked about rather than allowed, whatever its tool (rules nobody can read may name any), until a read of them succeeds.";
73
+ return `Your saved permission rules${head} could not be read ${at === "prepare" ? "when this run started" : "for a call on this run"}: ${clause}. ${cost} ${fixes} Every later check reads them again.`;
70
74
  }
71
75
  export function ruleStoreUnreadableRelaxedSentence(mode, at, faults, rows) {
72
76
  const { head, clause } = faultsClause(faults !== undefined && faults.length > 0 ? faults : UNSAID);
@@ -74,7 +78,8 @@ export function ruleStoreUnreadableRelaxedSentence(mode, at, faults, rows) {
74
78
  if (rows !== undefined) {
75
79
  return `${rows} deny or ask row${rows === 1 ? "" : "s"} of the person's saved permission rules${head} could not be read ${at === "prepare" ? "when a run started" : "for a call of a run"} (the rule itself — its tool, its text or its behavior — is not plain data): ${clause}. Under the run's permission mode (${mode}) the calls ${rows === 1 ? "it" : "they"} may reach are released with nobody asked, unless a readable deny refuses them or a readable ask row asks; every other row applies as read. ${fixes}`;
76
80
  }
77
- return `The person's saved permission rules${head} could not be read ${at === "prepare" ? "when a run started" : "for a call of a run"}: ${clause}. Under the run's permission mode (${mode}) the unread rules alone put no call to a person, so the person is not told: until a read of them succeeds, only the deny and ask rows of the last read that succeeded apply (none, if no read has). ${fixes}`;
81
+ const modeNote = mode === "auto" ? " (the classifier judges such a call)" : "";
82
+ return `The person's saved permission rules${head} could not be read ${at === "prepare" ? "when a run started" : "for a call of a run"}: ${clause}. Under the run's permission mode (${mode}) the unread rules by themselves do not make the engine ask${modeNote} (the person is told by their own notice): until a read of them succeeds, only the deny and ask rows of the last read that succeeded apply (none, if no read has) — a deny rule saved since may not be in force. ${fixes}`;
78
83
  }
79
84
  export function ruleStoreUnreadableAskSentence(faults) {
80
85
  const { head, clause } = faultsClause(faults !== undefined && faults.length > 0 ? faults : UNSAID);
@@ -43,6 +43,7 @@ export type DeclaredScopeReading = {
43
43
  } | {
44
44
  readonly kind: "none";
45
45
  readonly fault: string;
46
+ readonly at?: "scope" | "ttlMs" | "undeclared";
46
47
  };
47
48
  /**
48
49
  * The ONE reading of "this opt-in names its scope": a `durableApproval` — the task's own, or the record a parked row keeps of it — names
@@ -10,8 +10,10 @@ export function readDeclaredCheckpointScope(declared) {
10
10
  if (typeof declared !== "object" || declared === null)
11
11
  return { kind: "none", fault: declared === null ? "null, not an object" : `a ${typeof declared}, not an object` };
12
12
  const data = receive(declared, DECLARED_SCOPE_DATA);
13
- if (!data.ok)
14
- return { kind: "none", fault: `not plain data — ${describeFault(data.fault)}` };
13
+ if (!data.ok) {
14
+ const f = data.fault.path[0];
15
+ return f === undefined || f === "scope" ? { kind: "none", ...(f === "scope" ? { at: "scope" } : {}), fault: `not plain data — ${describeFault(data.fault)}` } : { kind: "none", at: f === "ttlMs" ? "ttlMs" : "undeclared", fault: describeFault({ kind: data.fault.kind, path: [] }) };
16
+ }
15
17
  const record = data.value;
16
18
  if (!isPlainRecord(record))
17
19
  return { kind: "none", fault: "a list, not a record" };
@@ -272,7 +272,7 @@ const PARKED = {
272
272
  undone: "a parked session's resume rewinds its branch to the checkpoint's leaf, where a summary written now would not be read, so nothing was compacted; decide the checkpoint (resume it) or expire it, then compact",
273
273
  };
274
274
  function sessionBusyRefusal(sessionId) {
275
- const e = new Error(`${VERB}: a task is running or queued on session "${sessionId}" in this Runner, or a write one of its tasks issued has not settled — compacting it now would rewrite the transcript under that work, so nothing was compacted; a running task takes the request through its own stream (TaskStream.compact), otherwise retry once it has ended and its writes have settled`);
275
+ const e = new Error(`compacting session "${sessionId}" was refused: this Runner is using the session — a task is running or queued on it, a compaction or rewind of it is in progress, or a write one of its tasks issued has not settled — and compacting now would rewrite the transcript under that work, so nothing was compacted; a running task can compact through its own stream, otherwise retry once that work has ended and its writes have settled`);
276
276
  e.code = "compact.session_busy";
277
277
  return e;
278
278
  }
@@ -14,6 +14,7 @@ import { receiveCacheRetention } from "./model-lane-seat.js";
14
14
  import { assertJournalStoreGivesClaimsBack } from "../workflow-journal-store.js";
15
15
  import { screenPermissionModeWhenUnset } from "../mode-policy.js";
16
16
  import { receiveAutoModeFace } from "../auto-mode.js";
17
+ import { screenDeploymentShape } from "../deployment-shape.js";
17
18
  export function retainRunnerDeps(deps) {
18
19
  const words = { subject: "RunnerDeps", unit: "seat", moment: "at new Runner" };
19
20
  refuseProxy(deps, words);
@@ -38,6 +39,7 @@ export function retainRunnerDeps(deps) {
38
39
  Object.defineProperty(retained, "modelFallback", { value: receiveModelFallbackPolicy(Reflect.get(retained, "modelFallback"), "RunnerDeps.modelFallback"), enumerable: true, writable: true, configurable: true });
39
40
  receiveCacheRetention(retained.cacheRetention, "RunnerDeps.cacheRetention");
40
41
  screenPermissionModeWhenUnset(retained.permissionModeWhenUnset);
42
+ screenDeploymentShape(retained.deploymentShape, retained.crossBoundaryPosture);
41
43
  if (Object.hasOwn(retained, "autoMode"))
42
44
  Object.defineProperty(retained, "autoMode", { value: receiveAutoModeFace(Reflect.get(retained, "autoMode"), "RunnerDeps.autoMode"), enumerable: true, writable: true, configurable: true });
43
45
  const honorsReadChanges = retained.executionEnvFactoryHonorsReadChanges;
@@ -22,7 +22,7 @@
22
22
  */
23
23
  import type { AgentTool } from "../../internal/harness.js";
24
24
  import type { ExecutionEnv, SessionTreeEntry } from "../../internal/harness-types.js";
25
- import { type CrossBoundaryCheck, type CrossBoundaryPosture, type CrossBoundaryTreeToken, type OwedDeliveries } from "../cross-boundary-taint.js";
25
+ import { type BoundaryLeg, type CrossBoundaryCall, type CrossBoundaryCheck, type CrossBoundaryPosture, type CrossBoundaryTreeToken, type OwedDeliveries } from "../cross-boundary-taint.js";
26
26
  import type { NoticeRoute } from "../leg-identity.js";
27
27
  import { type ToolRoster } from "../tool-roster.js";
28
28
  import type { RunnerDeps } from "../types.js";
@@ -58,6 +58,10 @@ export interface CrossBoundaryLane {
58
58
  /** How many times this leg's record writes have waited on the session store — a station that judged before an exit reads again
59
59
  * when the count moved across it (the exit's own form: judged again after a wait). */
60
60
  storeWaits(): number;
61
+ /** The legs one call declares it travels, on its arguments, read off the live roster as the station reads them ({@link legsOfCall}:
62
+ * a call no row answers, or a `"per_call"` resolver that is missing, throws or answers outside its type, reads as every leg — the
63
+ * fault reported). Engaged or not: a confined Runner's mode point reads it for the one call it may release. */
64
+ legsOf(view: CrossBoundaryLegView, call: CrossBoundaryCall): readonly BoundaryLeg[];
61
65
  }
62
66
  /** What the seat reads per call: the live roster (the legs a row declares) and the mounted instances (a `"per_call"` row's resolver,
63
67
  * read off the later mount under the row's name — the instance the row was minted from, but in a redial window: KL-2284-c). */
@@ -90,5 +94,8 @@ export interface CrossBoundaryLaneInput {
90
94
  noticeRoute: NoticeRoute;
91
95
  deps: Pick<RunnerDeps, "onError" | "onNotice" | "tracer">;
92
96
  }
97
+ /** A confined Runner's destination reading for one call: it lands on the leg's hands (`onHands` — the sandbox boundary's own judgment:
98
+ * a hand of the environment with no egress mark) and every boundary leg it declares ({@link CrossBoundaryLane.legsOf}) is the environment's. */
99
+ export declare function destinationOnHands(onHands: boolean, legs: readonly BoundaryLeg[]): boolean;
93
100
  /** The leg's lane: the tree ref joined with what this leg knows, the session's record read and (when the state grew) written. */
94
101
  export declare function prepareCrossBoundaryLane(input: CrossBoundaryLaneInput): Promise<CrossBoundaryLane>;
@@ -62,6 +62,9 @@ function legsOfCall(view, legEnv, token, call, report) {
62
62
  return strictest("answered outside its type ({ legs: a list of boundary legs, env?: an environment })");
63
63
  return { legs: legs, env: env ?? legEnv };
64
64
  }
65
+ export function destinationOnHands(onHands, legs) {
66
+ return onHands && legs.every((leg) => leg === "env");
67
+ }
65
68
  export async function prepareCrossBoundaryLane(input) {
66
69
  const { posture, externalContentTargetActive, env, session, resumeLeg, sessionId, runId, hostTaskId, noticeRoute, deps } = input;
67
70
  const report = (message) => {
@@ -235,6 +238,7 @@ export async function prepareCrossBoundaryLane(input) {
235
238
  },
236
239
  owe: (atLeaf, owed) => write("suspend", atLeaf, () => owedBit(owed)),
237
240
  storeWaits: () => storeWaits,
241
+ legsOf: (view, call) => legsOfCall(view, env, token, call, report).legs,
238
242
  recorded: () => ref.current.targetExecutionArmed === true,
239
243
  settle: (owed, boundMs) => raceTeardownLegOr(() => write("settle", undefined, () => owedBit(owed)).then(() => undefined), "crossBoundary.settle (settle leg)", (timeout) => unwritten("settle", ref.current, timeout), boundMs),
240
244
  };
@@ -473,6 +473,13 @@ export interface GatePass {
473
473
  * or `declined`, or no answer): no row of the leg's read-deny table was applied to those reads. Writer: the fold's read
474
474
  * station. Reader: the release record ({@link releaseRecordOf}). */
475
475
  shellReadUnestablished?: true;
476
+ /** borrowed-mutable — the read check went silent over an ask a person was already required on (its real-approval bit stood,
477
+ * whoever brought it). Writer: the silence
478
+ * (`silencedBy`). Readers: a confined Runner's mode point and its headless way out (`confinedCallOf`). On no decision. */
479
+ silencePersonRequired?: boolean;
480
+ /** borrowed-mutable — the read station gave this call no answer (its wait elapsed or threw) and the gate put the station's fallback
481
+ * in its place. Writer: the fold's read station. Readers: a confined Runner's mode point and its headless way out (`confinedCallOf`). */
482
+ shellReadFallback?: true;
476
483
  /** borrowed-mutable — what the call's release read of the read-deny table those reads went past: the table, or `"unread"`.
477
484
  * Read once, by the first release record minted for the call; absent until a mode releases it. Writer and reader:
478
485
  * {@link releaseRecordOf}. */
@@ -2,6 +2,7 @@ import { DENIED_BY_MAY_ECHO, modeReleaseOf, readDenyTableOf, screenGateOutcome,
2
2
  import { traceHookCrash } from "../gate-crash-trace.js";
3
3
  import { thrownText } from "../thrown-value.js";
4
4
  import { ASK_CLASSES, askFaceOf, classifyAsk, headlessApprovalRemedy, withParkRemedy, NOBODY_CAN_APPROVE, unresolvedAskDenialMessage } from "../ask-origin.js";
5
+ import { confinedCallOf } from "../shell-read-silence.js";
5
6
  import { NOT_RESUMABLE_CARRY_ON, notResumableWayOut } from "../park-resumability.js";
6
7
  import { wireOf } from "../tool-name-readings.js";
7
8
  import { isProtectedWrite } from "../tool-registry.js";
@@ -394,7 +395,7 @@ export async function exitGate(pass) {
394
395
  const floated = ledger.settled?.origin === "ancestor_marked";
395
396
  const parkCanWait = unavailableLandingOf({ parkRoute: pass.suspendAsk !== undefined, suspendTargetGap: floated ? undefined : pass.suspendTargetGap, attemptFailed: false, question: false, durableQuestionFace: undefined }) === "park";
396
397
  const nobodyMayAnswer = input.askSeatForm !== undefined && input.askSeatForm !== "callback" && !parkCanWait && pass.askClassification?.classes.has("content_question") !== true;
397
- const remedyOf = (approverSeat) => headlessApprovalRemedy({ mode: input.permissionMode?.(), classification: foldCause !== undefined ? ancestorUnresolvedClassification(pass.req) : pass.askClassification, approverSeat, coveredWrite: isProtectedWrite(pass.req), ...(pass.shellUnplacedOptions !== undefined ? { unplacedOptions: pass.shellUnplacedOptions } : {}), ...(wayOut !== undefined ? { notResumableWayOut: wayOut } : {}) });
398
+ const remedyOf = (approverSeat) => headlessApprovalRemedy({ mode: input.permissionMode?.(), classification: foldCause !== undefined ? ancestorUnresolvedClassification(pass.req) : pass.askClassification, approverSeat, coveredWrite: isProtectedWrite(pass.req), ...(pass.shellUnplacedOptions !== undefined ? { unplacedOptions: pass.shellUnplacedOptions } : {}), ...(wayOut !== undefined ? { notResumableWayOut: wayOut } : {}), ...confinedCallOf(input.confined, pass, pass.policyRewrite ?? pass.currentInput, input.confined !== undefined ? input.trackedCwd?.() : undefined) });
398
399
  const headless = bindingRefusal !== undefined || remedySeat === undefined ? undefined : remedyOf(remedySeat);
399
400
  const parkNote = pass.parkFailed !== undefined ? ((r) => ({ kind: "failed", cause: pass.parkFailed, ...(r !== undefined ? { reason: r } : {}) }))(suspendLaneReasonOf(pass.parkFailedReason)) : unresolvable !== undefined && pass.parkTargetGap !== undefined ? { kind: "no_target", gap: pass.parkTargetGap } : undefined;
400
401
  const parkFailedSaid = parkNote?.kind === "failed" && headless !== undefined ? foreignLine(parkNote.cause, PARK_FAILURE_CAUSE_MAX) : "";
@@ -22,6 +22,9 @@ export declare function meteredDepsOf<D extends {
22
22
  /** The deployment's own bag behind a run's bag (itself for a bag that is no run's): the identity a once-per-deployment side
23
23
  * table keys on — a run's metered bag is a fresh object per run, and keying on it would say "once per deployment" once per run. */
24
24
  export declare function deploymentBagOf(deps: object): object;
25
+ /** Carry `from`'s deployment identity (`DEPLOYMENT_BAG`) onto a shallow copy minted before {@link meteredDepsOf} (e.g.
26
+ * role-map normalisation), so once-per-deployment side tables still key on the deployment's own bag. */
27
+ export declare function keepDeploymentOf<D extends object>(from: object, copy: D): D;
25
28
  /** The meter a run's bag carries, if it is one. */
26
29
  export declare function meterOf(deps: object): SpendMeter | undefined;
27
30
  /** The model lane over a deps bag's Brain seat and its fallback policy (`RunnerDeps.modelFallback`; absent ⇒ the default gate),
@@ -40,6 +40,10 @@ export function deploymentBagOf(deps) {
40
40
  const own = deps[DEPLOYMENT_BAG];
41
41
  return typeof own === "object" && own !== null ? own : deps;
42
42
  }
43
+ export function keepDeploymentOf(from, copy) {
44
+ Object.defineProperty(copy, DEPLOYMENT_BAG, { value: deploymentBagOf(from), enumerable: true, writable: true, configurable: true });
45
+ return copy;
46
+ }
43
47
  export function meterOf(deps) {
44
48
  const m = deps[RUN_METER];
45
49
  return m === undefined ? undefined : m;
@@ -64,6 +64,7 @@ import { type HomeViewSource, type PlacedReadDenyMatcher } from "../../tools/fs/
64
64
  import { type ReadStationMember } from "../../tools/fs/file-read-check.js";
65
65
  import { type ShellReadCheck } from "../../tools/fs/shell-read-check.js";
66
66
  import type { ReadAskRow } from "../../tools/fs/shell-read-judge.js";
67
+ import type { ConfinedDenyRows } from "../shell-read-silence.js";
67
68
  import { type SessionPermissionRules } from "../session-policy-store.js";
68
69
  import type { SkillGrantRecord } from "../skill-grant.js";
69
70
  import type { AgentTool, ExecutionEnv } from "../../internal/harness-types.js";
@@ -317,6 +318,11 @@ export declare function denySeatsOf(t: PathTables): {
317
318
  readonly read: ReadDenySeat;
318
319
  readonly write: WriteDenySeat;
319
320
  };
321
+ /** The deny rows ONE call may meet, as a confined Runner's mode point reads them (`ConfinedDenyRows`): on the call's own tables
322
+ * (`forCall(toolCallId)`, the read its judgment started with) or on the ones in force now (`forCall(undefined)`), by the presence
323
+ * rules the station's boundary is built with ({@link denySeatsOf}). Rows that could not be read (`unreadFor`), no tables (a leg
324
+ * without hands) or tables that could not be handed over (a throw) count as both kinds of row. */
325
+ export declare function confinedDenyRowsOf(tables: Pick<PathTablesFacade, "forCall"> | undefined, unreadFor: (toolCallId: string | undefined) => boolean, toolCallId: string): ConfinedDenyRows;
320
326
  /**
321
327
  * The leg's read stations as ONE gate input, each judgment on its call's pinned read of the person's rules: the station in
322
328
  * the fold judges ahead of the rule lanes, so it takes the call's read before it judges — the read every later consumer of
@@ -534,6 +534,19 @@ export function denySeatsOf(t) {
534
534
  }
535
535
  return seats;
536
536
  }
537
+ const EVERY_ROW = Object.freeze({ any: true, guardsWrites: true });
538
+ export function confinedDenyRowsOf(tables, unreadFor, toolCallId) {
539
+ try {
540
+ if (tables === undefined || unreadFor(toolCallId) || unreadFor(undefined))
541
+ return EVERY_ROW;
542
+ const seats = [tables.forCall(toolCallId), tables.forCall(undefined)].map(denySeatsOf);
543
+ const guardsWrites = seats.some((s) => s.write.writeDenyMatch !== undefined);
544
+ return { any: guardsWrites || seats.some((s) => s.read.denyMatch !== undefined), guardsWrites };
545
+ }
546
+ catch {
547
+ return EVERY_ROW;
548
+ }
549
+ }
537
550
  const VOUCHED = { disposition: "vouch", finding: "none" };
538
551
  export function onPinnedRead(rows, stations) {
539
552
  const check = composeReadChecks(stations);
@@ -24,6 +24,7 @@ import { malformedPricingField, priceTableOf } from "../pricing.js";
24
24
  import { ownMoneyCeiling, priceTableInput, unpricedModelRefusal } from "./side-call-account.js";
25
25
  import { fastTierNoticeTo } from "../fast-tier-door.js";
26
26
  import { receiveRoleMapPriced, resolveRunModel } from "./seat-model-doors.js";
27
+ import { keepDeploymentOf } from "./model-lane-seat.js";
27
28
  import { preflightLockedConfig, received } from "../locked-config.js";
28
29
  import { enterConfigDoor, refusalAbout, resolveSeatValue } from "../config-refusal-input.js";
29
30
  import { assertRetentionWords } from "../retention.js";
@@ -111,9 +112,12 @@ export function assertDurableApprovalDeclaresScope(declared) {
111
112
  const reading = readDeclaredCheckpointScope(declared);
112
113
  if (reading.kind === "scope")
113
114
  return;
114
- const e = limitConfigError("config.invalid_argument", `TaskSpec.durableApproval must be an object carrying a non-empty string \`scope\` (got ${typeof declared === "object" && declared !== null ? "an object" : describeRejectedValue(declared)}: ${reading.fault}) — the object is plain data (no accessor, no Proxy) and the scope is a name (visible content; no control, separator or format character), the rule \`isolationScope\` is judged by; it is the isolation key every durable approval is filed under, and the one a parked child's revival reads the opt-in back by; an opt-in that names none is refused, never read as the isolation scope on one path and as no opt-in on another. Set \`scope\`, or omit \`durableApproval\`.`);
115
- e.detail = { field: "durableApproval.scope" };
116
- throw e;
115
+ const message = reading.at === "ttlMs"
116
+ ? `TaskSpec.durableApproval.ttlMs must be a finite number >= 0 when present (got ${reading.fault}) — the opt-in is read as plain data, and its \`ttlMs\` is the lifetime of every approval parked under it; omit \`ttlMs\` for an approval no operator bounds.`
117
+ : reading.at === "undeclared"
118
+ ? `TaskSpec.durableApproval must be plain data (got ${reading.fault} in a member the opt-in does not declare) — an opt-in carries \`scope\` and, optionally, \`ttlMs\`; remove the other member.`
119
+ : `TaskSpec.durableApproval must be an object carrying a non-empty string \`scope\` (got ${typeof declared === "object" && declared !== null ? "an object" : describeRejectedValue(declared)}: ${reading.fault}) — the object is plain data (no accessor, no Proxy) and the scope is a name (visible content; no control, separator or format character), the rule \`isolationScope\` is judged by; it is the isolation key every durable approval is filed under, and the one a parked child's revival reads the opt-in back by; an opt-in that names none is refused, never read as the isolation scope on one path and as no opt-in on another. Set \`scope\`, or omit \`durableApproval\`.`;
120
+ throw Object.assign(limitConfigError("config.invalid_argument", message), { detail: { field: reading.at === "ttlMs" ? "durableApproval.ttlMs" : reading.at === "undeclared" || (reading.at === undefined && reading.fault.startsWith("not plain data — ")) ? "durableApproval" : "durableApproval.scope" } });
117
121
  }
118
122
  export function assertDurableApprovalDeclaration(declared) {
119
123
  assertDurableApprovalDeclaresScope(declared);
@@ -266,7 +270,7 @@ export function configValueDoors(input) {
266
270
  const promptHost = enterConfigDoor("taskConfig", () => resolveHost(spec));
267
271
  const deploymentRoles = enterConfigDoor("deps", () => receiveRoleMapPriced(deps.roles, "RunnerDeps.roles", deps.pricing, input.tellFastTier));
268
272
  if (deploymentRoles !== undefined)
269
- deps = { ...deps, roles: deploymentRoles };
273
+ deps = keepDeploymentOf(deps, { ...deps, roles: deploymentRoles });
270
274
  const taskRoles = enterConfigDoor("taskConfig", () => receiveRoleMapPriced(spec.roles, "TaskSpec.roles", deps.pricing, input.tellFastTier));
271
275
  const promptBinding = enterConfigDoor("taskConfig", () => resolvePromptBinding(spec));
272
276
  const promptLocale = enterConfigDoor("taskConfig", () => resolvePromptLocale(spec));
@@ -442,7 +446,7 @@ export function prepareConfigDoors(input) {
442
446
  const tellFastTier = input.refusalSink !== undefined ? fastTierNoticeTo(input.refusalSink, callerSpec.sessionId ?? "(pre-session)") : undefined;
443
447
  const { toolFaceLists, promptHost, promptBinding, promptLocale, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin, nestedMemory, deploymentRoles, hostInstance, taskRoles, resolvedInteractionPosture, interactionPostureInput } = configValueDoors({ spec: callerSpec, deps: input.deps, resumeLeg: resume !== undefined, sessions, leg: internals, parentInteractionPosture: internals?.parentInteractionPosture, discloseInteractionPosture: discloseInteractionPostureRefusal, ...(tellFastTier !== undefined ? { tellFastTier } : {}), receivedPeers: input.receipt, ...(resume !== undefined ? { resumedRow: { recorded: screenRecordedRunOrigin(resume.seed.runOrigin), ...(resume.opening !== undefined ? { opening: resume.opening } : {}) } } : {}) });
444
448
  const doorRead = (value) => ({ value, enumerable: value !== undefined, writable: false, configurable: false });
445
- const deps = deploymentRoles !== undefined || hostInstance !== undefined ? { ...input.deps, ...(deploymentRoles !== undefined ? { roles: deploymentRoles } : {}), ...(hostInstance !== undefined ? { host: hostInstance } : {}) } : input.deps;
449
+ const deps = deploymentRoles !== undefined || hostInstance !== undefined ? keepDeploymentOf(input.deps, { ...input.deps, ...(deploymentRoles !== undefined ? { roles: deploymentRoles } : {}), ...(hostInstance !== undefined ? { host: hostInstance } : {}) }) : input.deps;
446
450
  const declaredDurableApproval = callerSpec.durableApproval;
447
451
  const hostApprovalParksNotResumable = declaredDurableApproval === false;
448
452
  let spec = Object.create(Object.getPrototypeOf(callerSpec), { ...Object.getOwnPropertyDescriptors(callerSpec), skills: doorRead(skills), projectMemory: doorRead(projectMemory), runOrigin: doorRead(runOrigin), durableApproval: doorRead(hostApprovalParksNotResumable ? undefined : declaredDurableApproval), ...(taskRoles !== undefined ? { roles: doorRead(taskRoles) } : {}) });
@@ -182,6 +182,12 @@ export interface PrepareGateStationsInput {
182
182
  shellReadCheck: ShellReadCheck | undefined;
183
183
  /** borrowed-readonly — the leg's cross-boundary seat (`ToolGateInput.crossBoundaryCheck`), or undefined on a leg whose station is not engaged. */
184
184
  crossBoundaryCheck: import("../cross-boundary-taint.js").CrossBoundaryCheck | undefined;
185
+ /** borrowed-readonly — PRESENT ⇔ the Runner declares its shape (`RunnerDeps.deploymentShape`): the legs one call declares, off the
186
+ * leg's cross-boundary lane (`CrossBoundaryLane.legsOf`), and the deny rows one call may meet — the gate's `confined` seat reads them. */
187
+ confinedLeg?: {
188
+ readonly legsOf: (call: import("../cross-boundary-taint.js").CrossBoundaryCall) => readonly import("../cross-boundary-taint.js").BoundaryLeg[];
189
+ readonly denyRows: (toolCallId: string) => import("../shell-read-silence.js").ConfinedDenyRows;
190
+ };
185
191
  /** borrowed-readonly — the leg's resolved read face (`undefined` with no hands), read per call into the class derivation. */
186
192
  readFace: () => ContainmentFace | undefined;
187
193
  /** borrowed-readonly — the read-deny table the call is judged with (`ToolGateInput.readDenyInForce`): the active built-in
@@ -19,6 +19,7 @@ import { callParkRoute, extensionCallOf } from "../mods/extension-call.js";
19
19
  import { extensionCallOverlap } from "../mods/tool-call.js";
20
20
  import { leavesByEscape } from "../command-sandbox.js";
21
21
  import { perTaskEnvParkRefusal } from "../remote-env.js";
22
+ import { destinationOnHands } from "./cross-boundary-lane.js";
22
23
  const PEER_MESSAGE_NAMES = new Set([SEND_MESSAGE_TOOL_NAME]);
23
24
  function screenGateResult(result) {
24
25
  if (result.suspend !== undefined)
@@ -52,7 +53,7 @@ export function maybeHumanRejectionHalt(input) {
52
53
  };
53
54
  }
54
55
  export function prepareGateStations(input) {
55
- const { askLane, parkAsk, tools, refusedAsks, toolRosterDeltas, deps, toolCallGateArmedRef, effectivePolicy, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, deferredAskIdentities, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, hookScreens, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, legNotice, handsCwdRef, stampCallTarget, hookEnvFace, writeProtectionCheck, shellReadCheck, crossBoundaryCheck, readFace, readDenyInForce, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, askRoute, notResumable, permissionMode, toolMarkSources, a2aIsolatePeers, a2aInsidePeerOf, ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, durableQuestionFace, suspendTargetGap, continuationCalls, workflowParkGap, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, seatInputsFor, modBus, inheritedInstallations, commandSandboxArmed, sandboxPlanOf } = input;
56
+ const { askLane, parkAsk, tools, refusedAsks, toolRosterDeltas, deps, toolCallGateArmedRef, effectivePolicy, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, deferredAskIdentities, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, hookScreens, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, legNotice, handsCwdRef, stampCallTarget, hookEnvFace, writeProtectionCheck, shellReadCheck, crossBoundaryCheck, confinedLeg, readFace, readDenyInForce, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, askRoute, notResumable, permissionMode, toolMarkSources, a2aIsolatePeers, a2aInsidePeerOf, ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, durableQuestionFace, suspendTargetGap, continuationCalls, workflowParkGap, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, seatInputsFor, modBus, inheritedInstallations, commandSandboxArmed, sandboxPlanOf } = input;
56
57
  const noticeAddress = legNotice.route.address;
57
58
  const admitsLegNotice = legNotice.admission;
58
59
  const tellAskUnresolvable = askUnresolvableTeller(noticeAddress);
@@ -135,6 +136,7 @@ export function prepareGateStations(input) {
135
136
  ...seatInputsFor(e.toolName, wireOf("gate.skillActivationSeat", call)),
136
137
  ...(mountedToolRequiresUserInteraction(tools, e.toolName) ? { requiresUserInteraction: true } : {}),
137
138
  ...(commandSandboxArmed ? { leavesCommandSandbox: (args) => leavesByEscape(sandboxPlanOf({ toolName: e.toolName, toolCallId: e.toolCallId, args })) } : {}),
139
+ ...(confinedLeg !== undefined ? { confined: { staysOnHands: (args) => destinationOnHands(!sandboxBoundaryCapable(call), confinedLeg.legsOf({ toolName: e.toolName, args, toolCallId: e.toolCallId })), bypassArmed: () => permissionMode.armsAs("bypassPermissions") === "bypassPermissions", denyRows: () => confinedLeg.denyRows(e.toolCallId) } } : {}),
138
140
  ...(a2aIsolatePeers === true ? { a2aIsolatePeers: true } : {}),
139
141
  ...((inside) => (inside !== undefined ? { a2aInsidePeer: inside } : {}))(a2aInsidePeerOf(e.toolName)),
140
142
  ancestorArbitrationOf: (toolCallId) => ancestorArbitrations.get(toolCallId),
@@ -252,9 +252,10 @@ export async function prepareHandsMount(input) {
252
252
  backgroundTaskToolsActive = roster.mounts.holds("monitor");
253
253
  const shellFaceHere = roster.mounts.holding((e) => isShellFaceToolName(e.name));
254
254
  const checkpointTracked = resume?.seed.handsCwd !== undefined;
255
- wsSnapshot = checkpointTracked || !(handsIncludeShell && !handsReadOnly) ? undefined : await session.getWorkspaceState().catch(() => undefined);
255
+ const tracksCwd = (handsIncludeShell && !handsReadOnly) || roster.mounts.holds("enter-worktree");
256
+ wsSnapshot = checkpointTracked || !tracksCwd ? undefined : await session.getWorkspaceState().catch(() => undefined);
256
257
  rebaseWsPath = (p) => (wsSnapshot === undefined || wsSnapshot.taskRoot === rootCanonical ? p : rebaseWorkspacePath(p, wsSnapshot.taskRoot, rootCanonical));
257
- if (handsIncludeShell && !handsReadOnly) {
258
+ if (tracksCwd) {
258
259
  handsCwdRef = { current: rootCanonical };
259
260
  if (resume?.seed.handsCwd !== undefined)
260
261
  handsCwdRef.current = rebaseRestoredPath(resume.seed.handsCwd);
@@ -41,7 +41,7 @@ export function prepareOffloadWrappers(input) {
41
41
  const maybeOffload = (tool, perTool) => {
42
42
  if (!offloadStore || perTool?.offload === false)
43
43
  return tool;
44
- return withToolResultOffload(tool, offloadStore, perTool?.offloadThresholdChars ?? offloadThreshold, sessionId, () => offloadReachableToolsRef.current?.());
44
+ return withToolResultOffload(tool, offloadStore, perTool?.offloadThresholdChars ?? offloadThreshold, sessionId, () => offloadReachableToolsRef.current?.(), deps.onNotice);
45
45
  };
46
46
  const firstPartyOffload = (tool) => {
47
47
  const face = faceOf(tool);
@@ -20,7 +20,7 @@ import { isValidReminderMark, mintReminderMark } from "../reminder-mint.js";
20
20
  import { renderOutputStyle } from "../output-style.js";
21
21
  import { prepareLanguageSeat } from "./language-frame.js";
22
22
  import { emitTrace } from "../trace.js";
23
- import { personPathRowsOfTask, ruleRowsDroppedNotice } from "./person-path-rows.js";
23
+ import { confinedDenyRowsOf, personPathRowsOfTask, ruleRowsDroppedNotice } from "./person-path-rows.js";
24
24
  import { ruleStoreUnreadableNotice } from "./rule-store-unreadable-notice.js";
25
25
  import { STALL_FIRST_BYTE_MS, STALL_FIRST_TOKEN_MS, STALL_IDLE_MS, withBrainCallGuardrail } from "../../brain/timeout.js";
26
26
  import { createFastModeLeg, SessionFastModeSeats } from "./fast-mode-seat.js";
@@ -114,6 +114,7 @@ import { sessionAddressOf } from "../task-notification.js";
114
114
  import { createFrameSettlement } from "../frame-settlement.js";
115
115
  import { announceSchedulerStoreUnmoved, createSchedulerTools } from "../../tools/scheduler-tools.js";
116
116
  import { readSchedulerDeclaration } from "../scheduler.js";
117
+ import { announceModelShellUnmounted, readModelShell } from "../model-shell.js";
117
118
  import { selfOrchestrationFailClosedReason } from "../../orchestration/workflow-script-runner.js";
118
119
  import { runLedgerBookFor, withRunLedgerTask } from "../run-ledger.js";
119
120
  import { managerLaunchCheck, managerLaunchCheckSentence, managerLaunchFactsOf, managerLaunchNarrowedNotice } from "../manager-launch-check.js";
@@ -410,7 +411,6 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
410
411
  if (!handsEnabled)
411
412
  refuseUserAttachmentPathsWithoutWorkspace(userAttachmentsSeat);
412
413
  const schedulerReading = readSchedulerDeclaration(executionEnv);
413
- const mountFacts = { ...legMountFacts, ...envMountFacts(handsEnabled, executionEnv, schedulerReading) };
414
414
  const externalContentTargetActive = targetIsExternal(executionEnv) !== false || resume?.seed.externalContentTarget === true || internals?.externalContentTarget === true;
415
415
  const crossBoundaryTree = joinedCrossBoundaryTree(internals?.crossBoundaryTree, (m) => deps.onError?.(new Error(m), { phase: "config", sessionId }));
416
416
  const abortController = new AbortController();
@@ -483,6 +483,8 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
483
483
  }
484
484
  const ownedEnv = ownedEnvSeat.current;
485
485
  const { taskRootFinal: taskRootRestored, rebaseRestoredPath, remote: workspaceRemote, ownTarget } = await prepareWorkspaceRestore({ ownedEnv, deps, spec, resume, taskRootInitial, placementFence, abortController, sessionId });
486
+ const modelShellReading = handsEnabled ? await readModelShell(executionEnv) : { kind: "undeclared" };
487
+ const mountFacts = { ...legMountFacts, ...envMountFacts(handsEnabled, executionEnv, schedulerReading, modelShellReading.kind === "mounted") };
486
488
  const reportWorkspace = (cwd) => {
487
489
  if (internals?.onWorkspaceResolved === undefined)
488
490
  return;
@@ -765,6 +767,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
765
767
  const { worktreeSessionRef, sendMessageTier } = prepareDelegationSurface({ runLedger: runLedgerSeats, spec, deps, internals, resume, sessionId, sessionAddress, legOccupant, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, shellReadAdmission, runReadFloor: runFloor, ...(commandSandboxStart !== undefined ? { commandSandbox: commandSandboxStart } : {}), peerLaneActive, peerLaneRefs, sessionBox, roster, toolEffects, axisExplicitNegatives, toolFaceSnapshot, firstPartyOffload, offloadStore, toolResultBytes, taskArtifacts, subagentRetain, continuationReach, enrichSpecToolCtx, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle, worktreeSeat });
766
768
  const { liveQuestionFace, contentAskBindings, contentAskRoutable, strandLateAnswer, settleContentAskBindings, durableQuestionFace, questionToolMounted, mountedQuestionTool } = prepareQuestionFace({ frozenOnQuestion, spec, askSource, deps, checkpointStore, runtimeCaps, approvalParkNotResumable, resolvedInteractionPosture, resume, sessionId, roster, inheritedUnavailableAsks: () => inheritedUnavailableAsks });
767
769
  announceSchedulerStoreUnmoved(schedulerReading, deps.onNotice);
770
+ announceModelShellUnmounted(modelShellReading, mountFacts, deps.onNotice);
768
771
  if (roster.mounts.holds("cron-list")) {
769
772
  roster.mountAll(createSchedulerTools(executionEnv, {
770
773
  ...(spec.principal !== undefined ? { principal: spec.principal } : {}),
@@ -1017,7 +1020,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
1017
1020
  legParkClosureSeat.built = parkAsk?.suspendAsk !== undefined;
1018
1021
  legParkClosureSeat.suspendTargetGap = suspendTargetGap;
1019
1022
  const seatInputsFor = skillGateWiring({ tools, skillToolName: SKILL_TOOL_NAME, seatOf: skillSeatOf, mode: () => permissionMode.current, lane: skillGrantLane, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.skill_allowed", version: 1, taskId: hostTaskId, ...info, entries: [...info.entries], ts: Date.now() })), allowEntries: { deploymentAllows: { ...allowEntryLanes.deployment, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.allowed_tools_allowed", version: 1, taskId: hostTaskId, source: "deployment", ...info, entries: [...info.entries], ts: Date.now() })) }, requestAllows: { ...allowEntryLanes.request, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.allowed_tools_allowed", version: 1, taskId: hostTaskId, source: "request", ...info, entries: [...info.entries], ts: Date.now() })) } } });
1020
- const { approvedCallScreen, continuationGate } = prepareGateStations({ askLane, parkAsk, tools, refusedAsks, toolRosterDeltas: rosterSeat, crossBoundaryCheck: crossBoundary.seat({ tools, roster: rosterSeat }), deps, toolCallGateArmedRef, effectivePolicy, modBus: legMods.bus, inheritedInstallations, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, deferredAskIdentities, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, hookScreens, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, legNotice, handsCwdRef, stampCallTarget, readDenyInForce: (toolCallId) => ({ tiers: handsReadFace.readDenyBuiltinTiersActive, rows: [...readDenyAdditionsNormalized.map((e) => e.pattern), ...(pathTables?.forCall(toolCallId).ruleRows ?? handsReadFaceInput.denyRuleRows).filter((r) => r.faces.includes("read")).map((r) => r.rule)] }), hookEnvFace, writeProtectionCheck, shellReadCheck, readFace: () => resolvedReadFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider: autoModeDeciderRef, autoModeDenialTracking: autoModeDenialTrackingRef, askRoute: { ...wiringManifest.ask, effective: askSeatWord }, notResumable: legNotResumable, permissionMode, toolMarkSources, ...(deps.a2a?.isolatePeers === true ? { a2aIsolatePeers: true } : {}), a2aInsidePeerOf: a2aInsidePeerReader(lockedPreflight.a2a, deps.a2a?.isolatePeers === true), ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane: permissionRuleGateLane, seatInputsFor, permissionRuleOrgLane, questionToolMounted, durableQuestionFace, suspendTargetGap, continuationCalls: legParkClosureSeat.continuationCalls, workflowParkGap: internals?.workflowParkGap, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, commandSandboxArmed: commandSandboxRun.state === "armed", sandboxPlanOf });
1023
+ const { approvedCallScreen, continuationGate } = prepareGateStations({ askLane, parkAsk, tools, refusedAsks, toolRosterDeltas: rosterSeat, crossBoundaryCheck: crossBoundary.seat({ tools, roster: rosterSeat }), ...(deps.deploymentShape !== undefined ? { confinedLeg: { legsOf: (call) => crossBoundary.legsOf({ tools, roster: rosterSeat }, call), denyRows: (toolCallId) => confinedDenyRowsOf(pathTables, (id) => personRows.unreadFor(id), toolCallId) } } : {}), deps, toolCallGateArmedRef, effectivePolicy, modBus: legMods.bus, inheritedInstallations, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, deferredAskIdentities, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, hookScreens, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, legNotice, handsCwdRef, stampCallTarget, readDenyInForce: (toolCallId) => ({ tiers: handsReadFace.readDenyBuiltinTiersActive, rows: [...readDenyAdditionsNormalized.map((e) => e.pattern), ...(pathTables?.forCall(toolCallId).ruleRows ?? handsReadFaceInput.denyRuleRows).filter((r) => r.faces.includes("read")).map((r) => r.rule)] }), hookEnvFace, writeProtectionCheck, shellReadCheck, readFace: () => resolvedReadFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider: autoModeDeciderRef, autoModeDenialTracking: autoModeDenialTrackingRef, askRoute: { ...wiringManifest.ask, effective: askSeatWord }, notResumable: legNotResumable, permissionMode, toolMarkSources, ...(deps.a2a?.isolatePeers === true ? { a2aIsolatePeers: true } : {}), a2aInsidePeerOf: a2aInsidePeerReader(lockedPreflight.a2a, deps.a2a?.isolatePeers === true), ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane: permissionRuleGateLane, seatInputsFor, permissionRuleOrgLane, questionToolMounted, durableQuestionFace, suspendTargetGap, continuationCalls: legParkClosureSeat.continuationCalls, workflowParkGap: internals?.workflowParkGap, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, commandSandboxArmed: commandSandboxRun.state === "armed", sandboxPlanOf });
1021
1024
  const postureFrameRef = { report: (err) => deps.onError?.(err, { phase: "degraded", sessionId }) };
1022
1025
  const limitApproachRef = {};
1023
1026
  const renderTurnStartRequest = async (view, signal) => {
@@ -173,10 +173,9 @@ export function prepareWiringManifest(input) {
173
173
  ungatedWarnedShapes.set(deployment, shapes);
174
174
  }
175
175
  shapes.add(what);
176
- deps.onError?.(new Error(`write-capable ${what} are present but UNGATED — ` +
177
- (hasEffectAwareGate
178
- ? `no question of the ${permissionMode.current} mode reaches their calls. `
179
- : `wire an effect-aware tool policy (or a PreToolUse hook). bash/MCP irreversible actions are otherwise unadjudicated; the deployment sandbox/egress boundary is the only protection. `) +
176
+ deps.onError?.(new Error((hasEffectAwareGate
177
+ ? `write-capable ${what} are present and no question of the ${permissionMode.current} mode reaches their calls — a tool policy the deployment wired may still ask about a call; this warning does not see what it decides. `
178
+ : `write-capable ${what} are present but UNGATED — wire an effect-aware tool policy (or a PreToolUse hook). bash/MCP irreversible actions are otherwise unadjudicated; the deployment sandbox/egress boundary is the only protection. `) +
180
179
  (peerWriteUngated.length > 0 ? `Under ${permissionMode.current} a server's tools run with nobody stating them; a deny or ask rule naming them still gates them. ` : "") +
181
180
  (callerWriteUnasked.length > 0
182
181
  ? `Under ${permissionMode.current} a caller's tool that declares no permission seat answers for itself: the mode's question never reaches its calls (in auto, the classifier rules only on what a rule or a policy asks); declare permissionSeat: "passthrough" on it to put each call to the mode's question. A deny or ask rule naming it still gates it, and a read target it declares (pathTarget access "read") is judged by the read station whatever its seat. `