Skip to content

fix(bin): deliver seated Codex credential home to the agent, not the hooks export - #50

Merged
jazz127 merged 1 commit into
housefrom
fm/firstmate-codex-seat-home-order-r1
Sep 26, 2026
Merged

jazz127 merged 1 commit into
housefrom
fm/firstmate-codex-seat-home-order-r1

Conversation

@jazz127

@jazz127 jazz127 commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Intent

do both #42 followup and codex account seat bug items

Context for reading that ask. The Codex account-seat bug on the fork's house branch: fork PR 43 bound Codex dispatch seats to dock-local credential homes, so a worker launched on a seat runs with CODEX_HOME pointing at that seat's credential home and never spends the default account. In bin/fm-spawn.sh on current house, the seat step prefixes $(fm_worker_account_codex_shed) CODEX_HOME=<seat home> onto LAUNCH after an earlier step has already turned LAUNCH into export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.hooksPath GIT_CONFIG_VALUE_0=...; <rest> (the AI-trailer commit-msg strip). A shell command-prefix assignment applies only to the first simple command, so CODEX_HOME and the shed attach to that export statement instead of the agent, and a seat worker silently runs on the default Codex account. tests/fm-spawn-dispatch-profile.test.sh fails on it, but ci-house.yml does not run that test, so house CI stayed green. No Codex work is being launched right now because both Codex accounts are out of quota; the fix must land before they reset.

What Changed

  • In bin/fm-spawn.sh, a seated Codex launch now sets its credential home as a statement (export CODEX_HOME=<seat home>) instead of a command-prefix assignment. Before, the prefix attached only to the earlier GIT_CONFIG_* hooks export, so the agent ran on the default Codex account. fm_worker_account_codex_shed in bin/fm-worker-account-lib.sh now prints unset <ambient vars> instead of an env -u … prefix, so the ambient OpenAI/Codex credential overrides are removed for every later step of the compound launch.
  • Added tests/fm-spawn-codex-seat-launch.test.sh. It runs a real seated spawn and executes the launch command the pane receives, in a pane environment that contains ambient credentials. It checks that the probe codex binary sees the seat's CODEX_HOME and none of the ambient credentials. It covers both the absent and the enabled launch-env allowlist. tests/fm-spawn-dispatch-profile.test.sh now expects the unset form.
  • House CI (.github/workflows/ci-house.yml) now lints bin/fm-spawn.sh, bin/fm-worker-account-lib.sh and the new test, and runs the new test. tests/fm-ci-workflow.test.sh requires that the new test is included, and bin/fm-test-run.sh places it in the backend-dispatch family.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: This is a small, focused fix. The shed and CODEX_HOME are now shell statements, so they reach the agent after the hooks export, and they work both under the env -i allowlist wrapper and without it. Only one caller uses the changed helper. The new test runs the real generated launch, and it would fail at base because env -u … export fails and the agent keeps the ambient account.

Testing

All validation here is synthetic/offline built-CLI validation; 0 of 4 scenarios were driven live against a real Codex account, because both Codex accounts are out of quota.

  • tests/fm-spawn-codex-seat-launch.test.sh passes on this PR head (55fb1e2) and fails at base 61fb548 (and at the original base 854257f) with "the seated agent did not start on its seat's credential home". It runs the real bin/fm-spawn.sh through a dock seat, then executes the emitted launch with a probe codex binary under fake ambient CODEX_HOME and OpenAI/Codex credential variables, for both the absent and the enabled launch-env allowlist.
  • The pipeline's test step also ran the real codex-cli 0.156.1 binary through seated spawns in a throwaway lab home with a fake seat credential and fake ambient credentials (no real account signed in; the worker stopped at Codex's folder-trust prompt). With the fix the codex process had the seat CODEX_HOME and none of the fake credentials, including when the allowlist forwarded them; with the base-commit scripts the pane showed env: export: No such file or directory and Codex started on the ambient CODEX_HOME. Transcripts are below.
  • tests/fm-ci-workflow.test.sh (house CI must run the new test) and bin/fm-test-run.sh --check-coverage pass; house CI on this PR is green and runs the new test.
  • tests/fm-spawn-dispatch-profile.test.sh: on the original base 854257f the full file stopped early at the chore: update pull request #42 scratch-hook GIT_CONFIG_* launch prefix (unrelated to the seat fix; its seat cases passed when run in isolation). The separate chore: update pull request #42 follow-up (fix(bin): simplify scratch guards and keep scratch out of published changes #48) has since removed that prefix, and on this rebased head the full file passes.

