Skip to content

feat(spawn): opt-in fail-closed worker sandbox wrapper hook - #8600

Open
dominikbullo wants to merge 10 commits into
kunchenguid:mainfrom
dominikbullo:fm/fm-sandbox-upstream-pr
Open

dominikbullo wants to merge 10 commits into
kunchenguid:mainfrom
dominikbullo:fm/fm-sandbox-upstream-pr

Conversation

@dominikbullo

@dominikbullo dominikbullo commented Nov 19, 2026 •

Copy link
Copy Markdown

Implements the plan agreed in #6170: an opt-in, fail-closed worker command sandbox that is a generic operator-supplied wrapper hook, not a built-in sandbox.

Closes #6170
We have been running this shape in production on our side.

What it does

  • config/sandbox (local, gitignored) drives it; absent, every launch is exactly what it is today.
  • fm-spawn.sh wraps only the agent segment of the launch command: <wrapper> --profile <name> <binds> --host-helper <helper> -- <agent command>.
    The wrapper is applied after placeholder substitution and before the status reporter, the FM_TASK_INBOX export, and the launch-env-allowlist layer, so those stay outside the sandbox and compose unchanged.
  • Grammar: wrapper=, enforce=off|on|strict, default=, project:<name>=, kind:ship|scout=, and --sandbox <profile|off>.
    enforce=on allows --sandbox off as a one-spawn waiver, strict refuses it and any unmapped ship or scout, off is a kill switch.
  • Fail-closed: a profile that applies is always enforced.
    The spawn refuses, before any endpoint, worktree, or task record exists, and never launches the worker raw, for a missing or unnamed wrapper, a wrapper whose --dry-run rejects the profile, an unknown profile, a raw launch command, a non-omp harness, backend=t3code (T3 starts the agent itself, so there is no pane Firstmate launches into), and a secondmate.
  • --relaunch re-applies the profile recorded in the task meta (sandbox=<profile>, or sandbox=off for a waiver), refuses a different profile, and accepts only --sandbox off.
  • Teardown removes the per-task relay directory.
  • The token refresher and any network proxy stay operator-side inside the wrapper; nothing here knows about a particular sandbox runtime.

docs/configuration.md ("Worker sandbox (config/sandbox)") owns the grammar, enforce levels, refusals, and the wrapper contract; the script headers own mechanics.

Relay trust boundary

A sandboxed omp worker cannot have a writable state/ (it holds every other worker's inbox and extension), so its busy extension cannot run fm-busy-event.sh.
Instead:

  • The sandbox gets exactly one writable path under state/: its own state/<id>.sbx/events/ spool, plus its own status and turn-ended files, steering inbox, and data directory.
    Never state/ itself and never FM_HOME.
  • The extension drops one small JSON edge file ({"state","event"}) per turn edge by rename.
  • bin/fm-sandbox-relay.sh runs on the host as the wrapper's --host-helper, validates each file, and applies it through fm-busy-event.sh.
    Malformed, oversize (over 512 bytes), non-regular or symlinked, flooding, or writer-refused files are dropped and counted in a host-side log.
  • The busy gen, task id, state directory, and spool path are fixed on the helper's command line at spawn, never read from a file, so an event can only update this task's own busy record, a superseded incarnation cannot move its replacement's record, and no other task's state or inbox is reachable.
  • It authenticates the incarnation, not the claim: a worker can still misreport its own busy state, exactly as a compromised unsandboxed extension could.

Only the omp harness is supported for now because the relay is omp-specific; any other harness with a resolved profile refuses rather than running unwrapped.

Tests

  • tests/fm-spawn-sandbox.test.sh: default launch, task record, and busy extension are byte-identical with no config/sandbox (compared against an inactive config, and against origin/main by hand, see below); the wrap is at the one seam with only the task binds and the reporter, inbox export, and launch-env allowlist outside it; enforce levels; malformed config; each refusal (no wrapper, missing or old wrapper, unknown profile, raw launch, non-omp harness, secondmate); relaunch reusing the recorded profile, refusing a changed one, and refusing when no wrapper is configured; the sandboxed extension spooling edges and the relay applying them; and the zsh word-splitting regression (optional --env NAME words must reach the wrapper as separate argv words under bash and zsh, since zsh does not word-split a single unquoted expansion).
  • tests/fm-sandbox-relay.test.sh: relay validation, ordering, gen pinning, symlink and flood handling, shutdown drain.
  • tests/fm-backend-t3code.test.sh (t3code refusal) and tests/fm-teardown.test.sh (relay directory removal).
  • The zsh half of the regression skips where zsh is not installed (bash always runs).

By hand, outside the suite: running the same scout spawn fixture on origin/main and on this branch with no config/sandbox and diffing the normalized launch, pane staging, task record, and busy extension gave identical output.

How it composes with the related PRs

Not verified

  • No real sandbox runtime is exercised in the test suite; tests use a stub wrapper that records argv.
    An end-to-end omp ship task inside a real wrapper ran on our side, which is the only real-runtime evidence.
  • The OpenCode end-to-end is not done: the relay is omp-only, so an OpenCode worker with a profile refuses.

Checklist

  • Raised through git push no-mistakes with no steps skipped.
  • Shell passes bin/fm-lint.sh; docs follow one sentence per line and pass bin/fm-doc-audience-check.sh.
  • Default-off, no default behavior change, no new dependency.

Intent

Implement the changes needed for firstmate to allow hooks, that we need for sandboxing.

Context: upstream issue #6170 "Add opt-in fail-closed worker command sandbox" is ready-for-pr. The agreed plan: config-driven and off when absent (default launch byte-identical, with a test proving it); refusal under enforce for a missing wrapper, an unknown profile, a backend without a pane, secondmate and t3code; the profile re-applied on --relaunch from the task meta; a generic operator-supplied wrapper hook rather than a built-in sandbox. This push resolves CI failures on the PR: the portable serial shards exceeded the 900000ms packing target because of the two new sandbox test scripts, so a 20th shard was added.

Risk Assessment

✅ Low: The round-2 fix (P1) widens the wrapper's --dry-run probe so it uses every flag the real launch passes (--ro, --rw, --rw-create, --env, --host-helper). The placeholder paths sit under the existing project dir, and a regression test rejects each flag one at a time and checks the refusal leaves no record and no launch; the rest of the branch was already reviewed and nothing new turned up.

Testing

Both sandbox suites pass (spawn seam and relay). They cover the byte-identical default launch against the 427056c golden, the enforce levels, refusals for a missing, old, unknown-profile or flag-rejecting wrapper, the secondmate refusal, the relaunch re-wrap and the relay. I also drove the real fm-spawn.sh against real bubblewrap wrappers. A wrapper that predates --env is refused up front: exit 1, no task record, no launch, and the dry-run probe carried every launch flag. A complete wrapper wraps the scout and records sandbox=strict. Inside real bwrap the worker sees its own worktree and only its own state files: no meta, no operational-inbox, no other task's files, nothing else from the host home. The t3code refusal was not re-driven. This is a CLI-only change, so there is no visual evidence.

  • Live validation: ✅ go - 6 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Operator's real bwrap wrapper predates --env: spawn of a mapped scout is refused before any record or launch, and the probe carried every launch flag ✅ pass live live-bwrap-preflight.txt Scenario A: exit=1, refusal names --ro, --rw, --rw-create, --env and --host-helper, wrapper dry-run argv includes all of them, task record exists? no, pane launched? no
A complete real bwrap wrapper wraps a scout: sandbox=strict is recorded, and inside bwrap the worker sees only its worktree and its own task files ✅ pass live live-bwrap-preflight.txt Scenario B: spawned ... sandbox=strict; 44-word wrapper argv; PROBE state/ contents limited to sbx-new-b1.* task files (no .meta, no operational-inbox); other case dir not fou…
No config/sandbox, or an inactive one: launch, task record and busy extension match the pre-seam golden bytes ✅ pass live tests/fm-spawn-sandbox.test.sh test_default_launch_is_byte_identical ok
Enforce refusals: missing, unnamed, old or flag-rejecting wrapper, an unknown profile, a non-omp harness, a raw command, and a secondmate (local and remote) all refuse and never launch raw ✅ pass live fm-spawn-sandbox.test.log: unusable_wrapper, unsupported_shapes, secondmate_is_never_sandboxed, enforce_levels ok
--relaunch re-wraps with the recorded profile and a fresh relay gen; strict refuses a recorded waiver ✅ pass live fm-spawn-sandbox.test.log test_relaunch_rewraps_with_the_recorded_profile ok
Sandboxed busy edges reach the host through the relay; floods and malformed entries are bounded or dropped ✅ pass live fm-sandbox-relay.test.log all passed
A t3code (no-pane) backend refuses a sandbox profile ⏸️ untested no This commit does not touch this path. In an earlier round, which the user declined to pursue, the t3code suite aborted in this environment on an unrelated unbound variable in bin/fm-pending-reply-lib.…
Evidence: Live bwrap preflight and isolation transcript

Source: Live bwrap preflight and isolation transcript

== Scenario A: real bwrap wrapper predating --env: spawn refused up front
exit=1
error: sandbox profile strict cannot be applied: the sandbox wrapper '/tmp/fm-live-sbx.Dyi4ip/old/old-wrapper' does not accept --profile strict with --ro, --rw, --rw-create, --env and --host-helper (profile unknown or wrapper too old); fix the wrapper named in config/sandbox, or --sandbox off where config/sandbox enforce=on allows it, and the worker was not launched
wrapper calls:
WRAP --profile strict --worktree /tmp/fm-live-sbx.Dyi4ip/old/project --ro /tmp/fm-live-sbx.Dyi4ip/old/project --rw /tmp/fm-live-sbx.Dyi4ip/old/project --rw-create /tmp/fm-live-sbx.Dyi4ip/old/project/.fm-probe --env PATH --host-helper /etc/profiles/per-user/dominikbullo/bin/true --dry-run -- true
task record exists? no
pane launched? no

== Scenario B: real bwrap wrapper accepting every flag: spawn wrapped and worker runs inside bwrap
exit=0
spawned sbx-new-b1 harness=omp kind=scout window=firstmate:fm-sbx-new-b1 worktree=/tmp/fm-live-sbx.Dyi4ip/new/wt sandbox=strict
record sandbox field: sandbox=strict
wrapper calls:
  WRAP --profile strict --worktree /tmp/fm-live-sbx.Dyi4ip/new/project --ro /tmp/fm-live-sbx.Dyi4ip/new/project --rw /tmp/fm-live-sbx.Dyi4ip/new/project --rw-create /tmp/fm-live-sbx.Dyi4ip/new/project/.fm-probe --env PATH --host-helper /etc/profiles/per-user/dominikbullo/bin/true --dry-run -- true
launch file: none
-- pane launch log (agent segment):
new-wrapper' '--profile' 'strict' '--worktree' '/tmp/fm-live-sbx.Dyi4ip/new/wt' '--ro' '{run-worktree}/bin' '--ro' '{run-worktree}/.agents' '--ro' '{run-worktree}/.omp' '--rw-create' '/tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.status' '--rw-create' '/tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.turn-ended' '--rw' '/tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.inbox' '--rw' '/tmp/fm
-- probe inside real bwrap via the same wrapper and binds:
(args parsed: 1194 chars)
-- launch log head:
export COMPACT_ADVISER_DISABLE=1; export FM_TASK_INBOX='/tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.inbox'; '{run-worktree}/bin
-- launch segment tail: /fm-live-sbx.Dyi4ip/new/wt' -e '/tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.omp-ext.ts' "$('{run-worktree}/bin/fm-operational-input.sh' encode launch-brief < '/tmp/fm-live-sbx.Dyi4ip/new/home/data/sbx-new-b1/launch-brief.md')"
-- wrapper argv:
-- inside: is bwrap? systemd
-- running real wrapper call under bwrap with probe in place of omp
-- real wrapper argv from the launch text (44 words):
  /tmp/fm-live-sbx.Dyi4ip/new/new-wrapper
  --profile
  strict
  --worktree
  /tmp/fm-live-sbx.Dyi4ip/new/wt
  --ro
  {run-worktree}/bin
  --ro
  {run-worktree}/.agents
  --ro
  {run-worktree}/.omp
  --rw-create
  /tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.status
  --rw-create
  /tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.turn-ended
  --rw
  /tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.inbox
  --rw
  /tmp/fm-live-sbx.Dyi4ip/new/home/data/sbx-new-b1
  --ro
  /tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.git-hooks
  --ro
  /tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.omp-ext.ts
  --rw
  /tmp/fm-sbx-new-b1
  --rw
  /tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.sbx/events.g1795983169.2346035.10031
  --env
  COMPACT_ADVISER_DISABLE
  --env
  FM_TASK_INBOX
  --env
  FM_TASK_ID
  --env
  GOTMPDIR
  --env
  TRACEPARENT
  --env
  LAVISH_AXI_HOST
  --env
  LAVISH_AXI_PORT
  --host-helper
  /tmp/fm-live-sbx.Dyi4ip/new/home/state/sbx-new-b1.sbx/relay-helper
  --
PROBE inside: FM_TASK_ID=sbx-new-b1 pwd=/tmp/fm-live-sbx.Dyi4ip/new/wt
PROBE worktree visible: yes
PROBE state/ contents: sbx-new-b1.git-hooks sbx-new-b1.inbox sbx-new-b1.omp-ext.ts sbx-new-b1.sbx sbx-new-b1.status sbx-new-b1.turn-ended 
PROBE other case dir contents: ls: cannot access '/tmp/fm-live-sbx.Dyi4ip/old': No such file or directory 
PROBE host HOME visible: .no-mistakes 
PROBE worktree writable: yes
probe rc=0
Evidence: fm-spawn-sandbox suite output

Source: fm-spawn-sandbox suite output

ok - fm-spawn: no config/sandbox leaves the launch, record, and busy extension untouched
ok - fm-spawn: a mapped scout is wrapped at the one seam with the task binds, never state/ or FM_HOME
ok - fm-spawn: explicit --sandbox beats project, which beats kind, which beats default
ok - fm-spawn: launch-env-allowlist and the sandbox compose; the agent keeps its task variables
ok - fm-spawn: enforce=off is a kill switch, on allows --sandbox off, strict refuses it and unmapped spawns
ok - fm-spawn: a malformed config/sandbox refuses the spawn instead of launching unsandboxed
ok - fm-spawn: a missing, unnamed, old, or profile-ignorant wrapper refuses and never launches raw
ok - fm-spawn: a non-omp harness and a raw launch command refuse while a profile applies
ok - fm-spawn: a secondmate, local or remote, is never sandboxed, even under enforce=strict, and refuses --sandbox
ok - fm-spawn: --relaunch re-wraps with the recorded profile and a fresh relay gen; --sandbox off is the only override; strict refuses a recorded waiver
ok - fm-spawn: with FM_HOME at the code root the wrapper never sees the home, state/, data/, config/ or projects/
ok - fm-spawn: the sandbox is never handed another task's launch record
ok - fm-spawn: the sandboxed omp extension spools its edges and the relay applies them to the busy record
ok - fm-spawn: the launch, task record, and busy extension match the pre-seam bytes with no or an inactive config/sandbox
skip: fish not installed
ok - fm-spawn: the wrapper's env names parse as static --env pairs in every pane shell
all fm-spawn-sandbox tests passed
env -u DISABLE_AUTOUPDATER bash tests/fm-spawn-sandbox.test.sh  24.06s user 18.15s system 61% cpu 1:08.59 total
Evidence: fm-sandbox-relay suite output

Source: fm-sandbox-relay suite output

ok - relay: a valid edge file yields the same record as a direct fm-busy-event.sh apply
ok - relay: edges apply in sequence order
ok - relay: a superseded incarnation and a forged file gen leave the record unchanged
ok - relay: malformed, oversize, schema-violating, and stray entries are dropped and the record is unchanged
ok - relay: a symlink is dropped without following it
ok - relay: an entry swapped for a FIFO after the check cannot block the relay
ok - relay: a flood costs one bounded pass per poll, is logged once per pass, and the spool drains
ok - relay: run applies a file written while it polls and ends when teardown removes the spool
ok - relay: a relay whose incarnation was re-armed ends by itself
ok - relay: TERM drains the final edge, then ends
all fm-sandbox-relay tests passed

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 0 issues

✅ No issues found.

  • ⚠️ bin/fm-sandbox-lib.sh:215 - The preflight probe in fm_sandbox_wrapper_ready runs the wrapper as --profile P --worktree W --host-helper true --dry-run -- true. The real launch built by spawn_sandbox_wrap (bin/fm-spawn.sh:4268-4284) also passes --ro, --rw-create, --rw and seven --env NAME words, and the probe never exercises any of them. The library header says --dry-run validates the profile and flags, and the refusal text says 'profile unknown or wrapper too old', so the probe is meant to catch a wrapper that is too old. Concrete case: an operator's wrapper accepts --profile and --host-helper but predates --env (added in this branch's fix rounds) or --rw-create. Preflight passes, spawn_sandbox_resolve sets SANDBOX_PROFILE, and the spawn goes on to create the worktree, endpoint and task record (sandbox=<profile>). The wrapper then rejects the unknown flag in the pane, so the worker never starts, after the documented 'refuses before any endpoint, worktree, or record exists' point. This fails closed (never raw), but the task is left half-created instead of being refused up front. The same gap applies on --relaunch, which uses the same probe. Fix at the same owner: give the dry-run one word of each bind and env flag the launch uses, for example --ro &lt;worktree&gt; --rw &lt;worktree&gt; --rw-create &lt;worktree&gt;/.fm-probe --env PATH. The dry-run contract says nothing is minted, so these placeholder paths are safe.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Operator with no config/sandbox spawns an omp scout: the launch, task record and busy extension match the pre-seam golden from base 427056c ✅ pass live fm-spawn-sandbox.test.log: 'the launch, task record, and busy extension match the pre-seam bytes with no or an inactive config/sandbox'
