Repository navigation
feat(bin): opt-in per-home Claude and Pi worker account pin - #5358
kunchenguid merged 4 commits into
Conversation
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.
…-account-pin # Conflicts: # bin/fm-spawn.sh
|
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. VISION (per-rule):
Attestation: MATCH — body Squash merge |
…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
…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
…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
…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
…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
…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
…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
…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.
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
bin/fm-worker-account-lib.sh, which reads the optional local filesconfig/claude-accountandconfig/pi-account.config/claude-accountholdsordinaryor one absolute config root.config/pi-accountholds a root plus the providers the home may spend. The library checks sign-in by asking the runner itself (claude auth status, orpi auth check, falling back topi --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.shresolves the pin before any endpoint, worktree, or record exists.CLAUDE_CONFIG_DIRto the pinned root, or unsets it forordinary. It also unsets the environment credentials Claude ranks above a stored login, such asANTHROPIC_API_KEYandCLAUDE_CODE_OAUTH_TOKEN.PI_CODING_AGENT_DIR, requires--model <provider>/<id>naming a declared provider, and adds--provider.CLAUDE_CONFIG_DIRor one of those credentials refuses, and so does any raw Pi command.account=and Pi'saccount_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.shchecks 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, andbin/fm-test-run.shregisters 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).
Evidence: Claude pin spawn transcript (real fm-spawn + real claude, faked tmux)
Source: Claude pin spawn transcript (real fm-spawn + real claude, faked tmux)
Evidence: Pi pin spawn transcript (real fm-spawn + real pi, faked tmux)
Source: Pi pin spawn transcript (real fm-spawn + real pi, faked tmux)
Evidence: Live runner sign-in guard log
Source: Live runner sign-in guard log
Evidence: Relaunch suite log (pin cases pass; unrelated tasks-axi failure)
Source: Relaunch suite log (pin cases pass; unrelated tasks-axi failure)
Evidence: Signed-out pin refusal
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
⏭️ **Rebase** - skipped
Step was skipped.
✅ **Review** - passed
✅ No issues found.
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.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 overridebash $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.