evidence-artifact: /tmp/fm-firstmate-codex-seat-home-order-r1/seat-evidence.txt
evidence-command: bash tests/fm-spawn-codex-seat-launch.test.sh (PR head and a git-archive copy of base 61fb548) and bash tests/fm-spawn-dispatch-profile.test.sh
evidence-captured: 2026-09-26T02:12:19Z

Evidence: Fixed: live seated codex worker env (default launch environment)

Source: Fixed: live seated codex worker env (default launch environment)

== pid 37731: bash
== pid 42462: -zsh
== pid 42995: /bin/zsh
== pid 53134: ~/.local/bin/codex -c cli_auth_credentials_store=
CODEX_HOME=/private/var/folders/9h/6hvtvt257md69k7nq7ycyq5h0000gn/T/fm-lab.OYNtxb/seat home
GIT_CONFIG_VALUE_0=/private/var/folders/9h/6hvtvt257md69k7nq7ycyq5h0000gn/T/fm-lab.OYNtxb/state/seatprobe.git-hooks
Evidence: Fixed: pane has ambient creds, codex process has seat CODEX_HOME and none of them (allowlist grants them)

Source: Fixed: pane has ambient creds, codex process has seat CODEX_HOME and none of them (allowlist grants them)

# seated codex worker (launch-env-allowlist grants CODEX_HOME and every OPENAI/CODEX credential; tmux session ambient: CODEX_HOME=/ambient/default-account OPENAI_API_KEY=ambient-... CODEX_API_KEY=ambient-... OPENAI_BASE_URL=https://ambient.invalid)
== pid 58677: 58646 treehouse get
CODEX_API_KEY=ambient-CODEX_API_KEY
CODEX_HOME=/ambient/default-account
OPENAI_API_KEY=ambient-OPENAI_API_KEY
OPENAI_BASE_URL=https://ambient.invalid
== pid 58907: 58677 /bin/zsh
== pid 64066: 58907 /bin/sh -c export COMPACT_ADVISER_DISABLE=1; unset OPENAI_API_KEY CODEX_AP
CODEX_HOME='/private/var/folders/9h/6hvtvt257md69k7nq7ycyq5h0000gn/T/fm-lab.OYNtxb/seat home
GIT_CONFIG_VALUE_0='/private/var/folders/9h/6hvtvt257md69k7nq7ycyq5h0000gn/T/fm-lab.OYNtxb/state/seatprobe2.git-hooks';
== pid 64097: 64066 ~/.local/bin/codex -c cli_auth_credentials_store="file" -c mode
CODEX_HOME=/private/var/folders/9h/6hvtvt257md69k7nq7ycyq5h0000gn/T/fm-lab.OYNtxb/seat home
GIT_CONFIG_VALUE_0=/private/var/folders/9h/6hvtvt257md69k7nq7ycyq5h0000gn/T/fm-lab.OYNtxb/state/seatprobe2.git-hooks
Evidence: Fixed: worker pane transcript reaching Codex trust prompt

Source: Fixed: worker pane transcript reaching Codex trust prompt

treehouse get
~/.zshrc:source:1: no such file or directory: ~/.bashprofile
jarad@Mac demo % treehouse get
A new version of treehouse is available: v2.0.0 → v2.3.0
Run "treehouse update" to update
🌳 Setting up worktree...
🌳 Entered worktree at ~/.treehouse/demo-2b9de8/2/demo. Type 'exit' to return.
~/.zshrc:source:1: no such file or directory: ~/.bashprofile
jarad@Mac demo % export GOTMPDIR=/tmp/fm-seatprobe2/gotmp
jarad@Mac demo % export COREPACK_HOME="${COREPACK_HOME:-/tmp/fm-seatprobe2/cache/corepack}"
jarad@Mac demo % export npm_config_cache="${npm_config_cache:-${NPM_CONFIG_CACHE:-/tmp/fm-seatprobe2/cache/npm}}"
jarad@Mac demo % export COMPACT_ADVISER_DISABLE=1
jarad@Mac demo % export FM_TASK_ID=seatprobe2
jarad@Mac demo % . '/tmp/fm-seatprobe2+9675ad7fa94649a7401b6287daa65a13a845ffee074599362e42367aa9f39dbe/launch.s1790387958.56842.11888.sh'
  Folder access
  ~/.treehouse/demo-2b9de8/2/demo
  Note: You’re in a subdirectory of a Git project. Trusting will apply to the repository root:
  /private/var/folders/9h/6hvtvt257md69k7nq7ycyq5h0000gn/T/fm-lab.OYNtxb/projects/demo
  Trust this folder? Codex can read, edit, and run files here, subject to your permission settings. Folder settings can run code automatically, even without a model request. Continue only if you
  trust these files. Your trust decision will be saved.
› 1. Trust and continue
  2. Quit
  enter continue · esc quit
Evidence: Base 61fb548: pane shows 'env: export: No such file' and Codex using /ambient/default-account

Source: Base 61fb548c: pane shows 'env: export: No such file' and Codex using /ambient/default-account

treehouse get
~/.zshrc:source:1: no such file or directory: ~/.bashprofile
jarad@Mac demo % treehouse get
A new version of treehouse is available: v2.0.0 → v2.3.0
Run "treehouse update" to update
🌳 Setting up worktree...
🌳 Entered worktree at ~/.treehouse/demo-2b9de8/3/demo. Type 'exit' to return.
~/.zshrc:source:1: no such file or directory: ~/.bashprofile
jarad@Mac demo % export GOTMPDIR=/tmp/fm-seatprobe3/gotmp
jarad@Mac demo % export COREPACK_HOME="${COREPACK_HOME:-/tmp/fm-seatprobe3/cache/corepack}"
jarad@Mac demo % export npm_config_cache="${npm_config_cache:-${NPM_CONFIG_CACHE:-/tmp/fm-seatprobe3/cache/npm}}"
jarad@Mac demo % export COMPACT_ADVISER_DISABLE=1
jarad@Mac demo % export FM_TASK_ID=seatprobe3
jarad@Mac demo % . '/tmp/fm-seatprobe3+9675ad7fa94649a7401b6287daa65a13a845ffee074599362e42367aa9f39dbe/launch.s1790387989.3726.15328.sh'
env: export: No such file or directory
WARNING: proceeding, even though we could not create PATH aliases: CODEX_HOME points to "/ambient/default-account", but that path does not exist
Error finding codex home: CODEX_HOME points to "/ambient/default-account", but that path does not exist
jarad@Mac demo %
Evidence: Base 61fb548: worker process env (no codex process on seat home)

Source: Base 61fb548c: worker process env (no codex process on seat home)

# BASE commit 61fb548c scripts, same seated launch + same allowlist + same ambient
== pid 6778: 6720 treehouse get
CODEX_API_KEY=ambient-CODEX_API_KEY
CODEX_HOME=/ambient/default-account
OPENAI_API_KEY=ambient-OPENAI_API_KEY
OPENAI_BASE_URL=https://ambient.invalid
== pid 7037: 6778 /bin/zsh
Evidence: Base-commit pane excerpt
env: export: No such file or directory
WARNING: proceeding, even though we could not create PATH aliases: CODEX_HOME points to "/ambient/default-account", but that path does not exist
Error finding codex home: CODEX_HOME points to "/ambient/default-account", but that path does not exist
- Outcome: 🔧 2 issues found ✅ across 2 runs (16m20s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
🔧 **Test** - 2 issues found ✅
  • ℹ️ tests/fm-spawn-dispatch-profile.test.sh:187 - The full fm-spawn-dispatch-profile.test.sh file still fails early on 'no-profile claude launch did not use the canonical launch kind': the launch gains a leading scratch-hooks GIT_CONFIG prefix. This also happens at base 854257f and is unrelated to this change. The file is not in house CI. Because the file-level run aborts, its seat cases only run when invoked in isolation; all six pass that way after the fix. (Superseded after the rebase onto 61fb548: fix(bin): simplify scratch guards and keep scratch out of published changes #48 removed that prefix and the full file now passes.)
  • ⚠️ live validation verdict: inconclusive (0 of 4 scenarios were driven live against the product); untested: A Codex worker spawned on a dock seat runs with CODEX_HOME set to the seat's credential home, even though the launch starts with the AI-trailer hooks export, Regression reproduction: the same seated launch at the base commit delivers the ambient default account, Adversarial: ambient credentials explicitly passed through the launch-env allowlist are still shed for a seated agent, House CI runs the seat-launch regression, so this bug can no longer merge with green CI (chore: update pull request #42 follow-up)
  • Live validation: ⚠️ inconclusive - 0 of 4 scenarios driven live against the product
Scenario Result Live Evidence
A Codex worker spawned on a dock seat runs with CODEX_HOME set to the seat's credential home, even though the launch starts with the AI-trailer hooks export ⏸️ untested no The earlier payload checked this only with a probe codex binary in tests/fm-spawn-codex-seat-launch.test.sh, not a live seated spawn. A live run needs a signed-in Codex seat credential home. Using the…
Regression reproduction: the same seated launch at the base commit delivers the ambient default account ⏸️ untested no The earlier payload reproduced this only with the real spawn script and a probe binary against a base-commit tree, not in a live Codex session. A live reproduction needs a disposable signed-in seat cr…
Adversarial: ambient credentials explicitly passed through the launch-env allowlist are still shed for a seated agent ⏸️ untested no The earlier payload checked this only through the test-suite probe (the 'enabled' allowlist posture and test_codex_seat_overrides_allowlisted_ambient_credentials), not live. A live run is blocked the…
House CI runs the seat-launch regression, so this bug can no longer merge with green CI (#42 follow-up) ⏸️ untested no The earlier payload checked this only by parsing the workflow with tests/fm-ci-workflow.test.sh and running the coverage check, not with a live GitHub Actions run. The actual CI run belongs to the out…
  • bash tests/fm-spawn-codex-seat-launch.test.sh at da7ba639 (pass)
  • bash tests/fm-spawn-codex-seat-launch.test.sh against a base 854257f0 tree to reproduce the bug (fails: agent sees CODEX_HOME=/ambient/default-account and all ambient OPENAI_/CODEX_ values)
  • Seat-related functions of tests/fm-spawn-dispatch-profile.test.sh (luna seat, Herdr backend, refusal, allowlisted-ambient override, secondmate recovery, scout/batch), run in isolation at base and at the fix
  • bash tests/fm-spawn-dispatch-profile.test.sh full file at base and at the fix (fails early at both on an unrelated claude no-profile case)
  • bash tests/fm-ci-workflow.test.sh (house workflow must include the new test)
  • bin/fm-test-run.sh --check-coverage

✅ No issues found.

  • Round 2 (after rebase): synthetic lab runs with the real codex-cli binary and fake credentials; not driven against a real account.

  • Lab setup: bin/fm-lab-home.sh create $LAB, a private tmux socket tmux -L fm-lab, a disposable git project, config/dock.json with seat luna pointing at a lab seat home holding a fake API-key auth.json, and scout briefs from bin/fm-brief.sh

  • The lab tmux session was seeded with fake default-account credentials: CODEX_HOME=/ambient/default-account, OPENAI_API_KEY, CODEX_API_KEY and OPENAI_BASE_URL

  • bin/fm-spawn.sh seatprobe $LAB/projects/demo --scout --harness codex --seat luna (fixed code, default launch environment), then read the live codex process environment with ps -E

  • bin/fm-spawn.sh seatprobe2 ... --seat luna with config/launch-env-allowlist explicitly allowing CODEX_HOME and every OpenAI/Codex credential (adversarial), then read the environment of the pane, the wrapper, and the codex process

  • Base-commit spawn: git archive 61fb548c extracted into the lab, then bin/fm-spawn.sh seatprobe3 ... --seat luna with the same allowlist and ambient credentials, then read the codex environment and captured the pane

  • bash tests/fm-spawn-codex-seat-launch.test.sh

  • bash tests/fm-ci-workflow.test.sh

  • Teardown: tmux -L fm-lab kill-server, treehouse destroy &lt;lab pool&gt; --all --yes, then deleted the lab home and the /tmp/fm-seatprobe* task temp dirs

✅ **Document** - passed

✅ No issues found.

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

The seat step prefixed the credential shed and CODEX_HOME onto a launch
that already began with the AI-trailer hooks export statement, so the
assignment bound that export and a seated worker ran on the default Codex
account. Express the shed and home as their own statements, add a
behavioural regression that executes the seated launch, and run it in
house CI.
@jazz127
jazz127 force-pushed the fm/firstmate-codex-seat-home-order-r1 branch from da7ba63 to 55fb1e2 Compare September 26, 2026 02:03
@jazz127
jazz127 merged commit a33076a into house Sep 26, 2026
1 check passed
@jazz127 jazz127 added the house-only Part of our own line by design - not intended for upstream label Sep 26, 2026
@jazz127
jazz127 deleted the fm/firstmate-codex-seat-home-order-r1 branch September 28, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

house-only Part of our own line by design - not intended for upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant