Skip to content

fix(ui-sdk): keep a separate-identity payload out when its coordinator dies before release - #4007

Merged
schlessera merged 4 commits into
mainfrom
fix/3402-identity-helper-start-gate
Nov 15, 2026
Merged

schlessera merged 4 commits into
mainfrom
fix/3402-identity-helper-start-gate

Conversation

@schlessera

@schlessera schlessera commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #3402

Supersedes draft #3464, which was stacked on #3408 (since merged). This PR carries #3464's single commit onto current main (3f8ff2934) and redoes the citation moves against the current launcher.

What changed

A separate-UID worker launch no longer starts its payload when its identity coordinator dies between spawn and release. Before this change, the payload's only gate was bubblewrap's --block-fd, whose pipe has one writer, the same-UID coordinator (WORKER_IDENTITY_SUPERVISOR), and the launcher removed STATE_GATE from these payloads. bubblewrap starts the sandbox when that pipe reads end-of-file. Now every separate-identity payload, with or without runtime state, runs behind STATE_GATE (function identityStartGate): the trusted absolute /bin/sh that needs one complete go line on stdin and exits 125 on end-of-file or anything else. The server writes that line only after the coordinator confirms release, and it holds stdin's only writer, so the payload starts only when both holders have authorised it. The synchronous host probe's identity path does the same. The ruling is a dated section in docs/decisions/policy-write-boundary.md (replacing the #3392 amendment's "Not covered" pointer), and a paragraph under "Separate worker identity" in docs/hosting/agent-workers.md.

Why this shape

This is #3392's mechanism (an in-sandbox gate that needs an explicit go line and fails closed on EOF), carried into the helper path on stdin rather than fd 4. The fd 4 gate needs bubblewrap to run without --block-fd and a descriptor that survives into the sandbox. The identity helper protocol requires --json-status-fd and --block-fd on the coordinator's pipes and closes every other descriptor before it execs bubblewrap, so moving to fd 4 would break every installed helper and need a breaking-contract ruling. The protocol never constrains the command after --, so the stdin gate needs no helper change. It reads a byte at a time, so payload stdin after the gate line is unchanged. No contract surface moved.

Proof

Tests ran at 33325124b on origin/main 3f8ff2934; the receipt is from 5326175 after merging main (governed-writable-workers.md overlapped). Host: Linux 7.0.0-42, Bun 1.4.4, bubblewrap 0.11.1, real user namespaces, no container. No network or provider key; the only payload content is Odysseus marker files in owned temporary directories.

packages/ui-sdk/tests/identity-gate-holder-crash.test.ts (with tests/fixtures/identity-gate-holder-crash-server.ts and the same-UID stand-in helper tests/fixtures/identity-gate-helper.py) runs the real launchAgentWorker/launchAgentWorkerAsync separate-identity path and the real coordinator in a separate server process; only workerIdentityHelper is spied to select the stand-in. It SIGKILLs the coordinator during setup, after setup before release (sync, async, and with no runtime state), the server and coordinator together, and the server alone; each case waits until every process of the launch is dead before it looks for the marker. The released control starts the payload exactly once with descriptors 0 1 2 and byte-identical stdin (itself starting with go\n and containing NUL/0xff).

Failing first — the new test against origin/main's worker-launcher.ts, 2 of 2 runs:

error: COORDINATOR_DEATH_PAYLOAD_NEVER_STARTS  Expected: false  Received: true
(fail) a coordinator killed during setup never starts the payload
(fail) a coordinator killed after setup, before release, never starts the payload
(fail) an asynchronous launch's coordinator killed before release never starts the payload
error: STATELESS_COORDINATOR_DEATH_PAYLOAD_NEVER_STARTS  Expected: false  Received: true
(fail) a stateless launch's coordinator killed before release never starts the payload
error: HOLDERS_DEATH_PAYLOAD_NEVER_STARTS  Expected: false  Received: true
(fail) a server and coordinator killed together before release never start the payload
 2 pass, 5 fail

After the fix: 7 pass, 0 fail.

Mutations (scripted on worker-launcher.ts, restored and confirmed byte-identical with cmp):

Mutation Caught by
identityStartGate is a no-op (state launches keep their gate, stateless ones have none) STATELESS_COORDINATOR_DEATH_PAYLOAD_NEVER_STARTS (1 fail)
Write go\n before the coordinator's release instead of after it COORDINATOR_DEATH_… (sync, async), HOLDERS_DEATH_… (3 fail)
STATE_GATE accepts EOF (IFS= read -r go; exec "$@") COORDINATOR_DEATH_… (setup, sync, async), STATELESS_…, HOLDERS_DEATH_… (5 fail)

Neighbouring suites on the host, patched: ui-sdk gate-holder-crash, refused-launch-gate, worker-launcher, worker-status (57 pass), default-identity-phases, native-identity-inspector, worker-identity-progress (22 pass); ui-server qualified-identity-helper, worker-host-gate, worker-host-status, worker-probe-placement (34 pass). bun run typecheck passes. bun scripts/check-citations.ts reports no drifted worker-launcher.ts citation.

bun run check:pr --base origin/main   # Local preflight passed; affected fast invariants 993 pass, 0 fail
{"version":1,"kind":"brain-check-pr-receipt","head":"532617581ea77ff1231d1a8846a319eb47a22719","base":"origin/main","mode":"focused","startedAt":"2026-11-15T14:18:41.351Z","finishedAt":"2026-11-15T14:20:17.120Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":15452.427912000003},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":147.84460599999875},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":158.6832609999983},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":23.541333000001032},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":79969.786913}]}

