@sema-agent/core 7.71.1 → 7.72.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 (151) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/dist/agents/cross-session-ref.d.ts +2 -2
  3. package/dist/agents/cross-session-ref.js +7 -2
  4. package/dist/agents/inherited-tool-pool.d.ts +4 -1
  5. package/dist/agents/inherited-tool-pool.js +7 -5
  6. package/dist/agents/send-message-tool.js +6 -2
  7. package/dist/agents/subagent.js +5 -1
  8. package/dist/agents/verify.js +1 -0
  9. package/dist/core/a2a.d.ts +24 -3
  10. package/dist/core/a2a.js +27 -8
  11. package/dist/core/agent-state.d.ts +28 -7
  12. package/dist/core/agent-state.js +19 -6
  13. package/dist/core/approval-object.d.ts +7 -3
  14. package/dist/core/approval-object.js +30 -9
  15. package/dist/core/checkpoint-features.d.ts +13 -3
  16. package/dist/core/checkpoint-features.js +34 -5
  17. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  18. package/dist/core/checkpoint-row-verdict.js +3 -3
  19. package/dist/core/effective-path-target.d.ts +19 -0
  20. package/dist/core/effective-path-target.js +95 -38
  21. package/dist/core/engine-notice.d.ts +4 -1
  22. package/dist/core/engine-version.js +1 -1
  23. package/dist/core/file-history-store.d.ts +15 -4
  24. package/dist/core/file-history-store.js +53 -23
  25. package/dist/core/gate-fold.js +3 -1
  26. package/dist/core/governance-codes.d.ts +4 -1
  27. package/dist/core/governance-codes.js +4 -0
  28. package/dist/core/judged-read.d.ts +57 -0
  29. package/dist/core/judged-read.js +1 -0
  30. package/dist/core/mcp-host-seat.d.ts +5 -0
  31. package/dist/core/mcp-host-seat.js +7 -1
  32. package/dist/core/mcp.js +3 -1
  33. package/dist/core/memory-engine/index.d.ts +1 -1
  34. package/dist/core/memory-engine/index.js +1 -1
  35. package/dist/core/memory-engine/layout.js +6 -4
  36. package/dist/core/memory-engine/scope-contract.d.ts +59 -6
  37. package/dist/core/memory-engine/scope-contract.js +90 -25
  38. package/dist/core/mounted-mcp.d.ts +7 -2
  39. package/dist/core/mounted-mcp.js +10 -1
  40. package/dist/core/param-rule-reach.d.ts +8 -3
  41. package/dist/core/param-rule-reach.js +9 -1
  42. package/dist/core/parent-spec-seat.d.ts +11 -1
  43. package/dist/core/parent-spec-seat.js +14 -0
  44. package/dist/core/peer-registration.d.ts +52 -0
  45. package/dist/core/peer-registration.js +37 -0
  46. package/dist/core/peer-seat.d.ts +3 -1
  47. package/dist/core/permission-rule-model.js +1 -1
  48. package/dist/core/runner/chain-mismatch.d.ts +32 -0
  49. package/dist/core/runner/chain-mismatch.js +29 -0
  50. package/dist/core/runner/changes-history.d.ts +1 -0
  51. package/dist/core/runner/changes-history.js +2 -2
  52. package/dist/core/runner/contracts.d.ts +3 -0
  53. package/dist/core/runner/file-history-restore.d.ts +3 -1
  54. package/dist/core/runner/file-history-restore.js +9 -6
  55. package/dist/core/runner/loaded-skills.d.ts +2 -0
  56. package/dist/core/runner/loaded-skills.js +10 -0
  57. package/dist/core/runner/person-path-rows.d.ts +2 -4
  58. package/dist/core/runner/person-path-rows.js +2 -3
  59. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
  60. package/dist/core/runner/prepare-caps-and-workflow.js +7 -2
  61. package/dist/core/runner/prepare-file-history.js +1 -1
  62. package/dist/core/runner/prepare-hands-readface.d.ts +5 -0
  63. package/dist/core/runner/prepare-hands-readface.js +24 -21
  64. package/dist/core/runner/prepare-inherited-gate.d.ts +2 -2
  65. package/dist/core/runner/prepare-inherited-gate.js +1 -1
  66. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
  67. package/dist/core/runner/prepare-memory-engine-session.js +2 -2
  68. package/dist/core/runner/prepare-memory.js +3 -15
  69. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  70. package/dist/core/runner/prepare-project-context.js +3 -7
  71. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
  72. package/dist/core/runner/prepare-protocol-tools.js +2 -2
  73. package/dist/core/runner/prepare-task.js +20 -16
  74. package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -0
  75. package/dist/core/runner/prepare-wiring-manifest.js +4 -3
  76. package/dist/core/runner/read-session-changes.js +1 -1
  77. package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
  78. package/dist/core/runner/resume-checkpoint-screen.js +7 -6
  79. package/dist/core/runner/rewind-files.js +3 -2
  80. package/dist/core/runner/run-leg.js +6 -2
  81. package/dist/core/runner/terminal-account.d.ts +4 -0
  82. package/dist/core/runner/terminal-account.js +7 -2
  83. package/dist/core/runner/tool-face-overlay.d.ts +2 -11
  84. package/dist/core/runner/tool-face-overlay.js +39 -0
  85. package/dist/core/runner/trim-stretch.js +7 -2
  86. package/dist/core/scheduler.d.ts +47 -7
  87. package/dist/core/scheduler.js +19 -7
  88. package/dist/core/secret-env.d.ts +7 -0
  89. package/dist/core/secret-env.js +1 -1
  90. package/dist/core/sensitive-path-policy.js +14 -7
  91. package/dist/core/shell-read-silence.js +1 -0
  92. package/dist/core/store-contracts/checkpoint-store-contract.js +7 -0
  93. package/dist/core/task-event.d.ts +4 -3
  94. package/dist/core/task-notification.d.ts +2 -1
  95. package/dist/core/task-spec.d.ts +13 -5
  96. package/dist/core/tool-catalog-entries.js +2 -0
  97. package/dist/core/tool-face-reader.js +1 -1
  98. package/dist/core/tool-face.d.ts +7 -0
  99. package/dist/core/tool-face.js +1 -0
  100. package/dist/core/tool-mount-facts.d.ts +4 -2
  101. package/dist/core/tool-mount-facts.js +3 -3
  102. package/dist/core/tool-mount-plan.d.ts +4 -2
  103. package/dist/core/tool-mount-plan.js +5 -5
  104. package/dist/core/tool-mount-static.d.ts +1 -1
  105. package/dist/core/tool-mount-static.js +25 -13
  106. package/dist/core/tool-registry.d.ts +33 -1
  107. package/dist/core/tool-registry.js +33 -0
  108. package/dist/core/tool-roster.d.ts +16 -0
  109. package/dist/core/tool-roster.js +6 -0
  110. package/dist/core/tool-spec.d.ts +4 -2
  111. package/dist/core/tools.d.ts +6 -0
  112. package/dist/core/tools.js +1 -1
  113. package/dist/core/wiring-manifest.d.ts +66 -12
  114. package/dist/core/wiring-manifest.js +37 -1
  115. package/dist/engine/harness/messages.d.ts +1 -1
  116. package/dist/engine/harness/messages.js +2 -1
  117. package/dist/engine/loop/types.d.ts +2 -0
  118. package/dist/engine/session/session.js +1 -1
  119. package/dist/index.d.ts +9 -5
  120. package/dist/index.js +7 -4
  121. package/dist/orchestration/workflow.js +2 -1
  122. package/dist/stores/file/adoption/marker.d.ts +2 -27
  123. package/dist/stores/file/adoption/marker.js +12 -0
  124. package/dist/stores/file/index.d.ts +1 -1
  125. package/dist/stores/file/index.js +1 -1
  126. package/dist/tools/artifact/artifact-tool.js +11 -6
  127. package/dist/tools/fs/file-read-check.d.ts +45 -11
  128. package/dist/tools/fs/file-read-check.js +200 -57
  129. package/dist/tools/fs/judged-reads.d.ts +51 -0
  130. package/dist/tools/fs/judged-reads.js +68 -0
  131. package/dist/tools/fs/safety.d.ts +8 -0
  132. package/dist/tools/fs/safety.js +12 -1
  133. package/dist/tools/fs/shell-read-check.d.ts +16 -3
  134. package/dist/tools/fs/shell-read-check.js +4 -1
  135. package/dist/tools/fs/shell-read-establish.js +13 -3
  136. package/dist/tools/scheduler-store-move.d.ts +74 -0
  137. package/dist/tools/scheduler-store-move.js +103 -0
  138. package/dist/tools/scheduler-tools.d.ts +43 -29
  139. package/dist/tools/scheduler-tools.js +161 -118
  140. package/package.json +2 -2
  141. package/test/export-surface.snapshot.json +43 -3
  142. package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
  143. package/wire-changes/answers/core@7.72.0.json +84 -0
  144. package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
  145. package/wire-changes/answers/primitives@7.72.0.json +6 -0
  146. package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
  147. package/wire-changes/core-stores-sql@7.72.0.json +215 -0
  148. package/wire-changes/core@7.72.0.json +2426 -0
  149. package/wire-changes/mods-kernel@7.72.0.json +147 -0
  150. package/wire-changes/primitives@7.72.0.json +143 -0
  151. package/wire-changes/wiki-gate@7.72.0.json +145 -0
