Skip to content

feat(bin): opt-in per-home Claude and Pi worker account pin - #5358

Merged
kunchenguid merged 4 commits into
kunchenguid:mainfrom
tiago-peixoto:fm/upstream-4265-home-account-pin
Sep 23, 2026
Merged

kunchenguid merged 4 commits into
kunchenguid:mainfrom
tiago-peixoto:fm/upstream-4265-home-account-pin

Conversation

@tiago-peixoto

@tiago-peixoto tiago-peixoto commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Fixes #4265.
Clear base conflicts on #5358 (branch fm/upstream-4265-home-account-pin, head 89adb32): the opt-in per-home account pin for issue 4265, whose accepted intent stays unchanged.
Do not open a second PR. Never merge upstream.

Accepted intent of that pin, unchanged: a home that mixes work and personal accounts for the same runner can declare, in private local configuration, which account its own workers and scouts launch on. A launch that cannot resolve a signed-in pinned account refuses with an actionable message rather than falling back to whatever is ambient. A home that declares nothing behaves exactly as it does today. The pin stays inert until a home creates it, so a single-account installation sees no behaviour change. The pin covers Claude (config/claude-account: ordinary or one absolute config root) and Pi (config/pi-account: a root plus the providers that home may spend). A pinned Claude launch selects that root and sheds environment credentials Claude ranks above the stored login; a raw Claude command that sets CLAUDE_CONFIG_DIR or one of those credentials is refused. A pinned Pi launch requires an explicit --model provider/id among the declared providers and passes --provider; a raw Pi command is refused. The pin is checked before a relaunch stops the running agent, is not inherited into secondmate homes, and is recorded on the spawned line and task record only when set.

What Changed

  • Adds bin/fm-worker-account-lib.sh, which reads the optional local files config/claude-account and config/pi-account. config/claude-account holds ordinary or one absolute config root. config/pi-account holds a root plus the providers the home may spend. The library checks sign-in by asking the runner itself (claude auth status, or pi auth check, falling back to pi --list-models) with a stripped environment. A malformed file, an unusable root, or a signed-out account refuses the launch with a message naming the file to fix, and never falls back to the ambient account.
  • bin/fm-spawn.sh resolves the pin before any endpoint, worktree, or record exists.
    • A pinned Claude launch sets CLAUDE_CONFIG_DIR to the pinned root, or unsets it for ordinary. It also unsets the environment credentials Claude ranks above a stored login, such as ANTHROPIC_API_KEY and CLAUDE_CODE_OAUTH_TOKEN.
    • A pinned Pi launch sets PI_CODING_AGENT_DIR, requires --model <provider>/<id> naming a declared provider, and adds --provider.
    • A raw Claude command that sets CLAUDE_CONFIG_DIR or one of those credentials refuses, and so does any raw Pi command.
    • account= and Pi's account_provider= appear on the spawned line and in the task record only when a pin is set. Without a pin, launches work exactly as before.
  • bin/fm-control.sh checks the pin during relaunch profile resolution, before the running agent is stopped. The docs (configuration, agent control, remote secondmates, secondmate provisioning, harness adapter references, runtime-backend verification) explain the pin and state that it is not inherited into secondmate homes. New unit and live e2e tests (tests/fm-worker-account*.test.sh) and a relaunch test cover the behavior, and bin/fm-test-run.sh registers the new test files.

Risk Assessment

✅ Low: The merge conflict in bin/fm-spawn.sh is resolved correctly: the account suffix stays on the spawned line and main's fleet-ledger hook is kept. The account pin does nothing unless a home creates the config file, and when set it matches the accepted intent: it refuses before any endpoint exists or before the relaunch stop, sheds higher-ranked credentials, requires provider/id for Pi, refuses raw Pi commands and raw Claude account overrides, is not inherited because the config inheritance list is explicit, and records the account only when set.

Testing

