Skip to content

feat(bin): switch Claude seats for new workers without moving running ones - #4

Merged
max-metaplanet merged 13 commits into
mainfrom
fm/seat-switch
Sep 23, 2026
Merged

max-metaplanet merged 13 commits into
mainfrom
fm/seat-switch

Conversation

@max-metaplanet

@max-metaplanet max-metaplanet commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Why this was built now

The captain stopped the whole fleet to change Claude seats: four homes interrupted, one worker needing two interrupts. Switching accounts should not cost a fleet-wide interruption, which is what this change removes.

Which probe states can be told apart, and which cannot

Measured read-only against the installed quota-axi on macOS, with no sign-in performed:

  • Signed in and Keychain-approved is distinguishable: the keychain attempt reports status: success and the provider source is oauth.
  • Never logged in and signed in but not yet Keychain-approved are not distinguishable from each other: both report every credential source skipped, with the keychain keychain_unreachable.

Because those two collapse into one observable state, the probe reports them as undecided rather than as "not logged in". A plain switch refuses both; switch --force is the owner accepting that uncertainty, which is safe because a forced switch to a genuinely empty seat stops the next worker on its first message with Not logged in rather than spending another account. A not-logged-in verdict, which --force never crosses, requires that every credential source was actually consulted and came back empty - rarely reachable on macOS, reported normally on a file-backed store.

Follow-up worth considering

This change and the usage-warner feature being built in parallel now make the same quota-axi --json --full --no-credential-refresh call. They may want to become one shared read rather than two independent pollers.

Intent

i want to see if it unblocks a way for easy switching of seats when threshold is approached

no lets not wait for 5pm -- build the thing now we can test by building and testing switching not waiting. the threshold should be configurable and also manually triggered e.g. if i want to switch 'now' then mechanism should allow for it easy

Build a way to switch which Claude account (seat) firstmate's workers run on. Three parts were asked for explicitly: the switching mechanism itself; a configurable threshold, not a hardcoded one; and a manual trigger - "switch now" must be one easy command, independent of any threshold. The manual trigger is the primitive the automatic path sits on and the half that can be tested immediately.

The safety property that stands: switching must never disturb a worker already running. New workers go to the new seat; existing ones finish where they started. A mechanism that moves live work is an outage, not a switch. A worker's seat must survive relaunch and resume, because a silent fallback to the default profile is that same failure in disguise.

Credentials: the account owner logs into the second seat personally. Nothing here logs in, copies a credential between profiles, or writes to a credential store. Exactly what the owner must do to set up a second seat is part of the deliverable.

Context: an earlier review of the third-party tool claude-swap argued against automatic switching because it fires exactly at the limit, when every worker is mid-task, so all of them move accounts at once. That decision is held with two blockers - upstream token-destroying bugs, and an unanswered terms-of-service question about the tool presenting itself as Claude Code - and stays untouched: this is firstmate's own mechanism on a Claude Code primitive, CLAUDE_CONFIG_DIR, that the review found underneath that tool's safe isolation. Do not install claude-swap or borrow its code.