@@ -0,0 +1,52 @@
1
+ /**
2
+ * A protocol peer's REGISTRATION as a person's yes binds it: the declaration as the host wrote it — the facts it states about where a
3
+ * call to the peer's tools goes, as whom and with which identity, each as written (no spelling is judged equal to another: the
4
+ * deployment's peer seat is handed the spelling and may answer each differently), read off the declaration the dial judged by that
5
+ * protocol's materializer (`a2aPeerRegistration`, `mcpPeerRegistration`), never off the peer. The one equality is a default the
6
+ * declaration type itself states (`boundary` absent is `outside`, `callerMeta` absent is `false`), which the materializer writes out.
7
+ *
8
+ * A tool carries only their digest (`AgentTool.peerRegistration`), minted here once; the roster row copies it
9
+ * (`ToolRosterEntry.registration`, a declaration member), so a parked approval's declaration digest covers the registration and a
10
+ * resume whose registration moved — another spelling included — vetoes the approved call (`resume.target_moved`). The digest is
11
+ * deterministic and unsalted: one registration has one digest in every frame and deployment. The facts never ride the tool object: it
12
+ * is handed whole to a host's model adapter and counted by the spend meter.
13
+ */
14
+ import type { CredentialRef } from "@sema-agent/primitives";
15
+ import type { A2aServerSpec, McpServerSpec, McpTransportKind } from "./mcp-server-spec.js";
16
+ /** The facts of one registration: JSON data (strings, lists of strings, a credential reference record), an absent fact not a key. */
17
+ export type PeerRegistrationFacts = {
18
+ readonly [fact: string]: unknown;
19
+ };
20
+ /** The digest a tool carries for its peer's registration, keyed by protocol (an MCP server's facts and an A2A peer's never read as one
21
+ * another's). The one mint of `AgentTool.peerRegistration`. */
22
+ export declare function peerRegistrationDigestOf(source: "mcp" | "a2a", facts: PeerRegistrationFacts): string;
23
+ /**
24
+ * A credential reference as a registration fact, by its content (`CREDENTIAL_REF_KINDS`): its kind always — declaring none and
25
+ * declaring one are two registrations — and, for a reference that IS its own content, the rest as written: `env` (header → variable
26
+ * names), `vault` (the stored entry it names), `assertion` (the audience it is requested for). A `handle`'s id is not content: an opaque
27
+ * id the deployment minted, which a deployment may mint again per process for the same credential, so a handle enters as its kind
28
+ * alone (KL-5333-c). The one reading both protocols take.
29
+ */
30
+ export declare function credentialReferenceFact(ref: CredentialRef | undefined): {
31
+ credentials?: CredentialRef | {
32
+ readonly kind: "handle";
33
+ };
34
+ };
35
+ /**
36
+ * An A2A peer's registration facts, each as the host wrote it: its addresses (`url`, `cardUrl`), its side of the trust boundary (absent
37
+ * is `outside`, the declaration type's own default), its owning team, its identity stamp, its credential reference when that is its own
38
+ * content ({@link credentialReferenceFact}) and the header the end user's identity rides under. Not among them: its display name (the
39
+ * card's label for people, as a row's render hints are) and which skills it exposes (`allowSkills` says whether a tool is there at all —
40
+ * a skill no longer mounted is `resume.tool_unavailable`). Read off the declaration the dial judged, never off the card.
41
+ */
42
+ export declare function a2aPeerRegistration(spec: A2aServerSpec): PeerRegistrationFacts;
43
+ /**
44
+ * An MCP server's registration facts, each as the host wrote it: its transport as the peer seat is asked about it ({@link mcpPeerTarget}:
45
+ * the endpoint, or the whole start command, each with its credential reference when that is its own content; or the host's own pipe),
46
+ * the header the end user's identity rides under, its mount identity stamp, and what its requests disclose of the caller
47
+ * (`sessionMetaKey`, `callerMeta` — absent is `false`, the declaration type's own default). A host pipe has no address: what is compared
48
+ * is its stamp and the two caller settings (KL-5333-b). Not among them: which tools it exposes (`allowTools` — a tool no longer mounted
49
+ * is `resume.tool_unavailable`), its startup bound, and the axes the roster row already carries as declaration members. `kind` is the
50
+ * dial's one read of the transport's kind.
51
+ */
52
+ export declare function mcpPeerRegistration(spec: McpServerSpec, kind: McpTransportKind | undefined): PeerRegistrationFacts;
@@ -0,0 +1,37 @@
1
+ import { canonicalJsonStringify, sha16 } from "./canonical-json.js";
2
+ import { mcpPeerTarget } from "./peer-seat.js";
3
+ export function peerRegistrationDigestOf(source, facts) {
4
+ return sha16(canonicalJsonStringify({ source, registration: facts }));
5
+ }
6
+ export function credentialReferenceFact(ref) {
7
+ if (ref === undefined)
8
+ return {};
9
+ return { credentials: ref.kind === "handle" ? { kind: "handle" } : ref };
10
+ }
11
+ export function a2aPeerRegistration(spec) {
12
+ return {
13
+ url: spec.url,
14
+ ...(spec.cardUrl !== undefined ? { cardUrl: spec.cardUrl } : {}),
15
+ boundary: spec.boundary === "inside" ? "inside" : "outside",
16
+ ...(spec.ownerTeam !== undefined ? { ownerTeam: spec.ownerTeam } : {}),
17
+ ...(spec.fingerprint !== undefined ? { fingerprint: spec.fingerprint } : {}),
18
+ ...credentialReferenceFact(spec.credentials),
19
+ ...(spec.principalHeader !== undefined ? { principalHeader: spec.principalHeader } : {}),
20
+ };
21
+ }
22
+ export function mcpPeerRegistration(spec, kind) {
23
+ const target = mcpPeerTarget(spec, kind);
24
+ const t = spec.transport;
25
+ const where = target.transport === "host"
26
+ ? {}
27
+ : target.transport === "stdio"
28
+ ? { command: target.command, args: target.args, ...credentialReferenceFact(target.credentials) }
29
+ : { url: target.url, ...credentialReferenceFact(target.credentials), ...("principalHeader" in t && t.principalHeader !== undefined ? { principalHeader: t.principalHeader } : {}) };
30
+ return {
31
+ transport: target.transport,
32
+ ...where,
33
+ ...(typeof spec.fingerprint === "string" ? { fingerprint: spec.fingerprint } : {}),
34
+ ...(spec.sessionMetaKey !== undefined ? { sessionMetaKey: spec.sessionMetaKey } : {}),
35
+ ...(spec.callerMeta === true ? { callerMeta: true } : {}),
36
+ };
37
+ }
@@ -312,7 +312,9 @@ export type PeerCarrierIdentity = PeerSeatTarget | {
312
312
  readonly transport: "host";
313
313
  };
