Skip to content

fix(acp): spell a Crew agent's tools in KAS ids so the kas backend can read files - #17280

Merged
bolichen97 merged 2 commits into
mainfrom
takeover/13375-kas-tool-ids
Oct 10, 2026
Merged

bolichen97 merged 2 commits into
mainfrom
takeover/13375-kas-tool-ids

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Supersedes #13375 (maintainer takeover of @billygerhard's fork PR, which touches hooks.py and so cannot clear Sensitive Change Review from a fork). The fork head 5fbf2f6 is cherry-picked onto current main with Co-authored-by, plus one review-fix commit. Previous head: 75924917db.

Problem / Motivation

Goal: An agent spec written in kiro-cli tool names gives the kas backend's agent the same file-reading, listing and searching tools it has on kiro-cli, governed by the same operator rules.

Set agent.acp_backend to kas and every new chat runs read-blind. The agent can run a shell command and write a file, but it has no tool to read a file, list a directory, or search — it shells out with cat and grep for every read. Asked to read a file without the shell, a live KAS session on the shipped spec answers: "I don't have a dedicated file-reading tool available in this environment."

Why it matters

The kas switch is offered in Settings (Developer mode) and crew-member DM sessions default to it. On that engine the shipped agent loses most of its file surface silently: no error, no warning, just a model that cannot read. Reads through the shell also skip the read-only auto-approve path, so a --approval reads gateway prompts for what should have been free.

Not a goal

  • Mapping KAS display titles (model-influenceable prose) onto tool identities; only engine-stamped identity is read.
  • Mounting delete_file in the shipped agent spec; it mounts only when a spec names it, and this PR only makes a mounted one governable.
  • Changing what kiro-cli's own gate path sees. Every new gate mechanism (kind cache, identity retention, provenance admission, alias fold, KAS read-only proof) is gated on ACP_BACKENDS_PERMISSION_KIND_FROM_TOOL_CALL; pinned in test_tool_call_classification.py and test_codex_session_mcp.py.
  • Bounding the tool-call liveness map on every harness, and a session-start drift warning. Both were removed from this PR and are tracked in Bound the tool-call liveness map and restore the kas drift warning (split from #17280) #18627.
  • Splitting out the two kas bounds that stay here. Each closes an upheld GPT review finding on fix(acp): spell a Crew agent's tools in KAS ids so the kas backend can read files #13375 about this PR's own kas caches and identity channel, so removing either would reopen it:
    • The per-turn provenance-cache admission (admit_tool_call_cache_entry, with _refuse_unretained_provenance for a request whose row was not retained) closes: KAS metadata retained without size or count bounds (#13375 comment); the kind cache has no entry cap (comment); an overflow dropping the provenance the delete gate needs (comment); a degraded rendering passing the size bound (comment).
    • The refusal of a kas MCP identity over the 512-character name bound (mcp_identity_unreadable, _refuse_unreadable_mcp_identity) closes: an over-bound identity read as absent skipping a per-tool deny (comment); permission metadata relabelling a cached built-in as an MCP tool (comment).
  • Re-measuring the KAS vocabulary automatically on an engine bump; kirocrew doctor reports drift, and the fixture's note says how to re-measure.

Backwards compatibility

Mostly compatible, with one deliberate widening on the kas backend. Every other harness evaluates as on main. Each change is listed per reader below.

  • Admits more (kas only). An allow-mode tools ceiling or profile written in kiro-cli names now permits the KAS ids that do the same work: tools: ["fs_write"] admits str_replace / fs_append, and fs_read / grep / glob admit read_file / list_directory / grep_search / file_search. On main the raw KAS id was asked on its own, so that same rule refused them. This is the kiro-cli parity the PR exists for. delete_file is NOT admitted by fs_write (deny-only alias). An explicit deny on either spelling still refuses at every layer and through every fold. kiro-cli, claude, codex, goose and opencode see no change: the fold runs only for a permission event the KAS harness built (AcpEvent.kas_builtin_ids).
  • Denies more (kas only). A kiro-cli-named deny (auto_deny_tools, a deny-mode tools rule) now reaches the KAS id it governs. New KAS-only refusals: an MCP identity over the name bound, a request whose provenance the per-turn cache did not retain, and a delete whose target is relative (or, on Windows, rooted without a drive).

Per reader of the changed seams:

  • Reader: hook_runtime/gate_tiers._tier_governance -- for a KAS built-in (kas_builtin_ids), the raw id and its kiro-cli name travel as ONE alias_groups entry, so an allow-mode tools: ["fs_write"] now admits KAS str_replace / fs_append that main refused. Off KAS the call is asked under its raw id exactly as on main. Pinned: test_governance_policy.py::TestGateDecisionAliasGroups::test_allow_mode_written_in_kiro_cli_names_admits_the_kas_write, test_hooks.py::TestKasAliasesAreGovernedUnderTheirKiroCliName::test_an_allow_mode_profile_written_in_kiro_cli_names_permits_the_kas_write, and the off-KAS control test_hooks.py::TestKasIdFoldIsKasOnly.
  • Reader: gate_tiers.GateFacts.deny_targets -- adds the kiro-cli name of a KAS built-in, KAS only (TestKasIdFoldIsKasOnly).
  • Reader: tool_identity._is_host_read_only_builtin -- a KAS read id is proven read-only, KAS only; another harness's bare read_file is not (TestKasIdFoldIsKasOnly).
  • Reader: platform/governance.gate_decision -- callers that pass no alias_groups / deny_aliases evaluate as on main; asking the inner half after an outer allow-mode miss only adds a reason. Pinned: TestGateDecisionAliasGroups (the read_file / fs_read pair per layer, across a fold both ways, through a profile extends fold).
  • Reader: hooks.on_tool_call write-protected tier (is_edit_call) -- a KAS delete_file of a config file is now DENIED where before the delete kind routed nowhere; an edit is judged as before. A delete target that is relative, or on Windows rooted with no drive (\foo), is unanchored and denied. Pinned: test_hooks_edit_gate_diff_path.py::TestADeleteIsOnTheWritePlane, ::test_a_windows_target_is_anchored_only_with_a_drive.
  • Reader: every harness's write-plane routing (is_edit_call, classify_tool_args, the always-enforced tier) -- the route reads the ACP kind, not the backend, so a call any harness sends with kind: "delete" now gets the write-plane target gate: a protected-config or sensitive target is denied, and a relative (or on Windows driveless) params target is denied as unverifiable. Edits are judged as before. Split tracked in Split the delete write-plane routing from #17280 into its own review #18582.
  • Reader: governance.classify_tool_args -- a delete's target joins filesystem.write; edits unchanged.
  • Reader: decisions/points/tool_risk.py -- a delete keeps its caution badge (is_workspace_edit_call).
  • Reader: the spec-hook matcher -- KAS_TOOL_IDS_BY_KIRO_TOOL is derived from the policy table, rows set-equal to main's.
  • Reader: cli_doctor -- a new advisory row; no verdict changes. Session start is as on main.

The delete write-plane routing stays in this PR: a spec that names delete_file mounts it on kas, and without the routing that call would reach the gate with no target path. Splitting the mount and the routing out together is tracked in #18582.

What changed (motivation → approach → change)

Crew writes one agent spec, src/kiro_crew/config/defaults.json, in kiro-cli's tool vocabulary: fs_read, fs_write, grep, glob, code. _project_tools in src/kiro_crew/acp/kas_agents.py sent that list to KAS as written. KAS matches an allowlist entry against a tool's exact id or a tag and translates nothing. On KAS, fs_read and fs_write are policy capabilities, not tool ids, and grep / glob are no tool at all. So only the names both engines share mounted: execute_bash, fs_write, code, web_fetch, plus the MCP refs.

One table, both directions. src/kiro_crew/platform/tool_names.py holds the two vocabularies, pinned to a recorded registry of the engine's built-in ids (test/fixtures/kas_builtin_tool_ids.json: engine commit, kiro-cli version, the two id spaces KAS has, and the ACP kind each built-in stamps). It is the ONE kiro-cli <-> KAS table: the spec-hook matcher vocabulary in src/kiro_crew/acp/kas_permissions.py (KAS_TOOL_IDS_BY_KIRO_TOOL), which used to hand-keep the same rows, is now derived from this module's policy table (its inverse grouped per kiro-cli name, plus the three hook-only rows -- web_fetch, web_search, use_subagent -- and the shared fs_write id), with a test asserting the two agree pair for pair. The projection carries each kiro-cli built-in with its KAS family beside it: fs_read → read_file, list_directory; grep → grep_search; glob → file_search; fs_write → str_replace, fs_append. A mount family stops at what the kiro-cli tool can do, so delete_file mounts only when a spec names it; an excludedTools entry has the opposite polarity and reaches everything governed under the name, so excluding fs_write also excludes delete_file. Nothing on the kiro-cli path changes.

The gate reads the table the other way. An operator's auto_deny_tools or a tools-scope ceiling is written in kiro-cli names, so on_tool_call in src/kiro_crew/hooks.py evaluates a KAS built-in under its kiro-cli name too, in three places: the deny tier (both spellings, since a deny only denies), the tools-scope ceiling (the raw KAS id and its kiro-cli name travel as ONE identity with two spellings, gate_decision's new alias_groups: an explicit deny on either spelling binds -- read from a new Decision.explicit_deny provenance flag that ScopedRuleset.permits sets on a deny-mode match and that _AndRuleset.permits and resolve carry through every fold, with an outer allow-mode miss still consulting the inner half so a composed central+local ceiling or a profile extends cannot hide a subordinate tier's deny behind an authority's allow -- otherwise the group is judged per level, a level permitting any spelling and the identity admitted when every governing level does, so a ceiling granting str_replace beneath a profile granting fs_write admits the one tool both granted -- governance profiles are written in kiro-cli vocabulary and an allow-mode profile requires every queried item to match, so asking the raw id beside the alias would refuse a permitted write for an entry no operator wrote, while asking the alias alone would let a deny-mode deny: [str_replace] stop binding), and the read-only auto-approve classifier (_is_host_read_only_builtin) so a KAS read is free under --approval reads exactly where fs_read is. One alias may only deny (POLICY_ALIAS_DENY_ONLY_IDS, split by policy_alias_split): delete_file reads under fs_write so a write deny reaches it, but kiro-cli's fs_write cannot delete -- the same line the mount table draws -- so an allow-mode tools: ["fs_write"] written for kiro-cli must not become a deletion grant on KAS; the delete is asked on its own name and fs_write travels in gate_decision's deny_aliases, consulted for an explicit deny only, never a permit. fs_write binds str_replace / fs_append / delete_file, execute_bash binds the shell's permission id run_command. Only for built-ins: KAS names an MCP server on the tool_call as _meta.kiro.serverName and the tool on the permission request as _meta.kiro.mcpTool.identity, both read by src/kiro_crew/acp/_dispatch.py, so an MCP server's own read_file is seen as a served call and left alone. The request's identity.serverName is never adopted as the call's server: the trust flag records the tool_call's cache hit, and a built-in's tool_call writes that hit with an empty server, so a server taken from the request would carry trust into the server-keyed grants (the app-own MCP auto-approve) for a built-in -- agreement with the cached server is a no-op, and a server the tool_call did not name is refused on the KAS wire as an unreadable identity (pinned for the built-in-then-server, different-server and 512-character cases; a first-class harness, never handed the store, ignores the half as before). A built-in stamps only _meta.kiro.toolId, read as the tool name when the preceding tool_call wrote the identity cache with an empty name (the id fills that blank, and is not read on a request no tool_call preceded, such as a sub-agent spawn, whose identity comes from the consent classifier alone); it adds a deny target and cannot satisfy a trust-gated grant. Every value taken from the frame -- toolId and the mcpTool.identity server/tool pair -- passes _harness_identifier, the one length-and-spelling bound (128 characters, identifier characters only) that _permission_tool_id already applied, at the point of retention, so an oversized or glob-shaped field is read as absent and never reaches the event, the gate or the audit log. The fold reads that identity and nothing else: the display title is the model's own description, so a shell call described as str_replace folds to execute_bash, not fs_write, and a deny fs_write never refuses a command the operator did not name.

src/kiro_crew/cli_doctor.py adds a KAS-block row that reports ✅ only when the installed kiro-cli is one of the releases the tables were verified on (KAS_TOOL_IDS_VERIFIED_ON_KIRO_CLI, pinned equal to the fixture's verified_kiro_cli_versions: 2.24.0, where the id tables were first read; 2.24.1, where the write-plane path shapes were measured and the ids re-checked; and 2.27.1, the current release and the first above this repo's 2.27.0 kiro-cli floor, where every table was re-read against the extracted KAS bundle -- so a supported install reports ✅ rather than warning on every session start), and warns (advisory) for a release newer than the latest, older than the earliest, or between two verified ones and itself never measured -- a list, not an exact pin, so a routine release the tables were re-measured on does not warn on every session start, and the fixture's engine-bump note now ends with the step that maintains it (re-measure, then append the release to verified_kiro_cli_versions), which the doctor row names: the policy direction fails permissive on an id a newer engine may have renamed, and an older engine was never measured, so it is unverified rather than compatible. The .github/black-baseline.txt entries for test/test_cli_doctor.py and test/test_governance_policy.py are pruned: the added test classes made each file fully black-clean, so the ratchet graduates them.

A delete is on the write plane. WRITE_PLANE_KINDS in src/kiro_crew/platform/tool_paths.py adds the ACP delete kind beside edit in the routing predicate the hook gate, the always-enforced tier (src/kiro_crew/llm_helpers.py) and governance share, and targetFile joins TARGET_PATH_KEYS, so a delete_file of the crew config.json is refused by the same write-protected-config hard deny an edit is, and a delete of an SSH key by the sensitive-path keystone. KAS's targetFile is workspace-relative in its schema's terms, and the sensitive-path resolvers anchor a relative input to the gateway process CWD, so {"targetFile": "../config.json"} judged there would be a verdict about a different file from the one the engine deletes; edit_target_candidates therefore withholds a params path that is still relative after ~/env expansion and marks the union unanchored (the flag the diff-block path already set, which the hook gate, the always-enforced tier and governance each hard-deny as unverifiable) -- but ONLY for the kinds in PARAMS_ONLY_TARGET_KINDS (delete): a delete carries no diff block, so its one params spelling is the call's whole target, while an edit also names its file in the diff block and its params spellings are judged verbatim as they always were, so an ordinary relative file_path on an edit is not refused on any backend. The kind is read off the ACP kind the consumer routed on (the hook gate's tool_kind, the always-enforced tier's event.tool_kind, governance's tool_kind), never off the backend. That rule is also moot in practice on the kas write plane because the engine spells its write paths absolute: measured live (kiro-cli 2.24.1, engine 076b7d57b) through this PR's projection of the shipped spec, a fs_write create, a str_replace edit and a fs_append all completed under the carry-over with rawInput.path absolute (<workspace>/<file>), and a delete_file (spec extended to name it) put an absolute targetFile on its frame -- recorded per write tool as tool_call_path_shape in the fixture, matching the tools' own schema text ("Absolute path to the file"). A trusted delete gains the target gate and keeps its scan (it has no document body to suppress). The tool.risk caution-badge carve-out (src/kiro_crew/decisions/points/tool_risk.py) read the same predicate and would have dropped the badge on every delete; it now reads is_workspace_edit_call, the edit-only sibling added beside is_edit_call, so a delete_file keeps its caution badge on the auto-approving sessions where the badge is the only signal (docs/system-specs/modules/decisions.md updated). The route has to be reachable from the wire, and on KAS it was not: KAS's request_permission names no kind (its toolCall is id, status and title), so every KAS call reached the gate's kind-keyed tiers as "". build_permission_event now takes the kind the preceding tool_call frame carried, from a tool_kind_cache written by _build_tool_call_event beside the params/shell/identity/diff-path caches (src/kiro_crew/acp/_dispatch.py), owned and cleared per turn by AcpSessionHandle beside its siblings -- and it retains only a WRITE-PLANE kind (edit/delete), bounded at the point of retention: the frame's kind is an externally-sized string, and only membership in the closed WRITE_PLANE_KINDS vocabulary is stored, so an entry is one of those literals and never the frame's own bytes (a 1 MiB kind per unique toolCallId retains nothing). The per-turn provenance caches as a whole -- params, shell, MCP server, tool name, diff path, kind, rendered input and its redaction bit, all keyed on the same scoped toolCallId -- are ONE population with ONE admission (admit_tool_call_cache_entry) on the KAS harness, and only there: the handle hands the wire parsers the overflow record that opts a harness into the admission (AcpSessionHandle._tool_call_cache_overflow_for_wire, members of ACP_BACKENDS_PERMISSION_KIND_FROM_TOOL_CALL, the same per-frame shape as the kind cache), and every other harness is handed None and retains as it always did, so the bound is the KAS projection's and no first-class path gains a refusal mode (H13). Under it, a new id only while their union holds fewer than TOOL_CALL_CACHE_MAX_ENTRIES (256) distinct ids -- a population of calls IN FLIGHT, not of calls the turn has made: the handle releases a call's rows from every store (release_tool_call_provenance, AcpSessionHandle._release_settled_tool_call) the moment its result frame reports a status in TERMINAL_TOOL_STATUSES -- on members of ACP_BACKENDS_PERMISSION_KIND_FROM_TOOL_CALL only, the same membership that hands the wire the kind cache, the overflow record and the unreadable mark, because the release exists to keep the KAS-only admission's count a bound on calls in flight, while a first-class harness holds its rows until the turn's clear() exactly as on main so a same-id permission request after a terminal status (a re-ask after reject_once, a mode-change re-prompt) still finds its trusted row (H13) -- at every parse site -- the main route, the KAS sub-agent hand-off, the child-prefix hand-off and the native-child arm, whose frames share the parent's stores and population under the child's own scope and re-tag only calls and text, so a child's terminal reaches no other release -- and AFTER the frame's own readers (the spec-disabled tripwire reads raw_params at the terminal), under the frame's origin-scoped key so a child's terminal never releases a parent's row; the permission request precedes execution and nothing reads a settled call's provenance afterwards, so the count bound is a bound on concurrency rather than on turn length, and a long unattended turn that settles each call as it goes never reaches it (a stream of ids whose results never arrive still does, which is the shape the cap exists for), and any frame only while its rendered input -- the LARGER of the params rendering (the raw_params dict the row retains) and the FINAL form the tool_input string takes (diff content block or derived edit diff over the params, then redaction), both measured because either can be the bigger one: a small rawInput beside a large diff block must not pass on the params' size, and a near-limit rawInput beside a tiny diff must not pass on the diff's -- is within TOOL_CALL_CACHE_MAX_PAYLOAD_CHARS (2,000,000; a rendering the encoder DEGRADED to the fixed nested-too-deeply placeholder is no measurement and counts as over the bound -- _params_chars_for_admission -- so a dict too deep to serialise cannot pass admission at 49 characters while retaining strings of any length), its scoped key -- the frame's sessionId joined to its toolCallId, both backend-authored -- is within TOOL_CALL_CACHE_MAX_KEY_CHARS (512; real ids are UUIDs or short prefixed tokens) and the diff-block path it names is within TOOL_CALL_CACHE_MAX_PATH_CHARS (4096, Linux PATH_MAX; refused, never cut, since a truncated path names a different file to the target gate) -- the three externally-sized strings a row keeps, each measured by the one admission; every other retained field is a bool, a WRITE_PLANE_KINDS literal or a bounded name: the built-in _meta.kiro.toolId by _harness_identifier (128 identifier characters, the KAS engine-name bound), and the KAS identity channel's MCP names -- the tool_call serverName row of the _meta channel table (_MetaIdentityChannel.bounds_names, the only row that bounds; consulted first, and answering only for a frame carrying its own serverName so a kiro-cli built-in's bare toolName falls through to the kiro-cli row) and both halves of the permission frame's mcpTool.identity -- by mcp_gateway.tool_surface.mcp_identity_name, the ONE definition of what Crew's own MCP tool surface admits (admits_name, 512 characters, any spelling; the surface guard now reads through the same predicate), so a name the surface listed always carries an identity for an exact per-tool deny to bind to (bounding it at 128 emptied a valid 129-character name, dropped the deny target, and handed the call to the title-keyed grant loop). The first-class channels (kiro-cli mcpServerName/toolName, the codex rawInput pair, goose) retain a string verbatim exactly as they always did and gain neither the bound nor what follows from it (H13). A KAS name over the bound is never cut and is NOT read as absent either: a half that is PRESENT but over the bound marks the frame mcp_identity_unreadable (tool_surface.mcp_identity_unreadable; carried per scoped toolCallId in identity_unreadable_cache, a sibling store under the same admission, eviction and release that the handle hands the wire parsers only for the KAS harness (_identity_unreadable_cache_for_wire, the same per-frame membership gate as the kind cache and the overflow record; the client gates its store on the same set), and read off the permission frame's own mcpTool.identity only when that store was handed), because a call that names a tool Crew cannot retain is not a call that names none -- judged under the empty name, the exact @server/tool deny it may be under would not bind and the title-keyed grant loop could approve it. Such a request is refused wherever a permission request is answered: in the hook gate itself (on_tool_call(mcp_identity_unreadable=...), extracted by hook_gate_kwargs so every dispatcher and the client's transport floor see it, a security deny), by the handle before any consumer sees the event (_refuse_unreadable_mcp_identity, audited mcp_identity_unreadable), and in the always-enforced tier of _resolve_permission for AUTO_APPROVE callers that skip HookManager wiring -- and since only KAS is ever handed the store, only a KAS frame is ever marked: the refusal is a KAS refusal mode and no first-class path gains it (H13); no frame-authored identity string is retained past its channel's bound -- so cache memory per turn is bounded by MAX_ENTRIES * (payload + key + path) (~512 MiB). A refused frame gets no row in any cache -- and a refused REFINEMENT evicts the row the earlier admitted frame wrote under the same id from every sibling store (the three stores a refinement never writes are passed to its admission for exactly this), since a stale row would otherwise stay raw_params_trusted against a superseded target and short-circuit the handle's refusal below -- a same-id refinement within the size bound is always admitted, overflow is logged once per emitting scope PER SNAPSHOT (the warning is deduplicated against the handle's own record, which is cleared with the caches at turn reset, so no process-global state outlives the turn and the next snapshot's overflow is said again), and the scope is recorded on the handle (_tool_call_cache_overflow, cleared with the caches) as a fixed-size SHA-256 digest (overflow_scope_key: the scope is the frame's own sessionId, an unbounded backend-authored string the admission may have refused for its size, so the handle's record never holds the text and the warning carries only the digest's head), one entry per scope, and past TOOL_CALL_CACHE_MAX_ENTRIES distinct scopes the OVERFLOW_EVERY_SCOPE marker instead, so the record is bounded and every later scope reads as overflowed (scope_overflowed, the one reader). The permission request for a refused id misses every cache, and rather than yielding a call with no kind, identity or target to a consumer -- whose AUTO_APPROVE path would judge the title alone, so a mounted KAS delete_file flooded past the cap would stop being refused -- the handle refuses it itself (AcpSessionHandle._refuse_unretained_provenance, audited as provenance_cache_overflow, and its warning names both bounds -- the count of distinct calls in flight and the per-call input size -- so an operator reading the refusal alone knows which limit a call can meet); a retained id and every request from a scope the bound never refused are untouched. The bound narrows what is provable, not what is permitted. What each party sees on a refusal is the shape every handle-owned refusal already has on main (the spec-disabled deny, the fidelity gate): the AGENT gets the adapter's own deny option answered on its permission request -- a per-tool "permission denied" it can act on by retrying with a smaller input or after its calls settle, never a cancelled outcome that would end the turn; the OPERATOR gets a SEL row (provenance_cache_overflow, or mcp_identity_unreadable for the name bound) plus a warning naming the bound that was hit and the two ways past it, and the hang-resilience counter for a child denial; the USER sees the tool card end denied like any other refused call. No new user-facing surface is added because none of the existing refusal paths has one, and a KAS turn that stays under 256 distinct calls in flight with inputs under the payload bound (TOOL_CALL_CACHE_MAX_PAYLOAD_CHARS = 2,000,000 characters -- a single fs_write of about 2 MB of file content; the largest write observed in any KAS hands-test was under 10 KB) never meets the refusal. The engine's kind map (mapActionTypeToToolKind) stamps search on grep_search, file_search and list_directory and other on code/tool_search, recorded per built-in as tool_call_kind in test/fixtures/kas_builtin_tool_ids.json, and a carried search would veto the host read-only proof that auto-approves a KAS search by identity, so every other kind is not written and the event stays "" as before. Real classifications only, and a kind the permission frame does state is never overridden; a non-string kind on the frame (an unvalidated harness value) is read as absent rather than stamped, and both write-plane predicates and the always-enforced tier's delete route test membership only on a string, so an unhashable kind classifies instead of raising and aborting the turn. The cache is handed to the wire parsers per frame (AcpSessionHandle._tool_kind_cache_for_wire) only for members of a new capability set ACP_BACKENDS_PERMISSION_KIND_FROM_TOOL_CALL (src/kiro_crew/agent_sdk/backends.py, KAS only; re-exported via acp/types.py and acp_backends.py, classified off-card in backend_cards.py); the handle's construction is identical for every harness, and a non-member is handed None, which disables both writer and reader: kiro-cli's permission frames omit kind too, but it routes edits by the diff content block already and its kindless governance classification is additive, so a carried edit would change what its gate sees. The kiro-cli path (AcpClient and the non-member handle) is unchanged. The owning spec docs/system-specs/modules/security.md records the write-plane kinds, the delete route, and the carry-over.

flowchart LR
  subgraph Before
    a1[spec: fs_read, grep, glob]:::ctx --> a2[KAS matcher: exact id or tag]:::ctx --> a3[nothing mounted]:::removed
  end
  subgraph After
    b1[spec: fs_read, grep, glob, fs_write]:::ctx --> b2[tool_names: expand]:::added --> b3[read_file, list_directory, grep_search, file_search, str_replace, fs_append]:::added --> b4[KAS mounts them]:::changed
    b4 --> b5[permission frame _meta.kiro.toolId]:::added --> b6[gate: policy_aliases]:::added --> b7[deny / ceiling evaluated under the kiro-cli name too]:::changed
  end
  classDef added fill:#DCFCE7,stroke:#16A34A
  classDef changed fill:#FEF3C7,stroke:#D97706
  classDef removed fill:#FEE2E2,stroke:#DC2626,stroke-dasharray:4 3
  classDef ctx fill:#E0F2FE,stroke:#0284C7
Loading

🟩 added · 🟨 changed · 🟥 removed · 🟦 unchanged

The spec's kiro-cli names arrive at KAS with the ids KAS registers, and a rule written in kiro-cli names still binds to them.

The tools row in src/kiro_crew/docs/agent-spec-fields.md records the expansion and the exclusion polarity.

Tests

  • test/test_tool_names.py — the two tables agree; delete_file is governed as a write but mounted by no family; the shell's run_command is governed as execute_bash; the exclusion reading withholds delete_file under fs_write and equals the gate's policy table per owner name (execute_bash included) less the permission-frame-only run_command, which the engine's exclusion matcher cannot see and whose registered owner already withholds; every mounted id is in the recorded engine registry, every policy key is an id the gate can receive, and every registered filesystem/shell id has a policy spelling or is listed as shared; the runtime's measured-version constant equals the fixture's; policy_aliases dedupes and never echoes an input; policy_alias_split files a same-capability alias (str_replace, read_file, run_command) as admitting and delete_file's as deny-only, and the deny-only set equals exactly the policy keys outside every mount family; expand is pure and order-preserving.
  • test/test_hooks.py::TestClassifierOnlyHostTrustedProof — a trusted KAS read built-in is proven read-only under its kiro-cli name (auto-approved under --approval reads); a KAS write/shell alias is not; a KAS read of a sensitive path is still denied first; the fold still demands trust and no server.
  • test/test_tool_call_classification.py::TestKasMcpServedIdentity — a KAS MCP-served read_file (server on the tool_call as serverName, the pair on the permission request as mcpTool.identity) reads as a server call, so a built-in fs_read deny does not bind and the read-only proof does not fire, while a @probefs/read_file rule does bind; a kiro-cli mcpServerName frame still reads through the first channel; an oversized (513+) server/tool half is ignored (the pair reads as no identity, the toolId stands), a 512-character half is kept, and a 129/300/512-character MCP tool name keeps its exact @server/<name> deny binding against a title-keyed auto_approve_tools grant; test/test_mcp_tool_surface.py::TestTheNameBoundIsOneDefinition pins that the surface guard and the identity read agree at the bound. A 513-character half on the KAS channel (tool_call serverName/toolName, the permission frame's mcpTool.identity) marks the tool_call identity and the permission event unreadable while an absent half does not, and the same half on a first-class channel (kiro-cli toolName, the codex pair) is retained verbatim and never marked; the KAS handle refuses such a request (rejected on the wire, audited) and is wired before the consumer yield, while a kiro handle is handed no store, records nothing and refuses nothing; only the KAS row of the channel table bounds, it is consulted first, and a kiro-cli built-in's bare toolName falls through it unbounded; test_hooks.py::TestAnUnreadableMcpIdentityIsDeniedByTheGate — the gate denies it ahead of any grant while a 512-character or absent identity takes the ordinary path, and hook_gate_kwargs extracts the flag; test_llm_helpers_edit_gate.py::TestAnUnreadableMcpIdentityIsRefusedOnEverySurface — the always-enforced tier denies it as always_deny; test_codex_session_mcp.py — a codex pair whose tool half is 513 characters is retained verbatim, identified, and never marked (first-class, H13).
  • test/test_cli_doctor.py::TestTheKasBlockReportsToolVocabularyDrift — the measured engine is reported matching; a newer one and an older one each warn and name both versions (advisory, no issue; older is unverified, not compatible); an unknown version is its own row.
  • test/test_tool_call_classification.py::TestKasPermissionFrameTakesTheToolCallKind — a KAS permission frame (no kind, toolId only) carries the tool_call's kind for edit/delete and NOT for read/search/execute/fetch/other; the carried set is exactly the write plane and the fixture's per-built-in tool_call_kind map agrees (search on all three search-shaped reads, read on read_file); a KAS grep_search/file_search/list_directory whose tool_call stamped search still auto-approves under the read-only proof with the cache present; without the cache the kind is "" (the pre-fix shape); a kind the frame states is not overridden; a non-string frame kind is read as absent (the cached kind fills it, or "" without one); placeholders are not cached; the cache retains only the closed write-plane vocabulary (a 1 MiB kind and every non-write kind retain nothing; the stored values are the edit/delete literals); end to end from the wire, a KAS delete_file of ~/.kiro/crew/config.json is denied by the hook tier and the same frame without the carry-over is not, and a delete_file naming ../config.json, ../.kiro/crew/config.json or notes/plan.md is denied as a relative target (a delete carries no diff block, so its relative params path is the unverifiable whole target). TestTheKindCarryOverIsKasOnly — the KAS handle hands its cache to the wire and every other backend's handle (and a runtime double with no backend) hands None, with the attribute constructed identically on all; a kiro-cli search tool_call followed by a kindless permission frame stays kindless and read-only-proven both without the cache (the kiro path) and with it (the reader withholds search); a kiro-cli edit tool_call is what the membership gate keeps kindless (the reader would carry it).
  • test/test_decisions_tool_risk.py — a delete-kind call at caution 0.99 under a trust policy still records its badge (a deletion is not the workspace edit the carve-out describes). test/test_hooks_edit_gate_diff_path.py — is_edit_call and is_workspace_edit_call differ only on delete and agree on every other kind/diff-path pair; WRITE_PLANE_KINDS == {edit, delete}.
  • test/test_kas_agents.py::TestTheSpecIsSpelledInKasToolIds — each kiro-cli read tool carries its KAS family; the write family stops at str_replace, fs_append and projects no fs_write allow rule; delete_file mounts only when named; the spec's own name is kept; shared names and @refs pass through unchanged; a spec already in KAS ids is not duplicated; excluding fs_write also excludes delete_file; the table names only registered ids (from the fixture).
  • test/test_kas_agents.py — TestToolsFailClosed pins the mixed spec's projection to its exact list; TestAgainstTheRealBundledSpec pins the shipped defaults.json projection exactly to expand_kiro_cli_tool_names(spec["tools"]), with the read family present and delete_file absent.
  • test/test_hooks.py::TestKasAliasesAreGovernedUnderTheirKiroCliName — auto_deny_tools: ["fs_write"] denies str_replace, fs_append, delete_file by engine-stamped identity; a model-authored title spelling a KAS id never folds, and an identified shell call (run_command / execute_bash) titled str_replace is not refused by a write rule but is by a shell rule; fs_read / grep / glob rules deny their KAS read aliases; the governance tools scope is asked str_replace and fs_write as one alias group (also when the title is the raw id), and through the real gate_decision an allow-mode profile of {title, fs_write} permits the KAS write, a deny-mode profile denying either spelling refuses it, and a raw-id auto_deny_tools still binds; a KAS delete_file is asked on its own name with fs_write deny-only (no alias group), and through the real gate an allow-mode {title, fs_write} refuses the delete while admitting str_replace, naming delete_file admits it, and a deny under fs_write refuses it; test/test_governance_policy.py::TestGateDecisionAliasGroups — allow-mode in either vocabulary admits, neither spelling listed refuses naming the kiro-cli name, deny-mode on either spelling binds with rule1-deny, a ceiling deny on the raw id is final, a subordinate deny folded under an allow ceiling (either fold order) still binds and answers the same as a single-tier ceiling, a central delete_file deny folded with a local fs_write allow (either order) refuses the delete on its own name, an allow-mode fs_write grant does not admit the delete (an allow-set miss, not a written deny), an allow set naming delete_file admits it without naming fs_write, a deny under the deny-only alias binds, a sibling verb's deny does not reach it, and a permitted deny-only alias never admits; deny provenance survives every fold while an allow-mode miss never gains it, a title equal to a group member is covered by the group, empty groups are ignored, each level granting a different spelling admits the one tool (either way round), a level granting neither spelling still refuses, and a profile deny is reported over a ceiling allow-miss; a shared name gains no alias and is not asked twice; an MCP-served read_file / str_replace gains no alias at either tier while a @filesystem/read_file rule still binds.
  • test/test_hooks.py — a sensitive path under targetFile is denied like the other spellings; a KAS delete_file on an AWS credentials path is denied; an ordinary targetFile is still allowed.
  • test/test_hooks_edit_gate_diff_path.py::TestADeleteIsOnTheWritePlane — a delete of config.json / cloud.json / playwright-cli-config.json is denied by the write-protected tier; an ordinary delete passes; a delete naming no target is denied; the read allowance is untouched. TestADiffBlockRoutesOntoTheWritePlane — a non-string kind (list, dict, number, None) classifies as "not on the plane by kind" in both readings instead of raising, and a diff block still routes it. TestARelativeParamsPathIsUnverifiableOnlyWhereItIsTheWholeTarget — a relative targetFile on a delete, alone or beside a safe absolute one, is denied by the hook gate and the always-enforced tier as a relative target and an absolute one is judged on its merits; a relative path/file_path on an ordinary edit is NOT refused by either tier; a relative diff-block path is still denied whatever the params say; a ~-spelled delete target stays anchored; edit_target_candidates withholds the relative spelling and sets unanchored for the delete kind only (PARAMS_ONLY_TARGET_KINDS == {"delete"}) and judges it verbatim for edit and for an unknown kind; governance emits the never-permittable marker for a delete and the verbatim path for an edit. test/test_cli.py::TestChatPermissionRequest — through the production direct-client parser and the CLI consumer, a trusted edit of an absolute path and a trusted edit of a relative one each reach the human and are approved (the relative edit is the routine shape on every backend); the cache-miss pin now names an absolute inline path so what it asserts is provenance (unverified_shell), not a target denial.
  • test/test_spec_hook_kas_tool_names.py::test_the_hook_rows_are_the_gate_s_policy_table_inverted — every policy-table pair appears in the hook matcher rows and every row entry outside the hook-only tools is a policy-table pair (plus the shared fs_write id).
  • test/test_tool_call_classification.py::TestTheProvenanceCachesShareOneBound — after TOOL_CALL_CACHE_MAX_ENTRIES distinct ids the next id is written to none of the nine sibling caches (the eight this PR bounds plus main's toolCallId -> harness_tool_name store, which the rebase placed under the same admission and the same terminal release -- test_the_harness_name_store_is_a_sibling_under_the_same_admission), the scope is recorded and the overflow is logged once -- and again on the next snapshot once the record is cleared with the caches, while more refused frames in the same snapshot add no line; an oversized payload is refused whether the id is new or already held (a small first frame reserves no row for a huge refinement); a frame whose scoped key is over TOOL_CALL_CACHE_MAX_KEY_CHARS or whose diff-block path is over TOOL_CALL_CACHE_MAX_PATH_CHARS is refused the same way -- written to no cache, the scope recorded -- while a key and a path at exactly the bound are admitted, and the property over frame shapes also drives oversized keys and paths through both builders (initial frame and refinement) and finds no key, no path and no payload retained over its bound; the size bound measures the FINAL retained rendering, not the params -- with the bound lowered under the unified-diff renderer's own cap, a ~20-char rawInput beside a diff block rendering to ~6 KiB is refused on the initial frame and on a refinement of a held id, and the converse -- a rawInput over the bound beside a two-character diff block -- is refused on both too while the same shape one under the bound is admitted (so it is the params' size that refuses, not the block's presence), and a property over five frame shapes (create/strReplace/insert bodies, a diff block, an oversized refinement) finds nothing retained over the bound; a refinement of a held id within the size bound is admitted past the count cap; a refused id's permission event carries no trusted params, shell classification, identity or kind; through the real handle, a mounted KAS delete_file whose frame arrived past the cap is refused by _refuse_unretained_provenance with the adapter's own reject option, while a retained id and an unknown id on a scope that never overflowed go to the consumer as before; the overflow record is cleared wherever the kind cache is (AST pin); the record holds 64-character digests, never the scope (a 10 MiB sessionId that pushes a key over the bound is recorded as its digest and reads back as overflowed while another scope does not), and past the entry cap it takes the every-scope marker (MAX_ENTRIES + 1 entries at most; a never-refused scope then reads as overflowed, below the cap it does not); a refused refinement evicts the id from every cache (params, diff path, identity and kind written by the first frame are gone, the permission event carries no trusted provenance) and, through the real handle, a benign cached KAS write followed by an oversized same-id refinement naming a different target is refused rather than judged on the stale one; the four earlier pins that asserted the held row survived a refused refinement now assert the eviction.
  • test/test_llm_helpers_edit_gate.py::TestADeleteIsGatedOnItsTarget — the always-enforced tier refuses a trusted delete of config.json, allows an ordinary one, does not target-gate an untrusted frame on its own word, and still runs the scan on a delete.
  • test/test_llm_helpers_mcp_document_body_real_frames.py::TestKasReadsTheSameBarFromItsOwnFrames — on captured kiro-cli 2.27.1 KAS frames, a resident knowledge_add_document call reaches the document-body exemption on the pair the permission frame states and the tool_call's server confirms (approved; the pre-PR pin had this fail-closed because no KAS identity was parsed); a deferred call's nested body keeps the full scan (denied); a request naming a server the tool_call did not is denied; a benign body is approved in both modes.
  • test/test_tool_call_classification.py::TestKasPermissionFrameCarriesTheBuiltinId — a KAS permission frame's _meta.kiro.toolId becomes the event's tool name; a cached toolName wins over it; malformed ids are ignored (non-strings, blanks, one over the 128-character bound, a 100 KiB id, a glob, whitespace), the bound is exactly _permission_tool_id's, and an oversized or glob-shaped mcpTool.identity field reads as absent (the cached server and the toolId stand); a frame no tool_call preceded (a sub-agent spawn's synthetic toolCallId) is not named by its raw id -- the consent classifier's verified Crew name or nothing -- and a built-in id with no preceding tool_call is not named either; the frame id cannot satisfy the spawn rung or the identified-MCP-call reader; end to end, auto_deny_tools: ["fs_read"] denies a KAS Read File permission from the frame alone. test/fixtures/acp_frames/kas/session.expected.json re-recorded for the same reason.
  • test/test_kas_mode_binding.py — the injected agent's wire tools list carries the family beside fs_read.

Mutation-probed: emptying the mount table fails 8; re-adding delete_file to the fs_write family fails 3; removing the deny-tier alias fold fails 8; feeding the title back into the fold fails 2 and also dropping its identity guard fails 5; removing the governance alias fold fails 1; appending the alias beside the raw id in the governance query (requiring every spelling) fails 4; dropping the explicit-deny short-circuit in the alias group (alias-only semantics) fails 4; hiding the inner half's deny behind an outer allow-miss fails 2; resolving each spelling through the intersection instead of per level fails 3; emptying the deny-only alias set (routing delete_file through the admitting group) fails 4; letting the deny-only channel refuse on an allow-set miss fails 2; dropping the mcpServerName guard fails 2; using the mount reading for excludedTools fails 1; emitting permission-frame-only ids in exclusions fails 2; disabling the permission-frame id read fails 5; reading the frame id on a request no tool_call preceded fails 10; reverting WRITE_PLANE_KINDS to edit only fails 5; dropping run_command from the policy table fails 2; removing the read-only classifier alias fold fails 5; removing the KAS serverName identity channel fails 1; neutralizing the mcpTool identity read fails 1; disabling the doctor newer-engine warning fails 1; restoring <= in the doctor row fails 1; comparing drift against the single first-measured release instead of the verified list fails 3; disabling the permission-frame kind carry-over fails 5; caching the unknown placeholder fails 1; handing the kind cache to every backend's wire fails 4; routing a delete into the caution-badge carve-out fails 1; stamping a non-string frame kind on the event fails 5; testing write-plane membership without the string guard fails 3; appending a delete's relative params path to the target set instead of withholding it (emptying PARAMS_ONLY_TARGET_KINDS) fails 5; retaining every non-placeholder kind in the cache instead of the write-plane vocabulary fails 8; dropping delete_file from the derived hook rows fails 1; reading the frame toolId with a plain strip instead of the identifier bound fails 5; admitting every id into the provenance caches regardless of the shared cap fails 2; dropping the payload size bound fails 1; dropping the key and diff-path bounds from the admission (measuring the payload alone) fails 3; measuring the params rendering at the gate instead of the final retained rendering fails 1; measuring the final rendering alone (not the larger of it and the params rendering) fails 1; letting the handle yield a refused id's permission request instead of refusing it fails 1; warning on every KAS session instead of once per engine release fails 1; leaving a refused refinement's stale row in the caches (no eviction) fails 6; not releasing a settled call's provenance on the main route fails 2; releasing under the handle's own scope instead of the frame's fails 3; releasing on every harness instead of the KAS membership set fails 1; reading an oversized identity half as absent instead of unreadable fails 4; dropping the hook gate's unreadable-identity deny fails 2; dropping the handle's pre-yield refusal fails 1; handing the unreadable store to every harness fails 1; bounding the kiro-cli channel row too fails 5; recording the overflow scope's text instead of its digest fails 1; handing the overflow record (the admission) to every backend's wire fails 6; bounding the MCP identity halves (the mcpTool.identity pair and the _meta channels) with the built-in 128-character identifier bound instead of the surface's name bound fails 8; dropping the membership gate at the handshake call site (awaiting the KAS drift check on every harness) fails 1; deduplicating the overflow warning against a record that outlives the turn fails 1.

Manual verification

Live hands-test against the real engine (kiro-cli acp --agent-engine v3 --auth-method cli, kiro-cli 2.24.0, the kas backend's own argv), driven over stdio with the shipped defaults.json projected through to_client_custom_agent, injected as a client custom agent, activated, then prompted to read a file using a file-reading tool and not the shell:

spec sent as (main) spec projected (this PR)
tools on the wire execute_bash, fs_read, fs_write, code, grep, glob, … … fs_read, read_file, list_directory, fs_write, str_replace, fs_append, … grep, grep_search, glob, file_search, …
tool_call frames on the read turn 🟥 none 🟩 Read File, kind read, rawInput.path = the file
agent reply 🟥 "I don't have a dedicated file-reading tool available in this environment. The tools I have are shell execution, file writing, web fetch, and skill activation." 🟩 hello-from-kas-probe (the file's contents)
asked to delete_file a path under .ssh/ — 🟩 no tool call, file untouched (delete_file is not mounted by fs_write)

Both JSON reports are posted as a PR comment.

The per-built-in ACP kind recorded in the fixture was read from the engine source at the measured commit (packages/kiro-agent/src/acp/session-update-utils.ts mapActionTypeToToolKind, keyed by each tool file's actionType): list_directory stamps search, not other, which is why the carry is confined to the write plane rather than to "everything but search on the two grep-shaped tools".

Write-plane hands-test (kiro-cli 2.24.1, same argv, this PR's projection of the shipped spec, a fresh workspace, every permission answered allow): "create probe-created.txt" → Write File (fs_write, kind edit, rawInput.path absolute) and the file exists; "replace alpha with alpha-edited in probe-note.txt" → Read File then Replace in File (str_replace, kind edit, absolute path) and the line is edited; "append gamma" → Append to File (fs_append, kind edit, absolute path) and the line is appended; "delete probe-victim.txt" with the spec as shipped → no tool call, file untouched (not mounted); with delete_file added to the spec → Delete File (delete_file, kind delete, absolute targetFile) and the file is gone. Every permission frame carried _meta.kiro.toolId and no kind. Recorded per write tool as tool_call_path_shape in the fixture.

Re-measured on kiro-cli 2.27.1 (the extracted KAS bundle kiro-cli runs, @kiro/agent 0.66.22, read directly rather than through a live model turn): every registered id is present and none is renamed; the shell's static id is still run_command; the actionType → ACP-kind switch is byte-identical to the 2.24.1 bundle's for every kind the fixture records; each built-in's permission request still stamps _meta.kiro.toolId with its own class id; and the path-parameter descriptions that produced the absolute shapes are unchanged. 2.27.1 is appended to verified_kiro_cli_versions (and the pinned constant), with the reading recorded under the fixture's remeasured key. 2.27.0 was not measured and stays unverified.

Related Issues

no linked issue: found while hands-testing the kas backend; no open issue reports it.

Pattern harvest

Rule candidate: review-prompt
Pattern: a spec or policy written in one engine's tool vocabulary is applied to another engine's allowlist or name-keyed gate without translation; check the target engine's matcher when a backend switch is added, and translate in both directions (mount AND govern).

Sensitive change review (for a human reviewer to sign off)

## Sensitive change review
- Head commit: 3579d6d1e710e748a5053a6db63919ff31e3e350
- What rule changed: The tool gate (hooks.py, hook_runtime/gate_tiers.py, governance_gate.py, tool_identity.py) reads a KAS built-in id (read_file, str_replace, run_command, ...) under the kiro-cli name an operator's rule is written in, for permission events built by the KAS harness only (AcpEvent.kas_builtin_ids, forwarded by AcpProvider). Deny tier: both spellings are deny targets. Governance tools scope: one alias group (explicit deny on either spelling binds; otherwise a level permits if it permits any spelling). delete_file reads under fs_write for denies only. A KAS MCP identity over the name bound is denied. A delete's params target must be anchored (absolute; on Windows with a drive).
- Before -> after (what was allowed/blocked, now): Before: on kas, a kiro-cli-named deny (fs_write, execute_bash) did not reach str_replace / fs_append / delete_file / run_command; an allow-mode tools: [fs_write] refused str_replace. After: the deny reaches them; the allow admits str_replace / fs_append (not delete_file). A KAS read is auto-approved under --approval reads like fs_read. Other harnesses: unchanged, a bare read_file / run_command / delete_file is judged under that id alone.
- Worst case if wrong (breaks commands / leaks secret / locks user out): An allow-mode ceiling written in kiro-cli names admits a KAS write the author meant to refuse; or a KAS read is auto-approved when it should prompt. Both are limited to the kas backend; the sensitive-path floor and the write-protected-config tier run before governance and are unchanged for reads/edits.
- Evidence checked (which sandbox result proves it): test_governance_policy.py::TestGateDecisionAliasGroups (deny beats allow per layer, across _AndRuleset folds in both orders, through a profile extends fold, read_file/fs_read pair); test_hooks.py::TestKasAliasesAreGovernedUnderTheirKiroCliName and ::TestKasIdFoldIsKasOnly (off-KAS harness gets no fold, no auto-approve); test_tool_call_classification.py (wire-level KAS vs non-KAS frame); test_hooks_edit_gate_diff_path.py (delete routing, Windows anchoring).
- No regression:
  - Tools still work (which tools/commands were run, result): kiro-cli path unchanged by construction (kas_builtin_ids is False off KAS); first-class frame tests in test_tool_call_classification.py and test_codex_session_mcp.py pass.
  - Backward compatible (old config / old data / old callers still work, how checked): gate_decision callers without alias_groups evaluate as on main (TestGateDecisionAliasGroups); old deny/allow configs unchanged off KAS (TestKasIdFoldIsKasOnly).
  - Existing tests (which suites passed on this head): 10,187 tests in the 86 files that call the gate, permission builder or path anchoring, plus the 18 files this PR touches (1,907), on this head locally; CI on this head.
- How to undo: Revert the two commits of this PR; no data or config migration.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/hook_runtime/gate_tiers.py

  • src/kiro_crew/hook_runtime/governance_gate.py

  • src/kiro_crew/hook_runtime/tool_identity.py

  • src/kiro_crew/hooks.py

  • @iamwhatever: missing the ## Sensitive change review heading

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: 3579d6d1e710e748a5053a6db63919ff31e3e350
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of 3579d6d1e710e748a5053a6db63919ff31e3e350 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

delete now routes onto the write plane by ACP kind for every harness, but the description presents it as KAS-only. On another engine that sends kind: "delete", relative-path deletes start being refused.

Watch

  • The delete write-plane change isn't limited to KAS. The patch adds WRITE_PLANE_KINDS: frozenset({"edit", "delete"}) and PARAMS_ONLY_TARGET_KINDS = {"delete"}. Its own comment says the kind is read "off the ACP kind, never off the backend". That means is_edit_call and edit_target_candidates change for any harness whose permission or tool_call frame carries kind: "delete". On that harness, a delete that used to reach no gate is now checked against the config hard-deny, and a relative path/file_path is denied as unanchored. The description says the opposite: "Every other harness evaluates as on main", and the hooks.on_tool_call reader is described only as "a KAS delete_file". This only ever adds refusals, so a revert fixes it. But it is an unlisted new refusal mode on codex/claude/goose/opencode. If one of those emits delete with workspace-relative paths, users there lose deletes without warning.
    Clears when: either the delete routing is limited to ACP_BACKENDS_PERMISSION_KIND_FROM_TOOL_CALL, like the kind cache, or the Backwards compatibility section lists the cross-harness is_edit_call reader and a test shows which non-KAS backends emit kind: "delete" and what they now see.

Suggestions

  • gate_decision's alias_groups OR-within-a-layer logic resolves the whole ceiling as one layer. Policy tiers inside a composed _AndRuleset therefore don't get the per-tier OR. That is fail-closed, so it's safe, but the docstring should say so. Otherwise a later "parity" fix may loosen it without anyone noticing.

[DESIGN-REVIEWED] 3579d6d

Description read

[DESCRIPTION-READ] 19afa1ba3a58cbd4fd6dacc57cd25713ef146a58691c996f0c8dc9e9a75c2704

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 3579d6d1e710e748a5053a6db63919ff31e3e350 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The read-tool fix is about 60 lines, but the PR also ships delete_file write-plane routing and roughly 250 lines of KAS cache bounds, and neither is in the Goal.

Not justified as shipped

What this change ships

Inventory (8 items) — 5 justified

Intent: give a kas-backend agent the same read, list and search tools it has on kiro-cli, under the same operator rules. This is a FIX.

  1. The shipped spec mounts read_file, list_directory, grep_search, file_search, str_replace and fs_append on KAS — justified
  2. A spec's excludedTools withholds the matching KAS ids too — justified
  3. Operator deny and allow rules written in kiro-cli names now apply to KAS ids; delete_file can only be denied that way — justified
  4. KAS read calls auto-approve under --approval reads — justified
  5. A KAS delete_file is routed through the write-plane gate, and a relative target is denied — rides along, oversized
  6. On KAS, a request is refused when it is past 256 calls in flight or its payload is too large — oversized
  7. On KAS, an MCP identity over 512 characters is refused — justified
  8. kirocrew doctor shows a tool-vocabulary row checking the installed kiro-cli against the verified releases — undeclared drift: the description lists a session-start warning that isn't in the diff

[FIRST-PRINCIPLES-REVIEWED] 3579d6d

Description read

[DESCRIPTION-READ] 4555ff67ac62f74b9d9c1ade740b220ec93c102f4af5fa78e6fb8e31d54c5a54

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🟡 CONCERNS

Which legitimate operations does 3579d6d1e710e748a5053a6db63919ff31e3e350 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: the reviewer's own judgement; no confirmed regression.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 12 classified, 0 newly refused, 12 still allowed.
  • ubuntu-latest (platform posix): 12 classified, 0 newly refused, 12 still allowed.
  • windows-latest (platform windows): 11 classified, 0 newly refused, 11 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: CONCERNS

TIGHTENING: the KAS write-plane gate now covers deletes, and KAS tool names are now read under their kiro-cli policy names. The one threat it refuses is a KAS delete_file on a write-protected config, which no gate checked before. The hunk that names it, in platform/tool_paths.py: +WRITE_PLANE_KINDS: frozenset[str] = frozenset({"edit", "delete"}) — "before this, delete_file {"targetFile": "~/.kiro/crew/config.json"} declared a kind neither gate routed and the always-on config hard-deny never ran". The other pieces that support it:

  • TARGET_PATH_KEYS gains "targetFile".
  • PARAMS_ONLY_TARGET_KINDS = {"delete"} makes edit_target_candidates refuse a relative targetFile, and on Windows also a rooted path with no drive (_is_anchored(..., require_drive=True), ntpath).
  • _trusted_delete in llm_helpers._resolve_permission sends a trusted delete through _edit_target_denial.
  • A new refusal for an unreadable identity (identity_unreadable / mcp_identity_unreadable): an MCP server or tool name over 512 characters.
  • GateFacts.deny_targets gains policy_alias_names, and governance gains alias_groups / deny_aliases. The diff says governance now admits more than before; the deny side reads the extra names.

ADJUDICATED: 19 candidates, 0 confirmed newly-refused (no verdicts have been handed back for this run yet)

PLATFORM COVERAGE: The rows probe the shell spellings next to the touched area: deleting files in the workspace, reading config, removing a worktree by relative path, searching source, and the PR's own tests and doctor commands.

  • posix: rm, rm -rf, git worktree remove ../…, cat ~/.kiro/crew/config.json, grep/sed source reads, .venv/bin/python -m pytest ….
  • windows: Remove-Item and del with \ separators, Get-Content $env:USERPROFILE\…, type %USERPROFILE%\…, git worktree remove ..\…, Select-String, .venv\Scripts\python.exe -m pytest ….
  • any: kirocrew doctor, kiro-cli --version, git rm --cached, git log --grep=delete_file.

None of the diff's three shell tiers (is_sensitive_bash_command, audit_bash_exfiltration, is_denied) changed. Its platform assumptions sit in the non-shell path logic:

  • ntpath driveless-root handling.
  • Relative-path handling, which depends on the gateway's working directory.

Those are listed under UNADJUDICATED below. Shell rows cannot reach them.

UNADJUDICATED:

  • Relative and Windows-rooted delete targets. Guard: edit_target_candidates with tool_kind="delete", which sets unanchored. It is reached from hooks._tier_write_protected (edit_target_candidates(call.raw_params, call.diff_path, tool_kind=call.kind)), from llm_helpers._edit_target_denial through _trusted_delete, and from governance.classify_tool_args. Inputs I would have submitted:

    • KAS delete_file {"targetFile": "build/tmp.txt"} (an ordinary relative delete inside the workspace).
    • {"targetFile": "./scratch.md"}.
    • On Windows, {"targetFile": "\\Users\\dev\\repo\\tmp.txt"} (rooted, no drive).
    • {"targetFile": "C:\\Users\\dev\\repo\\tmp.txt"}.
    • On posix, {"targetFile": "/home/dev/repo/tmp.txt"}.

    If the KAS engine sends workspace-relative targetFile values (likely: the model writes them), every ordinary relative delete on KAS is now hard-denied with "relative target path that cannot be verified". That is a narrowing I can argue but not confirm. A narrower fix would resolve the path against the session's workspace directory instead of refusing it, and keep the refusal only for paths that leave the workspace.

  • Unreadable MCP identity. Guard: _tier_unverifiable_shell checks call.identity_unreadable. _resolve_permission also has an always_deny arm on mcp_identity_unreadable, reached through ToolCall.from_event and hook_gate_kwargs. Candidate inputs: a KAS MCP call whose server is named kirocrew-core and whose tool name is exactly 512 characters (must stay allowed), and one whose server name is a non-string value such as an integer. The second shows that mcp_identity_unreadable refuses any present value that is not a string, not only names that are too long.

  • Governance alias groups. Guard: _tier_governance passes alias_groups and deny_aliases to gate_decision. Candidate inputs:

    • An allow-mode profile tools: ["fs_write"] with a KAS str_replace call, which should be admitted.
    • A ceiling granting str_replace beneath a profile granting fs_write, which should be admitted.
    • An allow-mode tools: ["fs_write"] with a KAS delete_file call. This is now refused unless delete_file is named, which is intended.
    • A deny-mode profile tools.deny: ["fs_write"] with a KAS read_file call, which should stay allowed.

    The _AndRuleset.permits / resolve change now marks a refusal as an explicit deny when only the profile underneath denies, even if the outer policy refused only because the item wasn't listed. Classifying a shell line cannot measure this.

  • New auto_deny_tools binding. Guard: deny_targets, extended by policy_alias_names. Candidate input: an operator with auto_deny_tools: ["fs_write"] whose KAS agent calls str_replace or fs_append. These are newly refused, which is intended. Separately, an operator with auto_deny_tools: ["execute_bash"] meant for kiro-cli now also blocks the KAS shell run_command, meaning every KAS shell command. That is the stated parity, but it is a newly refused operation on KAS.

[SCOPE-REVIEWED] 3579d6d

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 3579d6d1e710e748a5053a6db63919ff31e3e350 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 3579d6d

Verdict parsed from the review's SHA-scoped output markers for commit 3579d6d1e710e748a5053a6db63919ff31e3e350.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 3579d6d1e710e748a5053a6db63919ff31e3e350: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 3579d6d1e710e748a5053a6db63919ff31e3e350 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 3579d6d

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 3579d6d1e710e748a5053a6db63919ff31e3e350: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 6, 2026
@bolichen97
bolichen97 force-pushed the takeover/13375-kas-tool-ids branch from 2ef562d to 71970e4 Compare October 6, 2026 09:19

Copy link
Copy Markdown
Contributor Author

Automated rebase onto current main (5edf2feecb), since nobody else had touched this PR in the last 6 hours.

  • Old head: 2ef562d3d0 → new head: 71970e49c2 (1 commit, --force-with-lease)
  • The rebase applied cleanly with no conflicts. git range-diff shows only context-line drift in docs/system-specs/modules/security.md, and the added/removed lines are byte-identical to the original patch.
  • Verification: py_compile passed on every changed .py file. pytest on the 18 test files this PR touches: 2196 passed, 7 skipped.

CI will re-run on the new head.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 6, 2026
@bolichen97
bolichen97 force-pushed the takeover/13375-kas-tool-ids branch from 71970e4 to b2e0719 Compare October 9, 2026 07:08
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (a098d44d9a): 71970e49c2 → b2e07197b6, still one commit.

main moved the tool gate into a tier table (hook_runtime/gate_tiers.py, ToolCall in hook_runtime/tool_identity.py) and the liveness map into InFlightToolTracker. This PR's gate changes were ported onto that shape, with the same behaviour:

  • ToolCall.identity_unreadable (filled by from_event, emitted by kwargs()); _tier_unverifiable_shell denies it beside the unreadable shell command.
  • GateFacts.policy_alias_names feeds the KAS alias fold into deny_targets and the governance tier's alias_groups / deny_aliases. The read → fs_read alias main added in fix(hooks): prove kiro-cli's read built-in read-only on the side chat #18275 is kept on the non-KAS branch.
  • _tier_write_protected passes tool_kind to edit_target_candidates; tool_paths keeps both main's patchText targets and this PR's delete-kind anchoring.
  • InFlightToolTracker(max_calls=...) holds the eviction bound and an evicted flag; the session handle reads them in place of its own map. Unit test added in test_acp_liveness.py.
  • backend_cards.py / backends.py: both new backend sets kept.

Local: AGENTS.md gate clean; this PR's test files plus test_acp_liveness, test_gate_tiers, test_hooks_composition_contract, test_backend_cards pass (2483); the 8 failures in local-gate shard 1 also fail on clean main.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 3579d6d1e710e748a5053a6db63919ff31e3e350 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Oct 9, 2026
@bolichen97
bolichen97 merged commit 52f909c into main Oct 10, 2026
119 of 146 checks passed
@bolichen97
bolichen97 deleted the takeover/13375-kas-tool-ids branch October 10, 2026 23:41
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 10, 2026
pepmach added a commit that referenced this pull request Oct 11, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.
pepmach added a commit that referenced this pull request Oct 11, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.
pepmach added a commit that referenced this pull request Oct 11, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.
pepmach added a commit that referenced this pull request Oct 11, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.
pepmach added a commit that referenced this pull request Oct 11, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.
pepmach added a commit that referenced this pull request Oct 11, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.
pepmach added a commit that referenced this pull request Oct 12, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.
pepmach added a commit that referenced this pull request Oct 12, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).
pepmach added a commit that referenced this pull request Oct 12, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.
pepmach added a commit that referenced this pull request Oct 12, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.
pepmach added a commit that referenced this pull request Oct 12, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.

Round 96: the runtime's cancel-during-preparation test now runs once per name-touching
worker the spawn hold reaches (the voice-runtime check, the sealed-target probe the spawn
plan's harness arm offloads, the skill projection), so the plan resolution's drain is
proven behaviourally, not only by the seams pin: on the previous production code the
spawn-plan case unwinds and releases under the probe (`['released']`). Test-only.
pepmach added a commit that referenced this pull request Oct 12, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and KAS-auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.

Round 96: the runtime's cancel-during-preparation test now runs once per name-touching
worker the spawn hold reaches (the voice-runtime check, the sealed-target probe the spawn
plan's harness arm offloads, the skill projection), so the plan resolution's drain is
proven behaviourally, not only by the seams pin: on the previous production code the
spawn-plan case unwinds and releases under the probe (`['released']`). Test-only.

Round 97: two hold tests asserted on a release the hold's `finally` schedules off the loop
without awaiting (the verified-hold drain test, right after the cancelled task ended; the
name-touch hold test, after the manager closed), so a slow executor could fail correct
code; both now wait for the releases to land (`async_wait_until`) before asserting.
Test-only.
pepmach added a commit that referenced this pull request Oct 12, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and agent-engine auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.

Round 96: the runtime's cancel-during-preparation test now runs once per name-touching
worker the spawn hold reaches (the voice-runtime check, the sealed-target probe the spawn
plan's harness arm offloads, the skill projection), so the plan resolution's drain is
proven behaviourally, not only by the seams pin: on the previous production code the
spawn-plan case unwinds and releases under the probe (`['released']`). Test-only.

Round 97: two hold tests asserted on a release the hold's `finally` schedules off the loop
without awaiting (the verified-hold drain test, right after the cancelled task ended; the
name-touch hold test, after the manager closed), so a slow executor could fail correct
code; both now wait for the releases to land (`async_wait_until`) before asserting.
Test-only.

Round 98: replayed onto main after its 17:04-17:30Z merge burst. The one conflict was
`error-code-baseline.json`, where both sides had lowered `missing_code` by one (this
change in `dashboard/chat_handlers.py`, main in `dashboard/file_api/uploads.py`); the file
is regenerated with the repository's own generator (`python
test/test_error_code_contract.py --update`) on the merged tree, so the totals follow the
per-file map (`missing_code` 1045, `_compliant` 2706). Seventeen other files main also
touched merged on their own. No content change.
pepmach added a commit that referenced this pull request Oct 12, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and agent-engine auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.

Round 96: the runtime's cancel-during-preparation test now runs once per name-touching
worker the spawn hold reaches (the voice-runtime check, the sealed-target probe the spawn
plan's harness arm offloads, the skill projection), so the plan resolution's drain is
proven behaviourally, not only by the seams pin: on the previous production code the
spawn-plan case unwinds and releases under the probe (`['released']`). Test-only.

Round 97: two hold tests asserted on a release the hold's `finally` schedules off the loop
without awaiting (the verified-hold drain test, right after the cancelled task ended; the
name-touch hold test, after the manager closed), so a slow executor could fail correct
code; both now wait for the releases to land (`async_wait_until`) before asserting.
Test-only.

Round 98: replayed onto main after its 17:04-17:30Z merge burst. The one conflict was
`error-code-baseline.json`, where both sides had lowered `missing_code` by one (this
change in `dashboard/chat_handlers.py`, main in `dashboard/file_api/uploads.py`); the file
is regenerated with the repository's own generator (`python
test/test_error_code_contract.py --update`) on the merged tree, so the totals follow the
per-file map (`missing_code` 1045, `_compliant` 2706). Seventeen other files main also
touched merged on their own. No content change.

Round 99: the Windows chain keeps a followed volume mount point's OWN handle. The walk
used to close the mount point's no-follow handle once the mounted volume's root was
open, so from then on nothing held the mount point's name on the host volume: a
same-account writer could rename it away and plant a symlink at its name, and the
walk's next by-name open of the child would follow that intermediate component (the
no-reparse flag covers the final component only), a share included. `pin_directory`
now appends the mount-point handle to the caller's held chain (`hold_through`), held
without delete or write sharing beside the volume root until the chain is released,
and refuses the follow for a caller that passes no chain. Red-first:
`test_the_mount_point_name_stays_held_beside_the_volume_root_until_the_chain_is_released`
(on the previous code the held chain carried no mount-point handle).
pepmach added a commit that referenced this pull request Oct 12, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and agent-engine auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.

Round 96: the runtime's cancel-during-preparation test now runs once per name-touching
worker the spawn hold reaches (the voice-runtime check, the sealed-target probe the spawn
plan's harness arm offloads, the skill projection), so the plan resolution's drain is
proven behaviourally, not only by the seams pin: on the previous production code the
spawn-plan case unwinds and releases under the probe (`['released']`). Test-only.

Round 97: two hold tests asserted on a release the hold's `finally` schedules off the loop
without awaiting (the verified-hold drain test, right after the cancelled task ended; the
name-touch hold test, after the manager closed), so a slow executor could fail correct
code; both now wait for the releases to land (`async_wait_until`) before asserting.
Test-only.

Round 98: replayed onto main after its 17:04-17:30Z merge burst. The one conflict was
`error-code-baseline.json`, where both sides had lowered `missing_code` by one (this
change in `dashboard/chat_handlers.py`, main in `dashboard/file_api/uploads.py`); the file
is regenerated with the repository's own generator (`python
test/test_error_code_contract.py --update`) on the merged tree, so the totals follow the
per-file map (`missing_code` 1045, `_compliant` 2706). Seventeen other files main also
touched merged on their own. No content change.

Round 99: the Windows chain keeps a followed volume mount point's OWN handle. The walk
used to close the mount point's no-follow handle once the mounted volume's root was
open, so from then on nothing held the mount point's name on the host volume: a
same-account writer could rename it away and plant a symlink at its name, and the
walk's next by-name open of the child would follow that intermediate component (the
no-reparse flag covers the final component only), a share included. `pin_directory`
now appends the mount-point handle to the caller's held chain (`hold_through`), held
without delete or write sharing beside the volume root until the chain is released,
and refuses the follow for a caller that passes no chain. Red-first:
`test_the_mount_point_name_stays_held_beside_the_volume_root_until_the_chain_is_released`
(on the previous code the held chain carried no mount-point handle).

Round 100: replayed onto main after #19331 rewrote the waits in `test/test_acp_runtime.py`.
The one conflict was that file's import of `kiro_crew.testing.wait`: main's line names
`async_wait_until, await_until, default_timeout`, this change had added `async_wait_until`
alone; main's superset is kept. The rest of the rewrite merged on its own. No content
change.
pepmach added a commit that referenced this pull request Oct 13, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and agent-engine auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.

Round 96: the runtime's cancel-during-preparation test now runs once per name-touching
worker the spawn hold reaches (the voice-runtime check, the sealed-target probe the spawn
plan's harness arm offloads, the skill projection), so the plan resolution's drain is
proven behaviourally, not only by the seams pin: on the previous production code the
spawn-plan case unwinds and releases under the probe (`['released']`). Test-only.

Round 97: two hold tests asserted on a release the hold's `finally` schedules off the loop
without awaiting (the verified-hold drain test, right after the cancelled task ended; the
name-touch hold test, after the manager closed), so a slow executor could fail correct
code; both now wait for the releases to land (`async_wait_until`) before asserting.
Test-only.

Round 98: replayed onto main after its 17:04-17:30Z merge burst. The one conflict was
`error-code-baseline.json`, where both sides had lowered `missing_code` by one (this
change in `dashboard/chat_handlers.py`, main in `dashboard/file_api/uploads.py`); the file
is regenerated with the repository's own generator (`python
test/test_error_code_contract.py --update`) on the merged tree, so the totals follow the
per-file map (`missing_code` 1045, `_compliant` 2706). Seventeen other files main also
touched merged on their own. No content change.

Round 99: the Windows chain keeps a followed volume mount point's OWN handle. The walk
used to close the mount point's no-follow handle once the mounted volume's root was
open, so from then on nothing held the mount point's name on the host volume: a
same-account writer could rename it away and plant a symlink at its name, and the
walk's next by-name open of the child would follow that intermediate component (the
no-reparse flag covers the final component only), a share included. `pin_directory`
now appends the mount-point handle to the caller's held chain (`hold_through`), held
without delete or write sharing beside the volume root until the chain is released,
and refuses the follow for a caller that passes no chain. Red-first:
`test_the_mount_point_name_stays_held_beside_the_volume_root_until_the_chain_is_released`
(on the previous code the held chain carried no mount-point handle).

Round 100: replayed onto main after #19331 rewrote the waits in `test/test_acp_runtime.py`.
The one conflict was that file's import of `kiro_crew.testing.wait`: main's line names
`async_wait_until, await_until, default_timeout`, this change had added `async_wait_until`
alone; main's superset is kept. The rest of the rewrite merged on its own. No content
change.

Round 101: replayed onto main after #19584 moved the three pure ownership helpers
(`_folder_owner_app`, `_subtree_holds_foreign_folder`, `_is_descendant`) out of
`dashboard/chat_folders.py` into `dashboard/folder_ownership.py`, re-exported from where
they were. The first conflict was that file: this change had inserted its inheritance and
filing functions between the two moved helpers and added one sentence to
`_subtree_holds_foreign_folder`'s docstring. Main's move is kept: the helpers are defined
once, in main's module, and reach this file through main's re-export; the inserted functions
stand where the helpers were; the docstring sentence goes with the function it described
(the rule it stated, that an agent may not change an existing binding at all, is
`api_chat_folder_update`'s `_agent_binding_refusal`). Main then merged #18342 (the plain
session is the default template, never the default crewmate), which appends a test to
`test/test_chat_agent_selection.py` where this change appends its re-pin test; both stand,
main's first. Every other file main touched merged on its own. No content change.
pepmach added a commit that referenced this pull request Oct 13, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and agent-engine auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.

Round 96: the runtime's cancel-during-preparation test now runs once per name-touching
worker the spawn hold reaches (the voice-runtime check, the sealed-target probe the spawn
plan's harness arm offloads, the skill projection), so the plan resolution's drain is
proven behaviourally, not only by the seams pin: on the previous production code the
spawn-plan case unwinds and releases under the probe (`['released']`). Test-only.

Round 97: two hold tests asserted on a release the hold's `finally` schedules off the loop
without awaiting (the verified-hold drain test, right after the cancelled task ended; the
name-touch hold test, after the manager closed), so a slow executor could fail correct
code; both now wait for the releases to land (`async_wait_until`) before asserting.
Test-only.

Round 98: replayed onto main after its 17:04-17:30Z merge burst. The one conflict was
`error-code-baseline.json`, where both sides had lowered `missing_code` by one (this
change in `dashboard/chat_handlers.py`, main in `dashboard/file_api/uploads.py`); the file
is regenerated with the repository's own generator (`python
test/test_error_code_contract.py --update`) on the merged tree, so the totals follow the
per-file map (`missing_code` 1045, `_compliant` 2706). Seventeen other files main also
touched merged on their own. No content change.

Round 99: the Windows chain keeps a followed volume mount point's OWN handle. The walk
used to close the mount point's no-follow handle once the mounted volume's root was
open, so from then on nothing held the mount point's name on the host volume: a
same-account writer could rename it away and plant a symlink at its name, and the
walk's next by-name open of the child would follow that intermediate component (the
no-reparse flag covers the final component only), a share included. `pin_directory`
now appends the mount-point handle to the caller's held chain (`hold_through`), held
without delete or write sharing beside the volume root until the chain is released,
and refuses the follow for a caller that passes no chain. Red-first:
`test_the_mount_point_name_stays_held_beside_the_volume_root_until_the_chain_is_released`
(on the previous code the held chain carried no mount-point handle).

Round 100: replayed onto main after #19331 rewrote the waits in `test/test_acp_runtime.py`.
The one conflict was that file's import of `kiro_crew.testing.wait`: main's line names
`async_wait_until, await_until, default_timeout`, this change had added `async_wait_until`
alone; main's superset is kept. The rest of the rewrite merged on its own. No content
change.

Round 101: replayed onto main after #19584 moved the three pure ownership helpers
(`_folder_owner_app`, `_subtree_holds_foreign_folder`, `_is_descendant`) out of
`dashboard/chat_folders.py` into `dashboard/folder_ownership.py`, re-exported from where
they were. The first conflict was that file: this change had inserted its inheritance and
filing functions between the two moved helpers and added one sentence to
`_subtree_holds_foreign_folder`'s docstring. Main's move is kept: the helpers are defined
once, in main's module, and reach this file through main's re-export; the inserted functions
stand where the helpers were; the docstring sentence goes with the function it described
(the rule it stated, that an agent may not change an existing binding at all, is
`api_chat_folder_update`'s `_agent_binding_refusal`). Main then merged #18342 (the plain
session is the default template, never the default crewmate), which appends a test to
`test/test_chat_agent_selection.py` where this change appends its re-pin test; both stand,
main's first. Every other file main touched merged on its own. No content change.
pepmach added a commit that referenced this pull request Oct 13, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and agent-engine auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.

Round 96: the runtime's cancel-during-preparation test now runs once per name-touching
worker the spawn hold reaches (the voice-runtime check, the sealed-target probe the spawn
plan's harness arm offloads, the skill projection), so the plan resolution's drain is
proven behaviourally, not only by the seams pin: on the previous production code the
spawn-plan case unwinds and releases under the probe (`['released']`). Test-only.

Round 97: two hold tests asserted on a release the hold's `finally` schedules off the loop
without awaiting (the verified-hold drain test, right after the cancelled task ended; the
name-touch hold test, after the manager closed), so a slow executor could fail correct
code; both now wait for the releases to land (`async_wait_until`) before asserting.
Test-only.

Round 98: replayed onto main after its 17:04-17:30Z merge burst. The one conflict was
`error-code-baseline.json`, where both sides had lowered `missing_code` by one (this
change in `dashboard/chat_handlers.py`, main in `dashboard/file_api/uploads.py`); the file
is regenerated with the repository's own generator (`python
test/test_error_code_contract.py --update`) on the merged tree, so the totals follow the
per-file map (`missing_code` 1045, `_compliant` 2706). Seventeen other files main also
touched merged on their own. No content change.

Round 99: the Windows chain keeps a followed volume mount point's OWN handle. The walk
used to close the mount point's no-follow handle once the mounted volume's root was
open, so from then on nothing held the mount point's name on the host volume: a
same-account writer could rename it away and plant a symlink at its name, and the
walk's next by-name open of the child would follow that intermediate component (the
no-reparse flag covers the final component only), a share included. `pin_directory`
now appends the mount-point handle to the caller's held chain (`hold_through`), held
without delete or write sharing beside the volume root until the chain is released,
and refuses the follow for a caller that passes no chain. Red-first:
`test_the_mount_point_name_stays_held_beside_the_volume_root_until_the_chain_is_released`
(on the previous code the held chain carried no mount-point handle).

Round 100: replayed onto main after #19331 rewrote the waits in `test/test_acp_runtime.py`.
The one conflict was that file's import of `kiro_crew.testing.wait`: main's line names
`async_wait_until, await_until, default_timeout`, this change had added `async_wait_until`
alone; main's superset is kept. The rest of the rewrite merged on its own. No content
change.

Round 101: replayed onto main after #19584 moved the three pure ownership helpers
(`_folder_owner_app`, `_subtree_holds_foreign_folder`, `_is_descendant`) out of
`dashboard/chat_folders.py` into `dashboard/folder_ownership.py`, re-exported from where
they were. The first conflict was that file: this change had inserted its inheritance and
filing functions between the two moved helpers and added one sentence to
`_subtree_holds_foreign_folder`'s docstring. Main's move is kept: the helpers are defined
once, in main's module, and reach this file through main's re-export; the inserted functions
stand where the helpers were; the docstring sentence goes with the function it described
(the rule it stated, that an agent may not change an existing binding at all, is
`api_chat_folder_update`'s `_agent_binding_refusal`). Main then merged #18342 (the plain
session is the default template, never the default crewmate), which appends a test to
`test/test_chat_agent_selection.py` where this change appends its re-pin test; both stand,
main's first. Every other file main touched merged on its own. No content change.
pepmach added a commit that referenced this pull request Oct 13, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and agent-engine auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.

Round 96: the runtime's cancel-during-preparation test now runs once per name-touching
worker the spawn hold reaches (the voice-runtime check, the sealed-target probe the spawn
plan's harness arm offloads, the skill projection), so the plan resolution's drain is
proven behaviourally, not only by the seams pin: on the previous production code the
spawn-plan case unwinds and releases under the probe (`['released']`). Test-only.

Round 97: two hold tests asserted on a release the hold's `finally` schedules off the loop
without awaiting (the verified-hold drain test, right after the cancelled task ended; the
name-touch hold test, after the manager closed), so a slow executor could fail correct
code; both now wait for the releases to land (`async_wait_until`) before asserting.
Test-only.

Round 98: replayed onto main after its 17:04-17:30Z merge burst. The one conflict was
`error-code-baseline.json`, where both sides had lowered `missing_code` by one (this
change in `dashboard/chat_handlers.py`, main in `dashboard/file_api/uploads.py`); the file
is regenerated with the repository's own generator (`python
test/test_error_code_contract.py --update`) on the merged tree, so the totals follow the
per-file map (`missing_code` 1045, `_compliant` 2706). Seventeen other files main also
touched merged on their own. No content change.

Round 99: the Windows chain keeps a followed volume mount point's OWN handle. The walk
used to close the mount point's no-follow handle once the mounted volume's root was
open, so from then on nothing held the mount point's name on the host volume: a
same-account writer could rename it away and plant a symlink at its name, and the
walk's next by-name open of the child would follow that intermediate component (the
no-reparse flag covers the final component only), a share included. `pin_directory`
now appends the mount-point handle to the caller's held chain (`hold_through`), held
without delete or write sharing beside the volume root until the chain is released,
and refuses the follow for a caller that passes no chain. Red-first:
`test_the_mount_point_name_stays_held_beside_the_volume_root_until_the_chain_is_released`
(on the previous code the held chain carried no mount-point handle).

Round 100: replayed onto main after #19331 rewrote the waits in `test/test_acp_runtime.py`.
The one conflict was that file's import of `kiro_crew.testing.wait`: main's line names
`async_wait_until, await_until, default_timeout`, this change had added `async_wait_until`
alone; main's superset is kept. The rest of the rewrite merged on its own. No content
change.

Round 101: replayed onto main after #19584 moved the three pure ownership helpers
(`_folder_owner_app`, `_subtree_holds_foreign_folder`, `_is_descendant`) out of
`dashboard/chat_folders.py` into `dashboard/folder_ownership.py`, re-exported from where
they were. The first conflict was that file: this change had inserted its inheritance and
filing functions between the two moved helpers and added one sentence to
`_subtree_holds_foreign_folder`'s docstring. Main's move is kept: the helpers are defined
once, in main's module, and reach this file through main's re-export; the inserted functions
stand where the helpers were; the docstring sentence goes with the function it described
(the rule it stated, that an agent may not change an existing binding at all, is
`api_chat_folder_update`'s `_agent_binding_refusal`). Main then merged #18342 (the plain
session is the default template, never the default crewmate), which appends a test to
`test/test_chat_agent_selection.py` where this change appends its re-pin test; both stand,
main's first. Every other file main touched merged on its own. No content change.
pepmach added a commit that referenced this pull request Oct 14, 2026
…paths

A sidebar folder's project_dir is what the gateway hands every chat opened in
the folder as its project, cwd and steering root — for the person's folders,
the person's chats. Four things about it were unfenced. Any caller the folder
routes admitted — an app's own token, any internal caller posting the field —
could set or clear a binding the person's chats then launched in. An agent
could reparent a folder under the person's bound folder, or out from under one,
rebinding every chat filed inside it — the same reach as changing the binding,
through the tree, and file the person's chat into a bound folder — the same reach
through filing. And a request-named project_dir was realpath'd without a UNC
check, so on a Windows gateway a `\\host\share` text — or a local link whose
target is one — opened an SMB connection to a host the text's author chose.

Who is the person is ONE POSITIVE bit at the folder routes, `_is_the_person`:
`request["is_dashboard_user"] is True`, the stamp the token middleware sets only
when the person's own cookie or session token validated (the sidebar's Folder
settings). The internal-secret transport (the managed MCP set, so every agent
session's tool call: an ordinary dashboard session's, a crew member's, an
app's, a cron's, a subagent's, a channel session's) never sets it, an app's own
token sets it False, and a request that met no middleware is refused rather
than admitted — no fence keys on the absence of another stamp, and no caller is
sorted by its key. A non-person caller's project_dir is refused whole, at
create and on the PATCH, set or clear, before the path is looked at
(`_agent_binding_refusal`, 403 `folder_project_dir_forbidden`, audited under
`app_isolation` against the caller's principal or its session key); the
person's meets the validators alone, as before. No MCP tool carries
project_dir: `chat_folder_create` is unchanged from main and there is no update
verb. What a binding confers is main's, unchanged: the nearest ancestor's
binding, for every chat filed beneath it.

The same bit keys two more rules. A non-person caller's reparent may not change
the stored binding the moved subtree resolves (`_move_changes_inherited_binding`
over `_inherited_project_dir`, same 403, decided under the store lock; a folder
carrying its own binding is exempt because nearest wins, and a move between
places that confer the same binding lands), nor the accumulated steering chain
with each declarer's owner (`_inherited_steering_dirs`, the steering gate's
403). The steering_dirs declaration gate itself (#11827) is widened in the
commit after this one, so a bisect of a steering refusal lands there.

The same two comparisons fence the filing route, the third way a chat comes
under a binding: `PATCH /api/chat/slots/{slot}/folder` (behind
`chat_folder_move_session` and `chat_folder_file_self`) wrote `slot.folder_id`
into any folder behind transcript-ownership checks alone, and a binding and
steering reach a chat through the folder it is filed in. A non-person filing
that would change what the session inherits is refused before the write, under
the slot's transaction lock, with the same two codes; a filing between places
that confer the same binding and steering lands; the person files anywhere.

The UNC gate is scoped to every principal OTHER than the person. The probe it
prevents is a caller other than the operator steering the gateway onto a host of
that caller's choosing, and that threat does not exist when the operator picks a
path for the operator's own gateway: a person could bind a project on a share
before this change and still can, resolved as main did. `_admit_project_dir`
takes the request's positive stamp and routes the person to
`_validate_project_dir` — main's own resolution by name — and everyone else to
`_admit_agent_project_dir`, the fenced path; the slot project endpoint has the
same two arms; the `set_project` directive is an agent's tool and is fenced
whole; the scaffold's scan root and create carry the stamp through. The read
path is main's for every stored value and runs neither half: only the person
binds a folder, so every stored binding is the operator's own choice. The gate
has two halves. `project_dir_unc_refusal` is lexical and admission-only: it runs
before the first filesystem call wherever a non-person principal names a
directory, on every host. `project_dir_link_target_refusal` closes
the gap one link away: a resolve follows every link in a path, and on a
Windows gateway it is itself the SMB probe when a link's target is a share, so
before anything follows a link the repo's one link-target screen —
`hooks.link_screen`, the walk `validate_file_path` already runs for file reads
(through the `screen_link_targets` wrapper, unchanged), its Windows-only target
normalizer given a POSIX branch and its refusal given a cause — reads each link
on the way with `os.readlink`, never following it, and hands back the path
re-spelled through every link it read. That screened spelling, never the
original, is what is resolved next, and never by name:
`pinned_fs.real_dir_path_pinned` opens every component without following a
link and reads the real path off the directory it holds (`fd_real_path`) — an
`openat` chain under `O_NOFOLLOW` on POSIX; on Windows a root-first chain of
`platform_compat.pin_directory` handles opened with
`FILE_FLAG_OPEN_REPARSE_POINT` and held without `FILE_SHARE_DELETE` until the
path is read, so nothing above a held component can be renamed or re-pointed
while the walk runs (the hold the issue_radar unit-order writer already takes)
— so a component swapped for a link between the screen and the open is refused
at the open on every host, and a host that pins neither way fails closed rather
than falling back to a by-name realpath. `pin_directory` gains
`allow_filter_reparse`: the project pin reads the reparse tag off the open
handle and refuses only a name surrogate (symlink, junction, WSL link), so a
cloud-files placeholder — every OneDrive-synced folder — is still the directory
it is; the default stays refuse-all for the gateway's own directories. The
directive and the slot project endpoint run `screen_and_resolve_project_dir`
on a worker thread and hold no realpath of their own; the endpoint's person
arm runs main's realpath off the loop too. A non-person request is refused for
any screen cause. The chain opens with `pinned_fs.traverse_flags` — `O_PATH`
where the platform has it — so it needs only the search permission a by-name
realpath needs and a directory under a search-only ancestor still pins (a link
or a file at a component is still ENOTDIR); a component this process may not
traverse answers its own text (no "retry"), and a spelling no filesystem can
carry (an embedded NUL) answers the missing-directory refusal on both arms
instead of escaping as a server error. The sensitive-path refusal keeps
main's precedence over the missing-directory one: judged on the real path when
the open finds one, on the link-free spelling when it does not. The
link-screen gate's baseline names the renamed hooks site.

The walk resolves in component order, the kernel's own. Nothing folds a `..`
lexically before it on POSIX: `_anchored_spelling` only anchors a relative
path there, `link_screen` renders the spelling through pathlib each hop (`.`
and doubled separators dropped, every `..` kept), takes the components below
a link as the path names them rather than through relpath, and the POSIX
target normalizer no longer normpaths — so `work/link/../sibling` with
`link -> projects/team/subdir` reaches `projects/team/sibling`, as realpath
does, and the pinned open then opens `..` relative to the directory it
holds. On Windows the Win32 parser folds `..` before any filesystem sees a
name, so abspath there is the platform's rule and runs first. The
`escaping_suffix` cause is gone: a component-order walk has nothing to
escape. A request whose link the screen cannot read or place is refused
apart from the share-shaped cause (`PROJECT_DIR_UNSCREENABLE_LINK_REFUSAL`;
at the slot project endpoint the code `project_dir_link_unscreenable`,
audited `unscreenable link`, while a share-shaped link target keeps the UNC
code and is audited `UNC link target`).

The filing fence judges the COMMITTED folder tree: `mutate_folders` applies
a change to the live list and restores it only if the off-loop write fails,
so the fence reads a snapshot through `read_folders` (the store lock
excludes a mutate in flight) and revalidates the slot after that await —
a binding clear about to roll back is never judged as unbound.

The Windows placeholder arm has a fixture on the Windows CI shard: a real
junction is refused through `real_dir_path_pinned` at the leaf and as an
ancestor, and the same reparse point is accepted as the directory it is —
resolving to its own path, never its target — once the tag read
(`platform_compat._win_reparse_tag`, split from the classifier
`_reparse_tag_redirects` so a test can hand it a real tag value) answers
`IO_REPARSE_TAG_CLOUD`; the classifier is pinned on every host with the
documented tags. A live Files On-Demand folder was not available; the PR
body names the one-line command a maintainer with OneDrive runs.

The packaging builder's settled-rejection test watched for pinned_fs
growing a Windows no-reparse path and fired. It is re-argued, not silenced:
pinned_fs now pins ONE directory on Windows but offers no handle-relative
walk (scandir, stat and open take no dir_fd there), which is what the
builder's enumeration needs, so its narrowing stands and the test pins the
confinement — a single `pin_directory` call site, inside
`real_dir_path_pinned`.

Dropped from this change: the agent bind path (#10432 stays open; filed as
it — a family of caller-class arms, then one containment rule on the agent's
own project directory — drew a finding on every head, the last that a bound
directory inside the agent's own tree can be swapped for a link after the
check and retarget the person's next chat; the owner-scoped read side that
existed for agent-written bindings goes with it. It ships as nothing rather
than as a rule with a known hole; the fence work it needed is what ships.

The scaffold routes are the person's verb: every folder a scaffold creates is
bound, so `POST /api/project-scaffold/scan` and `/create` refuse every other
principal -- an enabled app posting with its own credential, the internal
transport -- with the binding refusal's own 403 before the body is parsed
(`_refuse_non_person`, the same one bit), so an agent-named root is never
resolved on the way to a refusal; the create-rate limiter the create route
carried for internal callers goes with the caller it guarded. The link half and
the pinned resolve live in one function, `screen_and_resolve_project_dir`, whose
cause-to-refusal mappings the fenced folder admission shares. The person stamp's
writer is pinned: the four sites in token_auth that write `is_dashboard_user`,
a validated user credential stamping True, an app-claim credential False, and
an invalid one nothing.

The sensitive-path verdict after the pinned resolve is taken on the pinned real
path -- and, for a path the open does not find, on the link-free spelling -- as
it stands (`project_dir_sensitive_refusal` over `is_sensitive_resolved_path`,
on the worker thread, fail closed on a resolver stall), never by resolving the
name again: the by-name check walks its argument before matching, and after the
pin that walk would follow a component swapped for a link -- on a Windows
gateway, a junction to a share. The directive's two by-name checks and the slot
project endpoint's loop-side re-check are gone; the endpoint's person arm takes
the verdict from the same worker call as its realpath.

Filing is the one way a session acquires a folder's binding and steering, so
every request-driven filing takes ONE decision, `refuse_filing_across_inheritance`
(`filing_crosses_inheritance` underneath): the PATCH folder route, the
slot-create route -- where an app's own credential could until now create a
session under a person-bound folder and inherit its project_dir and steering --
and the agent tools `session_create` and `session_fork`, from the creator's or
the source's own placement. The person is never confined; any other principal
may not place a session where it would inherit a binding or steering it does not
have today. A structural test enumerates every function in the dashboard package
that writes a session's folder or project and holds each request-driven writer
to that decision, naming why every other writer (a restore, a fork's copy,
channel and cron placements from configuration, a session's own project) is not
a filing.

The filing decision and the WRITE share one section under the folder store lock
(`file_slot_across_inheritance` over `state.hold_folders`) at the PATCH folder
route -- its identity re-check runs inside the same section -- and at the
slot-create route, where a refusal at the write retracts the slot the request
minted; the agent tools re-run the comparison adjacent to the child's
assignment, inside the synchronous configuration window their own pin forbids
awaits in, refusing while a folder write is in flight rather than judging a
provisional tree, and retracting the child on refusal. The fenced pipeline
exists once, in `screen_and_resolve_project_dir`: no non-person `project_dir`
reaches the folder routes or the scaffold, so their admission is the person's
validator and the duplicate is gone.

WHO is the person is two positive facts, not one: the middleware's
`is_dashboard_user` stamp proves that a non-app dashboard token validated on the
request -- the credential's class -- and the repo's owner predicate
(`is_owner_dashboard_request`: the token's subject is the configured owner, or on
an install with no owner the machine-local bootstrap identity) says who holds
it. An allow-listed Slack user who asks the bot for a dashboard link holds an
app-less token stamped exactly like the owner's; on the stamp alone that user
passed every fence here and their binding became the owner's chats' working
directory and steering root. `_is_the_person` asks both, in the one place every
fence reads.

At the slot-create route the App Kit ownership gate runs FIRST, on the slot the
request's name already addresses and before anything reads it: the filing
decision compares that slot's placement with the destination, and run ahead of
the gate its 403 against the ownership 404 told an app token where a slot it
does not own is filed. One helper (`_foreign_slot_create_denial`) answers at
both sites -- the late gate below the mint stays as the race guard -- with the
one `slot_not_found` 404, byte-identical whether the foreign slot is bare or
bound.

The owner predicate is the repo's one definition of the owner, and it denies
the operator's own session from before `KIROCREW_OWNER_ID` was configured (a
token's subject is fixed at mint and kept by every refresh, so it carries a
bootstrap subject for life). That caller is not admitted; every refusal
`_is_the_person` decides runs through one tail, `_person_gate_refusal`, which
answers it with the repo's `401 stale_session_reauth` (the same
`stale_owner_session_response` every owner gate consults) instead of the
agent's 403, so signing in again is signalled where it is the remedy; an app's
token, the internal transport and an allow-listed user keep the gate's 403.

A refusal is audited against ATTESTED identity only (`_agent_audit_caller`):
the caller's principal, else the token subject the middleware validated, else
the declared `X-Session-Key` when the AF_UNIX peer check kernel-attested it,
else `unattributable`. The bare header is caller-chosen on TCP loopback, so a
refused caller could write any string -- the owner's own subject -- into the
fences' SEL rows; a row that names nobody is the honest one for an unattested
caller.

The fenced resolve releases its no-follow pin when the value is stored -- the
real path it returns is a name again -- and the spawn that enters it is
deferred to the next turn, so a same-UID process the agent started could
replace the directory at that name in between (on a Windows gateway a junction
to a share, which `CreateProcess` would follow into the SMB connection the pin
existed to prevent). Every BINDING therefore records what the spawn re-verifies,
on the SESSION: `slot.project_identity`, the `(st_dev, st_ino)` of the directory
bound -- the agent arms from the held descriptor
(`screen_and_resolve_project_dir(..., identity_out=)`; `real_dir_path_pinned`
gains `held_out` for it), the person's own choice, a folder's inherited binding
at creation and a fork's copy from what the name resolves to
(`sandbox.directory_identity_by_name`); the configured default records nothing.
The record is held in memory beside `project`, applied only while its spelling
is the slot's current project, and rides to the spawn with `cwd`
(`sessions.get_or_create(cwd_identity=)` -> the provider factory ->
`AcpProvider(work_dir_identity=)` -> `AcpClient` / `AcpRuntime`). The spawn
(`sandbox.verify_agent_workspace_for_spawn`) checks by IDENTITY, not by refusing
links -- the threat is a swap of the bound directory, so a benign link an
ancestor has always crossed is not a swap, and a binding with no identity is
not examined and spawns exactly as before. A recorded binding has its leaf
re-read without following a link at it (POSIX `O_NOFOLLOW` open + `fstat`;
Windows `os.lstat`, a name-redirecting reparse point refused, then `os.stat`)
and compared: a leaf that is now a link, missing, or a different directory
refuses the spawn as a governed refusal -- the site's own error naming the
remedy, re-bind the directory, so a recreated directory recovers by re-binding
and a second session on the same path carries its own record; equal, the spawn
enters the verified directory's real path, and on POSIX the verified
descriptor is closed on a worker thread scheduled after the PID bookkeeping --
no await and no loop-side close between a live child and its record. On macOS
the bound descriptor the child enters is verified by identity against the
check; other spawns keep the pathname `cwd` (no descriptor binds off macOS, a
recorded rule), so the residual there is a same-UID rename of the directory
itself in the window `AcpRuntime._session_work_dir` already records -- never a
link swap, never a share. A refused re-bind at the slot project endpoint rolls
the identity back with the project; a refused folder filing at creation
retracts the minted slot with its restricted-key marker.

At `POST /api/chat/slots` the filing runs before any other write the route
makes to the slot: a write-side refusal used to return after the title pin and
the artifact binding had landed, leaving both live on an existing slot the
request was refused to file; a refusal now returns the slot exactly as found.

The scaffolder manifest's `permissions.api` grant for `/api/project-scaffold`
is deleted: only app tokens consumed it and the route refuses every app token.
`_admit_project_dir`, a second name for `_validate_project_dir`, is deleted;
its callers call the validator directly.

The identity a by-name binding records is read off the descriptor that opened
the resolved directory without following a link at it
(`sandbox.directory_identity_pinned`, on the validating worker thread), never a
by-name stat after validation; every identity is read off a handle
(`platform_compat.handle_identity`: POSIX `fstat`, Windows
`GetFileInformationByHandle`), an unknown identity (a zero inode: SMB shares,
FAT) is never recorded and is reported, not refused, at spawn -- the contract
`project_scan.root_identity` pins for the same comparison. Every release of the
verified descriptor goes to a worker thread, the cancellation path included;
the verified spelling is the spawn `cwd` unless the macOS bind binds or names
another path. `hooks._components_below` splits on the platform's own
separators only: a trailing backslash is a name character on POSIX.

One identity function serves every recorder and the check
(`platform_compat.handle_identity`, composed as `os.stat` composes the pair):
the fenced resolve reads it off the held chain inside
`real_dir_path_pinned(identity_out=)` before the chain closes, the spawn's
Windows branch opens the leaf as itself and reads it off that handle, and the
agent-switch route records the folder project's identity the way the create
route does, rolled back with the project's commit token. A trailing backslash
is read through `getattr(os, "altsep", None)`. The remaining verify-to-spawn
window is held for a maintainer ruling (a sandbox-scope change).

A different REAL directory at the bound name (a re-clone, a remount) is logged
and spawned as bound -- a persisted record must not become a permanent refusal;
the swap that reaches a host is a link, and a link at the leaf still refuses.
With a `folder_id`, the slot-create mint's survey count waits for the filing
decision. The tests carry no platform skip: the Windows arm runs everywhere
through `platform_compat` seams (`_win_open_without_following`,
`_win_file_attributes`, `_win_reparse_tag`), the bound-descriptor comparison
through `sandbox._directory_identity_from_fd`, and a real directory link comes
from `platform_compat.symlink_or_junction`.
The macOS voice-runtime pre-flight the fenced sites run after the verdict
compares the pinned real path as it stands (`pre_resolved=True`), never
re-walking it by name. The scaffold routes' non-person refusal is their own:
the audit and the answer name the verb refused (`scan` or `scaffold`), 403
`scaffold_person_only`, on the person-gate tail. The spawn-shape tests assert
what the child enters -- the bound descriptor on a binding host, the verified
directory's real spelling elsewhere -- and run a forced-darwin arm on POSIX.
On Windows the spawn-time check walks the bound spelling ROOT-FIRST through the
pinned resolve's own chain walk (`pinned_fs.hold_windows_directory_chain`):
every component opened as itself and its reparse tag judged before the next is
opened, so a junction at any component is refused without being resolved; the
identity is read off the final handle and the chain is closed before the spawn.
A binding always records or is refused: a directory the bind cannot pin is a
failed bind surfaced to the caller (`sandbox.WorkspacePinFailed`), a volume that
reports no inode records the unavailable state (`IDENTITY_UNAVAILABLE`), and at
spawn a different directory at the bound name refuses with the governed error
naming the remedy. The spawn-time Windows check enters `real_dir_path_pinned`,
the module's one handle-pinned path, for its identity.
The identity lives for the gateway process's lifetime: recorded in memory at
bind, re-pinned from the bound path at the first spawn of a project that carries
no record in this process (every slot after a restart), and never persisted --
`st_dev` is reassigned across mounts and the transcript store is agent-writable,
so a stored pair would refuse unchanged directories after a reboot and accept a
forged one. A `project_identity` line in the transcript is never read back.
A bound directory the restart re-pin cannot open refuses the spawn as the
governed error (`WorkspacePinFailed`, the turn's `AcpError`), never an
unexamined `None`, which only a slot with no binding carries.
Bind, restart re-pin and spawn verification share one identity function per
platform (`sandbox.open_pinned_directory`: the Windows root-first no-reparse
walk; the POSIX `O_NOFOLLOW | O_DIRECTORY` leaf open + `fstat`), so a junction
at any component is refused by every path and none opens by name for an identity.

Round 44 (on the maintainer's rebase onto b5ca357ba8, which composed the fence
with #11680's folder-project inheritance): a session_create child filed into a
project folder carries the identity the fenced pin read off the folder's
directory before the slot existed when the caller's own record does not cover
that spelling -- the caller holds the binding by placement, so the record is
derived from the directory the binding names -- and a folder directory the pin
refuses fails the create with folder_project_invalid: the recordless-child case
in the folder-inheritance arm, found by the round's probe. test/
test_project_directory_seams.py pins every seam that hands a session a
directory: every writer of a session's project records a derived identity or is
listed as a configured or restored spelling re-pinned at first spawn (12 writers,
6 + 6), every provider-factory call passing cwd is the allocation body, a
resolver, or listed as spawning where no slot binds (4 doors), and every
cwd_identity producer takes the slot's record and never pins fresh (4 producers).

Round 46: the spawn-time verification keeps its hold across the process
creation on Windows too. The Windows arm of sandbox.open_pinned_directory hands
the pinned handle chain back OPEN (pinned_fs.real_dir_path_pinned(held_out=),
root-first, every component held without FILE_SHARE_DELETE) instead of closing
it before returning, and both ACP spawn sites release it -- through
release_agent_workspace_fd, which closes a descriptor or a chain, leaf-first --
on the worker thread they already schedule after the PID bookkeeping and on
every failure path. Before this the chain was closed before the check returned,
so CreateProcess entered a bare name a same-UID process could re-point at a
junction to a share in between, the outbound SMB authentication the check exists
to prevent; the docstring's "never a share" held only at check time
(review-caught, security-class). Nothing new is refused, pinned or masked, and
the POSIX arm is unchanged: its descriptor already spanned the spawn. This
restores the retention round 26 carried and round 30 removed under a hold
routed to the maintainers; that hold now covers only the POSIX chdir_fd half.

Round 47: two Windows-shard reds in the round-46 tests, both test-shape. The
pool-class stand-in provider (test_chat_slot_project.py) called the spawn-time
verification and dropped the hold it hands back; on Windows that is the held
chain, so the test's own swap could not remove the directory (WinError 32) --
the stand-in now releases the hold right after the check, as the real sites do
once the child exists. The held-out hand-over test (test_platform_compat.py)
counted descriptors with before + len(held); _open_descriptor_count answers a
true count only where /proc exists and on Windows is the lowest free CRT
descriptor, so a table with holes above it breaks the arithmetic -- the test
asserts the property instead: every handed-over descriptor open, one per
component the walk holds (the leaf on the POSIX pinned walk, every component on
the Windows handle arm), every one closed after close_all, nothing on a refusal.
No production code changes. Rebased onto a main that moved the shared ACP
transport code into owner modules and reverted the launcher-mask binding: the
one conflict, the client's sandbox import block, resolved by taking main's
deletions and keeping the identity-check names this change uses.

Round 48: the deferred session reset fires on an identity change as well as a
spelling change, at both binding sites -- the slot-project endpoint and the
set_project directive. Each recorded the new (st_dev, st_ino) unconditionally
but armed the reset on path text alone, so re-binding a directory replaced at
its name recorded the replacement and left a live provider serving turns in the
old directory, the identity being compared only at spawn (review-caught: the
fence is identity, and a reset keyed on spelling contradicted it on exactly the
case the identity check exists for). A re-pin that reads the same identity back
stays quiet; a first record is not a change. No new refusal, no seal, no
widening. The facade-patch census ratchet lists this change's two
module-parameter test helpers (the ACP client spawn harness and its bind spy),
the shape the ratchet's listed dict exists for. Rebased over the folder-create
dry run and duplicate-name refusal; the chat_folder_create description keeps
main's ownership sentences with this change's binding sentence after them.

Round 49: the two Windows-retention spawn tests answer the internal-sandbox
bind as a Windows host does -- the spelling back, nothing bound -- and run
under the host's platform and under darwin forced. On a darwin host the real
bind bound a descriptor and the bound-descriptor compare met the test's fake
handle chain, a combination no host produces (a Windows host never binds; a
darwin host never holds a chain); the compare's chain arm is unreachable in
production and is unchanged. Test shape only.

Round 50: two spawn-side doors the identity fence did not yet cover. The
provider's resume path builds its replacement runtime with the session's
recorded identity, exactly as the first spawn's construction does: when the
first runtime dies during session/load the path respawns, and that replacement
was built without work_dir_identity, so its spawn verified nothing and a bound
session could respawn into a directory swapped at its name while the first
runtime was dying (review-caught, security-class). One argument, the same seam
and value as the first spawn; no new refusal, no widening. The seams pin gains
the door its sweeps did not see: every runtime or client construction passing
work_dir also passes work_dir_identity per call, or is listed as spawning where
no slot binds (the review pool's own tree). And session_revive -- brought to
main while this change was under review -- files a revived archived session into
a caller-named folder; it now takes the one filing decision every other
request-driven filing takes, from the placement the session was archived in
(none reads as the top level) to the named folder, before the revive commits, so
a refused filing revives nothing, files nothing and unhides no folder; the
structural writer test is what caught the door.

Round 51: rebased onto main aec81410e2 to pick up #14925's test-side fix for #15361
(the revive tests' shared archive helper now backdates closed_at, so the two filing
tests this change added no longer meet the Windows clock-tick resume conflict
before their assertions run); no code change.

Round 52: the revive's filing decision is taken again at the write. The early
gate judged a snapshot before the resume, and the resume awaits, so a folder
mutation could commit in between -- the target folder acquiring a binding or
steering -- and the write, which compared only the slot's own placement, landed
on a tree the decision never saw (review-caught, security-class). The decision
and the assignment now share one section under the folder-store lock, the
shape the folder PATCH and the two child-filing tools already take adjacent to
their writes; a crossing there refuses the filing alone, in the fork's
in-window shape, with the revive committed: the session comes back where it
was archived, nothing filed, no folder unhidden, no filing noted. The early
gate stays as the fail-fast before the resume. Same writer, same chokepoint.

Round 53: the write-time decision declines instead of raising. A revive that
has happened is never turned into an error: the early gate keeps refusing
before anything is revived (a refusal is truthful only while nothing has
happened yet), and a decision gone stale at the write leaves the revive
standing and answers success with filed: false and the move rule's code in
filing_refused -- the posture every post-revive filing outcome takes; the fork
raises because it retracts its child, and nothing is retracted here. Same
section, same lock, same decision; one branch changed shape.

Round 58: the verified descriptor is the child's chdir_fd on POSIX. The spawn
check held the O_DIRECTORY descriptor of the verified directory across the
process creation but still entered the directory by its pathname -- Popen's
chdir in the fork child re-resolved the spelling -- so a same-UID rename of the
bound directory with a link planted at its name between the identity read and
the fork sent the agent into the link's target (review-caught, security-class;
the POSIX half of the round-30 item, held for a maintainer ruling since then and
ruled now). Both spawn sites hand the hold to create_subprocess_limited as
chdir_fd wherever nothing else bound one: the pathname leaves the spawn and the
shim fchdirs the inherited descriptor, as macOS internal-sandbox spawns always
did, and PATH is screened by the pinned identity the same way. A directory
bound with no identity still spawns by name; on Windows the held chain stays the
control. The specs drop the "never a link swap" residual the pathname entry had
left open.

Round 60: the restart re-pin keeps the first record, and the workspace default
is not a binding. Two first spawns of one restored slot could re-pin at the same
time -- the main chat and its side panel -- and both passed the no-record check
before either pin returned; the second then overwrote the identity the first
had recorded, so a directory an agent replaced between the two pins became the
identity every later spawn verified against (review-caught, security-class).
After the awaited pin the slot's record is read again and an established one is
returned instead of overwritten: the first writer wins and the second spawn
refuses the replacement. And a chat that chose no project stands on the
workspace default, which is the warm pool's own spawn directory; the re-pin
pinned that spelling like a binding, so every ordinary chat carried an identity,
took the bypass arm and cold-started -- the pool was never claimed
(review-caught). The workspace default now answers None at the re-pin: nothing
recorded, nothing examined, the warm path kept, as the specs state.

Round 61: the revive's post-filing decision judges the LIVE placement. The slot
is published before its filing takes the slot-metadata lock, and the lock
acquisition is an await; the decision compared the archived placement, so a
filing the person committed in that wait -- the revived slot refiled into a
steered folder -- was judged as "top level -> target", found no crossing, and
was overwritten without a refusal (review-caught, security-class). The decision
now reads `slot.folder_id` under the lock, the placement the write would
overwrite: leaving the steered folder crosses the inheritance, the filing is
refused with the move rule's code, and the person's placement stands.

Round 62: the spawn resolver consults a slot on the workspace default for that
slot's own spawns only. The default is configuration, not a binding -- a chat
that chose no project stands on it with no record, and the warm pool spawns
there -- but a record one chat put on it (it named the default explicitly
through the project endpoint) was matched for every spawn into the spelling, so
every default chat verified a stranger's identity, took the pool bypass and
cold-started (review-caught). The resolver now skips a slot standing on its
workspace's default unless the spawn is that slot's own -- the main chat, its
side panel, its threads -- so the explicit binding still fences its chat and
every other default chat keeps the warm path.

Round 63: both spawn sites acquire the verified hold FIRST. The check ran after
main's readiness mkdir and the rest of the preparation (the skill projection,
the governance reads, the sandbox wrapper), every one of them a pathname probe;
on Windows a bound directory swapped for a link to a UNC share was followed by
the mkdir's is_dir fallback into an SMB handshake with the attacker's host
before the check refused the spawn (review-caught). `_spawn_admitted` and
`_spawn` now verify and hold before anything touches the name, run the whole
preparation and the spawn inside one try under the hold, and release it exactly
once on every exit through `_release_spawn_hold` -- the success path after the
PID bookkeeping, the spawn failure handler, and the outer handler for a
preparation that raised. The readiness mkdirs (`_spawn_admitted`,
`_prepare_spawn_workspace`, `ensure_ready`) create the unbound default only: a
bound directory exists by construction and its name is not probed before the
hold. The body of each spawn method is indented one level by that try; the
source-shape tests that slice it by indented anchors (two deepseek and one pi
anchor) follow the new depth. A first cut of this round moved the body into a
helper method instead and was pushed, then withdrawn: twenty source-shape pins
across twelve test files read the spawn path off `_spawn` / `_spawn_admitted`
and stopped finding it; the local gate had run only the spawn files, not those
pins.

Round 64: the pinned open is the ONLY walk on the agent's project path. The
fenced admission screened links by name first (`link_screen` over the
ancestors, root-first, one `lstat` each, re-spelling benign links through) and
pinned afterwards; between two of those reads an ancestor swapped for a link --
on Windows, to a share -- was followed before the pin could refuse it
(review-caught: the same probe-before-pin class as Round 63, at the bind seam).
The screen is gone: an agent-named path is anchored, matched lexically for the
sensitive locations, and opened component by component with no link followed;
a link or a non-directory at any component is refused at the open with
`PROJECT_DIR_LINK_REFUSAL` (code `project_dir_link`, audited `link on the way`,
apart from the UNC text class) -- an agent path through a link is refused, not
re-spelled, the rule applied consistently; the person's bind resolves by name
as on main. `hooks.py` returns to main's (the screen refactor had no other
caller). The specs that restated the mechanism three times now state it once
(`security.md`) and point to it.

Round 65: the `..` test (`test_dotdot_is_opened_relative_to_the_directory_the_pin_holds`)
asserted the link refusal on every host; on Windows `_anchored_spelling` applies
`abspath` by design (the Win32 parser folds `..` before any filesystem sees a
name), so `work\link\..\sibling` legitimately resolves to `work\sibling` -- the
test now expects the folded directory there and the refusal on POSIX. The eight
largest `chat_folders.py` docstrings are condensed with every rule kept. Rebased
onto main `c6bfd72dba`: main's `slot_ownership` gates (PR #16212) now run the
slot-create ownership check ahead of the filing decision's placement read, the
same oracle this fence closed in Round 5x with `_foreign_slot_create_denial`, so
that helper is gone and both create-route gates are main's; the survey count
waits for the filing decision AND skips a cron's slot (both conditions); the
spawn-site bodies carry main's launch-agent and agent-engine auth edits under the hold.

Round 66: prose only, to bring the diff under the Design lane's 1,000,000-byte
cap (1,041,806 -> 944,598 bytes). Every multi-line test docstring this change
added is cut to its first sentence (24 test files, 86 KB; every assertion and
fixture byte unchanged -- the files' ASTs are identical with docstrings
blanked), and the two spec blocks that restated the fence's mechanism
(`docs/architecture/mcp.md`, `docs/system-specs/modules/session-control.md`)
state each rule once and point at `security.md` for the mechanism. Round 64's
condensation had dropped main's own paragraph on `session_create`'s filing
window (`suspend_slots_push`, the dry-run existence check); it is restored
verbatim. No source docstring or comment changed.

Round 67: the restore seam joins the fence. A resume whose producer named no
directory takes the one the session map stored, and the allocator probed that
name (`Path(stored_cwd).is_dir()`) and let the runtime preparation resolve it
before the identity seam ran -- on Windows a bound directory swapped for a link
to a share was followed into an SMB handshake before the spawn's hold could
refuse it (review-caught: the third seam of one class, after the spawn sites
and the bind). The allocator now resolves the identity FIRST -- for the stored
directory and for a producer's `cwd` alike -- and only then lets `is_dir` and
`prepare_runtime` see the name; a pinned directory is not probed again, an
unbound stored directory keeps main's existence check, and a member's project
the preparation hands back is resolved the same way when nothing was resolved
for it yet. Red-first: a link planted at the stored bound name is refused with
the resolver consulted before any probe (`['is_dir', 'resolve']` red,
`['resolve']` green). A structural pin
(`test_project_directory_seams.py::TestNoProbeOfABoundDirectorysNamePrecedesItsPin`)
now reads the source of every entry point where a bound directory's name can
reach the OS -- the two spawn sites, the agent bind seam, the allocator -- and
refuses any by-name probe (`is_dir`/`exists`/`resolve`/`realpath`/`stat`/
`mkdir`/`open`, called or handed to a thread) ahead of the hold or identity
call, so a fourth seam fails the test instead of a lane; it names both earlier
shapes when run against them.

Round 68: a volume mount point is the one surrogate the Windows walk follows.
`IO_REPARSE_TAG_MOUNT_POINT` is carried by a junction AND by a volume mount
point (a Dev Drive, a second disk mounted at a folder); the walk refused both,
so a project behind a mounted volume could not be bound or spawned
(review-caught). The two differ in their reparse data: a junction names a PATH
that any writer of the parent can retarget, a volume mount point names a DEVICE
(`\??\Volume{GUID}\`) that cannot point at a share or another directory and
that only an administrator retargets. `pin_directory`, for the opted-in caller
only, reads the data by name, follows the point exactly once when it names a
volume GUID, and keeps the descriptor only if the object held is a directory,
not itself a reparse point, and the ROOT of that same volume by its handle's
GUID path -- a mount point swapped for a junction between the read and the open
lands where the second check refuses. The identity pinned through a mount point
is the mounted volume's. A junction with a path as its data, a symlink, and a
point whose data cannot be read stay refused (`test_platform_compat.py::
TestAVolumeMountPointIsTheOneSurrogateTheWalkFollows`; the spec names the
carve-out). Also: the NUL-spelling test built its path under `/tmp`, a symlink
to `/private/tmp` on macOS, so the agent arm rightly refused the link before
judging the leaf; the spelling now hangs off a link-free root. And the slot's
own spawn is matched through the key the runner really spawns under
(`effective_session_key`: `dashboard:<slot>`, or a channel-born slot's linked
key), never the bare slot key (review-caught): the Round 62 predicate compared
the bare key, so a slot bound explicitly to the workspace default read its own
main session as a stranger and its hard-stop respawn spawned unverified; the
pool test now drives the own spawn under the real key shapes.

Round 69: the allocation holds what it touches. Between the identity resolve and
the spawn's own hold, `_get_or_create_impl` touched a bound directory's NAME
itself -- the runtime preparation resolved it, the provider's construction read
and wrote the effort overlay under it, the saved-capability recheck resolved it
again -- with nothing held, and a producer that passed `cwd_identity` in skipped
even the resolve (review-caught: on Windows a bound directory swapped for a
directory symlink to a share was followed into SMB by `Path.exists` before the
spawn could refuse it). Each of those steps now runs through
`_under_verified_hold`: the spawn sites' own primitive
(`sandbox.verify_agent_workspace_for_spawn`) verifies the directory against the
identity and holds it for the step, released in the same thread on every exit; a
swapped directory is refused with the re-bind remedy before the preparation or
the factory see the name, a directory with no identity runs as it always has.
A member project that replaces the directory is resolved afresh (an identity for
the old spelling says nothing about the new one). Red-first in
`test_chat_slot_project.py` (the order `verify, prepare_runtime, factory`; the
swap refused before either; the unbound directory untouched), and the source pin
(`test_project_directory_seams.py`) now refuses any of those steps called bare
in the allocator -- run against Round 68's allocator it names all four. Also:
the mount-point test's Windows arm faked the opener with `os.open`, which cannot
open a directory on Windows; a real junction now stands in for the point there,
with the real opener, attributes and tag, and only the reparse data, the
following open and the GUID read faked.

Round 70: the factory's hold is taken off the loop. The provider construction
is synchronous and stays on the loop as it always was, but Round 69 ran the
hold's pin opens and its release inline around it (review-caught, both lanes:
a slow volume would stall every chat and the heartbeat); the hold now comes
from the spawn sites' cancellation-safe off-loop wrapper
(`_verified_hold_async`) and is released on a worker in a `finally`
(`_release_allocation_hold`); the order test asserts the verify and the release
never run on the loop thread, and the source pin refuses a direct
`_under_verified_hold` call in the allocator.

Round 71: the task run's bootstrap door constructs under the hold too. The
shared-runtime bootstrap (`_get_or_bootstrap_run_runtime`), the one factory
call outside `get_or_create` that spawns into a caller-named directory,
resolved the identity but constructed the provider bare (review-caught: the
same `Path.exists` on a bound directory swapped for a link to a share); its
construction now runs under the same off-loop hold and release as the
allocation body's, the order test covers the door (verify before the factory,
a swap refused before it), and the source pin lists both doors. Also: the
hold tests drained the default executor with one no-op task, which on a
multi-worker executor can run ahead of the scheduled release and leave the
closes landing in the next iteration (macOS); they now wait for the release
itself. Prose: the largest docstrings this change adds are condensed, every
rule kept.

Round 72: two test shapes the deterministic-tests rule forbids, review-caught.
The clear-vs-filing race test waited 0.2 s for the filing to reach the folder
hold; it now waits on a signal the hold's own section sets. Two tests undid a
temporary `open_pinned_directory` override with a bare `monkeypatch.undo()`,
which also undid the autouse fixtures' patches on the shared module; each
override now lives in its own `MonkeyPatch.context()`. The Backwards
compatibility note names the #11680 narrowing (an orchestrator outside a
project folder can no longer dispatch a worker into one). Prose: this change's
own newest docstrings condensed.

Round 73: the spawn's hold claim narrowed to what it pins. On POSIX the held
`O_DIRECTORY` descriptor pins the child's working directory (`chdir_fd`), not
the spelling: the fork-governance, sealed-target, voice-runtime-guard,
derived-spec and skill-projection preparation reads still open the directory
by name between the verify and the spawn (a residual that pre-exists on main
and is tracked for descriptor-relative reads in the deferred-finding issue the
seams pin names); on Windows the held chain pins the spelling too. The seams
pin now lists every call the name reaches after the verify at both ACP spawn
sites, each with its reason, and fails an unlisted one; the specs, the spawn
sites' comments and this change's own largest docstrings say the narrowed
claim. The packaging identity pin's confinement of `pinned_fs` to two
handle-pin functions is declared in the description.

Round 75: rebased over the folder tools' new update verb (rename, icon,
colour). The pin that said no update verb exists now says what the verb may
carry -- those three fields and nothing that binds or steers -- and the
duplicate-name refusal main added to the folder PATCH sits beside the two
inheritance refusals under the same lock.

Round 77: rebased over the launch-tail refactor (#17214), which moved both
drivers' process creation into one shared tail (`acp/launch.py`). The two spawn
methods still verify and hold the directory before any preparation read; each
now hands the tail the hold and the verified spelling in its launch request,
and the tail assigns that spelling as the cwd after it discards the previous
bind, lets the macOS voice bind replace it only when it binds, cross-checks the
bind's descriptor against the hold, and enters the child through the bind's
descriptor or, on POSIX, the hold itself; the spawn method keeps the hold and
releases it after its PID bookkeeping. The seams pin derives both ends from the
code: the one function in `acp/` that creates the process must be that tail,
every ACP method that calls it must be a listed hold-first entry point, and the
request must carry the verify's own hold and spelling; a harness adapter's own
preparation (`resolve_spawn`) joins the by-name reads the pin lists under the
tracked residual. The agent-switch writer follows main's split into
`switch_slot_agent`; the create route's title and artifact writes carry main's
cron-title rule after the filing; the readiness mkdir uses main's
`ensure_directory` and stays gated on the binding carrying no identity; main's
own paragraph on `session_create`'s filing window is kept as main now words it.

Round 78: the autouse fixture of the Continue-with-project test
(`_no_side_effects`) patches through the isolation floor's own `MonkeyPatch`
(`_floor_monkeypatch`, testing-conventions D11) instead of the shared
`monkeypatch`, so a test's `monkeypatch.undo()` cannot lift its pins; the repo's
semgrep rule for that shape reported it on the previous head. No other change.

Round 79: the bootstrap-door hold test told the bootstrap's release from the
stand-in spawn's by ORDER (the first release after the factory), but the hold
schedules its release on the executor as the block exits and the stand-in's
`start()` releases on the loop right after, so which reaches the spy first is
thread scheduling: on the slower macOS runner the stand-in won and the test
charged its on-loop release to the bootstrap. The spy now tells the two apart by
caller (the stand-in's own frame is skipped), keeps the count-based wait, and
still fails when the hold really releases on the loop (proven by inlining the
release). Reproduced on Linux by delaying executor callables 50 ms; no
production change.

Round 81: the Windows-chain hold test spied every `os.close` in the process and
counted a descriptor numbered like one of its three fake handles (101-103) as the
chain. On a long-lived test worker an EARLIER test's off-loop release of a real
descriptor with one of those numbers landed during this test and read as "the
chain was released before the spawn"; the chain itself was never released
early (the driver releases exactly once, after the PID bookkeeping, proven by a
release trace). The fakes are now numbered far above any real descriptor, so a
straggler close passes through unrecorded; the test still fails when the hold
really is released before the create (proven by an early-release probe).
Reproduced on Linux by padding the descriptor table to ~100 and delaying
executor callables 50 ms; no production change.

Round 82: the slot-project route's UNC test (`test_a_unc_project_is_refused_before_realpath`)
installed its process-wide `realpath`/`isdir` spies before building the slot, and a slot's
construction mints its tags revision through `config_dir()`, whose first resolve of the data
home fired the spy when the per-process memo was cold; the slot and the app are now built
before the spies go in. Test only; the route is unchanged and the test still fails when the
route itself touches the name.

Round 86: rebased over #17280 and #14539, whose projected launch record reads the
bound directory's name twice inside the held preparation block
(`inherits_default_resources`, `projected_launch_paths`); the seams pin lists both
as #17395 residuals, as it lists the other preparation reads. Test only.

Round 87: the Windows handle chain now denies write sharing as well (`FILE_SHARE_READ`
only, the volume-follow handle included) for the brief hold between the verify and the
process creation. With `FILE_SHARE_WRITE` left on, a same-user writer could set a reparse
point on a held EMPTY leaf in place (`FSCTL_SET_REPARSE_POINT` needs a write handle; a
rename or delete was already refused) and a child entering by name on Windows would have
followed it. The cost is the posture the pin already takes for delete sharing: a spawn
fails closed only when another process holds the directory open for writing at that
instant. This narrows, not answers, the live-Windows question, which stays the owner's.

Round 88: the write-sharing denial of Round 87 narrows to the LEAF. Only an empty
directory can be turned into a reparse point in place and only the bound leaf can be
empty (every ancestor contains the next component), so the leaf alone is held without
`FILE_SHARE_WRITE` (the volume-follow handle included when the leaf is a mount point);
the ancestors keep the delete-share-deny posture they had, so a stray write handle on
the drive root or a profile directory does not fail the spawn. Same security effect,
smaller fail-closed surface.

Round 89: the whole-chain write-sharing denial of Round 87 returns. Round 88's leaf-only
narrowing re-opened the acquisition race on ancestors a writer can empty: an ancestor
"always contains the next component" only once that child is pinned, so between pinning a
write-shared ancestor and the by-name open of its child a same-account writer could
delete the unpinned child, convert the emptied ancestor, and the next by-name open would
cross the new reparse point before any tag check. Every held component now denies write
sharing again for the brief hold (verify through `CreateProcess` return); the fail-closed
exposure on a pre-existing write handle anywhere on the chain returns by necessity,
bounded to that hold, the same posture as the delete-sharing denial. Opening each child
relative to the held parent handle (`NtCreateFile` with `RootDirectory`) would need no
write denial at all; deferred, for the maintainers' triage.

Round 90: main's #18732 added the managed-agent shadow refusal to the kiro-cli spawn
preparation in `acp/client.py`; the fence holds that block re-indented under its verify,
so the seven lines are re-homed inside the held copy at main's position (the union is
mechanical; no unindented copy remains). The seams pin lists the new call,
`managed_agent_shadow_refusal`, as a tracked #17395 residual: like the other listed
preparation reads it takes the work dir's name after the verify, on main's own code.

Round 92: main's #19222 gives each new owner chat its own session folder and tests the
project-linked-folder arm with a create that files into a bound folder; under this fence a
create that would inherit a binding is admitted only for the person, so the test's owner
helper now carries the positive `is_dashboard_user` stamp (`stamp_the_person`), as the
fence's own folder tests do. Test-only; the gate is unchanged. A per-chat session folder
is a project a non-recording writer set, so the first spawn re-pins it like a restored
slot (cold start, PATH entries inside it screened), the same as any bound directory.

Round 93: two review findings on the fence's own code, both fixed. (1) `revive_session`'s
folder-filing refusal raised a plain `SessionControlError`, bypassing the verb's `deny`
factory, so that 403 wrote no SEL `denied` row while every other refusal of the verb does;
it is re-raised through `deny` now (`test_revive_filing_refusal_is_an_audited_denial`).
(2) `asyncio.to_thread` cannot interrupt its thread: a cancellation inside `verified_hold`
(an ordinary tab close during preparation) raised at once while the preparation or the
saved-capability recheck kept resolving the bound directory's name, and the hold's
`finally` released the pinned chain under it, re-opening the swap window on Windows. Every
off-loop step inside the hold is awaited through `_drained` now: a cancellation waits for
the worker to return, the chain is released after it, and `CancelledError` then propagates
(`test_a_cancelled_step_keeps_the_hold_until_its_worker_returns`; the seams pin derives
every held off-loop sink and refuses a bare await).

Round 94: three follow-ups on Round 93. (1) The hold-drain test waited with a fixed
sleep as its barrier; its step now parks on an `Event` (`until_parked` is the handshake
before the cancel) and the property is the order at the task's completion. (2) The same
cancellation gap at the spawn hold in `acp/client.py` and `acp/runtime.py`: every
`to_thread` offload inside that hold (the workspace preparation, the agent
materialisation, the fork-governance and shadow checks, the launch-path resolution) was
awaited bare, so a cancellation released the handle chain while a thread still resolved
the directory's name. The drain is `kiro_crew.sandbox.drained` now, shared by the
`verified_hold` sites and the spawn holds, and a seams pin derives every offload inside
the spawn holds and refuses a bare await. (3) The PR's own short fixed waits (a 10 s
`wait_for`, a 5 ms poll loop, a turn budget before a lock wait) now await their signal
through `kiro_crew.testing.wait` (`await_until`, `async_wait_until`, `until_parked`,
`wait_until`), as main's wait-discipline ratchet requires.

Round 95: the spawn-hold drain finished. (1) The hold's coroutine steps that offload by-name
reads of their own are drained as a whole: the adapters' `resolve_spawn` and
`prepare_spawn_env`, the runtime's `_resolve_spawn_plan` and its projected-spec handshake,
and both `_to_thread_guarding_sandbox` helpers drain inside; the seams pin lists those
callees and refuses a bare await. `launch` is not drained: the process-creation tail's
bookkeeping must not be deferred past a cancel. (2) `drained` logs its first deferral
(DEBUG), the handshake a test waits on before asserting the hold is still held. (3) One
behavioural test per spawn hold: a cancel while the first name-touching worker still
runs; the spawn keeps waiting (an undrained spawn unwinds and releases under the worker:
`['released']`), the release follows the worker's return, the caller is cancelled. D1
waits only.

Round 96: the runtime's cancel-during-preparation test now runs once per name-touching
worker the spawn hold reaches (the voice-runtime check, the sealed-target probe the spawn
plan's harness arm offloads, the skill projection), so the plan resolution's drain is
proven behaviourally, not only by the seams pin: on the previous production code the
spawn-plan case unwinds and releases under the probe (`['released']`). Test-only.

Round 97: two hold tests asserted on a release the hold's `finally` schedules off the loop
without awaiting (the verified-hold drain test, right after the cancelled task ended; the
name-touch hold test, after the manager closed), so a slow executor could fail correct
code; both now wait for the releases to land (`async_wait_until`) before asserting.
Test-only.

Round 98: replayed onto main after its 17:04-17:30Z merge burst. The one conflict was
`error-code-baseline.json`, where both sides had lowered `missing_code` by one (this
change in `dashboard/chat_handlers.py`, main in `dashboard/file_api/uploads.py`); the file
is regenerated with the repository's own generator (`python
test/test_error_code_contract.py --update`) on the merged tree, so the totals follow the
per-file map (`missing_code` 1045, `_compliant` 2706). Seventeen other files main also
touched merged on their own. No content change.

Round 99: the Windows chain keeps a followed volume mount point's OWN handle. The walk
used to close the mount point's no-follow handle once the mounted volume's root was
open, so from then on nothing held the mount point's name on the host volume: a
same-account writer could rename it away and plant a symlink at its name, and the
walk's next by-name open of the child would follow that intermediate component (the
no-reparse flag covers the final component only), a share included. `pin_directory`
now appends the mount-point handle to the caller's held chain (`hold_through`), held
without delete or write sharing beside the volume root until the chain is released,
and refuses the follow for a caller that passes no chain. Red-first:
`test_the_mount_point_name_stays_held_beside_the_volume_root_until_the_chain_is_released`
(on the previous code the held chain carried no mount-point handle).

Round 100: replayed onto main after #19331 rewrote the waits in `test/test_acp_runtime.py`.
The one conflict was that file's import of `kiro_crew.testing.wait`: main's line names
`async_wait_until, await_until, default_timeout`, this change had added `async_wait_until`
alone; main's superset is kept. The rest of the rewrite merged on its own. No content
change.

Round 101: replayed onto main after #19584 moved the three pure ownership helpers
(`_folder_owner_app`, `_subtree_holds_foreign_folder`, `_is_descendant`) out of
`dashboard/chat_folders.py` into `dashboard/folder_ownership.py`, re-exported from where
they were. The first conflict was that file: this change had inserted its inheritance and
filing functions between the two moved helpers and added one sentence to
`_subtree_holds_foreign_folder`'s docstring. Main's move is kept: the helpers are defined
once, in main's module, and reach this file through main's re-export; the inserted functions
stand where the helpers were; the docstring sentence goes with the function it described
(the rule it stated, that an agent may not change an existing binding at all, is
`api_chat_folder_update`'s `_agent_binding_refusal`). Main then merged #18342 (the plain
session is the default template, never the default crewmate), which appends a test to
`test/test_chat_agent_selection.py` where this change appends its re-pin test; both stand,
main's first. Every other file main touched merged on its own. No content change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants