Skip to content

feat: grant Codex workers task-scoped writable roots - #3708

Open
npayette84 wants to merge 41 commits into
kunchenguid:mainfrom
npayette84:fm/fm-codex-sandbox-pr3385-red-ci-repair
Open

npayette84 wants to merge 41 commits into
kunchenguid:mainfrom
npayette84:fm/fm-codex-sandbox-pr3385-red-ci-repair

Conversation

@npayette84

Copy link
Copy Markdown
Contributor

Intent

Repair the red checks on the existing upstream Firstmate PR #3385 (a recovery of the same PR, never a duplicate) and reach green hosted checks without merging.

Diagnose every failing check from its full hosted log and reproduce every code-related defect locally before fixing it, separating stale attestation, runner variance, and unrelated upstream failures from actual regressions. The current failures are: 'PR must be raised via no-mistakes' (stale attestation: the PR body binds an older head than the pushed tip), 'Behavior portable serial 2' (fm-remote-secondmate-trace-context: the enveloped cursor remote launch resolves cursor only on machines that happen to have the vendor CLI), and 'Behavior portable serial 4' (fm-remote-transport-lanes: the staged remote root lacks libraries fm-remote-secondmate-control.sh now sources).

Preserve the accepted feature: the narrow Codex writable-root grant that lets a worker write only the brief-permitted Firstmate paths while retaining the stronger sandbox and no-escalation posture. Preserve all already-green behavior for launch hardening, out-of-workspace denial, captain-question reporting, and every supported worker runtime and session provider.

Read and address every current human or automated review comment on the exact PR head; implement sound findings and document reasoned rejections. Address in particular: pinning the out-of-tree git-metadata grant to the recorded project (a worktree .git file is worker-rewritable), rejecting hard-linked writable-root files, refusing wrong-typed or uncreatable pre-created records, holding a raw cursor 'agent' alias launch to the cursor unattended bar through verified resolution, keeping launch-command substitution literal under bash 5.2 patsub_replacement, and recording the remote endpoint's actual cursor grant rather than an undelivered launch request.

Use behavioral tests through public script interfaces, never source-byte assertions; add regressions that fail on each defect and pass after the correction. Keep the branch limited to this PR's accepted scope; check the final diff against current upstream main; run relevant focused suites, bin/fm-doc-audience-check.sh, shellcheck on changed shell, and bin/fm-lint.sh.

Drive the full no-mistakes path against the corrected exact head, update the SAME PR 3385 (never a duplicate), reach green hosted checks, and never merge.

What Changed

  • Grant Codex workers the task-scoped Firstmate paths their briefs require, while rejecting unsafe writable-root records and git metadata paths.
  • Enforce Cursor’s unattended-launch exemption policy for raw, relaunch, and remote-secondmate routes, including accurate remote grant and trace-context handling.
  • Add regression coverage and operational documentation for sandbox grants, remote transport staging, and dispatch behavior.

Risk Assessment

✅ Low: The change is bounded and the reviewed sandbox-root, Cursor exemption, remote-route, and marker-safety paths contain no newly substantiated defect.

Testing

Focused public-script integration checks exercised the scoped Codex write grant, remote Cursor launch/grant delivery, remote transport staging, relaunch safety, and raw Cursor alias handling; all passed. The saved CLI transcript is the appropriate reviewer-visible evidence because this shell control-plane change has no rendered UI.

Evidence: Focused behavioral CLI transcript

Source: Focused behavioral CLI transcript