I ran the pin's focused suites and the live sign-in guard, which asks the real claude and pi binaries about synthetic account roots; that guard is the only scenario with a live result, and it passed. I also drove the real bin/fm-spawn.sh from throwaway homes, with real claude and pi answering the sign-in check and only tmux faked, and captured CLI transcripts for the Claude and Pi cases; because the terminal backend was faked, those scenarios are recorded as untested rather than live passes. I did not launch a worker pane in a Herdr lab. The relaunch suite stopped at an unrelated case that needs tasks-axi 0.2.6 (0.2.5 is installed).

  • Live validation: ⚠️ inconclusive - 1 of 8 scenarios driven live against the product
Scenario Result Live Evidence
The real claude and pi binaries accept a signed-in pinned root and refuse one that only an ambient credential signs in ✅ pass live tests/fm-worker-account-live-e2e.test.sh -> fm-worker-account-live-e2e.log
A home with no pin spawns a Claude worker unchanged, with no account= on the spawned line or in the record ⏸️ untested no The prior payload did not establish a live result: the run used the tmux fake from the test fixtures instead of a real terminal pane. Driving it live needs a bin/fm-herdr-lab.sh fm-lab-* session.
A pin to a signed-out Claude root refuses with an actionable message and creates no record or launch, even though the caller has ANTHROPIC_API_KEY ⏸️ untested no The prior payload did not establish a live result: the sign-in check used the real claude binary but the terminal backend was faked tmux. Driving it live needs a real Herdr or tmux lab session.
A pin to a signed-in Claude root selects it, sheds higher-ranked environment credentials, and records account= on the spawned line and in the task record ⏸️ untested no The prior payload did not establish a live result: the terminal backend was faked tmux and the launch command was captured rather than run in a pane. Driving it live needs a lab session and a signed-i…
A pinned home refuses a raw Claude command that sets CLAUDE_CONFIG_DIR ⏸️ untested no The prior payload did not establish a live result: the terminal backend was faked tmux. Driving it live needs a real lab session.
A pinned Pi launch refuses a missing --model or an undeclared provider, and a declared provider launches with PI_CODING_AGENT_DIR and --provider ⏸️ untested no The prior payload did not establish a live result: the sign-in check used the real pi binary but the terminal backend was faked tmux. Driving it live needs a lab session and a signed-in pinned Pi acco…
A relaunch checks the pin before the running agent stops, and the pin is not inherited into secondmate homes ⏸️ untested no The prior payload did not establish a live result: this was covered only by suites that use fake runners. Driving it live needs a running worker in a lab session to relaunch.
A pinned worker actually starts in a Herdr pane on the pinned account ⏸️ untested no Not driven here. It needs a bin/fm-herdr-lab.sh fm-lab-* session plus a real signed-in second Claude or Pi account to prove which account the pane uses. The operator can provide that account and run a…
Evidence: Claude pin spawn transcript (real fm-spawn + real claude, faked tmux)

Source: Claude pin spawn transcript (real fm-spawn + real claude, faked tmux)

claude: 2.1.281 (Claude Code)

## 1. unpinned home (no config/claude-account)
warning: /var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.9j0RfoBM6L/home/data/live-none/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 live-none harness=claude kind=ship mode=no-mistakes yolo=off window=firstmate:fm-live-none worktree=/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.9j0RfoBM6L/wt
[exit 0]
model=default
launch: export COMPACT_ADVISER_DISABLE=1; env -u CURSOR_AGENT -u CURSOR_INVOKED_AS -u GEMINI_CLI CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false CLAUDE_CODE_SEND_FEEDBACK=0 claude --dangerously-skip-permissions --settings '{"feedbackDrafts":"off","attribution":{"commit":"","pr":"","sessionUrl":false}}' --append-

## 2. pin -> signed-out root, invoker has ANTHROPIC_API_KEY
error: config/claude-account pins Claude workers to /var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.9j0RfoBM6L/empty, which is not signed in (claude auth status); sign in with CLAUDE_CONFIG_DIR=/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.9j0RfoBM6L/empty claude, then /login, or change the pin
[exit 1]
ls: /var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.9j0RfoBM6L/home/state/live-out.meta: No such file or directory
launch.log bytes:        0

## 3. pin -> signed-in root
warning: /var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.9j0RfoBM6L/home/data/live-in/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 live-in harness=claude kind=ship mode=no-mistakes yolo=off window=firstmate:fm-live-in worktree=/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.9j0RfoBM6L/wt account=/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.9j0RfoBM6L/signed
[exit 0]
account=/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.9j0RfoBM6L/signed
launch: export COMPACT_ADVISER_DISABLE=1; env -u CLAUDE_CODE_USE_BEDROCK -u CLAUDE_CODE_USE_VERTEX -u CLAUDE_CODE_USE_FOUNDRY -u CLAUDE_CODE_USE_ANTHROPIC_AWS -u CLAUDE_CODE_USE_MANTLE -u ANTHROPIC_AUTH_TOKEN -u ANTHROPIC_API_KEY -u CLAUDE_CODE_OAUTH_TOKEN -u ANTHROPIC_PROFILE -u ANTHROPIC_FEDERATION_RULE_ID CLAUDE_CONFIG_DIR='/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.9j0RfoBM6L/signed' env -u 

## 4. pinned home, raw Claude command overriding CLAUDE_CONFIG_DIR
error: config/claude-account pins Claude workers, but the raw launch command sets CLAUDE_CONFIG_DIR, which would override the pinned account; remove CLAUDE_CONFIG_DIR from the raw command, or change or remove config/claude-account
[exit 1]
launch.log bytes:        0
Evidence: Pi pin spawn transcript (real fm-spawn + real pi, faked tmux)

Source: Pi pin spawn transcript (real fm-spawn + real pi, faked tmux)

pi: 0.87.0; config/pi-account:
  /var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.N6XK05yIlR/pi
  openai

## 1. pinned Pi without --model
error: config/pi-account pins Pi workers to providers (openai), so a Pi launch needs --model <provider>/<id> naming one of them; 'none' names no provider, and Firstmate does not guess one
[exit 1] launch.log bytes:        0

## 2. pinned Pi with undeclared provider --model anthropic/claude-sonnet-5
error: config/pi-account pins Pi workers to providers (openai), but --model 'anthropic/claude-sonnet-5' names provider 'anthropic'
[exit 1] launch.log bytes:        0

## 3. pinned Pi with --model openai/gpt-5
warning: /var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.N6XK05yIlR/home/data/p3/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 p3 harness=pi kind=ship mode=no-mistakes yolo=off window=firstmate:fm-p3 worktree=/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.N6XK05yIlR/wt account=/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.N6XK05yIlR/pi account_provider=openai
[exit 0] launch.log bytes:      628
account=/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.N6XK05yIlR/pi
account_provider=openai
PI_CODING_AGENT_DIR='/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/tmp.N6XK05yIlR/pi'
--provider 'openai' --model 'openai/gpt-5'
Evidence: Live runner sign-in guard log

Source: Live runner sign-in guard log

ok - claude 2.1.281 (Claude Code): the pin check accepts a signed-in root and refuses an empty one despite an ambient API key
ok - pi 0.87.0: the pin check reads auth check and the model listing, and refuses what only an ambient credential signs in
skip-runner: pi-signed is not installed, so its pin check was not exercised
# worker account live guard checked: claude pi
Evidence: Relaunch suite log (pin cases pass; unrelated tasks-axi failure)

Source: Relaunch suite log (pin cases pass; unrelated tasks-axi failure)

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 - native Ultra relaunch preserves its profile and rejects an unsupported model before stopping
ok - fm-control relaunch: a signed-out worker account pin refuses before the old agent stops
ok - fm-control relaunch: the replacement follows the home's current worker account pin
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 child records fail checkpoint
ok - fm-control relaunch: unlistable state fails checkpoint
ok - fm-control relaunch: a vanished watcher scratch file does not fail the child-record 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
not ok - a relaunch must not re-run a transition the row already reflects
warning: /private/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/fm-control-relaunch.iulYuS/reverify-25142/home/data/rl40/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
error: task rl40 cannot be dispatched because its backlog data directory is inaccessible: /private/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/fm-control-relaunch.iulYuS/reverify-25142/home/data (automatic backlog transitions require tasks-axi 0.2.6 or newer with the required update and mv features)
error: the replacement agent for rl40 could not be launched on claude
error: rl40's agent was stopped but the replacement did not launch; no agent is running, and its work plus the recorded progress note are preserved at /private/var/folders/r8/cylyt7xd7t50y9x5wc05my380000gn/T/fm-control-relaunch.iulYuS/reverify-25142/wt: expected exit 0, got 1
Evidence: Signed-out pin refusal
error: config/claude-account pins Claude workers to .../empty, which is not signed in (claude auth status); sign in with CLAUDE_CONFIG_DIR=.../empty claude, then /login, or change the pin
[exit 1] no meta, launch.log 0 bytes
- Outcome: ⚠️ 2 warnings across 1 run (9m35s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped

Step was skipped.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 2 warnings
  • ⚠️ tests/fm-control-relaunch.test.sh:2284 - tests/fm-control-relaunch.test.sh fails at 'a relaunch must not re-run a transition the row already reflects' because the installed tasks-axi is 0.2.5 and the case needs 0.2.6 or newer. The case exists on main and is not part of this change. The pin cases in this suite run before it and pass, but cases after it did not run locally. Remote CI or a host with tasks-axi >= 0.2.6 must confirm the rest.
  • ⚠️ live validation verdict: inconclusive (1 of 8 scenarios were driven live against the product); untested: A home with no pin spawns a Claude worker unchanged, with no account= on the spawned line or in the record, A pin to a signed-out Claude root refuses with an actionable message and creates no record or launch, even though the caller has ANTHROPIC_API_KEY, A pin to a signed-in Claude root selects it, sheds higher-ranked environment credentials, and records account= on the spawned line and in the task record, A pinned home refuses a raw Claude command that sets CLAUDE_CONFIG_DIR, A pinned Pi launch refuses a missing --model or an undeclared provider, and a declared provider launches with PI_CODING_AGENT_DIR and --provider, A relaunch checks the pin before the running agent stops, and the pin is not inherited into secondmate homes, A pinned worker actually starts in a Herdr pane on the pinned account
  • Live validation: ⚠️ inconclusive - 1 of 8 scenarios driven live against the product
Scenario Result Live Evidence
The real claude and pi binaries accept a signed-in pinned root and refuse one that only an ambient credential signs in ✅ pass live tests/fm-worker-account-live-e2e.test.sh -> fm-worker-account-live-e2e.log
A home with no pin spawns a Claude worker unchanged, with no account= on the spawned line or in the record ⏸️ untested no The prior payload did not establish a live result: the run used the tmux fake from the test fixtures instead of a real terminal pane. Driving it live needs a bin/fm-herdr-lab.sh fm-lab-* session.
A pin to a signed-out Claude root refuses with an actionable message and creates no record or launch, even though the caller has ANTHROPIC_API_KEY ⏸️ untested no The prior payload did not establish a live result: the sign-in check used the real claude binary but the terminal backend was faked tmux. Driving it live needs a real Herdr or tmux lab session.
A pin to a signed-in Claude root selects it, sheds higher-ranked environment credentials, and records account= on the spawned line and in the task record ⏸️ untested no The prior payload did not establish a live result: the terminal backend was faked tmux and the launch command was captured rather than run in a pane. Driving it live needs a lab session and a signed-i…
A pinned home refuses a raw Claude command that sets CLAUDE_CONFIG_DIR ⏸️ untested no The prior payload did not establish a live result: the terminal backend was faked tmux. Driving it live needs a real lab session.
A pinned Pi launch refuses a missing --model or an undeclared provider, and a declared provider launches with PI_CODING_AGENT_DIR and --provider ⏸️ untested no The prior payload did not establish a live result: the sign-in check used the real pi binary but the terminal backend was faked tmux. Driving it live needs a lab session and a signed-in pinned Pi acco…
A relaunch checks the pin before the running agent stops, and the pin is not inherited into secondmate homes ⏸️ untested no The prior payload did not establish a live result: this was covered only by suites that use fake runners. Driving it live needs a running worker in a lab session to relaunch.
A pinned worker actually starts in a Herdr pane on the pinned account ⏸️ untested no Not driven here. It needs a bin/fm-herdr-lab.sh fm-lab-* session plus a real signed-in second Claude or Pi account to prove which account the pane uses. The operator can provide that account and run a…
  • bash tests/fm-worker-account.test.sh (13 cases pass)
  • bash tests/fm-worker-account-live-e2e.test.sh (real claude 2.1.281 and pi 0.87.0 checked; pi-signed not installed)
  • bash tests/fm-control-relaunch.test.sh (pin cases pass; stops at the unrelated tasks-axi 0.2.6 case)
  • bash tests/fm-secondmate-harness.test.sh (pass)
  • bash $EVIDENCE/pin-spawn-transcript.sh $PWD - real fm-spawn.sh + real claude, faked tmux: unpinned, signed-out pin, signed-in pin, raw CLAUDE_CONFIG_DIR override
  • bash $EVIDENCE/pin-spawn-pi-transcript.sh $PWD - real fm-spawn.sh + real pi, faked tmux: no --model, undeclared provider, declared provider
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

A home that mixes work and personal accounts for one runner had no way to
say which account its workers launch on: Claude workers inherited whatever
CLAUDE_CONFIG_DIR the supervising process had, Pi workers the pane's ambient
root, and an ambient API key outranked both, with no signal at launch.

config/claude-account and config/pi-account now pin that choice per home.
With neither file every launch is unchanged. With one, every launch of that
runner from the home (ship, scout, local secondmate, raw Claude command, and
relaunch) runs under the declared root, and the spawn refuses before any
endpoint exists when the file is malformed or the runner's own check
(claude auth status, pi auth check with a model-listing fallback) says the
pinned account is not signed in. The check runs in a cleared environment so
an ambient credential cannot answer for an empty root. A pinned Claude launch
sheds the environment credentials Claude ranks above a stored login; a pinned
Pi launch needs an explicit <provider>/<id> model for a declared provider and
also carries --provider. The chosen account is printed on the spawned line and
recorded in the task record, and relaunch checks the pin before stopping the
running agent.
…w host

test_config_reread_serializes_concurrent_pushes waited about two seconds for
the first fm-config-push.sh to reach its first send-keys. On a slower host
that push takes four to five seconds, so the test failed on main before the
push ever got there. The loop still leaves as soon as the marker appears, so
the larger bound costs nothing where the push is fast.
@tiago-peixoto tiago-peixoto changed the title feat(bin): add an opt-in per-home worker account pin feat(bin): opt-in per-home Claude and Pi worker account pin Sep 23, 2026
@kunchenguid
kunchenguid merged commit 0afc6b4 into kunchenguid:main Sep 23, 2026
20 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @tiago-peixoto — really appreciate you taking the time on this.

Contract-class (own tip-vs-main): opt-in. config/claude-account / config/pi-account gate the pin; absent either file, Claude/Pi launches stay on the ambient account (tests assert no account= on spawn line or task record). Pin refuses before endpoint/worktree/record when malformed, unusable, or signed-out; not inherited into secondmate homes. Matches accepted intent of ready-for-pr #4265.

VISION (per-rule):

  • One captain / interface: aligns — pin is private local config; refusal surfaces as an actionable spawn error, not a new captain chat surface.
  • Authority: aligns — only the captain chooses/changes the pin; agents must not edit/remove the file to unblock; ambient unchanged until opted in.
  • Scripts own mechanics: aligns — bin/fm-worker-account-lib.sh owns parse/sign-in/shed; spawn/control call it before launch/stop.
  • Restart / durability: aligns — pin lives on disk in gitignored config; recorded on meta only when set.
  • Delegation: aligns — composes with existing spawn/relaunch; no new task shape.
  • Fleet outlives vendor: aligns — sign-in asked of the runner itself (claude auth status / pi auth check / pi --list-models); Claude+Pi only as named adapters.
  • Scope: aligns — command-layer launch identity, not workshop.

Attestation: MATCH — body head_sha=75a21ec0c2e41ad826afff0378541e18482448aa equals HEAD.
Checks: CI 35928222496 SUCCESS; NM required check SUCCESS. MERGEABLE/CLEAN. workflow-zero. workflow-approved no (CI already running).
Closes-issue verified: yes — author body Fixes #4265; GraphQL closingIssuesReferences includes #4265 (ready-for-pr feature proposal for this exact opt-in pin).

Squash merge 0afc6b4d40325d264004062e7cd49b11ce86f16d. I am Kun's firstmate (automated triage for firstmate-oss).

mituso89 pushed a commit to mituso89/firstmate that referenced this pull request Sep 26, 2026
…uid#5358)

* feat(bin): add an opt-in per-home worker account pin

A home that mixes work and personal accounts for one runner had no way to
say which account its workers launch on: Claude workers inherited whatever
CLAUDE_CONFIG_DIR the supervising process had, Pi workers the pane's ambient
root, and an ambient API key outranked both, with no signal at launch.

config/claude-account and config/pi-account now pin that choice per home.
With neither file every launch is unchanged. With one, every launch of that
runner from the home (ship, scout, local secondmate, raw Claude command, and
relaunch) runs under the declared root, and the spawn refuses before any
endpoint exists when the file is malformed or the runner's own check
(claude auth status, pi auth check with a model-listing fallback) says the
pinned account is not signed in. The check runs in a cleared environment so
an ambient credential cannot answer for an empty root. A pinned Claude launch
sheds the environment credentials Claude ranks above a stored login; a pinned
Pi launch needs an explicit <provider>/<id> model for a declared provider and
also carries --provider. The chosen account is printed on the spawned line and
recorded in the task record, and relaunch checks the pin before stopping the
running agent.

* test(secondmate): give the concurrent config-push wait room for a slow host

test_config_reread_serializes_concurrent_pushes waited about two seconds for
the first fm-config-push.sh to reach its first send-keys. On a slower host
that push takes four to five seconds, so the test failed on main before the
push ever got there. The loop still leaves as soon as the marker appears, so
the larger bound costs nothing where the push is fast.

* no-mistakes(review): Refuse raw Claude account overrides under a pin
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…uid#5358)

* feat(bin): add an opt-in per-home worker account pin

A home that mixes work and personal accounts for one runner had no way to
say which account its workers launch on: Claude workers inherited whatever
CLAUDE_CONFIG_DIR the supervising process had, Pi workers the pane's ambient
root, and an ambient API key outranked both, with no signal at launch.

config/claude-account and config/pi-account now pin that choice per home.
With neither file every launch is unchanged. With one, every launch of that
runner from the home (ship, scout, local secondmate, raw Claude command, and
relaunch) runs under the declared root, and the spawn refuses before any
endpoint exists when the file is malformed or the runner's own check
(claude auth status, pi auth check with a model-listing fallback) says the
pinned account is not signed in. The check runs in a cleared environment so
an ambient credential cannot answer for an empty root. A pinned Claude launch
sheds the environment credentials Claude ranks above a stored login; a pinned
Pi launch needs an explicit <provider>/<id> model for a declared provider and
also carries --provider. The chosen account is printed on the spawned line and
recorded in the task record, and relaunch checks the pin before stopping the
running agent.

* test(secondmate): give the concurrent config-push wait room for a slow host

test_config_reread_serializes_concurrent_pushes waited about two seconds for
the first fm-config-push.sh to reach its first send-keys. On a slower host
that push takes four to five seconds, so the test failed on main before the
push ever got there. The loop still leaves as soon as the marker appears, so
the larger bound costs nothing where the push is fast.

* no-mistakes(review): Refuse raw Claude account overrides under a pin
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…uid#5358)

* feat(bin): add an opt-in per-home worker account pin

A home that mixes work and personal accounts for one runner had no way to
say which account its workers launch on: Claude workers inherited whatever
CLAUDE_CONFIG_DIR the supervising process had, Pi workers the pane's ambient
root, and an ambient API key outranked both, with no signal at launch.

config/claude-account and config/pi-account now pin that choice per home.
With neither file every launch is unchanged. With one, every launch of that
runner from the home (ship, scout, local secondmate, raw Claude command, and
relaunch) runs under the declared root, and the spawn refuses before any
endpoint exists when the file is malformed or the runner's own check
(claude auth status, pi auth check with a model-listing fallback) says the
pinned account is not signed in. The check runs in a cleared environment so
an ambient credential cannot answer for an empty root. A pinned Claude launch
sheds the environment credentials Claude ranks above a stored login; a pinned
Pi launch needs an explicit <provider>/<id> model for a declared provider and
also carries --provider. The chosen account is printed on the spawned line and
recorded in the task record, and relaunch checks the pin before stopping the
running agent.

* test(secondmate): give the concurrent config-push wait room for a slow host

test_config_reread_serializes_concurrent_pushes waited about two seconds for
the first fm-config-push.sh to reach its first send-keys. On a slower host
that push takes four to five seconds, so the test failed on main before the
push ever got there. The loop still leaves as soon as the marker appears, so
the larger bound costs nothing where the push is fast.

* no-mistakes(review): Refuse raw Claude account overrides under a pin
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 27, 2026
…uid#5358)

* feat(bin): add an opt-in per-home worker account pin

A home that mixes work and personal accounts for one runner had no way to
say which account its workers launch on: Claude workers inherited whatever
CLAUDE_CONFIG_DIR the supervising process had, Pi workers the pane's ambient
root, and an ambient API key outranked both, with no signal at launch.

config/claude-account and config/pi-account now pin that choice per home.
With neither file every launch is unchanged. With one, every launch of that
runner from the home (ship, scout, local secondmate, raw Claude command, and
relaunch) runs under the declared root, and the spawn refuses before any
endpoint exists when the file is malformed or the runner's own check
(claude auth status, pi auth check with a model-listing fallback) says the
pinned account is not signed in. The check runs in a cleared environment so
an ambient credential cannot answer for an empty root. A pinned Claude launch
sheds the environment credentials Claude ranks above a stored login; a pinned
Pi launch needs an explicit <provider>/<id> model for a declared provider and
also carries --provider. The chosen account is printed on the spawned line and
recorded in the task record, and relaunch checks the pin before stopping the
running agent.

* test(secondmate): give the concurrent config-push wait room for a slow host

test_config_reread_serializes_concurrent_pushes waited about two seconds for
the first fm-config-push.sh to reach its first send-keys. On a slower host
that push takes four to five seconds, so the test failed on main before the
push ever got there. The loop still leaves as soon as the marker appears, so
the larger bound costs nothing where the push is fast.

* no-mistakes(review): Refuse raw Claude account overrides under a pin
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 27, 2026
…uid#5358)

* feat(bin): add an opt-in per-home worker account pin

A home that mixes work and personal accounts for one runner had no way to
say which account its workers launch on: Claude workers inherited whatever
CLAUDE_CONFIG_DIR the supervising process had, Pi workers the pane's ambient
root, and an ambient API key outranked both, with no signal at launch.

config/claude-account and config/pi-account now pin that choice per home.
With neither file every launch is unchanged. With one, every launch of that
runner from the home (ship, scout, local secondmate, raw Claude command, and
relaunch) runs under the declared root, and the spawn refuses before any
endpoint exists when the file is malformed or the runner's own check
(claude auth status, pi auth check with a model-listing fallback) says the
pinned account is not signed in. The check runs in a cleared environment so
an ambient credential cannot answer for an empty root. A pinned Claude launch
sheds the environment credentials Claude ranks above a stored login; a pinned
Pi launch needs an explicit <provider>/<id> model for a declared provider and
also carries --provider. The chosen account is printed on the spawned line and
recorded in the task record, and relaunch checks the pin before stopping the
running agent.

* test(secondmate): give the concurrent config-push wait room for a slow host

test_config_reread_serializes_concurrent_pushes waited about two seconds for
the first fm-config-push.sh to reach its first send-keys. On a slower host
that push takes four to five seconds, so the test failed on main before the
push ever got there. The loop still leaves as soon as the marker appears, so
the larger bound costs nothing where the push is fast.

* no-mistakes(review): Refuse raw Claude account overrides under a pin
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 27, 2026
…uid#5358)

* feat(bin): add an opt-in per-home worker account pin

A home that mixes work and personal accounts for one runner had no way to
say which account its workers launch on: Claude workers inherited whatever
CLAUDE_CONFIG_DIR the supervising process had, Pi workers the pane's ambient
root, and an ambient API key outranked both, with no signal at launch.

config/claude-account and config/pi-account now pin that choice per home.
With neither file every launch is unchanged. With one, every launch of that
runner from the home (ship, scout, local secondmate, raw Claude command, and
relaunch) runs under the declared root, and the spawn refuses before any
endpoint exists when the file is malformed or the runner's own check
(claude auth status, pi auth check with a model-listing fallback) says the
pinned account is not signed in. The check runs in a cleared environment so
an ambient credential cannot answer for an empty root. A pinned Claude launch
sheds the environment credentials Claude ranks above a stored login; a pinned
Pi launch needs an explicit <provider>/<id> model for a declared provider and
also carries --provider. The chosen account is printed on the spawned line and
recorded in the task record, and relaunch checks the pin before stopping the
running agent.

* test(secondmate): give the concurrent config-push wait room for a slow host

test_config_reread_serializes_concurrent_pushes waited about two seconds for
the first fm-config-push.sh to reach its first send-keys. On a slower host
that push takes four to five seconds, so the test failed on main before the
push ever got there. The loop still leaves as soon as the marker appears, so
the larger bound costs nothing where the push is fast.

* no-mistakes(review): Refuse raw Claude account overrides under a pin
RooseveltAdvisors pushed a commit to RooseveltAdvisors/firstmate that referenced this pull request Sep 29, 2026
…uid#5358)

* feat(bin): add an opt-in per-home worker account pin

A home that mixes work and personal accounts for one runner had no way to
say which account its workers launch on: Claude workers inherited whatever
CLAUDE_CONFIG_DIR the supervising process had, Pi workers the pane's ambient
root, and an ambient API key outranked both, with no signal at launch.

config/claude-account and config/pi-account now pin that choice per home.
With neither file every launch is unchanged. With one, every launch of that
runner from the home (ship, scout, local secondmate, raw Claude command, and
relaunch) runs under the declared root, and the spawn refuses before any
endpoint exists when the file is malformed or the runner's own check
(claude auth status, pi auth check with a model-listing fallback) says the
pinned account is not signed in. The check runs in a cleared environment so
an ambient credential cannot answer for an empty root. A pinned Claude launch
sheds the environment credentials Claude ranks above a stored login; a pinned
Pi launch needs an explicit <provider>/<id> model for a declared provider and
also carries --provider. The chosen account is printed on the spawned line and
recorded in the task record, and relaunch checks the pin before stopping the
running agent.

* test(secondmate): give the concurrent config-push wait room for a slow host

test_config_reread_serializes_concurrent_pushes waited about two seconds for
the first fm-config-push.sh to reach its first send-keys. On a slower host
that push takes four to five seconds, so the test failed on main before the
push ever got there. The loop still leaves as soon as the marker appears, so
the larger bound costs nothing where the push is fast.

* no-mistakes(review): Refuse raw Claude account overrides under a pin
gkalyan added a commit to gkalyan/firstmate that referenced this pull request Oct 3, 2026
…mbient one

pi_model_validate (fork commit 1e34658) ran against the ambient Pi root
before the independently-added worker account pin (upstream kunchenguid#5358)
resolved which root the launch actually uses. When config/pi-account pins
a launch to a different root, the ambient-root catalog read judged a
catalog the pinned launch never reads from, while fm_worker_account_check
already proves the model's declared provider is listed under the correct
pinned root through its own sign-in check and --list-models fallback.
Skip pi_model_validate when a pin is active; it still guards every
unpinned launch exactly as before.

tests/fm-worker-account.test.sh's two unpinned Pi spawn cases now give
their ambient Pi root a matching --list-models catalog entry, the same
shape pi_model_validate itself reads, instead of relying on an unrelated
fixture that happened to return no rows.