314
314
  /** Who an MCP server is, as the seat is asked about it: its name, the whole start command or endpoint, its reference, its mount identity. */
315
- export declare function mcpPeerTarget(spec: McpServerSpec, kind: McpTransportKind | undefined): PeerCarrierIdentity;
315
+ export declare function mcpPeerTarget(spec: McpServerSpec, kind: McpTransportKind | undefined): Extract<PeerCarrierIdentity, {
316
+ readonly protocol: "mcp";
317
+ }>;
316
318
  /** Whether a failure is the HTTP endpoint answering 401 (the SDK's status error, on the thrown value or its cause chain). Structure only. */
317
319
  export declare function answeredUnauthorized(err: unknown): boolean;
318
320
  /** The one reading of a re-send's failure: its record says it was not delivered (`details.delivered === "no"` — the seat could not
@@ -1627,7 +1627,7 @@ export function adjudicatePersistedNameRules(rules, call) {
1627
1627
  if (!eligiblePersisted(rule, call, behavior))
1628
1628
  continue;
1629
1629
  const arm = mountedArgumentArmOf(rule);
1630
- if (arm !== undefined && paramRuleReaches(call.request, arm.param, arm.pattern))
1630
+ if (arm !== undefined && paramRuleReaches(call.request, arm.param, arm.pattern, undefined, behavior === "allow" ? "allow" : "tighten"))
1631
1631
  return { behavior, rules: [rule] };
1632
1632
  const subject = behavior === "allow" ? granted : name;
1633
1633
  if (subject === undefined)
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The checkpoint screen's chain comparison, the part that is not the digest: the one spelling difference it reads as no difference,
3
+ * and the causes its refusal (`resume.parent_constraint_mismatch`) names in `detail.reason` — `constraint_changed` (the chain the
4
+ * resume runs under is not the row's), `constraint_unjudgeable` (the chain could not be judged); the row judge names the third,
5
+ * `constraint_chain_damaged`, and `chainInstallationRefusal` (child-tree.ts) the three `installation_record_*` words.
6
+ */
7
+ import { CheckpointError } from "../checkpoint-features.js";
8
+ import type { ConstraintChainEntry } from "../tool-policy.js";
9
+ /** `resume.parent_constraint_mismatch` for a re-supplied chain that is not the one the row recorded: another layer count, or a
10
+ * layer whose facts or frozen deny data differ. */
11
+ export declare const chainChanged: (message: string) => CheckpointError;
12
+ /** `resume.parent_constraint_mismatch` for a chain that could not be judged: an entry that is neither one caller policy nor one
13
+ * installation, or a judgment that threw. */
14
+ export declare const chainUnjudgeable: (message: string) => CheckpointError;
15
+ /**
16
+ * The chain rung's refusal with its cause — every `resume.parent_constraint_mismatch` the rung answers carries a `detail.reason`.
17
+ * One that reaches it without one (an engine refusal thrown from inside a layer while the chain was rebuilt or judged, which the
18
+ * rung passes through as it was thrown) is a chain that could not be judged: answered as the one copy (`copyOfCheckpointError`: its
19
+ * message and cause where they can be read) with `constraint_unjudgeable`; the thrown object itself is not edited. Any other refusal
20
+ * is returned as it is.
21
+ */
22
+ export declare function withMismatchCause(refusal: CheckpointError | undefined): CheckpointError | undefined;
23
+ /**
24
+ * One value, two spellings: an entry with no frozen component and a live remainder (`{ components: [], requiresLiveRemainder: true }`,
25
+ * what `combinePolicies(p, createAllowDenyPolicy({}))` projects for an opaque `p`) and an opaque entry (`{ opaque: true }`) both
26
+ * freeze nothing and leave the whole decision to the live policy — the frozen deny layers execute no component of either, and the
27
+ * edit re-adjudication refuses an edit under either. A re-supplied entry spelled one way, against a row that recorded the other at
28
+ * its position, is read in the row's spelling, its layer facts its own; any other difference stays a difference (the remainder bit
29
+ * of an entry that freezes nothing, a component, the order or repeats of components or names). The row's digest then decides, as it
30
+ * does for every chain — a row whose chain was edited to the other spelling authenticates nothing it did not before.
31
+ */
32
+ export declare function inRecordedSpelling(supplied: ConstraintChainEntry, recorded: ConstraintChainEntry | undefined): ConstraintChainEntry;
@@ -0,0 +1,29 @@
1
+ import { CheckpointError, copyOfCheckpointError } from "../checkpoint-features.js";
2
+ export const chainChanged = (message) => new CheckpointError("resume.parent_constraint_mismatch", message, { reason: "constraint_changed" });
3
+ export const chainUnjudgeable = (message) => new CheckpointError("resume.parent_constraint_mismatch", message, { reason: "constraint_unjudgeable" });
4
+ export function withMismatchCause(refusal) {
5
+ if (refusal === undefined || refusal.code !== "resume.parent_constraint_mismatch")
6
+ return refusal;
7
+ let named;
8
+ try {
9
+ named = refusal.detail?.reason;
10
+ }
11
+ catch {
12
+ named = undefined;
13
+ }
14
+ return named !== undefined ? refusal : copyOfCheckpointError(refusal, "constraint_unjudgeable");
15
+ }
16
+ export function inRecordedSpelling(supplied, recorded) {
17
+ if (typeof recorded !== "object" || recorded === null)
18
+ return supplied;
19
+ const freezesNothing = (e) => !("opaque" in e) && Array.isArray(e.components) && e.components.length === 0 && e.requiresLiveRemainder === true;
20
+ if ("opaque" in supplied && freezesNothing(recorded)) {
21
+ const { opaque: _opaque, ...facts } = supplied;
22
+ return { ...facts, components: [], requiresLiveRemainder: true };
23
+ }
24
+ if (freezesNothing(supplied) && "opaque" in recorded) {
25
+ const { components: _components, requiresLiveRemainder: _remainder, ...facts } = supplied;
26
+ return { ...facts, opaque: true };
27
+ }
28
+ return supplied;
29
+ }
@@ -60,6 +60,7 @@ export declare function readSince(store: Pick<FileHistoryStore, "restore">, inpu
60
60
  readonly env: ExecutionEnv;
61
61
  readonly root: string;
62
62
  readonly signal: AbortSignal | undefined;
63
+ readonly forkedSession?: boolean;
63
64
  }, contentOf: ReadonlySet<string>): Promise<{
64
65
  readonly kind: "rows";
65
66
  readonly rows: ChangeRow[];
@@ -293,7 +293,7 @@ export async function readSince(store, input, contentOf) {
293
293
  const texts = sinceTextsOf(contentOf, input.root);
294
294
  let plan;
295
295
  try {
296
- plan = await planFileHistoryRestore(store, { scope: input.scope, entryId: input.entryId, env: input.env, root: input.root, ...(input.signal !== undefined ? { signal: input.signal } : {}), ...(texts !== undefined ? { readCurrent: texts.readCurrent } : {}) });
296
+ plan = await planFileHistoryRestore(store, { scope: input.scope, entryId: input.entryId, env: input.env, root: input.root, ...(input.signal !== undefined ? { signal: input.signal } : {}), ...(input.forkedSession === true ? { forkedSession: true } : {}), ...(texts !== undefined ? { readCurrent: texts.readCurrent } : {}) });
297
297
  }
298
298
  catch (err) {
299
299
  return { kind: "unavailable", reason: "history_unreadable", fault: thrownFault(err) };
@@ -309,7 +309,7 @@ export function sinceRowsOf(plan, contentOf, texts) {
309
309
  return { kind: "unavailable", reason: "no_checkpoint" };
310
310
  if (restore.outcome === "failed" || restore.error !== undefined)
311
311
  return { kind: "unavailable", reason: "history_unreadable", fault: faultOf(restore.error) };
312
- if (plan.unheld !== undefined)
312
+ if (plan.unheld !== undefined || plan.unplacedForFork === true)
313
313
  return { kind: "unavailable", reason: "history_unreadable", fault: { code: "restore_failed", permanence: "terminal" } };
314
314
  const rows = [];
315
315
  const handedAt = new Set();
@@ -631,6 +631,7 @@ export interface Prepared {
631
631
  * on THIS leg — a deny row found now vetoes, an operator's edit is judged on the `rejudge` seat. */
632
632
  shellReadCheck?: import("../../tools/fs/shell-read-check.js").ShellReadCheck;
633
633
  shellReadLandings?: import("../../tools/fs/shell-read-check.js").ShellReadLandings;
634
+ declaredReadKeys?: (toolCallId: string, call: Pick<import("../tool-registry.js").ToolCallLike, "face">) => readonly string[] | "unjudged" | undefined;
634
635
  crossBoundary?: {
635
636
  readonly check: import("../cross-boundary-taint.js").CrossBoundaryCheck | undefined;
636
637
  settle(owed: import("../cross-boundary-taint.js").OwedDeliveries, boundMs?: number): Promise<void>;
@@ -2167,6 +2168,8 @@ export interface RunInternals {
2167
2168
  * mirroring `insideFork`.
2168
2169
  */
2169
2170
  isDelegatedChild?: boolean;
2171
+ /** Default project verdict id inherited from the parent leg (used only when child declares none and has no marker; trusted internals). */
2172
+ parentProjectId?: string;
2170
2173
  /** Who wrote this leg's objective ({@link import("../input-author.js").InputAuthor}), stated by the seat that mints it; absent = the public
2171
2174
  * entry's caller, `operator`. Only the operator's objective passes `classic.UserPromptSubmit`; a non-member reads `unknown`, is screened and
2172
2175
  * reported once (`onError`, `"config"`). Never inherited — each seat says its own. TRUSTED run-scoped channel (NOT a {@link TaskSpec} field). */
@@ -47,6 +47,8 @@ export declare function settleFileHistoryRestore(input: {
47
47
  /** Refuse before any file moves when the restore would refuse or fail one ({@link planFileHistoryRestore}) — a caller that does
48
48
  * not accept a partial restore; a caller that reads the ledger itself leaves it off. */
49
49
  wholeOrNothing: boolean;
50
+ /** Handed to the store's restore as it is: the store's restore input (`forkedSession` there) says what the fact is and what it changes. */
51
+ forkedSession?: boolean;
50
52
  /** The rewind's record of whether the tree moved ({@link RewindOutcome.moved}): written here once the restore asked the env what
51
53
  * it asked — whatever the restore then answers, or if it throws; untouched when the restore is refused before it runs. */
52
54
  outcome?: Pick<RewindOutcome, "moved">;
@@ -108,7 +110,7 @@ export declare function refuseFailedPlan(planned: FileHistoryRestoreResult, targ
108
110
  * half on the env it is handed restores such a history). The sentence names the frozen files ({@link listFrozenFileHistoryEntries}'s
109
111
  * same set) and the way on. A plan with no such write returns.
110
112
  */
111
- export declare function refuseUnheldPlan(plan: Pick<FileHistoryRestorePlan, "restore" | "unheld">, target: string, sessionId: string, ask: BoundaryAsk): void;
113
+ export declare function refuseUnheldPlan(plan: Pick<FileHistoryRestorePlan, "restore" | "unheld" | "unplacedForFork">, target: string, sessionId: string, ask: BoundaryAsk): void;
112
114
  /** What {@link refuseTargetOutsideOwnLog} reads of the session: an entry by id. */
113
115
  export interface OwnLogReader {
114
116
  getEntry(id: string): Promise<unknown>;
@@ -3,7 +3,7 @@ import { planFileHistoryRestore, restoreMovedOf, restoreOptionsAt, witnessEnvOf,
3
3
  import { isGovernanceRetryClass } from "../governance-codes.js";
4
4
  export async function settleFileHistoryRestore(input) {
5
5
  const { store, sessionId, scope, target, env, root } = input;
6
- const plan = await planFileHistoryRestore(store, { scope, entryId: target, env, root, ...(input.signal !== undefined ? { signal: input.signal } : {}), ...(input.options !== undefined ? { options: input.options } : {}) });
6
+ const plan = await planFileHistoryRestore(store, { scope, entryId: target, env, root, ...(input.signal !== undefined ? { signal: input.signal } : {}), ...(input.options !== undefined ? { options: input.options } : {}), ...(input.forkedSession === true ? { forkedSession: true } : {}) });
7
7
  refuseUnheldPlan(plan, target, sessionId, input.before ? "before" : "restore");
8
8
  if (input.wholeOrNothing) {
9
9
  const planned = plan.restore;
@@ -12,7 +12,7 @@ export async function settleFileHistoryRestore(input) {
12
12
  throw restoreFailedError({ ...planned, filesChanged: [], identicalSkipped: [] }, `rewind-files: restore to entry "${target}" was refused before any file moved — the restore would be PARTIAL. Nothing was written or deleted; the plan: ${fileHistoryRestoreLedgerLine(planned, true)}. Repeating the same rewind plans the same; a rewind that restores the rest and answers this ledger is Runner.rewindFiles, and a run spec that accepts a partial restore (acceptPartialRestore) does the same where its host offers that member.`, RUN_STOPPED_RESTORE);
13
13
  }
14
14
  }
15
- const witness = witnessEnvOf(env, plan.holds, plan.states);
15
+ const witness = witnessEnvOf(env, plan.holds, plan.states, input.forkedSession === true ? root : undefined);
16
16
  let answered;
17
17
  try {
18
18
  answered = await store.restore(scope, target, witness.env, root, input.signal, restoreOptionsAt(input.options, root));
@@ -59,10 +59,13 @@ export function refuseFailedPlan(planned, target, sessionId, ask) {
59
59
  }
60
60
  export function refuseUnheldPlan(plan, target, sessionId, ask) {
61
61
  const keys = plan.unheld;
62
- if (keys === undefined)
63
- return;
64
62
  const what = ask === "preview" ? `nothing was previewed for entry "${target}"` : `this rewind to entry "${target}" was not done at all: nothing was written or deleted`;
65
- throw restoreFailedError({ ...plan.restore, filesChanged: [], identicalSkipped: [] }, `rewind-files: session "${sessionId}" has ${keys.length} file(s) an earlier version recorded through a link (${keys.join(", ")}), which this engine no longer writes through a link under any key; this deployment's file-history store did not hand the restore of its files to the engine's shared restore step (applyFileRestoreViaEnv, called on the env the store is handed), so which file each of its writes would land on cannot be read, and none of them can be kept off those files — ${what}. Repeating it answers the same until the store restores through that step; listFrozenFileHistoryEntries lists these files.`, RUN_STOPPED_RESTORE);
63
+ if (keys !== undefined) {
64
+ throw restoreFailedError({ ...plan.restore, filesChanged: [], identicalSkipped: [] }, `rewind-files: session "${sessionId}" has ${keys.length} file(s) an earlier version recorded through a link (${keys.join(", ")}), which this engine no longer writes through a link under any key; this deployment's file-history store did not hand the restore of its files to the engine's shared restore step (applyFileRestoreViaEnv, called on the env the store is handed), so which file each of its writes would land on cannot be read, and none of them can be kept off those files — ${what}. Repeating it answers the same until the store restores through that step; listFrozenFileHistoryEntries lists these files.`, RUN_STOPPED_RESTORE);
65
+ }
66
+ if (plan.unplacedForFork) {
67
+ throw restoreFailedError({ ...plan.restore, filesChanged: [], identicalSkipped: [] }, `rewind-files: session "${sessionId}" was forked from another, and a fork's rewind leaves every file outside its root as it is; this deployment's file-history store did not hand the restore of its files to the engine's shared restore step (applyFileRestoreViaEnv, called on the env the store is handed), so which file each of its writes would land on cannot be read, and none of them can be kept inside its root — ${what}. Repeating it answers the same until the store restores through that step.`, RUN_STOPPED_RESTORE);
68
+ }
66
69
  }
67
70
  function noBoundaryFor(target, sessionId, ask) {
68
71
  return ask === "before" ? beforeWithoutBoundaryRefusal(target, sessionId) : noBoundaryRefusal(target, sessionId, ask === "preview");
@@ -92,7 +95,7 @@ const LEFT_AS_IS_WORDS = {
92
95
  },
93
96
  recorded_outside_root: {
94
97
  ledger: "recorded outside this root",
95
- why: "the version to restore was recorded under a directory outside the one this rewind works in (the session, or the session it was forked from, worked there), so this rewind writes or deletes it neither there nor here; a rewind handed the root it was recorded under restores it",
98
+ why: "this file lies in a directory outside the root this rewind works in (either its version was recorded under another root, or this session was forked from another — a forked session's rewind leaves every file outside its root untouched), so this rewind writes or deletes it neither there nor here; for an unforked session, a rewind handed the root it was recorded under restores it, and for a forked session, rewind in the source session or restore it by hand",
96
99
  beforehand: "a preview (Runner.rewindFiles with dryRun) lists such files before a rewind",
97
100
  },
98
101
  };
@@ -0,0 +1,2 @@
1
+ import { normalizeSkills } from "./synthetic-tools.js";
2
+ export declare function loadedSkills(skills: unknown, onRejected?: (skill: ReturnType<typeof normalizeSkills>[number], delivered: number) => void): ReturnType<typeof normalizeSkills>;
@@ -0,0 +1,10 @@
1
+ import { skillLoadReading } from "./skill-base-dir.js";
2
+ import { SKILL_CONTENT_MAX_CHARS, normalizeSkills } from "./synthetic-tools.js";
3
+ export function loadedSkills(skills, onRejected) {
4
+ return normalizeSkills(skills).filter((s) => {
5
+ const { loads, delivered } = skillLoadReading(s, SKILL_CONTENT_MAX_CHARS);
6
+ if (!loads)
7
+ onRejected?.(s, delivered);
8
+ return loads;
9
+ });
10
+ }
@@ -61,6 +61,7 @@ import { type RuleStoreFault } from "../rule-store-fault.js";
61
61
  import type { RunnerDeps } from "../runner-deps.js";
62
62
  import { type JudgedPathRow, type PathRuleDenyRow, type ReadDenyBuiltinConfig, type ReadDenyEntry, type ReadDenySeat, type WriteDenyMatcher } from "../../tools/fs/read-deny.js";
63
63
  import { type HomeViewSource, type PlacedReadDenyMatcher } from "../../tools/fs/read-deny-home.js";
64
+ import { type ReadStationMember } from "../../tools/fs/file-read-check.js";
64
65
  import { type ShellReadCheck } from "../../tools/fs/shell-read-check.js";
65
66
  import type { ReadAskRow } from "../../tools/fs/shell-read-judge.js";
66
67
  import { type SessionPermissionRules } from "../session-policy-store.js";
@@ -319,10 +320,7 @@ export declare function denySeatsOf(t: PathTables): {
319
320
  * read in is vouched for, as it would have been. (A partition of those rows that could not be read reaches the station on
320
321
  * the boundary it judges with — {@link PersonPathRows.unreadFor} — where it vouches for nothing.)
321
322
  */
322
- export declare function onPinnedRead(rows: PersonPathRows, stations: ReadonlyArray<{
323
- readonly check: ShellReadCheck;
324
- readonly tools: ReadonlySet<string>;
325
- }>): ShellReadCheck | undefined;
323
+ export declare function onPinnedRead(rows: PersonPathRows, stations: ReadonlyArray<ReadStationMember>): ShellReadCheck | undefined;
326
324
  /**
327
325
  * One read station judged ahead of the gate's fold — where an inherited station settles an ancestor's question about a call
328
326
  * before the call reaches the station's own seat: the run's newest tables, once they are ready, and no read taken (a call's
@@ -16,7 +16,7 @@ import { deliverEngineNotice } from "../engine-notice.js";
16
16
  import { entriesNotAppliedDetail } from "../entries-not-applied.js";
17
17
  import { compileReadDeny, compileWriteDeny, readDenySeat, rowsWhereTheyLead } from "../../tools/fs/read-deny.js";
18
18
  import { carryHomeViews, placeReadDenyAtHome, readDenyOver } from "../../tools/fs/read-deny-home.js";
19
- import { composeReadChecks } from "../../tools/fs/file-read-check.js";
19
+ import { composeReadChecks, readStationsHold } from "../../tools/fs/file-read-check.js";
20
20
  import { readStationMemberOf } from "../../tools/fs/shell-read-check.js";
21
21
  import { compileSessionRuleBucket, readSessionRulesShape, unreadableDenyEntries } from "../session-policy-store.js";
22
22
  import { readRuleEntry, wholeToolEntryOf } from "../allow-entry.js";
@@ -476,11 +476,10 @@ export function onPinnedRead(rows, stations) {
476
476
  const check = composeReadChecks(stations);
477
477
  if (check === undefined || !rows.holdsPersonRows)
478
478
  return check;
479
- const members = new Set(stations.flatMap((s) => [...s.tools]));
480
479
  return {
481
480
  judge(call, args, cwd, signal, callOpts) {
482
481
  const id = callOpts.toolCallId;
483
- if (readStationMemberOf(call, members) === undefined)
482
+ if (!readStationsHold(stations, call))
484
483
  return check.judge(call, args, cwd, signal, callOpts);
485
484
  const ready = id !== undefined && rows.holds(id) ? rows.pin(id, args).then(() => rows.tablesReady(id)) : rows.tablesReady(undefined, signal);
486
485
  return ready.then(() => check.judge(call, args, cwd, signal, callOpts) ?? VOUCHED);
@@ -43,6 +43,7 @@ import { RosterBuilder } from "../tool-roster.js";
43
43
  import type { ParentSpecSeat } from "../parent-spec-seat.js";
44
44
  import type { ApprovalParkNotResumable } from "../park-resumability.js";
45
45
  import { type RosterSpec } from "./caller-roster.js";
46
+ import { type JudgedReadsSeat } from "../../tools/fs/judged-reads.js";
46
47
  export interface PrepareCapsAndWorkflowInput {
47
48
  /** borrowed-readonly — the REBOUND spec, whole: the roster map reads `tools`; the mounts read `enableBlockedReport`,
48
49
  * `enablePlanMode`, `interactiveTools`; the caps/compliance stations read `principal`, `selfOrchestration`,
@@ -111,6 +112,9 @@ export interface PrepareCapsAndWorkflowInput {
111
112
  inheritedGateForChildren: () => InheritedGate;
112
113
  /** borrowed-readonly — the caller-tool ctx enrichment the roster map wraps every raw ToolSpec with. */
113
114
  enrichSpecToolCtx: (ctx: ToolExecuteContext) => ToolExecuteContext;
115
+ /** ownership-ref — the leg's judged-read port seat, filled by the driver after the hands phase: a caller tool that declares a read
116
+ * target reads `ctx.judgedReads` through it at call time. */
117
+ judgedReadsSeat: JudgedReadsSeat;
114
118
  /** borrowed-readonly — the large-result wrapper every roster entry passes through (per-tool policy honored inside). */
115
119
  maybeOffload: (tool: AgentTool, perTool?: {
116
120
  offload?: boolean;
@@ -38,6 +38,7 @@ import { enterConfigDoor, refusalAbout } from "../config-refusal-input.js";
38
38
  import { callerEntryOrigin, rebindProductEntry, specArmCanBuild } from "./caller-roster.js";
39
39
  import { rootAnchorOf } from "../leg-identity.js";
40
40
  import { workflowCatalogOfFactory } from "../../orchestration/workflow-catalog.js";
41
+ import { withJudgedReads } from "../../tools/fs/judged-reads.js";
41
42
  function assembleParentCaptureState(o, i, ctl, ancestors) {
42
43
  const build = (optedOut, indeterminate) => ({
43
44
  optedOut: optedOut === true,
@@ -127,7 +128,11 @@ export async function prepareCapsAndWorkflow(input) {
127
128
  roster.mount(mounted, { source: callerMountSource(mounted), mountedBy: "scenario", ...(t.perTurn === true ? { perTurn: true } : {}) });
128
129
  }
129
130
  function mountCallerTool(t) {
130
- const rebound = rebindProductEntry(t, enrichSpecToolCtx);
131
+ const declaresRead = t.pathTarget?.access === "read";
132
+ if (declaresRead)
133
+ (input.judgedReadsSeat.ported ??= new Set()).add(t.name);
134
+ const enrich = declaresRead ? (ctx) => withJudgedReads(enrichSpecToolCtx(ctx), input.judgedReadsSeat) : enrichSpecToolCtx;
135
+ const rebound = rebindProductEntry(t, enrich);
131
136
  if (rebound !== undefined)
132
137
  return maybeOffload(rebound, t);
133
138
  if (!specArmCanBuild(t)) {
@@ -139,7 +144,7 @@ export async function prepareCapsAndWorkflow(input) {
139
144
  const execute = t.execute, self = callerEntryOrigin(t);
140
145
  return maybeOffload(defineTool({
141
146
  ...t,
142
- execute: (args, ctx) => execute.call(self, args, enrichSpecToolCtx(ctx)),
147
+ execute: (args, ctx) => execute.call(self, args, enrich(ctx)),
143
148
  }), t);
144
149
  }
145
150
  const blockedRef = {};
@@ -82,7 +82,7 @@ export async function prepareFileHistory(input) {
82
82
  throw own.refused ?? unaddressedRewindRefusal(sessionId, rewindTarget);
83
83
  await refuseTargetOutsideOwnLog(session, sessionId, rewindTarget, rewindBefore ? "before" : "restore");
84
84
  refuseRestoreOnForkWithOwnTree(forkWithOwnTree, sessionId, rewindTarget, rewindBefore ? "before" : "restore");
85
- const restored = await settleFileHistoryRestore({ store: fileHistoryStore, sessionId, scope: own.scope, target: rewindTarget, before: rewindBefore, env: executionEnv, root: historyRoot, signal: restoreSignal, readStates: internals?.sessionReadStates, options: request.restoreOptions, wholeOrNothing: spec.acceptPartialRestore !== true, ...(input.rewindOutcome !== undefined ? { outcome: input.rewindOutcome } : {}) });
85
+ const restored = await settleFileHistoryRestore({ store: fileHistoryStore, sessionId, scope: own.scope, target: rewindTarget, before: rewindBefore, env: executionEnv, root: historyRoot, signal: restoreSignal, readStates: internals?.sessionReadStates, options: request.restoreOptions, wholeOrNothing: spec.acceptPartialRestore !== true, ...(row !== undefined && row.origin !== undefined && row.origin !== sessionId ? { forkedSession: true } : {}), ...(input.rewindOutcome !== undefined ? { outcome: input.rewindOutcome } : {}) });
86
86
  tellLeftAsIs({ restored, target: rewindTarget, scope: own.scope, sessionId, rewindNotes, onceLedger, onNotice: deps.onNotice });
87
87
  const outsideRoot = restoreOutsideRootNote(restored, rewindTarget);
88
88
  if (outsideRoot !== undefined)
@@ -6,6 +6,7 @@ import type { HeadLeads } from "../path-rule-binding.js";
6
6
  import { type ShellReadAdmission, type ShellReadCheck, type ShellReadLandings } from "../../tools/fs/shell-read-check.js";
7
7
  import { type ReadFloorSeat } from "../../tools/fs/read-floor.js";
8
8
  import type { CommandSandboxSeat } from "../command-sandbox.js";
9
+ import type { JudgedReadsSeat } from "../../tools/fs/judged-reads.js";
9
10
  import type { ShellReadBoundary } from "../../tools/fs/shell-read-judge.js";
10
11
  import { type SeenFiles } from "../existing-target.js";
11
12
  import type { RunnerDeps, ShellGateDoctrine, TaskSpec } from "../types.js";
@@ -27,6 +28,8 @@ import type { PermissionMode } from "../ask-origin.js";
27
28
  * phase; prepare-task.ts keeps a re-export so the existing import sites stand. */
28
29
  export declare function __resetReadFaceClampAnnouncement(): void;
29
30
  export interface PrepareHandsReadFaceInput {
31
+ /** borrowed-readonly — the leg's judged-read port seat: which tools read through the port (`ported`); absent ⇒ none does. */
32
+ judgedReadsSeat?: JudgedReadsSeat;
30
33
  /** owned (value) — `ownedEnv !== undefined || deps.executionEnv !== undefined`, computed in the
31
34
  * driver: the phase's own branch condition (hands mount vs the hands-less resolver arm). */
32
35
  handsEnabled: boolean;
@@ -259,6 +262,8 @@ export interface PrepareHandsReadFaceResult {
259
262
  * (an out-of-root Read / Grep / Glob target is a question) and the file write tools' (a target their fence refuses is refused).
260
263
  * ⇔ hands with a real shell, or hands with an approval face, or the write half. */
261
264
  shellReadCheck: ShellReadCheck | undefined;
265
+ /** owned — the file read station's judged-read port per call (`ToolExecuteContext.judgedReads`); absent ⇔ no file read station. */
266
+ judgedReadsOf: ((toolCallId: string) => readonly import("../judged-read.js").JudgedRead[] | undefined) | undefined;
262
267
  /** owned — the shell read station is mounted (⇔ a real shell): the wiring manifest's cell. */
263
268
  shellReadStationArmed: boolean;
264
269
  /** owned — the same station's pre-spawn ADMISSION, published for the P11 face that spawns a shell command
@@ -8,7 +8,7 @@ import { EMPTY_READ_ROOTS, afterCallTables, boundaryRowsOver, denySeatsOf, onNew
8
8
  import { bindRetiredReads, createShellOverflowSpoolFence } from "../../tools/fs/fs-shared.js";
9
9
  import { createShellReadStation } from "../../tools/fs/shell-read-check.js";
10
10
  import { judgeReadFloorKept, readFloorSeat } from "../../tools/fs/read-floor.js";
11
- import { createFileReadStation, outsideReadDisposition } from "../../tools/fs/file-read-check.js";
11
+ import { createFileReadStation, outsideReadDisposition, unjudgedReadsMember } from "../../tools/fs/file-read-check.js";
12
12
  import { createFileWriteStation } from "../../tools/fs/file-write-check.js";
13
13
  import { readBlockLeg, readBlockOf } from "./read-block-judge.js";
14
14
  import { isShellFaceToolName, readTargetToolNames, writeTargetToolNames } from "../tool-registry.js";
@@ -92,7 +92,8 @@ export function resolveHandsLessReadFace(input) {
92
92
  wsSnapshot: undefined,
93
93
  rebaseWsPath: (p) => p,
94
94
  backgroundTaskToolsActive: false,
95
- shellReadCheck: undefined,
95
+ shellReadCheck: unjudgedReadsMember((name) => input.judgedReadsSeat?.ported?.has(name) === true).check,
96
+ judgedReadsOf: undefined,
96
97
  shellReadStationArmed: false,
97
98
  shellReadAdmission: undefined,
98
99
  runReadFloor: undefined,
@@ -144,6 +145,7 @@ export async function prepareHandsMount(input) {
144
145
  let runReadFloor;
145
146
  let shellReadTools = new Set();
146
147
  let fileReadStation;
148
+ let fileToolAdmission;
147
149
  let readBlockJudge;
148
150
  let fileWriteStation;
149
151
  let resolvedReadFace;
@@ -392,23 +394,23 @@ export async function prepareHandsMount(input) {
392
394
  });
393
395
  }
394
396
  const outsideReads = outsideReadDisposition({ readOnlyMount: handsReadOnly, readBlock });
395
- if (outsideReads !== "tool_fence") {
396
- const bgOutputExempt = backgroundOutputReadExemption(defaultTaskRegistry, { taskOwner: hostTaskId, taskScope, ...(sessionId !== undefined ? { sessionId } : {}), occupant: input.legOccupant }, executionEnv);
397
- fileReadStation = createFileReadStation({
398
- outsideReads,
399
- env: executionEnv,
400
- rootCanonical,
401
- roots: readRoots,
402
- readDeny: tables.readDeny,
403
- ...(liveReadFace !== undefined ? { readFace: liveReadFace } : {}),
404
- ...("homeDir" in executionEnv && executionEnv.homeDir !== undefined ? { homeDir: executionEnv.homeDir } : {}),
405
- tools: readTargetToolNames(),
406
- excluded: (key) => artifactStoreRef.current !== undefined && rootAdmittingArtifactStore(artifactStoreRef.current, [key]) !== undefined,
407
- exempt: (key) => bgOutputExempt?.(key) === true,
408
- });
409
- if (outsideReads === "refusal")
410
- readBlockJudge = onNewestRead(input.personRows, fileReadStation);
411
- }
397
+ const bgOutputExempt = backgroundOutputReadExemption(defaultTaskRegistry, { taskOwner: hostTaskId, taskScope, ...(sessionId !== undefined ? { sessionId } : {}), occupant: input.legOccupant }, executionEnv);
398
+ fileReadStation = createFileReadStation({
399
+ outsideReads,
400
+ env: executionEnv,
401
+ rootCanonical,
402
+ roots: readRoots,
403
+ readDeny: tables.readDeny,
404
+ ...(liveReadFace !== undefined ? { readFace: liveReadFace } : {}),
405
+ ...("homeDir" in executionEnv && executionEnv.homeDir !== undefined ? { homeDir: executionEnv.homeDir } : {}),
406
+ tools: outsideReads === "tool_fence" ? new Set() : readTargetToolNames(),
407
+ excluded: (key) => artifactStoreRef.current !== undefined && rootAdmittingArtifactStore(artifactStoreRef.current, [key]) !== undefined,
408
+ exempt: (key) => bgOutputExempt?.(key) === true,
409
+ });
410
+ if (outsideReads === "refusal")
411
+ readBlockJudge = onNewestRead(input.personRows, fileReadStation);
412
+ if (outsideReads !== "tool_fence")
413
+ fileToolAdmission = fileReadStation.admitted;
412
414
  const writeContainmentSeat = {};
413
415
  const valveLeft = valveLeaves(toolFaceSnapshot.selector);
414
416
  const band = createHandsToolkit(executionEnv, readFileState, rootCanonical, {
@@ -430,7 +432,7 @@ export async function prepareHandsMount(input) {
430
432
  readOnly: handsReadOnly,
431
433
  ...(shellReadStation !== undefined ? { shellReadAdmission: shellReadStation.admit } : {}),
432
434
  ...(input.commandSandbox !== undefined ? { commandSandbox: input.commandSandbox } : {}),
433
- ...(fileReadStation !== undefined ? { readAdmission: fileReadStation.admitted } : {}),
435
+ ...(fileToolAdmission !== undefined ? { readAdmission: fileToolAdmission } : {}),
434
436
  ...(handsCwdRef ? { cwdRef: handsCwdRef } : {}),
435
437
  taskRegistry: defaultTaskRegistry,
436
438
  taskOwner: hostTaskId,
@@ -521,11 +523,12 @@ export async function prepareHandsMount(input) {
521
523
  rebaseWsPath,
522
524
  backgroundTaskToolsActive,
523
525
  shellReadCheck: onPinnedRead(input.personRows, [...(shellReadStation !== undefined ? [{ check: shellReadStation.check, tools: shellReadTools }] : []), ...(fileReadStation !== undefined ? [fileReadStation] : []), ...(fileWriteStation !== undefined ? [fileWriteStation] : [])]),
526
+ judgedReadsOf: fileReadStation?.judgedReadsOf,
524
527
  shellReadStationArmed: shellReadStation !== undefined,
525
528
  shellReadAdmission: shellReadStation?.admit,
526
529
  runReadFloor,
527
530
  shellReadLandings: shellReadStation?.landings,
528
- readAdmission: fileReadStation?.admitted,
531
+ readAdmission: fileToolAdmission,
529
532
  readBlock,
530
533
  readBlockJudge,
531
534
  outsideReadRemedy,
@@ -140,8 +140,8 @@ export interface PrepareInheritedGateInput {
140
140
  toolFaceSnapshot: ToolFaceSnapshot;
141
141
  /** borrowed-readonly — the ctx's `mountsCallerTool` seat: identity membership in the caller's `spec.tools`, pre-gate. */
142
142
  mountsCallerTool: (tool: ToolSpec) => boolean;
143
- /** borrowed-readonly — the ctx's `mountedMcp` seat: the MCP surface the run mounts right now (call-time; the roster is minted after this phase). Present iff the run declared a server. */
144
- mountedMcp?: () => import("../mounted-mcp.js").MountedMcp;
143
+ /** borrowed-readonly — the ctx's `mountedMcp` seat: the MCP surface the run mounts right now (call-time; the roster is minted after this phase), on every leg — `servers: []` on one that declares none. */
144
+ mountedMcp: () => import("../mounted-mcp.js").MountedMcp;
145
145
  /** borrowed-readonly — the task-level lean switch (ctx seat; absent ⇒ no key). */
146
146
  promptLean: ToolExecuteContext["promptLean"];
147
147
  /** borrowed-readonly — the resolved interaction posture (ctx seat; absent ⇒ no key). */
@@ -229,7 +229,7 @@ export function prepareInheritedGate(input) {
229
229
  ...(frozenOnQuestion !== undefined ? { onQuestion: frozenOnQuestion } : {}),
230
230
  oneShot: spec.oneShot,
231
231
  mountsCallerTool,
232
- ...(input.mountedMcp !== undefined ? { mountedMcp: input.mountedMcp } : {}),
232
+ mountedMcp: input.mountedMcp,
233
233
  parentSpecSeat,
234
234
  ...(internals?.questionFaceStripped === true ? { questionFaceStripped: true } : {}),
235
235
  toolSelector: toolFaceSnapshot.selector,
@@ -35,8 +35,8 @@ export interface PrepareMemoryEngineSessionInput {
35
35
  externalContentTargetActive: boolean;
36
36
  /** borrowed-readonly — the frozen preflight; only `mcp` (the declared entries the announcement walks). */
37
37
  lockedPreflight: Pick<LockedPreflight, "mcp">;
38
- /** borrowed-readonly — the run's MCP mount, read at call time (present iff the run declared a server): the children a delegation tool spawns inherit it, so its tools are rows of their pool. */
39
- mountedMcp?: () => import("../mounted-mcp.js").MountedMcp;
38
+ /** borrowed-readonly — the run's MCP mount, read at call time (every leg's; `servers: []` on one that declares none): the children a delegation tool spawns inherit it, so its tools are rows of their pool. */
39
+ mountedMcp: () => import("../mounted-mcp.js").MountedMcp;
40
40
  /** borrowed-readonly — the acquired session id (notice detail). */
41
41
  sessionId: string;
42
42
  /** borrowed-readonly — the run's invocation id (notice detail; the once-per-leg claims are per-RUN claims). */
@@ -139,8 +139,8 @@ export function prepareMemoryEngineSession(input) {
139
139
  const external = delegationCallIsExternal({
140
140
  requestedType: typeof requested === "string" ? requested : undefined,
141
141
  faces: delegation.faces,
142
- pool: delegation.pool !== undefined && delegation.inheritsMcp && mountedMcp !== undefined ? [...delegation.pool, ...mountedMcpPoolRows(mountedMcp())] : delegation.pool,
143
- isPolluting: poolToolPollutes, ...(delegation.inheritsMcp && mountedMcp !== undefined ? { inheritedServers: mountedMcp().servers.map((m) => ({ name: m.server.name, ...(m.server.contentOrigin !== undefined ? { contentOrigin: m.server.contentOrigin } : {}) })) } : {}),
142
+ pool: delegation.pool !== undefined && delegation.inheritsMcp ? [...delegation.pool, ...mountedMcpPoolRows(mountedMcp())] : delegation.pool,
143
+ isPolluting: poolToolPollutes, ...(delegation.inheritsMcp ? { inheritedServers: mountedMcp().servers.map((m) => ({ name: m.server.name, ...(m.server.contentOrigin !== undefined ? { contentOrigin: m.server.contentOrigin } : {}) })) } : {}),
144
144
  });
145
145
  const result = await inner(toolCallId, params, signal, onUpdate);
146
146
  const delivery = delegationDeliveryOf(result);