What Changed

  • Added bin/fm-seat.sh and bin/fm-seat-lib.sh, which choose the Claude account ("seat") that new claude workers launch on. A seat is a separate CLAUDE_CONFIG_DIR profile. The command has these subcommands: status, list, switch <name|default> / switch --next (manual switch, refused for a seat that isn't logged in unless --force is given), probe, add (creates an empty profile directory and prints the login command for the account owner, but never logs in or touches a credential), threshold [<percent>|off], threshold-reached, and arm/retire. arm sets up a one-shot fm-procevent-when.sh watch that runs switch --next when the active seat's remaining quota falls to the configured threshold. There is no default threshold. Automatic rotation only uses named, logged-in seats and never picks the default profile. After a switch, fm-config-push.sh --local-only (new flag, which skips remote routes) sends the setting to local secondmate homes.
  • bin/fm-spawn.sh works out the seat once for each fresh Claude spawn. It pre-registers workspace trust in that profile, launches with CLAUDE_CONFIG_DIR set to it, and writes claude_seat= to the task record. A Claude-to-Claude relaunch reuses the recorded seat, so a switch never moves a live, relaunched or resumed worker. Records from before seats existed keep the ambient default. Non-claude harnesses record no seat.
  • The new config/claude-seat, config/claude-seats-root and config/claude-seat-threshold files are inherited by local secondmates but marked machine-local, so they are never sent to remote routes. The quota "most constraining availability" jq logic moved into a shared quota_effective helper in fm-quota-axi-lib.sh, and fm-quota-choose.sh now uses it. Added docs/claude-seats.md (operator and owner login procedure) plus updates to the configuration and scripts docs. Added tests/fm-seat.test.sh, and extended tests/fm-control-relaunch.test.sh to cover relaunches keeping their seat.

Risk Assessment

⚠️ Medium: The latest fix round is small and correct: --local-only skips only remote records, and with no flag behaviour is unchanged. But the branch as a whole changes the claude launch path and the relaunch metadata in fm-spawn.sh, which every claude worker goes through, so it should get a careful merge even though no blocking defect remains.

Testing

I ran the two targeted suites (fm-seat and fm-control-relaunch) and both passed. I drove the real fm-seat.sh CLI in a throwaway home, first with the installed quota-axi on freshly created empty seat profiles, then with a stubbed quota report covering signed-in seats, threshold crossings and rotation. I fired the armed threshold watch through its real watcher child. In a guarded Herdr lab I spawned two real Claude workers either side of a seat switch. Every live scenario passed: the running worker's record and live process kept seats/work after the switch to spare, and the new worker launched on spare. The lab was torn down with its tripwire intact, and I removed the scratch treehouse pool. Relaunch/resume seat preservation, secondmate propagation and remote exclusion were proven only by the automated tests with fake backends, not live. No UI surface is involved; the evidence is CLI transcripts.

  • Live validation: ✅ go - 8 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Owner adds a second seat: fm-seat.sh add work creates an empty profile dir, prints the exact login command, and touches no credential ✅ pass live seat-cli-live.txt Part A: add work/spare created the directories, wrote 0 files in them, and printed the CLAUDE_CONFIG_DIR=... claude + /login instructions
Manual 'switch now' is one command, and new workers launch on the new seat ✅ pass live seat-herdr-lab-live.txt: fm-seat.sh switch work --force, then the real fm-spawn claude worker ran with CLAUDE_CONFIG_DIR=seats/work and its record carried claude_seat=seats/work; after `switch spare…
A switch never disturbs a running worker: its record and live process keep the original seat ✅ pass live seat-herdr-lab-live.txt: after the switch to spare, task A's meta still read seats/work, pid 84731's environment still held seats/work, and fm-seat.sh status listed A on work and B on spare
Switch to a seat whose login cannot be confirmed is refused by default; --force crosses an undecided probe ✅ pass live seat-cli-live.txt Part A: with the real quota-axi, the empty profile probed unknown (exit 2), switch work was refused with config unchanged, and switch work --force succeeded
Adversarial: a forced switch to a typo'd or path-escaping seat name is refused ✅ pass live seat-cli-live.txt: switch nosuch --force gave error 'has no profile directory' (exit 1), switch ../escape --force gave 'invalid seat name' (exit 1), and the active seat stayed work
Threshold is configurable, absent by default, and an unset or unreadable threshold never reports reached ✅ pass live seat-cli-live.txt: threshold unset, then threshold-reached exit 2; threshold 15 set it; threshold-reached on an unreadable real quota still exited 2
Adversarial: a model-scoped window below the threshold does not trip it; only account-level all_models counts ✅ pass live seat-cli-live.txt Part B (stubbed quota report): all_models 50% with model:opus 1% gave exit 1; all_models 12% gave exit 0
Armed automatic switch fires switch --next once when the threshold is crossed, rotating only among named seats ✅ pass live seat-cli-live.txt Part C: arm, then the real fm-procevent-when.sh run when-claude-seat child moved the active seat work -> spare; retire stopped the watch. Part B also showed that --next rotates…
Relaunch/resume keeps the task's recorded seat; harness-changing relaunches resolve or drop the seat ⏸️ untested no The earlier payload did not show a live result for this. It was covered only by tests/fm-control-relaunch.test.sh, which uses a fake backend. A live check needs a lab session where the earlier real…
A switch propagates to local secondmate homes via fm-config-push --local-only and never contacts remote routes; remote homes never receive seat settings ⏸️ untested no The earlier payload did not show a live result for this. It was covered only by automated tests in tests/fm-seat.test.sh; the live CLI switches found no live secondmate homes. A live check needs a r…
A seat the owner actually signed into probes logged-in and can be switched to without --force ⏸️ untested no Needs a named seat the account owner has signed into personally. I did not point the tool at the owner's real ~/.claude-seats profiles, to avoid reading or refreshing production credentials. To cover…
Evidence: Live CLI transcript: manual switch, guards, threshold, rotation, armed watch firing

Source: Live CLI transcript: manual switch, guards, threshold, rotation, armed watch firing

\### Part A: REAL installed quota-axi (~/.local/state/fnm_multishells/15215_1789844557659/bin/quota-axi), empty profiles, no sign-in

$ fm-seat.sh status
active seat for NEW workers: default
active profile: (ambient default login)
login state: logged-in
auto-switch threshold: (unset - no automatic switching)
auto-switch watch: not armed

live workers keep the seat they launched with:
  (no task records)
[exit 0]

$ fm-seat.sh add work
seat profile directory: /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/work

This created an empty profile directory and nothing else. No credential
was read, copied, or written, and the Keychain was not touched.

The account owner now logs this seat in, personally, in a terminal:

  CLAUDE_CONFIG_DIR=/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/work claude

then runs /login inside that session and signs in as the account this
seat should bill to. Claude Code stores those credentials under a
Keychain entry derived from this directory path, so they never mix with
the default login. Confirm with:

  bin/fm-seat.sh probe work

and then make it the active seat with:

  bin/fm-seat.sh switch work
[exit 0]

$ fm-seat.sh add spare
seat profile directory: /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/spare

This created an empty profile directory and nothing else. No credential
was read, copied, or written, and the Keychain was not touched.

The account owner now logs this seat in, personally, in a terminal:

  CLAUDE_CONFIG_DIR=/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/spare claude

then runs /login inside that session and signs in as the account this
seat should bill to. Claude Code stores those credentials under a
Keychain entry derived from this directory path, so they never mix with
the default login. Confirm with:

  bin/fm-seat.sh probe spare

and then make it the active seat with:

  bin/fm-seat.sh switch spare
[exit 0]
(profile dirs now: spare work  ; files inside work: 0)

$ fm-seat.sh list
seats root: /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats
* default	logged-in	-	(ambient default login)
  spare	unknown	-	/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/spare
  work	unknown	-	/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/work
[exit 0]

$ fm-seat.sh probe work
work	unknown
[exit 2]

$ fm-seat.sh switch work
error: could not confirm seat 'work' is logged in (quota read gave no verdict); re-run with --force to switch anyway
[exit 1]
(config/claude-seat after refused switch: <absent>)

$ fm-seat.sh switch work --force
switched: default -> work
applies to NEW claude workers only; running workers keep their own seat
config-push: no live secondmate homes found
[exit 0]
(config/claude-seat: work)

$ fm-seat.sh switch nosuch --force
error: seat 'nosuch' has no profile directory at /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/nosuch; run 'fm-seat.sh add nosuch' first
[exit 1]

$ fm-seat.sh switch ../escape --force
error: invalid seat name: ../escape
[exit 1]
(config/claude-seat still: work)

$ fm-seat.sh threshold
(unset - no automatic switching)
[exit 0]

$ fm-seat.sh threshold-reached
[exit 2]

$ fm-seat.sh threshold 15
auto-switch threshold: 15% remaining
[exit 0]

$ fm-seat.sh threshold
15
[exit 0]

$ fm-seat.sh threshold-reached
[exit 2]

$ fm-seat.sh switch default
error: could not confirm seat 'default' is logged in (quota read gave no verdict); re-run with --force to switch anyway
[exit 1]
(config/claude-seat: work)

\### Part B: stub quota-axi reporting work+spare signed in; remaining quota driven by a file

$ fm-seat.sh list
seats root: /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats
  default	unknown	-	(ambient default login)
  spare	logged-in	[email protected]	/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/spare
* work	logged-in	[email protected]	/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/work
[exit 0]

$ fm-seat.sh switch work
seat unchanged: work
[exit 0]

$ fm-seat.sh status
active seat for NEW workers: work
active profile: /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/work
login state: logged-in
auto-switch threshold: 15% remaining
auto-switch watch: not armed

live workers keep the seat they launched with:
  (no task records)
[exit 0]
(work all_models=50%, model:opus=1%, threshold 15)

$ fm-seat.sh threshold-reached
[exit 1]
(work all_models=12%, threshold 15)

$ fm-seat.sh threshold-reached
[exit 0]

$ fm-seat.sh switch --next
switched: work -> spare
applies to NEW claude workers only; running workers keep their own seat
config-push: no live secondmate homes found
[exit 0]

$ fm-seat.sh switch --next
switched: spare -> work
applies to NEW claude workers only; running workers keep their own seat
config-push: no live secondmate homes found
[exit 0]

\### Part C: automatic path - arm the watch and run its real blocking child once

$ fm-seat.sh switch work
seat unchanged: work
[exit 0]

$ fm-seat.sh arm --interval 1 --stable 1
armed: when-claude-seat
starts on the watcher's next cycle; or run: bin/fm-procevent.sh reconcile
reminder: deterministic, safe, reversible actions only; judgment and destructive actions stay on the wake-and-decide path
armed: automatic switch at 15% remaining
fires once; re-arm after it fires to watch the next crossing
[exit 0]

$ fm-seat.sh status
active seat for NEW workers: work
active profile: /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-live.d3DzlG/seats/work
login state: logged-in
auto-switch threshold: 15% remaining
auto-switch watch: armed

live workers keep the seat they launched with:
  (no task records)
[exit 0]
$ fm-procevent-when.sh run when-claude-seat   (the watcher's child, bounded to 30s)
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
config-push: no live secondmate homes found
[exit 0]
(config/claude-seat after the watch fired: spare)

$ fm-seat.sh retire
warning: the action had fired but no outcome was captured; verify its effect manually
retired: when-claude-seat
retired: when-claude-seat
[exit 0]
Evidence: CLI transcript driver script

Source: CLI transcript driver script

#!/usr/bin/env bash
# Live CLI transcript of bin/fm-seat.sh in a throwaway FM_HOME.
set -u
ROOT=~/.no-mistakes/worktrees/61c6dd39b831/01M37ZTM3S1MSB43MCT4NNZRTF
T=$(mktemp -d "${TMPDIR:-/tmp}/fm-seat-live.XXXXXX")
H=$T/home; S=$T/seats; mkdir -p $H/config $H/state $H/data $S
printf '%s\n' "$S" > $H/config/claude-seats-root
seat() { echo; echo "\$ fm-seat.sh $*"; FM_HOME=$H FM_ROOT_OVERRIDE=$ROOT CLAUDE_CONFIG_DIR= PATH="${EXTRA_PATH:-}$PATH" "$ROOT/bin/fm-seat.sh" "$@" 2>&1; echo "[exit $?]"; }
echo "### Part A: REAL installed quota-axi ($(command -v quota-axi)), empty profiles, no sign-in"
seat status
seat add work
seat add spare
echo "(profile dirs now: $(ls $S | tr '\n' ' ') ; files inside work: $(ls -A $S/work | wc -l | tr -d ' '))"
seat list
seat probe work
seat switch work
echo "(config/claude-seat after refused switch: $(cat $H/config/claude-seat 2>/dev/null || echo '<absent>'))"
seat switch work --force
echo "(config/claude-seat: $(cat $H/config/claude-seat))"
seat switch nosuch --force
seat switch ../escape --force
echo "(config/claude-seat still: $(cat $H/config/claude-seat))"
seat threshold
seat threshold-reached
seat threshold 15
seat threshold
seat threshold-reached
seat switch default
echo "(config/claude-seat: $(cat $H/config/claude-seat 2>/dev/null || echo '<absent>'))"

echo; echo "### Part B: stub quota-axi reporting work+spare signed in; remaining quota driven by a file"
FB=$T/fakebin; mkdir -p $FB
cat > $FB/quota-axi <<SH
#!/usr/bin/env bash
case "\${CLAUDE_CONFIG_DIR:-}" in
  $S/work|$S/spare) r=\$(cat $T/remaining-\$(basename "\$CLAUDE_CONFIG_DIR") 2>/dev/null || echo 80)
    printf '{"schemaVersion":5,"providers":[{"provider":"claude","source":"oauth","account":{"email":"%[email protected]"},"quotaSemantics":{"status":"known","effectiveAvailability":[{"scope":"model:opus","status":"known","effectivePercentRemaining":1},{"scope":"all_models","status":"known","effectivePercentRemaining":%s}]}}]}\n' "\$(basename "\$CLAUDE_CONFIG_DIR")" "\$r"; exit 0;;
esac
echo '{"schemaVersion":5,"providers":[{"provider":"claude","source":"unavailable","attempts":[{"source":"oauth-file","status":"skipped","error":"credentials_missing"},{"source":"keychain","status":"skipped","error":"keychain_unreachable"}],"quotaSemantics":{"status":"unknown","effectiveAvailability":[]}}]}'; exit 1
SH
chmod +x $FB/quota-axi
export EXTRA_PATH=$FB:
seat list
seat switch work
seat status
echo 50 > $T/remaining-work
echo "(work all_models=50%, model:opus=1%, threshold 15)"; seat threshold-reached
echo 12 > $T/remaining-work
echo "(work all_models=12%, threshold 15)"; seat threshold-reached
seat switch --next
seat switch --next
echo; echo "### Part C: automatic path - arm the watch and run its real blocking child once"
seat switch work
seat arm --interval 1 --stable 1
seat status
SID=$(FM_HOME=$H "$ROOT/bin/fm-procevent-when.sh" source-id claude-seat)
echo "\$ fm-procevent-when.sh run $SID   (the watcher's child, bounded to 30s)"
FM_HOME=$H FM_ROOT_OVERRIDE=$ROOT CLAUDE_CONFIG_DIR= PATH="$FB:$PATH" perl -e "alarm 30; exec @ARGV" "$ROOT/bin/fm-procevent-when.sh" run "$SID" 2>&1 | tail -5; echo "[exit ${PIPESTATUS[0]}]"
echo "(config/claude-seat after the watch fired: $(cat $H/config/claude-seat))"
seat retire
rm -rf "$T"
Evidence: Live Herdr lab: real claude workers across a seat switch (records + process env)

Source: Live Herdr lab: real claude workers across a seat switch (records + process env)

lab session: fm-lab-seatlive-74929-16540
$ fm-seat.sh switch work --force
switched: default -> work
applies to NEW claude workers only; running workers keep their own seat
config-push: no live secondmate homes found
[exit 0]
$ fm-spawn.sh seat-lab-a <proj> --backend herdr   (harness claude)
[exit 0]
warning: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/home/data/seat-lab-a/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
spawned seat-lab-a harness=claude kind=ship mode=no-mistakes yolo=off window=fm-lab-seatlive-74929-16540:w1:p2 worktree=~/.treehouse/proj-dfded3/1/proj
task A record: harness=claude claude_seat=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/seats/work 
task A live claude process:
pid 84731 cwd=~/.treehouse/proj-dfded3/1/proj CLAUDE_CONFIG_DIR=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/seats/work
$ fm-seat.sh switch spare --force
switched: work -> spare
applies to NEW claude workers only; running workers keep their own seat
config-push: no live secondmate homes found
[exit 0]
$ fm-spawn.sh seat-lab-b <proj> --backend herdr   (harness claude)
[exit 0]
warning: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/home/data/seat-lab-b/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
spawned seat-lab-b harness=claude kind=ship mode=no-mistakes yolo=off window=fm-lab-seatlive-74929-16540:w1:p3 worktree=~/.treehouse/proj-dfded3/2/proj
task B record: claude_seat=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/seats/spare
task B live claude process:
pid 93546 cwd=~/.treehouse/proj-dfded3/2/proj CLAUDE_CONFIG_DIR=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/seats/spare
task A record AFTER switch: claude_seat=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/seats/work
task A live claude process AFTER switch:
pid 84731 cwd=~/.treehouse/proj-dfded3/1/proj CLAUDE_CONFIG_DIR=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/seats/work
$ fm-seat.sh status
active seat for NEW workers: spare
active profile: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/seats/spare
login state: unknown
auto-switch threshold: (unset - no automatic switching)
auto-switch watch: not armed

live workers keep the seat they launched with:
  seat-lab-a	/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/seats/work
  seat-lab-b	/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-seat-lab.SSrUhg/seats/spare
[exit 0]
seat profile dirs got trust entries? work: .claude.json backups cache sessions  | spare: .claude.json backups cache sessions 

\### teardown
lab teardown exit 0
Evidence: Herdr lab driver script

Source: Herdr lab driver script

#!/usr/bin/env bash
# Live proof in a throwaway Herdr lab: real fm-spawn launches REAL claude workers
# on the active seat; a switch moves only the next worker.
set -u
ROOT=~/.no-mistakes/worktrees/61c6dd39b831/01M37ZTM3S1MSB43MCT4NNZRTF
export FM_GATE_REFUSE_BYPASS=1
unset HERDR_ENV HERDR_PANE_ID HERDR_TAB_ID HERDR_WORKSPACE_ID HERDR_SOCKET_PATH HERDR_SESSION
LAB=$ROOT/bin/fm-herdr-lab.sh
SESSION=$($LAB name seatlive) || exit 1
export HERDR_SESSION=$SESSION
T=$(mktemp -d "$(cd "${TMPDIR:-/tmp}" && pwd -P)/fm-seat-lab.XXXXXX")
H=$T/home; S=$T/seats; P=$T/proj
WTS=()
cleanup() {
  echo; echo "### teardown"
  for id in seat-lab-a seat-lab-b; do
    [ -f $H/state/$id.meta ] && FM_HOME=$H FM_ROOT_OVERRIDE=$ROOT FM_SPAWN_NO_GUARD=1 "$ROOT/bin/fm-teardown.sh" $id --force >/dev/null 2>&1
  done
  for wt in ${WTS[@]+"${WTS[@]}"}; do treehouse return --force "$wt" >/dev/null 2>&1; done
  $LAB teardown "$SESSION"; echo "lab teardown exit $?"
  rm -rf "$T"
}
trap cleanup EXIT
echo "lab session: $SESSION"
$LAB provision "$SESSION" || exit 1
mkdir -p $H/{state,config,data,projects} $S/work $S/spare $P
touch $H/state/.last-watcher-beat
printf 'claude\n' > $H/config/crew-harness
printf 'off\n' > $H/config/herdr-presentation-spaces
printf '%s\n' "$S" > $H/config/claude-seats-root
git -C $P init -q; echo '# s' > $P/README.md; git -C $P add README.md
git -C $P -c user.name=t -c [email protected] commit -qm init
git clone -q --bare $P $P.origin.git; git -C $P remote add origin "file://$P.origin.git"
for id in seat-lab-a seat-lab-b; do mkdir -p $H/data/$id; printf '# Task\n## Captain'"'"'s intent\nsay hi\n\n## Firstmate spec\nnothing\n' > $H/data/$id/brief.md; done
seat() { echo "\$ fm-seat.sh $*"; FM_HOME=$H FM_ROOT_OVERRIDE=$ROOT CLAUDE_CONFIG_DIR= "$ROOT/bin/fm-seat.sh" "$@" 2>&1; echo "[exit $?]"; }
spawn() {
  echo "\$ fm-spawn.sh $1 <proj> --backend herdr   (harness claude)"
  env HERDR_SESSION=$SESSION FM_SPAWN_NO_GUARD=1 FM_HOME=$H FM_ROOT_OVERRIDE=$ROOT CLAUDE_CONFIG_DIR= \
    "$ROOT/bin/fm-spawn.sh" "$1" "$P" --backend herdr --mode no-mistakes --yolo off > $T/$1.out 2>&1
  echo "[exit $?]"; tail -4 $T/$1.out
  wt=$(sed -n 's/^worktree=//p' $H/state/$1.meta 2>/dev/null); [ -n "$wt" ] && WTS+=("$wt")
}
claude_env_of() { # print CLAUDE_CONFIG_DIR of live claude processes whose cwd is the task worktree
  local wt=$1 pid
  for pid in $(pgrep -x claude 2>/dev/null) $(pgrep -f 'claude' 2>/dev/null); do
    cwd=$(lsof -a -p $pid -d cwd -Fn 2>/dev/null | sed -n 's/^n//p')
    [ "$cwd" = "$wt" ] || continue
    printf 'pid %s cwd=%s %s\n' $pid "$cwd" "$(ps eww -o command= -p $pid | tr ' ' '\n' | grep '^CLAUDE_CONFIG_DIR=' | head -1)"
  done | sort -u
}
seat switch work --force
spawn seat-lab-a
echo "task A record: $(grep '^claude_seat=\|^harness=' $H/state/seat-lab-a.meta | tr '\n' ' ')"
sleep 8
WTA=$(sed -n 's/^worktree=//p' $H/state/seat-lab-a.meta)
echo "task A live claude process:"; claude_env_of "$WTA"
seat switch spare --force
spawn seat-lab-b
sleep 8
WTB=$(sed -n 's/^worktree=//p' $H/state/seat-lab-b.meta)
echo "task B record: $(grep '^claude_seat=' $H/state/seat-lab-b.meta)"
echo "task B live claude process:"; claude_env_of "$WTB"
echo "task A record AFTER switch: $(grep '^claude_seat=' $H/state/seat-lab-a.meta)"
echo "task A live claude process AFTER switch:"; claude_env_of "$WTA"
seat status
echo "seat profile dirs got trust entries? work: $(ls -A $S/work | tr '\n' ' ') | spare: $(ls -A $S/spare | tr '\n' ' ')"
Evidence: tests/fm-seat.test.sh output

Source: tests/fm-seat.test.sh output

ok - an unset seat setting is the ambient default and configures no automatic switching
ok - a switch to a logged-in seat records the seat and nothing else
ok - a switch to a profile that is not logged in is refused and changes nothing
ok - --force does not override a seat proven to be logged out
ok - a rate-limited signed-in seat is undecided, and --force switches onto it
ok - an unreadable credential store reads as undecided and --force may cross it
ok - a forced switch refuses a seat whose profile directory does not exist
ok - switching to the default seat clears the setting and restores ambient behaviour
ok - a seat switch reaches running local secondmate homes and reports each one
ok - a failed secondmate push is reported and never undoes the primary switch
ok - seat settings reach local secondmate homes only and never cross to a remote route
ok - a seat switch pushes only local secondmate homes and never waits on a remote route
ok - fm-config-push reaches remote routes by default and skips them only with --local-only
ok - the auto-switch threshold is configurable, validated, clearable, and unset by default
ok - the threshold condition turns true exactly at the configured percent
ok - an unreadable quota never trips an automatic switch
ok - only account-level quota windows count toward the auto-switch threshold
ok - the default seat's probe and threshold read the ambient profile new workers launch with
ok - rotation chooses the next logged-in seat under the root and skips ones with no credentials
ok - rotation never targets the default profile, even when it is the only other logged-in store
ok - rotation never assumes which seats exist and picks up seats added later
ok - rotation refuses rather than pretending to switch when no other seat is usable
ok - adding a seat creates an empty profile directory and prints the owner's login steps
ok - a directory named 'default' is never offered, added, or rotated to
ok - seat names that are not a single safe path component are refused
ok - an unset seat setting leaves the launch and the task record exactly as before
ok - a spawn launches on the active seat and records it in the task's own record
ok - switching seats leaves a running worker's recorded profile unchanged
ok - after a switch new workers get the new seat while existing ones keep theirs
ok - an ambient CLAUDE_CONFIG_DIR still reaches workers and is recorded per task
ok - a configured seat takes precedence over firstmate's own ambient config dir
ok - a non-claude spawn records no Claude seat while a named seat is active
# all fm-seat tests passed
exit=0
Evidence: tests/fm-control-relaunch.test.sh output

Source: tests/fm-control-relaunch.test.sh output

ok - fm-control relaunch: a same-harness relaunch replaces the agent in the same endpoint and worktree
ok - fm-control relaunch: pending composer text refuses before the exit command is typed
ok - fm-control relaunch: an unreadable composer fails safe before the exit command is typed
ok - fm-control relaunch: a linked spawning home preserves committed and unfinished work in the recorded copy
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: progress and the Firstmate-worktree worker identity reach the replacement
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: a relaunch keeps the seat its task launched on, not the home's new one
ok - fm-control relaunch: a task with no recorded seat is never moved onto one
ok - fm-control relaunch: a task that predates seats keeps the ambient profile, not the home's new seat
ok - fm-control relaunch: a relaunch onto claude from another harness takes and records the active seat
ok - fm-control relaunch: a relaunch from claude onto another harness records no seat
ok - native Ultra relaunch preserves its profile and rejects an unsupported model before stopping
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-promote/fm-spawn --relaunch: the current ship contract supersedes stale scout delivery text
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 its work
ok - tmux: a window absent from its session refuses both verbs rather than being assumed gone
ok - tmux: an unfindable session refuses both verbs, so a live agent is never duplicated
ok - tmux: a dead server on this socket refuses both verbs rather than proving absence
ok - reclaim: an unclassifiable endpoint is still refused, so two agents cannot share one
ok - reclaim: a herdr pane that outlived its stopped server is adopted, never orphaned beside a new tab
ok - fm-control exit: a herdr pane that outlived its stopped server is already-stopped, not gone
ok - reclaim: a herdr rebind is created in the session the record names, never the ambient one
ok - reclaim: a herdr agent that came back with its server refuses, so one worktree keeps one agent
ok - reclaim: a herdr reclaim rebinds the endpoint and leaves the whole rest of the task alone
ok - reclaim: a herdr secondmate whose endpoint is gone is sent to its own respawn owner
ok - reclaim: a rebind refused from a plain shell reports the real cause, not a fabricated session mismatch
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
exit=0
Evidence: Running worker keeps its seat across a switch (lab excerpt)
task A live claude process: pid 84731 CLAUDE_CONFIG_DIR=.../seats/work
$ fm-seat.sh switch spare --force -> switched: work -> spare
task B live claude process: pid 93546 CLAUDE_CONFIG_DIR=.../seats/spare
task A record AFTER switch: claude_seat=.../seats/work
task A live claude process AFTER switch: pid 84731 CLAUDE_CONFIG_DIR=.../seats/work
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (42m22s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ⚠️ bin/fm-spawn.sh:1666 - A relaunch that changes harness gets the wrong seat, or leaves a stale seat line. fm-control.sh supports relaunch --harness &lt;name&gt;. (1) Codex to claude: a codex task spawned while seat spare is active records no claude_seat line, as the earlier decision requires. After fm-control.sh &lt;id&gt; relaunch --harness claude, SEAT_CONFIG_DIR falls back to firstmate's ambient CLAUDE_CONFIG_DIR. The new claude session, which has no prior Claude history to protect, therefore launches silently on the default profile, not the active seat. That is the owner's interactive login, which rotation deliberately avoids and which may be the account that just hit its threshold. Line 4513 also never writes claude_seat on a relaunch. (2) Claude to codex: preserve_relaunch_meta carries claude_seat forward onto the codex record, so fm-seat.sh status lists a codex worker as running on a Claude seat. That reintroduces the misreporting the user asked to fix in seat-recorded-for-non-claude. Suggested fix: when a relaunch's prior harness is not claude and the new harness is claude, resolve fm_seat_spawn_config_dir and record it. When the new harness is not claude, drop the claude_seat line. Which account a harness-switched relaunch should bill to is a product choice, so confirming it is needed.
  • ⚠️ bin/fm-config-inherit-lib.sh:71 - claude-seat and claude-seats-root are added to FM_INHERITABLE_CONFIG. The header of that file says the same list is the allowlist for remote routes (fm-remote-inherit-push.sh / fm-remote-inherit.sh). A remote secondmate on another machine therefore receives claude-seat=work. It resolves the seat to $HOME/.claude-seats/work on the remote host, or to the primary's absolute claude-seats-root path, which may not exist there. The owner never logged that profile in, so every claude crewmate the remote home spawns stops with Not logged in. Before this change those crewmates used the remote's working default login. A seat is a per-machine Keychain-backed profile, and docs/claude-seats.md itself says 'every home on the machine'. Options: keep the seat items local-only for remote routes, or make spawn fall back or refuse when the seat directory is missing. Which one is right is a policy decision about inheritance scope.
  • ℹ️ bin/fm-seat.sh:214 - write_active changes only the primary's config/claude-seat. Inherited items are copied only at convergence points: secondmate spawn, bootstrap, and fm-config-push. So after a manual switch now or an automatic threshold switch, a running secondmate keeps spawning claude crewmates on the old seat until the next convergence. The docs say secondmates 'launch on the same seat as the primary's'. It is worth either running the config push after a switch or saying in the docs that a push is required.

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-seat.sh:277 - The user asked for the existing convergence to run 'for local secondmate homes', but propagate_to_secondmates runs the whole bin/fm-config-push.sh. That script also walks every remote secondmate record (fm-config-push.sh:122-170). So every manual or automatic seat switch opens an SSH inherit push to each remote host, carries any other pending inherited config across with it, and can send remote reread nudges, even though remote homes never receive seat settings. If a remote host is down, the push exits non-zero, and cmd_switch prints 'not every secondmate home was updated ... those homes keep spawning on their previous seat'. That is wrong for a remote home, which never had a seat to begin with. It also means an automatic threshold switch waits on SSH to other machines. Concrete case: the primary has one local and one unreachable remote secondmate, and the owner runs fm-seat.sh switch work. The local home updates, the remote SSH fails, and the owner is told a home is still on the previous seat when that home has no seat. The smallest fix is to limit the push to local routes, for example a local-only mode in fm-config-push.sh that skips records with remote_host. That adds an option to a shared script, and the user said to reuse the script and write no new propagation path, so the remedy needs the user's sign-off.

🔧 Fix applied.
1 info still open:

  • ℹ️ bin/fm-seat.sh:129 - live_task_seats prints a line for every state/*.meta record, whatever its harness. A codex, opencode or other non-Claude task, which now correctly records no claude_seat, still shows up under 'live workers keep the seat they launched with' as (ambient default login). That tells the reader the task runs on the owner's default Claude login. Concrete case: seat spare is active, a codex task is spawned, and fm-seat.sh status lists it as &lt;id&gt; (ambient default login). That weakens status as evidence of which workers a switch left alone, which is the goal behind the round-1 seat-recorded-for-non-claude fix. Fix: skip records whose harness= is not claude, or print the harness in place of the seat for them.
🔧 **Test** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-seat.sh:238 - fm-seat.sh switch nosuch --force succeeds (live: 'switched: default -> nosuch') even though no directory exists under the seats root. fm_seat_dir only builds the path and never checks that it exists, and the missing profile probes as unknown, which --force crosses. So one typo in a forced manual switch sends every new claude worker to a profile that doesn't exist, and list never shows that seat. Those workers stop at login or onboarding, so no other account gets spent, but the error message 'does not resolve to a profile directory' suggests a missing seat was meant to be refused. Suggested fix: refuse a named seat whose directory does not exist, even with --force.
  • Live validation: ✅ go - 9 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Owner runs fm-seat.sh switch seat-max and the active seat for new workers changes immediately (one command, no threshold needed) ✅ pass live 01-manual-switch-real-seats.txt: 'switched: default -> seat-max', config/claude-seat=seat-max, status shows the seat-max profile logged-in; a repeat switch prints 'seat unchanged'
Owner sets a configurable threshold, and threshold-reached compares it against the active seat's real account-level quota ✅ pass live 09-threshold-real-quota-fresh.txt: seat-max2 all_models at 39%; threshold 15 gives exit 1, threshold 60 gives exit 0; 02: abc/0/101/-5/15% rejected, off clears it
Armed watch fires the automatic switch --next when the threshold is crossed, once ✅ pass live 11-armed-watch-fires-live.txt: when-runner status fired, condition_polls 1, 'switched: seat-max2 -> seat-max'
Adversarial: an unreadable or rate-limited quota never triggers a switch ✅ pass live 02 and 10: a stale quota read (Claude endpoint rate-limited) gives threshold-reached exit 2; the watch ends with condition-error, 'the action was not run', and config/claude-seat is unchanged
A running claude worker keeps its seat when the owner switches; the next spawn gets the new seat ✅ pass live 04 and 07: w1 recorded lab-a and its claude process env is CLAUDE_CONFIG_DIR=.../lab-a after the switch to lab-b; w2 is on lab-b; fm-seat.sh status lists both separately; each worktree's trust entry…
A new worker on a seat never silently falls back to the owner's default login ✅ pass live 05 and 06: both lab workers show the fresh-profile onboarding screen of their own empty seat, not the owner's signed-in default account
A claude-to-claude relaunch keeps the task's recorded seat, even after a switch ✅ pass live 08-relaunch-keeps-seat.txt: fm-spawn.sh w1 --relaunch with lab-b active writes a new launch script with CLAUDE_CONFIG_DIR=.../lab-a; the meta still says lab-a; the new claude pid has lab-a in its en…
Adding a seat creates only an empty profile and prints the owner's login steps; no credential is touched ✅ pass live 03-add-seat-and-guards.txt: an empty 0700 dir plus the printed CLAUDE_CONFIG_DIR=... claude and /login instructions; 'default' and '../evil' are refused
Adversarial: switching to an unconfirmed seat refuses without --force; rotation and arm refuse when no other logged-in seat exists and never pick the default profile ✅ pass live 03: probe lab-a returns unknown (exit 2); a plain switch is refused; --force switches; switch --next and arm both refuse
A relaunch that switches onto claude from another harness takes the active seat; a relaunch from claude onto another harness drops the seat ⏸️ untested no The prior payload did not establish a live result. Only tests/fm-control-relaunch.test.sh covers this, because no second harness (codex/opencode/pi/gemini/kimi/grok) is installed on this host. Install…
A switch reaches this machine's local secondmate homes via fm-config-push --local-only; remote homes never get seat settings ⏸️ untested no The prior payload did not establish a live result. Only tests/fm-seat.test.sh covers this. Live runs printed 'config-push: no live secondmate homes found' because no running secondmate home or remote…
  • bin/fm-seat.sh list / probe seat-max / status / switch seat-max (isolated FM_HOME, seats root ~/.claude-seats, real quota-axi)
  • bin/fm-seat.sh threshold abc|0|101|-5|15%|15|60|100|off and threshold-reached against real quota for seat-max (stale, rate-limited) and seat-max2 (fresh, ~39%)
  • bin/fm-seat.sh add lab-a, add default, add ../evil, probe lab-a, switch lab-a, switch lab-a --force, switch --next, arm with a single empty seat
  • bin/fm-seat.sh arm --interval 20 --stable 1 then bin/fm-procevent-when.sh run when-claude-seat (fired: seat-max2 -> seat-max), then retire
  • Herdr lab fm-lab-seatlab-94718-30252 via bin/fm-herdr-lab.sh provision/run/teardown: fm-spawn.sh w1 --harness claude --backend herdr on seat lab-a, fm-seat.sh switch lab-b --force, fm-spawn.sh w2, checked meta, the launch script, the process env, the trust entry per profile, and the pane screen
  • stopped the lab w1 claude process, then fm-spawn.sh w1 --relaunch while lab-b was active; checked the recorded seat, the new launch script, and the process env
  • bash tests/fm-seat.test.sh (31 ok)
  • bash tests/fm-control-relaunch.test.sh (72 ok)

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

  • Live validation: ✅ go - 8 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Owner adds a second seat: fm-seat.sh add work creates an empty profile dir, prints the exact login command, and touches no credential ✅ pass live seat-cli-live.txt Part A: add work/spare created the directories, wrote 0 files in them, and printed the CLAUDE_CONFIG_DIR=... claude + /login instructions
Manual 'switch now' is one command, and new workers launch on the new seat ✅ pass live seat-herdr-lab-live.txt: fm-seat.sh switch work --force, then the real fm-spawn claude worker ran with CLAUDE_CONFIG_DIR=seats/work and its record carried claude_seat=seats/work; after `switch spare…
A switch never disturbs a running worker: its record and live process keep the original seat ✅ pass live seat-herdr-lab-live.txt: after the switch to spare, task A's meta still read seats/work, pid 84731's environment still held seats/work, and fm-seat.sh status listed A on work and B on spare
Switch to a seat whose login cannot be confirmed is refused by default; --force crosses an undecided probe ✅ pass live seat-cli-live.txt Part A: with the real quota-axi, the empty profile probed unknown (exit 2), switch work was refused with config unchanged, and switch work --force succeeded
Adversarial: a forced switch to a typo'd or path-escaping seat name is refused ✅ pass live seat-cli-live.txt: switch nosuch --force gave error 'has no profile directory' (exit 1), switch ../escape --force gave 'invalid seat name' (exit 1), and the active seat stayed work
Threshold is configurable, absent by default, and an unset or unreadable threshold never reports reached ✅ pass live seat-cli-live.txt: threshold unset, then threshold-reached exit 2; threshold 15 set it; threshold-reached on an unreadable real quota still exited 2
Adversarial: a model-scoped window below the threshold does not trip it; only account-level all_models counts ✅ pass live seat-cli-live.txt Part B (stubbed quota report): all_models 50% with model:opus 1% gave exit 1; all_models 12% gave exit 0
Armed automatic switch fires switch --next once when the threshold is crossed, rotating only among named seats ✅ pass live seat-cli-live.txt Part C: arm, then the real fm-procevent-when.sh run when-claude-seat child moved the active seat work -> spare; retire stopped the watch. Part B also showed that --next rotates…
Relaunch/resume keeps the task's recorded seat; harness-changing relaunches resolve or drop the seat ⏸️ untested no The earlier payload did not show a live result for this. It was covered only by tests/fm-control-relaunch.test.sh, which uses a fake backend. A live check needs a lab session where the earlier real…
A switch propagates to local secondmate homes via fm-config-push --local-only and never contacts remote routes; remote homes never receive seat settings ⏸️ untested no The earlier payload did not show a live result for this. It was covered only by automated tests in tests/fm-seat.test.sh; the live CLI switches found no live secondmate homes. A live check needs a r…
A seat the owner actually signed into probes logged-in and can be switched to without --force ⏸️ untested no Needs a named seat the account owner has signed into personally. I did not point the tool at the owner's real ~/.claude-seats profiles, to avoid reading or refreshing production credentials. To cover…
  • bash tests/fm-seat.test.sh (all fm-seat tests passed)
  • bash tests/fm-control-relaunch.test.sh (all passed, including the claude->claude, codex->claude and claude->codex seat transitions)
  • seat-cli-live.sh Part A: real fm-seat.sh in a throwaway FM_HOME with the REAL installed quota-axi: status, add work/spare, list, probe, refused switch, switch work --force, switch nosuch --force, switch ../escape --force, threshold unset/set 15, threshold-reached, switch default
  • seat-cli-live.sh Part B: stubbed quota report (work/spare signed in): list, switch, status, threshold-reached with all_models 50%/model:opus 1% (exit 1) and all_models 12% (exit 0), switch --next rotation work->spare->work
  • seat-cli-live.sh Part C: fm-seat.sh arm --interval 1 --stable 1, then the real watcher child fm-procevent-when.sh run when-claude-seat fired switch --next (work -> spare), then fm-seat.sh retire
  • seat-herdr-lab-live.sh: guarded fm-herdr-lab.sh session fm-lab-seatlive-*: fm-seat.sh switch work --force, real fm-spawn.sh seat-lab-a --backend herdr launching real claude, ps eww of that claude pid, fm-seat.sh switch spare --force, fm-spawn.sh seat-lab-b, re-inspected A's record and process, fm-seat.sh status, fm-teardown, lab teardown
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Add a way to choose which Claude account (seat) new workers run on, with a
one-command manual switch and an optional configurable threshold.

A seat is a Claude Code profile directory named by CLAUDE_CONFIG_DIR. Claude
Code derives that profile's macOS Keychain service name from a hash of the
directory path, so each seat has its own credential store and a worker pointed
at a profile that was never logged in stops with "Not logged in" rather than
spending the default account.

The safety property: a switch changes only what the NEXT worker gets.
fm-spawn resolves the seat once per fresh spawn, pre-registers Claude workspace
trust in that same profile, and records it as claude_seat= in the task's own
record. Every relaunch reads that record instead of re-resolving the setting,
so a switch never moves a live or relaunched worker. That is a correctness
requirement, not only a billing one: a task's session history lives under its
profile directory, so moving it would strand the session.

bin/fm-seat.sh is the one command: list, status, probe, add, switch <name>,
switch --next, threshold, arm, retire. A switch to a profile with no
credentials is refused. `add` creates an empty profile directory and prints the
login command; nothing here logs in, copies a credential, or touches the
Keychain - the account owner signs a seat in personally.

The automatic path reuses the existing condition-to-action watch rather than
adding a daemon: condition `threshold-reached`, action `switch --next`. It
fires at most once, which is the edge trigger, and is off until a threshold is
configured. An unreadable quota is an error, never a crossing.

Settings are absent by default, so an unconfigured home behaves exactly as
before, and are inherited into secondmate homes.
Rotation now covers only named seats under the seats root. The default profile
is the account owner's own interactive login: it changes account whenever they
sign in somewhere else, and nothing here can tell which account it currently
holds, so an automatic switch must never land workers on it. `switch default`
stays available as an explicit, manual choice.

The seat set is read fresh from the seats root on every step, so nothing
assumes which seats exist or that any particular one is present.

Also fix a narrow relaunch regression this change surfaced: a task recorded
before seats existed carries no claude_seat line, and its launches always took
firstmate's own ambient CLAUDE_CONFIG_DIR. Falling through to the bare default
would have moved exactly the kind of task the recorded-seat rule exists to
leave alone, so a relaunch now keeps that ambient profile. The home's active
seat is still never consulted on a relaunch.

Docs state plainly that the sign-in prompts in a fresh profile, and the effect
of a second login on the default session, are written from documented behaviour
rather than an observed sign-in, because verifying them would mean logging in.
A directory literally named "default" under the seats root was listed as a
seat but refused by every switch, because that name is reserved for the ambient
login. Skip it in the listing, and refuse "add default" with the reason.
`fm_seat_logged_in` reported "not logged in" whenever every credential source
was skipped, including when the Keychain itself could not be read. That
conflates "the store says there is no login" with "the store could not be
consulted", and the second establishes nothing.

Measured read-only against the installed quota-axi on macOS, with no sign-in
performed: a profile that was never logged into and a profile that IS signed in
but whose one-time Keychain approval has not been granted produce the same
report - every source skipped, the keychain unreachable. A signed-in and
approved profile instead reports the keychain read as successful. So the
unreachable shape cannot tell the first two apart, and treating it as proof of
absence refused a correctly signed-in seat with no way through - the state an
owner is in moments after logging a seat in, and one that `--force` could not
cross because `--force` must never cross a proven-empty verdict.

A not-logged-in verdict now requires that every credential source was actually
consulted and came back empty. On macOS that is rarely reachable, because an
absent Keychain entry reads as unreadable; on a file-backed store, where an
empty profile really can be read and found empty, it is reported as before.
An undecided read is what `--force` may cross, and crossing it is safe: a forced
switch to a genuinely empty seat stops the next worker on its first message with
"Not logged in" rather than spending another account.

The docs already described this behaviour, so this brings the code up to them
and states which probe states can be told apart and which cannot.
@max-metaplanet
max-metaplanet merged commit 8bfb7c7 into main Sep 23, 2026
20 checks passed
max-metaplanet added a commit that referenced this pull request Oct 6, 2026
… ones

Carried from fork commit bd1c981 (#4).

Conflict resolutions:

AGENTS.md takes upstream's restructure, which replaced the inline operational-home
layout tree with a one-line pointer to the `operational-home-layout` skill.
The seat entry this commit added to that tree is re-homed into the skill beside
the worker account pin, so the layout keeps exactly one owner and the
always-loaded file does not regain the lines upstream moved out.

bin/fm-config-inherit-lib.sh unions the inheritable set: upstream's newer
`dispatch-never-send`, `keep-ai-trailers`, and `supervision-host-off` items stay
alongside the three seat items.
The machine-local list is kept as its own fork divergence, because a seat is a
per-machine profile the owner logged in here and a remote home handed its name
would resolve a profile nobody logged in there.

bin/fm-spawn.sh keeps upstream's worktree re-assert and then resolves the seat,
which must stay ahead of trust pre-registration so the trust entry lands in the
profile the worker will actually read.
The relaunch-preserved metadata key list unions both sides: upstream's `branch`,
`base_branch`, and `control_relaunch_tx` with this commit's `claude_seat`.

docs/scripts.md unions the two row descriptions, which gained independent detail:
upstream's ship-branch prefix on `fm-project-mode.sh` and this commit's
`--local-only` on `fm-config-push.sh`.
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