Operator maps a project to a profile: the spawn wraps only the agent segment with task-only binds and records sandbox=<profile> ✅ pass live live-bwrap-transcript.txt (spawned ... sandbox=strict, wrapper --dry-run probe, then the wrap call with --ro bin/.agents/.omp) and fm-spawn-sandbox.test.log mapped-project, code-root and other-task-re…
Adversarial: enforce=on with a missing wrapper, unknown profile, non-omp harness, raw launch, malformed config, strict unmapped or --sandbox off, secondmate (local and remote) or t3code: the spawn ref… ✅ pass live live-bwrap-transcript.txt: 'error: sandbox profile strict cannot be applied: the sandbox wrapper ... is not installed ... the worker was not launched'; spawn exit 1, no record, nothing launched. fm-sp…
Operator relaunches a sandboxed task: --relaunch re-wraps with the profile recorded in the task meta ✅ pass live fm-spawn-sandbox.test.log: test_relaunch_rewraps_with_the_recorded_profile ok
Sandboxed omp extension writes busy edges to the per-generation spool and the host relay applies them; floods, symlinks, FIFOs and stale generations are dropped ✅ pass live fm-sandbox-relay.test.log (all relay cases ok) and the spawn suite case 'the sandboxed omp extension spools its edges and the relay applies them to the busy record'
CI layout: 20 portable serial shards pass the workflow contract test and the packing guard, sandbox suites are each assigned to one shard, and a stale of19 lane is refused ✅ pass live fm-ci-workflow.test.log, check-coverage-20.log, lane19.err
Worker actually executes inside a real bubblewrap sandbox and cannot see fleet state/ or owner secrets ⏸️ untested no I captured the pane text from the spawn fixture's fake tmux and ran it through bash, but it was not a runnable command on its own, so the worker never started under bwrap. A real run needs a full lab…
  • env -u DISABLE_AUTOUPDATER bash tests/fm-spawn-sandbox.test.sh (all pass; fish case skipped, fish not installed)
  • bash tests/fm-sandbox-relay.test.sh (all pass)
  • nix shell nixpkgs#ruby -c bash tests/fm-ci-workflow.test.sh (pass; ruby is not on PATH, so it came from nix)
  • bin/fm-test-run.sh --check-coverage (FM_TEST_COVERAGE ok, serial_shards=20)
  • bin/fm-test-run.sh --list --lane portable-serial-&lt;k&gt;of20 for k=1..20 (sandbox suites land in shards 11 and 18)
  • bin/fm-test-run.sh --list --lane portable-serial-1of19 (refused, exit 2)
  • live-bwrap-driver.sh: real bin/fm-spawn.sh with an operator wrapper hook built on real bubblewrap, a project mapped to strict, then a missing wrapper under enforce=on

✅ No issues found.

  • Live validation: ✅ go - 6 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Operator's real bwrap wrapper predates --env: spawn of a mapped scout is refused before any record or launch, and the probe carried every launch flag ✅ pass live live-bwrap-preflight.txt Scenario A: exit=1, refusal names --ro, --rw, --rw-create, --env and --host-helper, wrapper dry-run argv includes all of them, task record exists? no, pane launched? no
A complete real bwrap wrapper wraps a scout: sandbox=strict is recorded, and inside bwrap the worker sees only its worktree and its own task files ✅ pass live live-bwrap-preflight.txt Scenario B: spawned ... sandbox=strict; 44-word wrapper argv; PROBE state/ contents limited to sbx-new-b1.* task files (no .meta, no operational-inbox); other case dir not fou…
No config/sandbox, or an inactive one: launch, task record and busy extension match the pre-seam golden bytes ✅ pass live tests/fm-spawn-sandbox.test.sh test_default_launch_is_byte_identical ok
Enforce refusals: missing, unnamed, old or flag-rejecting wrapper, an unknown profile, a non-omp harness, a raw command, and a secondmate (local and remote) all refuse and never launch raw ✅ pass live fm-spawn-sandbox.test.log: unusable_wrapper, unsupported_shapes, secondmate_is_never_sandboxed, enforce_levels ok
--relaunch re-wraps with the recorded profile and a fresh relay gen; strict refuses a recorded waiver ✅ pass live fm-spawn-sandbox.test.log test_relaunch_rewraps_with_the_recorded_profile ok
Sandboxed busy edges reach the host through the relay; floods and malformed entries are bounded or dropped ✅ pass live fm-sandbox-relay.test.log all passed
A t3code (no-pane) backend refuses a sandbox profile ⏸️ untested no This commit does not touch this path. In an earlier round, which the user declined to pursue, the t3code suite aborted in this environment on an unrelated unbound variable in bin/fm-pending-reply-lib.…
  • env -u DISABLE_AUTOUPDATER bash tests/fm-spawn-sandbox.test.sh (all 15 cases ok; the fish pane shell is skipped because fish is not installed)
  • env -u DISABLE_AUTOUPDATER bash tests/fm-sandbox-relay.test.sh (all cases ok)
  • Live driver script: real bin/fm-spawn.sh with a disposable FM_HOME (tests/fixtures.sh helpers, fake pane and omp), config/sandbox enforce=on, project:project=strict, and a real bubblewrap wrapper that rejects --env, to check the preflight refusal
  • Same driver with a real bubblewrap wrapper that accepts every contract flag: spawn, check sandbox=strict in the record, extract the wrapper argv from the launch text with shlex, run it under bwrap with an isolation probe in place of omp
✅ **Document** - passed

✅ No issues found.

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @dominikbullo, this matches the plan from #6170, and the relay trust-boundary write-up made the review much easier.

Checked on head ea0f30b3 against main 427056c4: I read the whole diff. It doesn't touch workflows, CI config, credentials or installer checksums, and it adds no network calls. The only new thing it executes is the wrapper the operator names in their own local config/sandbox. Because this is your first contribution from a fork, I approved the two pending CI runs (44484827373 and 44484827389). The no-mistakes check, Repo invariants and the Test coverage guard now pass. The attestation binds ea0f30b3 with no skipped steps, and the live validation is go (6 of 9, with the suite-only cases stated plainly). Closes #6170 is correct and the PR merges cleanly. The red "Full suite" row only means our full-ci label isn't on yet. That's on our side, not yours.

Contract class (my own read): opt-in. With no config/sandbox, the launch, task record and busy extension stay as they are on main, and the 427056c4 golden fixture checks that.

Waiting on you for one thing: spawn_sandbox_wrap binds state/operational-inbox read-only into the sandbox. On main that directory is shared by the whole home. bin/fm-operational-input.sh keeps <state>/operational-inbox/<name>.msg records there for about 7 days, and they include other workers' launch briefs. Record transport is only used for FM_OPERATIONAL_RECORD_HARNESSES='claude', and this seam only wraps omp. So a sandboxed omp worker can read other tasks' briefs. That contradicts the docs' "the binds name only the task's own files" and the "no other task's state ... is reachable" guarantee. Please drop that bind for the sandboxed omp worker, or narrow it to this task's own record, and add a test that the sandbox can't see another task's record. If omp does need it, reply here with the reason and correct the docs wording. Then re-raise once through git push no-mistakes.

After that, this goes to the normal full-suite gate. Because it's security-sensitive launch code, it also needs the captain's explicit word before it merges.

@dominikbullo

Copy link
Copy Markdown
Author

Addressed the operational-inbox ask in cdc6b173.

  • spawn_sandbox_wrap no longer binds state/operational-inbox at all, so a sandboxed omp worker cannot read any other task's launch record. The shared task_channel_dirs list is unchanged because the Claude --add-dir grant still uses it; the sandbox just skips that role.
  • Header comment, function comment and the sandbox section of docs/configuration.md now say the shared state/operational-inbox is never bound.
  • New test test_other_tasks_launch_record_is_never_bound in tests/fm-spawn-sandbox.test.sh: it publishes another task's launch record into state/operational-inbox, spawns a sandboxed omp task, and asserts that no bind the wrapper receives is or contains that record while the task's own inbox bind remains. The old "launch record is read-only" assertion was removed. tests/fm-spawn-sandbox.test.sh passes locally at this head.

Since this is a new push from a fork, the CI runs will need approving again.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @dominikbullo, cdc6b173 resolves the operational-inbox ask exactly as I hoped. The sandbox no longer receives that bind, the docs now say so, and the new peer-record test proves it.

I read the delta. It only removes a bind and touches docs and tests, with no workflow, network or credential changes. I approved the two new fork CI runs (44519244917 and 44519245070). The attestation binds cdc6b173 with no skipped steps. Contract class is still opt-in.

Nothing is waiting on you right now. Next steps are on our side: CI has to finish, and our main branch is currently red for an unrelated reason, so the full-ci label waits for main to go green. Because this touches the worker isolation boundary, it will also go to Kun for an explicit merge word, rather than auto-merging.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: CI on cdc6b173 has finished. The coverage guard, repo invariants and the no-mistakes check pass, there are no open review threads, and the PR merges cleanly. The red Full suite row only means our full-ci label isn't on yet.

This is ready for the full suite. I'm holding the full-ci label only because our own main is red right now, and it goes on once main is green again. After a green full suite, it goes to Kun for an explicit merge word because it touches the worker isolation boundary. Nothing is waiting on you.

@dominikbullo

Copy link
Copy Markdown
Author

Conflicts with current main are resolved at dbd3058. The no-mistakes pipeline passed review, test, document and lint on the rebased branch, and the sandbox tests (fm-sandbox-relay, fm-spawn-sandbox) pass locally. The GitHub workflows are waiting for maintainer approval (action_required), so they have not run yet. Ready for the full-ci label once main is green; happy to adjust anything.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @dominikbullo for resolving the conflicts.

What I checked on dbd30580 (vs main 4b1d93d2, which it merges cleanly onto): I compared your diff against the cdc6b173 version I reviewed on 2026-11-19. The only changes in your own code are two. First, the wrapper now gets --env for FM_TASK_ID, GOTMPDIR, TRACEPARENT, LAVISH_AXI_HOST and LAVISH_AXI_PORT as static words (so the launch line parses in fish too), with the wrapper skipping names unset at launch. Second, the docs say plainly that the wrapper passes the pane's launch environment through to the worker. That environment is the one an unsandboxed worker already gets, so nothing new is exposed. The fish test row covers the new parsing. Everything else (the operational-inbox bind removal and its peer-record test, the relay and the golden fixture) is unchanged, and the other differences come from main. Diff review: safe, with no workflow, network or credential changes.

Because it's a new push from a first-time fork, I approved its three CI runs (45796073452, 45796073422, 45796095585). The coverage guard, repo invariants and the no-mistakes check pass. The attestation binds dbd30580 with every step completed, live is go 7 of 9, and there are 0 threads.

One small body fix, not blocking the full suite: the regenerated description no longer has its Closes #6170 line. Please add it back as plain text when you next touch the PR, so #6170 closes on merge. If you'd rather not push again, tell me and I'll make sure #6170 gets closed.

Contract class: opt-in (no config/sandbox means main's launch). I'm adding full-ci now. Because this is security-sensitive launch code at the worker isolation boundary, a green full suite takes it to Kun for an explicit merge word rather than auto-merging. That part isn't waiting on you.

@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 26, 2026
@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · No new blocking issue was established.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] No new blocking issue was established.

Reviews (5) · Last reviewed commit: "no-mistakes(review): Probe every launch ..." · Reviewed by Greptile

Comment thread bin/fm-sandbox-lib.sh Resolved
Comment thread bin/fm-sandbox-lib.sh Resolved
Comment thread bin/fm-sandbox-relay.sh Resolved
@dominikbullo

Copy link
Copy Markdown
Author

Merged current main (c612290) into the branch; conflicts were in bin/fm-spawn.sh (adjacent arg-validation comment next to the --sandbox check) and docs/configuration.md (the topic table row, now carrying both the new Codex accounts link and the Worker sandbox row). Resolved keeping both sides. The Closes #6170 line is restored in the description. Head is now 4b49187.

Review-bot fixes folded in:

  • off is rejected as a profile name in default=/project:/kind: mappings, so a waiver only comes from an explicit --sandbox off.
  • Each launch generation gets its own events spool dir; the relay reads only the current one and older ones are removed at prepare.
  • The relay processes at most MAX_PASS entries per poll and logs one summary line per poll for excess/dropped entries.

fm-sandbox-relay and fm-spawn-sandbox tests pass locally. Workflows are waiting for maintainer approval; happy to adjust anything.

@dominikbullo

Copy link
Copy Markdown
Author

Hi @kunchenguid, a polite nudge on this one. I have now resolved conflicts with main twice (at dbd30580 and again at 4b49187c), and each round of upstream changes reopens them. The branch merges cleanly right now, the three Greptile security findings are fixed, the full suite passed on the previous head, and Closes #6170 is back in the description.

The workflows for 4b49187c are waiting for maintainer approval. If you could approve the runs and give it a look while it is conflict-free, that would let it land before the next drift. Happy to change anything you want. Thanks for your time!

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @dominikbullo, and thanks for keeping this conflict-free twice. Sorry for the wait on approvals.

What I checked on 4b49187c (against main 9ac0288e): your two merges of main change none of the PR's own lines (I compared the PR's net diff before and after). So the new review is 4b49187c itself. off is now rejected as a profile name in every mapping, so a waiver only comes from an explicit --sandbox off. Each launch generation gets its own events.<gen>/ spool, and prepare removes the old spools and inflight/ before creating the new one. Removal happens host-side with find -exec rm -rf, which does not follow symlinks. The relay takes at most MAX_PASS entries per poll (dot-file sweeping included). It moves each entry into inflight/ before looking at it, and drops a directory only with rmdir, so it never walks a tree the worker built. Floods are logged as one line per poll. The --rw bind and the relay path agree on the per-gen spool. No workflow, network or credential changes. Diff review: safe, no P1. Greptile's review of this head is 5/5.

Gates: the attestation binds 4b49187c with every step completed. Closes #6170 is back, thank you. I approved this head's runs (CI 46140307070, Require no-mistakes 46140306905 and 46143746768). full-ci is still on, so the full suite runs on this head.

One small thing: Greptile's Floods keep the host busy thread is outdated, and on my read 4b49187c addresses it. A short reply there would let it close. It does not block anything.

Contract class: opt-in, unchanged. As before, this is security-sensitive launch code at the worker isolation boundary, so a green full suite takes it to Kun for an explicit merge word. That part isn't waiting on you.

@dominikbullo
dominikbullo force-pushed the fm/fm-sandbox-upstream-pr branch from 8323456 to a350086 Compare November 28, 2026 16:43
@dominikbullo

Copy link
Copy Markdown
Author

Pushed a350086 (merged current main). Fixes the two red checks from run 46140307070:

  • Coverage guard / portable parallel 1 (same cause, tests/fm-test-run.test.sh): the two new sandbox test scripts pushed every serial shard just above the 900000ms target, so I added a 20th serial shard per docs/fm-test-portable-shards.md (PORTABLE_SERIAL_SHARDS, the ci.yml matrix, tests/fm-ci-workflow.test.sh, the docs and the CONTRIBUTING required-contexts list). --check-coverage is ok locally (max shard 940120ms, which is the pre-existing singleton). No timeout was raised.
  • Full suite is the aggregate of those.

Note: this adds a required context, Behavior portable serial 20, so branch protection will need that name. Workflows are waiting for approval again.

@dominikbullo

Copy link
Copy Markdown
Author

@kunchenguid could you approve the workflow runs for a350086c now? This is the third time I have resolved drift on this PR, and every day it waits it picks up new conflicts.

Status on a350086c:

  • Conflict-free with current main.
  • Both red checks from run 46140307070 are fixed (20th serial shard; no timeout raised).
  • Greptile thread answered; your firstmate's review of 4b49187c found nothing open.

Please add Behavior portable serial 20 to the required checks, approve the runs, and merge once the full suite is green. I'll stay on it until it lands.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @dominikbullo, and sorry for the wait. Here's where a350086c stands. In short, it needs Kun's word now, not anything more from you.

What I checked: a19159a6 (merge of main) changes none of the PR's own lines. I compared the net diff against main before and after. a350086c is exactly the 20th-shard change: PORTABLE_SERIAL_SHARDS=20 in bin/fm-test-run.sh, the matrix in .github/workflows/ci.yml, the tests/fm-ci-workflow.test.sh assertion, the shard doc and the CONTRIBUTING required-contexts list. That is the documented fix for the overpack in run 46140307070, and no timeout was raised. The attestation binds a350086c with every step completed. Greptile is 5/5 on this head. Diff review: safe, no P1 (sandbox code unchanged since my 4b49187c review).

Why I haven't approved the runs: this head edits .github/workflows/ci.yml. Our standing rule is that we never approve fork runs on a head that edits a workflow. Kun approves those himself (runs 46166700547, 46166700588, 46166712141). Adding Behavior portable serial 20 as a required check is also a branch-protection change that only Kun makes. So I'm taking three decisions to Kun together: approve this head's runs, add the new required context, and, once the full suite is green, give the merge word for this isolation-boundary change. full-ci stays on, so the full suite runs as soon as the runs are approved.

Still open but non-blocking: Greptile's outdated Floods keep the host busy thread. A one-line reply there would let it close.

Contract class: opt-in, unchanged. VISION: unchanged from my earlier rule-by-rule read, all rules align. The shard bump is CI mechanics only.

Status: waiting on Kun (captain decision), not on you.

@dominikbullo

Copy link
Copy Markdown
Author

@kunchenguid the last open review thread (Greptile "Floods keep the host busy") is now resolved, so nothing is left on our side. Only your three steps remain: approve runs 46166700547, 46166700588 and 46166712141, add Behavior portable serial 20 as a required check, and merge once the full suite is green. Could you do them while the branch is still conflict-free?

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @dominikbullo for closing the last thread. The head is still a350086c and it still merges cleanly, so nothing else has changed. The three steps you list (approve runs 46166700547, 46166700588 and 46166712141, add Behavior portable serial 20 as a required check, then the merge word after a green full suite) are all Kun's, and they're with him. Status: waiting on Kun (captain decision), not on you.

Add config/sandbox, an operator-supplied wrapper hook that runs a ship or
scout omp worker inside a sandbox wrapper the operator provides. Firstmate
ships no sandbox of its own.

- Off when config/sandbox is absent: the launch, task record and busy
  extension are byte-identical to today.
- config/sandbox grammar: wrapper=, enforce=off|on|strict, default=,
  project:<name>=, kind:ship|scout=, plus --sandbox <profile|off>.
- fm-spawn wraps only the agent segment, after placeholder substitution and
  before the status reporter, FM_TASK_INBOX export and launch-env layers.
- A profile that applies is always enforced: a missing or unnamed wrapper, a
  wrapper that rejects the profile, a raw launch command, a non-omp harness
  or backend=t3code refuses before any endpoint or record exists, and a
  secondmate is never sandboxed.
- The task record keeps sandbox=<profile|off>; --relaunch re-applies it.
- A host-side relay (fm-sandbox-relay.sh) applies the sandboxed omp busy
  extension's edges through fm-busy-event.sh, pinned to the task's gen, so
  the sandbox never needs a writable state/.
- Optional --env names reach the wrapper as separate words so zsh panes work.

Refs kunchenguid#6170
@dominikbullo
dominikbullo force-pushed the fm/fm-sandbox-upstream-pr branch from a350086 to 3c0508c Compare November 29, 2026 20:15
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @dominikbullo. I compared 3c0508c6 with the a350086c head I reviewed earlier. Apart from the rebase onto main (it picks up main's --closes field in the usage line and meta keys), the only new change is 3c0508c6. The preflight now probes the wrapper's --dry-run with every flag the launch passes (--ro, --rw, --rw-create, --env, --host-helper), and a test refuses a wrapper that rejects any of them. That tightens a refusal path. Diff review: safe, no P1. The attestation binds this head with every step completed, and Greptile passes.

The head still edits .github/workflows/ci.yml (the 20th serial shard), so under our standing rule Kun approves this head's fork runs himself. They're now 46305425590, 46305425422 and 46305449717, replacing the earlier ids. The rest is unchanged and also with Kun: add Behavior portable serial 20 as a required check, then give the merge word after a green full suite. Contract class: opt-in. Status: waiting on Kun (captain decision), not on you.

@dominikbullo

Copy link
Copy Markdown
Author

@kunchenguid friendly nudge on this one. Nothing is left on my side: head 3c0508c6 merges cleanly, your firstmate reviewed it as safe with no P1, Greptile passes, and there are no open threads. The three steps that only you can do are still open:

  1. Approve the fork CI runs 46305425590, 46305425422 and 46305449717. They need your approval because the head edits .github/workflows/ci.yml.
  2. Add Behavior portable serial 20 as a required check.
  3. Give the merge word once the full suite is green.

We have been running this sandbox shape in production for a while, so I would love to get it upstream. Thanks!

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks for the nudge, @dominikbullo. Nothing has changed since my last note: head 3c0508c6 is still the one I reviewed (safe, no P1), and the three steps you listed (approving fork runs 46305425590, 46305425422 and 46305449717 because the head edits .github/workflows/ci.yml, adding Behavior portable serial 20 as a required check, and the merge word after a green full suite) are still Kun's. Contract class: opt-in. Status: waiting on Kun (captain decision), not on you.

FYI: #8224 also adds a 20th serial shard in ci.yml. Whichever lands second will need its shard count reconciled, and that conflict is ours to fix, not yours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add opt-in fail-closed worker command sandbox

2 participants