Collisions (bun scripts/collisions.ts --json --pr 4007 at head 33325124b): textual with draft #3393 on docs/decisions/governed-writable-workers.md (citation line numbers only); otherwise closure-only reports.

Not run locally: the disposable-container cross-UID qualification (scripts/prove-worker-identity.ts), which needs the pinned native-runtime image and rootful Docker. Its existing cases exercise this path with the real setuid fixture helper, so hosted native proof is the cross-UID receipt.

Guard checklist (proportionate containment)

  • Trigger and gaps: the payload of one separate-identity launch waits for a go line on stdin; end-of-file or any other line ends that sandbox with exit 125. It does not cover post-release server or coordinator death, which is unchanged.
  • What it restricts: one launch, the narrowest scope there is. Nothing else on the host is affected.
  • Restricted mode considered: none applies; a payload whose gate holders have died has no authorised start, and the launch already fails as a setup failure.
  • How it clears: automatically; the next launch gets fresh holders. No owner action.
  • Where the cause is recorded: the existing launch failure path (worker exit 125 / identity setup failure) that the server already reports for a failed launch; no new state.
  • Scope isolation: each crash case kills one launch's holders and the released control in the same file starts its own payload normally.

Checklist

  • Focused local preflight/behavioral receipts and complete selected hosted proof passed; actual head/base/job checkout evidence is in Proof. (Local done; hosted proof through integrate.ts confirm.)
  • Acceptance criteria from the issue are all met, or the gap is named below.
  • The PR and completed/advanced issues have verified release milestones under docs/process/github.md.
  • A changeset is included, or this changes nothing a consumer can see.
  • No personal data anywhere in the diff — the leakage gate covers the whole tree.
  • The integration contract index or relevant component is updated in this same commit, or nothing in the machine surface moved. (Nothing moved: the helper protocol is unchanged.)
  • Docs under docs/ reflect the change, or nothing documented moved.
  • A fail-closed guard added or changed answers the proportionate-containment checklist in this body, or no guard changed.
  • Provider history stays append-only (docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed.

Anything left open

  • No native-container case kills the coordinator under a real separate UID; the cross-UID part (the helper's UID drop) is unchanged by this PR.

🤖 Generated with Claude Code

…r dies before release

A separate-UID launch was gated only by bubblewrap's --block-fd on a pipe
whose sole writer is the same-UID identity coordinator. bubblewrap starts the
sandbox on that pipe's end-of-file, so a coordinator SIGKILLed after spawn
and before release (alone, or together with the server) started the
unqualified payload.

Every separate-identity payload now runs behind STATE_GATE, the trusted
absolute /bin/sh that needs one complete `go` line on stdin and refuses
end-of-file or anything else. The server writes that line only after the
coordinator confirms its release. The live launch and the synchronous host
probe both do this. The identity helper protocol is unchanged: it requires
--block-fd and never constrains the command after `--`.

Adds a same-UID stand-in helper and a crash suite that runs the real
launcher and coordinator. Records the ruling in policy-write-boundary.md and
the host protocol doc, and moves the worker-launcher citations the edit
shifted.

Closes #3402

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 15, 2026
@schlessera schlessera added type: fix Something is broken and must behave the way it is documented. area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. security Auth, isolation, egress, secrets, or anything in the threat model. labels Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. security Auth, isolation, egress, secrets, or anything in the threat model. type: fix Something is broken and must behave the way it is documented.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ui-sdk: the identity-helper launch's start gate likely opens when the helper dies before release

1 participant