FM_TEST_BEGIN 2026-09-04T11:12:57Z tests/fm-codex-sandbox-grant.test.sh family=unclassified expected_gate_skip=none
ok - codex ship: grants only its own status + turn-ended files, its own steering inbox, and the out-of-tree git common dir, never the shared state directory
ok - the no-mistakes pipeline notice fires for no-mistakes alone, and every mode gets the same ship grant
ok - both pre-created state files are marked as already reported, and real later activity on each still reports
ok - precreation refuses unsafe status and turn-ended markers without following either link
ok - precreation refuses unwritable existing record files, inboxes, and handled directories
ok - the grant refuses a symlinked state record or inbox: nothing is created through it and no root outside the task's own paths is ever emitted
ok - the grant refuses a hard-linked state record: the shared inode is not written and no root is emitted
ok - the git-metadata grant is pinned to the recorded project: a redirected .git file refuses the spawn and grants no alien repository
ok - pre-creation refuses loudly: a wrong-typed or uncreatable record fails the spawn instead of stranding the worker
ok - a granted root containing an ampersand is substituted literally, on every bash version
ok - codex scout: the report, status, and completion-gate paths are all granted, and the shared data/ root is not
ok - codex secondmate: only the parent status file and its own steering inbox are granted, not the parent state directory or the crewmate set
ok - claude, opencode, and grok launches are unchanged
ok - ship grant is sufficient (status, turn-ended, commit) and isolates siblings: the shared state directory stays unwritable
ok - ship grant covers the steering-inbox acknowledgement, and that inbox root is load-bearing
ok - granted set is sufficient: status append, report, captain-hold completion gate, and commit all succeed
ok - each granted root is load-bearing: removing it breaks the report, the completion-gate lock, or staging
FM_TEST_END 2026-09-04T11:15:09Z tests/fm-codex-sandbox-grant.test.sh exit=0 duration_ms=132764 gate_skip=false
FM_TEST_BEGIN 2026-09-04T11:15:09Z tests/fm-remote-secondmate-trace-context.test.sh family=secondmate expected_gate_skip=none
ok - disabled: a remote-routed second mate records and receives no carrier and stays enabled-off end to end
ok - enabled: a remote-routed second mate receives one carrier in its pane, identical to the parent's recorded identity, before launch
ok - relaunch: a remote-routed second mate keeps one stable identity across restarts
ok - boundary: each remote-routed second mate roots its own trace and never adopts the spawning environment's carrier
ok - allowlist: the remote receiver accepts exactly the declared inherited-material set, including the enablement flag
ok - delivery: a parent-supplied carrier is accepted only for a secondmate launch and only as a strict W3C value
ok - remote route: an unattended cursor secondmate is refused before the remote host is reached
ok - remote route: a cursor exemption is refused on a non-cursor harness rather than recorded
ok - remote route: an envelope grant and a carrier both cross the wire and reach the remote spawn
ok - recovery: an unflagged respawn inherits the recorded envelope grant and brings the secondmate back
ok - recovery: a recorded attended grant is never inherited, so it cannot resurrect a cursor secondmate
ok - remote route: the parent records the endpoint's actual grant, never an undelivered request
ok - remote route: a reused non-cursor endpoint cannot republish a stale cursor grant
ok - wire: an older parent's bare positional carrier is still accepted as the traceparent
ok - wire: a bare argument that is not a carrier is still refused
ok - wire: the receiver forwards only an envelope grant, refusing attended and malformed grants
ALL TESTS PASSED
FM_TEST_END 2026-09-04T11:18:53Z tests/fm-remote-secondmate-trace-context.test.sh exit=0 duration_ms=223124 gate_skip=false
FM_TEST_BEGIN 2026-09-04T11:18:53Z tests/fm-remote-transport-lanes.test.sh family=secondmate expected_gate_skip=none
ok - atomic sequence claims remain unique and reap only after expiry
ok - lanes run homes concurrently while each home stays FIFO
ok - same-home jobs staged in the same second execute in staging-sequence order
ok - same-home sequence order follows completed staging publication
ok - a caller killed mid-wait cancels its queued job before execution
ok - a caller killed mid-wait stops its running job's process group
ok - a signal-less caller disconnect cancels the abandoned job through the parent probe
ok - bounded reads after a cancellation meet their own budget with no convoy
ok - an open caller stdin no longer wedges a non-payload remote command
ok - a live explicit-stdin stage survives the staging-litter age bound
ok - --stdin still delivers a payload caller's bytes
ok - abandoned stage litter is reaped by age while live staging survives
ALL TESTS PASSED
FM_TEST_END 2026-09-04T11:20:09Z tests/fm-remote-transport-lanes.test.sh exit=0 duration_ms=76614 gate_skip=false
FM_TEST_BEGIN 2026-09-04T11:20:09Z tests/fm-control-relaunch.test.sh family=backend-dispatch expected_gate_skip=none
ok - fm-control relaunch: a same-harness relaunch replaces the agent in the same endpoint and worktree
ok - fm-control relaunch: durable task metadata survives replacement launch publication
ok - fm-control relaunch: delivery and concurrent task metadata publication serialize
ok - fm-control relaunch: disabling tracing clears metadata and pane context
ok - fm-control relaunch: the progress note lands in the instructions the replacement reads
ok - fm-control relaunch: a ship task refuses without the progress note its replacement needs
ok - fm-control relaunch: switching harness is one ordinary relaunch, and the old wiring goes with the old agent
ok - fm-control relaunch: a harness switch resets model and effort unless they are named too
ok - fm-control relaunch: a prefixed recorded harness can switch adapters transactionally
ok - fm-control relaunch: a prefixed command requires an explicit replacement harness
ok - fm-control relaunch: a same-harness relaunch keeps the profile axes it was running with
ok - fm-control relaunch: explicit model and effort win over the recorded ones
ok - fm-control relaunch: refuses to relaunch onto an adapter with no verified mechanics
ok - fm-control relaunch: the retired incarnation's global turn-end token is revoked
ok - fm-control relaunch: wiring cleanup failure refuses replacement arming
ok - fm-control-lib: one owner resolves each harness's turn-end registry entry, and refuses a malformed token
ok - fm-control relaunch: a secondmate relaunch re-resolves its durable configured harness pin
ok - fm-control relaunch: invalid configured effort is ignored before stop
ok - fm-control relaunch: an adapter unverified for this task kind refuses before the agent is stopped
ok - fm-control relaunch: explicit secondmate harness resets unnamed profile axes
ok - fm-control relaunch: a ship task keeps its recorded harness instead of re-reading crew config
ok - fm-spawn --relaunch: with no explicit harness it reuses the task's recorded one, never the crew default
ok - fm-spawn --relaunch: an attended cursor grant is never inherited and the relaunch is refused
ok - fm-control relaunch: an attended cursor grant is refused before the agent is stopped
ok - fm-control relaunch: a cursor grant is dropped when the relaunch resolves to another harness
ok - fm-control relaunch: a refusal never stops the running agent, on either known door
ok - fm-control relaunch: a fresh attended grant passed on the verb permits the relaunch
ok - fm-control relaunch: a malformed grant is refused before the agent is stopped
ok - fm-spawn --relaunch: a named isolation-envelope grant is inherited so automatic recovery still works
ok - fm-control relaunch: a non-cursor stale envelope cannot authorize cursor
ok - fm-spawn --relaunch: wiring armed under a prefixed harness name is still retired
ok - fm-spawn --relaunch: switching away from muse retires its session binding
ok - fm-spawn --relaunch: switching away from cursor retires its session binding
ok - fm-control relaunch: an unaccountable local copy refuses before the agent is touched
ok - fm-control relaunch: a worker with nothing to work from is never launched
ok - fm-control relaunch: a refusal before the agent is stopped leaves the durable record untouched
ok - fm-control relaunch: checkpoint inspection failures refuse before stopping
ok - fm-control relaunch: a launch failure after the stop keeps the prior record and reports the real state
ok - fm-control relaunch: unpublished rollback keeps concurrent durable metadata
ok - fm-control relaunch: post-publication failure keeps the new durable record
ok - fm-control relaunch: partial stop reconciles actual agent state
ok - fm-control relaunch: failed journal replacement preserves durable phase
ok - fm-spawn relaunch: prepublication abort removes replacement state
ok - fm-control relaunch: the checkpoint records the exact unlanded work it preserved
ok - fm-control relaunch: a secondmate's child work is accounted for and its charter is left alone
ok - fm-control relaunch: a secondmate home that is not this secondmate's is refused
ok - fm-control relaunch: unreadable and untraversable child state fails checkpoint
ok - fm-control relaunch: two control actions on one task serialize instead of interleaving
ok - fm-spawn relaunch: direct entry participates in lifecycle serialization
ok - fm-promote: promotion participates in lifecycle serialization
ok - fm-spawn --relaunch: refuses to launch a second agent into a live endpoint
ok - fm-spawn --relaunch: symlinked records refuse before inspection
ok - fm-spawn --relaunch: keeps its early meta lock continuous
ok - fm-spawn --relaunch: pending closes refuse before replacement begins
ok - fm-spawn --relaunch: every identity axis comes from the record, and a contradicting flag refuses
ok - fm-spawn --relaunch: an unrecorded task is refused
ok - fm-spawn --relaunch: refuses to start a replacement outside the copy holding the work
ok - relaunch re-reads the backlog item instead of blindly re-running the transition
ok - relaunch heals an item that drifted out of In flight while the task stayed live
FM_TEST_END 2026-09-04T11:22:52Z tests/fm-control-relaunch.test.sh exit=0 duration_ms=162702 gate_skip=false
FM_TEST_BEGIN 2026-09-04T11:22:52Z tests/fm-spawn-dispatch-profile.test.sh family=backend-dispatch expected_gate_skip=none
ok - no --model/--effort records defaults and types the claude launch instructions
ok - non-cursor launches clear inherited Cursor identity markers
ok - relative home overrides ignore CDPATH and become absolute before spawn launch construction
ok - FM_HOME defaults resolve relative paths and preserve absolute spellings
ok - absolute override spellings are preserved in spawn launch paths
ok - unresolvable relative spawn overrides fail with named diagnostics
ok - active crew-dispatch profile requires an explicit harness for ship spawns
ok - active crew-dispatch profile requires an explicit harness for scout spawns
ok - active crew-dispatch profile allows an explicit resolved harness
ok - active crew-dispatch profile allows the legacy positional harness form
ok - active crew-dispatch profile allows the raw launch-command escape hatch
ok - a raw agent alias is resolved through the verified cursor owner and held to the cursor bar
ok - claude receives --model and --effort profile flags
ok - codex receives --model and model_reasoning_effort profile flags
ok - codex omits unsupported max effort instead of passing a bad config value
ok - grok receives --model and --reasoning-effort profile flags
ok - grok omits unsupported max reasoning effort
ok - grok omits unsupported xhigh reasoning effort
ok - cursor receives its model-qualified reasoning class and exact task workspace
ok - cursor is refused for ship and scout spawns and names codex and claude instead
ok - a cursor exemption is refused on a non-cursor harness rather than recorded as a stale grant
ok - an inherited cursor selection is barred and the refusal names config/crew-harness or a dispatch profile
ok - only the recognized cursor exemption tokens open the bar
ok - a cursor grant that could inject a second record line is refused before any record exists
ok - a recognized cursor exemption permits the spawn, keeps the sandbox posture, and is recorded single-valued
ok - a cursor exemption does not leak from one spawn to the next in the same shell
ok - a fresh spawn never inherits a cursor grant from a stale record of the same id
ok - an ambient environment grant never opens the cursor bar
ok - cursor refuses model ids absent from its resolved binary's live catalog
ok - cursor preserves the requested model when its live catalog is unreachable
ok - opencode receives --model and omits the unsupported effort axis
ok - pi receives --model and --thinking max profile flags
ok - Pi launch probing omits --tui-mode on older Pi and preserves it on supporting Pi
ok - pi-signed shares Pi launch semantics while preserving its configured and recorded identity
ok - pi-signed refuses safely and actionably when the selected executable is unavailable
ok - pi-signed is a distinct persistent secondmate runtime with shared Pi supervision semantics
ok - batch dispatch forwards shared --harness, --model, and --effort to every pair
ok - claude forwards firstmate's CLAUDE_CONFIG_DIR so the crewmate uses the same credential store
ok - claude omits the config-dir prefix when firstmate runs with the single-store default
ok - non-claude harnesses do not receive the claude CLAUDE_CONFIG_DIR prefix
ok - active crew-dispatch profile does not block secondmate launches
# all fm-spawn-dispatch-profile tests passed
FM_TEST_END 2026-09-04T11:26:03Z tests/fm-spawn-dispatch-profile.test.sh exit=0 duration_ms=191067 gate_skip=false
FM_TEST_SUMMARY total=5 failed=0 skipped_gate=0 duration_ms=786515
FM_TEST_SUMMARY_FAMILY family=backend-dispatch count=2 duration_ms=353769 failed=0
FM_TEST_SUMMARY_FAMILY family=secondmate count=2 duration_ms=299738 failed=0
FM_TEST_SUMMARY_FAMILY family=unclassified count=1 duration_ms=132764 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-remote-secondmate-trace-context.test.sh duration_ms=223124
FM_TEST_SLOWEST rank=2 script=tests/fm-spawn-dispatch-profile.test.sh duration_ms=191067
FM_TEST_SLOWEST rank=3 script=tests/fm-control-relaunch.test.sh duration_ms=162702
FM_TEST_SLOWEST rank=4 script=tests/fm-codex-sandbox-grant.test.sh duration_ms=132764
FM_TEST_SLOWEST rank=5 script=tests/fm-remote-transport-lanes.test.sh duration_ms=76614

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed (6) ✅
  • 🚨 bin/fm-wake-lib.sh:1735 - Criterion: “the narrow Codex writable-root grant that lets a worker write only the brief-permitted Firstmate paths while retaining the stronger sandbox.” A prior Codex scout can create state/.seen-<id>_turn-ended as a symlink; this new redirection follows it when a later ship spawn pre-creates that task’s marker, letting unsandboxed Firstmate overwrite the symlink target. Refuse unsafe marker entries and publish markers safely for both status and turn-ended paths.
  • 🚨 bin/fm-spawn.sh:1552 - Criterion: the grant “lets a worker write” its brief-permitted paths. Existing regular status/turn-ended files return success without a writability check, and an existing inbox/handled directory is accepted by mkdir -p without verifying its type or writability. A prior scout can leave either unwritable, causing a successful spawn whose Codex worker cannot report or acknowledge steers. Refuse unusable pre-existing files and inbox directories before launch.

🔧 Fix: Safeguard Codex writable roots
1 error still open:

  • 🚨 bin/fm-spawn.sh:1850 - The required criterion says to “hold[] a raw cursor ‘agent’ alias launch to the cursor unattended bar through verified resolution.” The new check only runs when the first non-assignment word is agent; a supported raw command such as env FOO=bar agent --flag is classified as env at the added hunk, skips Cursor verification and the shared refusal, then is delivered to an unattended pane without --cursor-exemption. Recognize leading env setup before classifying the executable (and cover that public raw-command invocation).

🔧 Fix: Guard env-wrapped Cursor agent aliases
1 error still open:

  • 🚨 bin/fm-spawn.sh:1852 - Captain: required criterion says to “hold[] a raw cursor ‘agent’ alias launch to the cursor unattended bar through verified resolution.” env -S agent (or env -S 'agent --flag') skips agent as the -S argument, leaving HARNESS empty and allowing the raw Cursor alias to launch outside the bar. Decide whether to parse the split string or fail closed on env -S; recommend fail closed until it can be recognized reliably.

🔧 Fix: Reject ambiguous Cursor split-string launches
2 errors still open:

  • 🚨 bin/fm-spawn.sh:1633 - Required criterion: “the narrow Codex writable-root grant that lets a worker write only the brief-permitted Firstmate paths.” The changed scout branch grants the entire shared state/ directory. A running Codex scout can directly overwrite state/<other-task>.status or metadata for another task, despite neither being in its brief. Move the scout completion-lock protocol to a task-scoped precreated root, then grant that root plus the scout’s own required files instead of shared state/.
  • 🚨 bin/fm-spawn.sh:1837 - Required criterion: “holding a raw cursor ‘agent’ alias launch to the cursor unattended bar through verified resolution.” The shell-unsafe for word in $line tokenizer misclassifies FOO='two words' agent --flag as executable words'; /usr/bin/env -S agent --flag also bypasses the exact-env check. Both launch the real Cursor alias as an unverified raw command, outside the unattended bar. Parse only a conservative, shell-aware supported wrapper grammar or fail closed on quoted/absolute-wrapper raw commands before classification.

🔧 Fix: Parse raw Cursor launch wrappers safely
2 errors still open:

  • 🚨 bin/fm-spawn.sh:1843 - Captain: required criterion: “holding a raw cursor ‘agent’ alias launch to the cursor unattended bar through verified resolution.” PATH=/cursor-bin agent --flag or env PATH=/cursor-bin agent --flag is classified as agent, but resolution uses Firstmate’s current PATH, not the command’s assigned PATH. It records unverified agent and bypasses the bar, while the pane launches Cursor unattended. bash -c agent similarly bypasses classification. Fail closed on PATH/CWD-changing and interpreter wrappers unless their effective executable is Cursor-verified.
  • 🚨 bin/fm-spawn.sh:1567 - If safe marker publication fails after creating a status or turn-ended file, the failed spawn leaves that untracked signal behind. With a pre-existing .seen-<id>_turn-ended symlink, the watcher later sees the orphaned turn-ended file and its existing marker write follows the symlink, recreating the out-of-bound write this guard was meant to prevent. Remove or safely reconcile records created by this invocation when marker publication fails.

🔧 Fix: Harden raw launches and marker rollback
2 errors still open:

  • 🚨 bin/fm-control-lib.sh:194 - envelope:* is inherited based only on its shape and the target harness. A legacy/stale cursor_exemption= on a task recorded as harness=codex therefore authorizes fm-control ... relaunch --harness cursor without a new grant, reopening the unattended Cursor bar. Require the recorded source harness to be Cursor before inheriting a grant.
  • 🚨 bin/fm-spawn.sh:791 - The remote route records any shape-valid endpoint exemption without checking that the returned endpoint harness is Cursor. A reused older non-Cursor endpoint with a stale grant can repopulate the parent record, then authorize a later Cursor recovery. Drop remote grants unless remote_harness is Cursor; cover reuse through the public remote route.

🔧 Fix: Bind exemptions to Cursor provenance
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bin/fm-test-run.sh --per-script-timeout-secs 900 tests/fm-codex-sandbox-grant.test.sh tests/fm-remote-secondmate-trace-context.test.sh tests/fm-remote-transport-lanes.test.sh tests/fm-control-relaunch.test.sh tests/fm-spawn-dispatch-profile.test.sh
  • Verified the worktree remained clean after test cleanup.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-04T18:34:15.413280Z 421d744 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

npayette84 and others added 3 commits September 4, 2026 07:34
Launch Claude with --permission-mode auto, Codex with -s workspace-write
-a never, and Cursor with --auto-review --sandbox enabled, instead of the
three full-bypass flags (--dangerously-skip-permissions,
--dangerously-bypass-approvals-and-sandbox, --yolo). A crewmate now runs
under its harness's own approval, review, and sandbox controls rather than
with them switched off.

Codex's workspace-write confines writes to the task worktree plus /tmp and
$TMPDIR. That is the intended blast radius, but it also denies the
supervision paths a crewmate's contract needs outside its worktree.
Granting those back narrowly is a separate, independently reviewable
change and is deliberately not bundled here.

Refreshes the launch expectations in the three suites that assert the
composed command, and the Cursor adapter reference rows. Other tracked
uses of the bypass flags are one-off CLI invocations in guard docs and
live probes, not spawn output, and are left untouched.
@greptile-apps

greptile-apps Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge because the previously reported shared-state exposure is no longer present.

No blocking failure remains; the Codex scout now receives only task-specific state, inbox, lock, and report roots while retaining every path required by its current workflows.

Reviews (4): Last reviewed commit: "no-mistakes(ci): scope scout artifacts t..." | Re-trigger Greptile

Comment thread bin/fm-spawn.sh Resolved
npayette84 and others added 24 commits September 4, 2026 07:37
Supersedes an aborted fix round that would have made an auto-detected
cursor silently fall back to another adapter. Silently substituting a
different tool changes which adapter runs the captain's work without
saying so, which is harder to notice than a refusal.

The bar now holds however cursor was selected, explicit or inherited, and
the refusal names the exact remedy: set config/crew-harness to a verified
adapter, or add an eligible crew-dispatch profile. Firstmate does not pick
one on the captain's behalf.

The two exemption grants are no longer interchangeable across relaunch.
envelope:<name> describes a mechanically proven outer isolation envelope
that still governs the replacement agent, so it is inherited and automatic
recovery keeps working. `attended` asserts a person is in the pane right
now; the captain who attested may have left long before stuck-worker
recovery relaunches, so inheriting it would let one attestation authorize
unlimited unattended launches. It is never inherited.

A cursor exemption is refused outright on a non-cursor harness rather than
recorded, so no stale grant can sit in a task's metadata waiting to
authorize a later relaunch onto cursor. Remote secondmate launches forward
only an envelope grant, through self-describing arguments whose
compatibility degradation is stated in the code: an older host misbinds the
token and fails validation there, and a cursor secondmate reaching fm-spawn
without a grant is refused by the bar. Both paths fail closed. An attended
grant cannot describe a worker on another host and is refused for a remote
launch.

Bootstrap now diagnoses a cursor crew-dispatch rule instead of validating
clean and failing later at spawn, since those rules resolve the harness for
crewmate and scout spawns and both are barred.

Also adds a contains mode to the bootstrap row runner with a guard that
fails on an unknown mode; the previous case statement let an unrecognized
mode pass vacuously.
Codex runs under -s workspace-write, which confines writes to the task
worktree. Every task worktree is a LINKED worktree, so that confinement
denied the three things every brief requires outside it: the scout report
at data/<id>/report.md, the status appends supervision reads, and the
captain-hold completion gate - and denied `git add` too, since a linked
worktree's index lock lives in the primary checkout's git directory.

Observed 2026-08-26: a codex scout produced a full report it could not
deliver, and the completion gate recursed inside its own lock retry until
the filename was too long. Both were the same denial. Codex has been out
of rotation since, for plumbing reasons rather than capability.

The launch now composes repeatable --add-dir roots, scoped per kind:

  ship crewmate  its own state/<id>.status and state/<id>.turn-ended FILES
                 (pre-created so single-file roots resolve), plus the
                 out-of-tree git common dir
  scout          state/ itself, its own data/<id>/, plus the git common dir
  secondmate     only the parent's state/<id>.status file

state/ must be a whole directory for the scout alone because the gate
creates a lock symlink and a mktemp-named owner directory in it, and
neither can be named ahead of time. $FM_HOME, .env, config/, projects/,
and the shared data/ root are never granted. --add-dir is used rather
than -c sandbox_workspace_write.writable_roots, which would REPLACE an
operator's own configured roots instead of adding to these.

Two suites cover it. The portable one pins the composition and proves
each root load-bearing with no codex present. The opt-in live guard
(FM_CODEX_LIVE_E2E=1) proves the vendor still enforces exactly these
roots, including the completion gate, and refuses to pass without the
real binary.

The dispatch notice claims only what is invariant: ~/.no-mistakes stays
denied, so a codex worker cannot run validation itself. Network is the
operator's own sandbox_workspace_write.network_access and varies per
machine, so it is deliberately not asserted.
…rebase

The rebase onto main picked up the brief split (kunchenguid#3597): a spawn now refuses
a brief without nonempty `## Captain's intent` and `## Firstmate spec`
subsections, so both codex sandbox-grant suites failed at the first ship
spawn on their one-line fixture brief.

Both fixtures now carry the two subsections, matching what
tests/fixtures.sh fm_test_spawn_brief writes. Nothing about the grant under
test changes.
…dings

Two hosted behavior failures and one stale attestation were all that stood
between PR 3385 and green; each is fixed at its root, and every automated
review finding still open on the exact head is implemented.

- The remote trace-context suite launched a real cursor second mate through a
  transport that composes the remote child's PATH from the filesystem (env -i
  with the remote root's bin first), so the cursor launch only resolved on
  machines that happen to have the vendor CLI installed. The remote fixture now
  ships its own cursor-agent stub in the remote root's bin, where the worker's
  composed PATH is guaranteed to find it.
- The transport-lanes fixture staged a partial remote root missing the two
  libraries fm-remote-secondmate-control.sh now sources, so every control-state
  call died at the missing source; the fixture's copy list now carries the full
  source closure and states the invariant.
- The git-metadata grant is pinned to the recorded project's own common
  directory: a linked worktree's .git file is writable by exactly the previous
  worker, so a repointed one must refuse the spawn rather than grant another
  repository's refs and hooks.
- A hard-linked state record refuses the spawn: a second name for one inode is
  never a shape firstmate creates, and the granted worker would write through
  the link into whatever shares the inode outside the task's boundary.
- Pre-creation now refuses loudly on a wrong-typed record and on a creation
  failure instead of reporting success for a root the worker cannot write.
- A raw launch through cursor's legacy agent alias resolves through the verified
  cursor owner and is held to the cursor unattended bar; an unrelated executable
  named agent stays on the unverified escape hatch.
- patsub_replacement is pinned off for launch-command assembly: the flagged
  substitution quotes its operand and was already literal on bash 5.2, but the
  adjacent unquoted substitutions carry the real hazard, and stock bash 3.2
  semantics are the only ones this script may rely on.
- A remote spawn records the grant the endpoint reports carrying rather than the
  one the launch request carried, so a reused endpoint never leaves the parent
  claiming cursor authority the live worker does not have; print_route reports
  the endpoint's own grant for that purpose.

Every regression here fails on the defect it pins and passes after the fix,
driven through the public spawn and transport interfaces.
@npayette84
npayette84 force-pushed the fm/fm-codex-sandbox-pr3385-red-ci-repair branch from f466963 to aab9308 Compare September 4, 2026 11:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f466963a99

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/fm-spawn.sh
Comment on lines +1875 to +1876
exit 2 if $words[$index] =~ m{/(?:bash|csh|dash|deno|env|exec|fish|ksh|nice|node|nohup|perl|python(?:\d+(?:\.\d+)?)?|ruby|sh|sudo|tcsh|time|zsh)\z};
exit 2 if $words[$index] =~ /\A(?:bash|command|csh|dash|deno|exec|fish|ksh|nice|node|nohup|perl|python(?:\d+(?:\.\d+)?)?|ruby|sh|sudo|tcsh|time|zsh)\z/;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject wrapper commands that conceal Cursor

Captain, when a raw launch wraps Cursor with an executable not in this blacklist, such as stdbuf -oL cursor-agent ... or setsid cursor-agent ..., the parser identifies the wrapper as the harness; its family is therefore unknown and fm_control_launch_refusal skips the Cursor bar. This launches an unattended Cursor worker that can park invisibly on an approval prompt, so wrappers must either be unwrapped reliably or refused as ambiguous.

AGENTS.md reference: AGENTS.md:L202-L202

Useful? React with 👍 / 👎.

Comment thread bin/fm-spawn.sh
Comment on lines +3680 to +3682
CODEX_ADD_DIRS=$(codex_add_dir_flags "$KIND" "$WT" "$PROJ_ABS" "$ID") || {
echo "error: refusing to launch $ID on codex: its writable-root grant could not be composed safely (see the refusal above); repair the named path, because launching without it would strand the worker outside the paths its brief requires" >&2
exit 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate Codex roots before stopping a relaunch

Captain, when a Codex relaunch encounters an unsafe or unwritable status file, inbox, data directory, or git metadata path, this newly fallible validation runs only after fm-control.sh has stopped the existing agent and fm-spawn.sh has published the replacement metadata. The resulting exit 1 rolls back metadata but cannot restore the stopped agent, leaving the task stranded without a worker; perform the non-mutating root checks before do_exit, or otherwise make this failure recover the previous agent.

Useful? React with 👍 / 👎.

Comment thread bin/fm-spawn.sh
Comment on lines +2506 to +2508
if [ "$HARNESS" = codex ] && [ "$MODE" = no-mistakes ]; then
echo "notice: $ID ships mode=$MODE on codex, whose sandbox denies the no-mistakes data directory - the worker can commit and reach the network but cannot run validation itself; expect to land it another way or choose another harness" >&2
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Refuse Codex for no-mistakes ships

Captain, when a ship selects mode=no-mistakes with the Codex harness, this branch knowingly continues even though the sandbox prevents that worker from invoking the required no-mistakes pipeline. The suggested “land it another way” contradicts the delivery contract: the same task worker must start and drive the pipeline, while Firstmate must not take over its responses. This combination therefore cannot complete its selected delivery path and should be refused before allocating the worker, or the required pipeline state should be granted safely.

AGENTS.md reference: AGENTS.md:L357-L359

Useful? React with 👍 / 👎.

Comment thread bin/fm-spawn.sh
echo "error: $file could not be created; refusing to grant a codex writable root the worker cannot actually write - inspect the state directory's permissions" >&2
return 1
fi
if ! fm_wake_signal_mark_current "$STATE" "$file" 2>/dev/null; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detect same-second turn-end notifications

Captain, when a Codex worker exits or completes its first turn within the same timestamp second in which this pre-created turn-ended file is marked current, the real notify-hook touch leaves the recorded size:mtime signature unchanged (0:<same second> on Linux). The watcher consequently treats the notification as already reported and never queues that turn end; the regression test misses this because it appends a byte instead of exercising the actual touch behavior. Use a signature with sufficient timestamp precision or otherwise ensure the first touch differs from the seeded marker.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6041119695

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

| Autonomy | `--permission-mode auto`, so the worker runs under Claude's own classifier rather than `--dangerously-skip-permissions`, which bypassed every check. The spawn also sets `CLAUDE_CODE_DISABLE_FAST_MODE=1`; see "Auto mode" below. |

Fresh-worktree or first-machine launch may show the workspace-trust confirmation.
That is the only launch surface that still requires a keypress: inspect within about 20 seconds, accept the required choice with `FM_HOME=<active-home> ../../../bin/fm-send.sh <window> --key Enter` unless already bound, and verify instructions started.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not submit Claude's default trust choice

Captain, when a Claude secondmate starts in a home that has not been trusted yet, this command presses Enter while the workspace-trust dialog defaults to No, exit; the verified capture in docs/verification/runtime-backends.md:239-247 and the shared guidance in references/common/control-and-recovery.md:20-27 both confirm that this terminates the worker rather than accepting trust. Since the harness adapter is the required trust-handling guide, retain operator-driven selection or document a sequence that actually selects Yes.

AGENTS.md reference: AGENTS.md:L200-L200

Useful? React with 👍 / 👎.

Comment thread bin/fm-spawn.sh Outdated
# cannot silently drop a crewmate back to interactive prompting. The
# remaining triggers are plan/model/server-side; the harness-adapters skill
# documents the resulting dialog so a degraded worker is recognizable.
claude) printf '%s' 'CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false CLAUDE_CODE_DISABLE_FAST_MODE=1 claude --permission-mode auto __MODELFLAG____EFFORTFLAG__"$(__OPINPUT__ encode launch-brief < __BRIEF__)"' ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve Claude feedback suppression

When a Claude worker encounters content that triggers the /bug or /feedback flow, this replacement launch no longer sets either CLAUDE_CODE_SEND_FEEDBACK=0 or feedbackDrafts=off. The parent version explicitly layered those controls so a fleet worker could not queue or submit a report on the captain's behalf even under managed settings; changing the permission mode does not replace that independent safeguard, so retain the feedback controls alongside --permission-mode auto.

Useful? React with 👍 / 👎.

Comment thread bin/fm-spawn.sh
Comment on lines +2038 to 2040
if ! SPAWN_LAUNCH_REFUSAL=$(fm_control_launch_refusal "$HARNESS" "$KIND" "$CURSOR_EXEMPTION"); then
echo "error: $SPAWN_LAUNCH_REFUSAL" >&2
exit 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject sandbox-disabling flags in raw Cursor launches

When a caller supplies a raw command such as cursor-agent --force ... together with --cursor-exemption attended, this check recognizes the command as Cursor and accepts the exemption, but the unchanged raw command is then launched with --force (or --yolo). The repository's own verification establishes that either flag overrides --sandbox enabled regardless of flag order, so a grant intended to attest attendance also silently removes filesystem confinement; reject those flags for recognized raw Cursor commands or route exempted Cursor launches through the hardened template.

Useful? React with 👍 / 👎.

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.

1 participant