Repository navigation
fix/no-ticket(bin): keep ship and scout relaunches on their recorded worker account - #5498
max-metaplanet wants to merge 12 commits into
Conversation
A home's worker account pin selects the directory a Claude or Pi worker's whole session lives in. It was resolved at spawn and recorded on the task as account=, then resolved again at relaunch from the home's current file, with no notion of the account the task already ran on. A pin changed between spawn and relaunch - for any reason, including one unrelated to that task - silently moved the task to the new account and rewrote its record, leaving the outgoing worker's session state unreachable under the previous root. A task now stays on the account it was launched on. One shared check, fm_worker_account_relaunch_guard, refuses a relaunch whose current pin selects a different account directory, naming the recorded account, the account the pin now selects, and both ways forward. It serves both relaunch paths and every pinnable runner, and runs before the sign-in check so the move is reported as itself. The same account, no recorded account, a relaunch onto a harness reading the other pin file, and a home with no pin all relaunch as before; the same directory named another way is compared physically, not textually. This changes documented default behaviour: docs/configuration.md and the test that pinned the follow-the-current-file relaunch are updated. Closes kunchenguid#5479
Resolve the branch against upstream main, which has since landed per-secondmate account pins (kunchenguid#7452): fm_worker_account_resolve now takes a setting label and fm_worker_account_select takes a secondmate id, and the AGENTS.md home layout listing moved into the operational-home-layout skill. Scope the relaunch account guard to ships and scouts. A secondmate replacement reconciles its own home's durable records at startup rather than continuing the outgoing agent's conversation, so there is no session state for an account move to orphan, and re-reading the pin stays how a per-secondmate account change is applied.
|
Speaking as Kun's firstmate: thank you @max-metaplanet, and sorry it took this long to get a proper look. Merging main back in today and re-raising through no-mistakes was really helpful. What I checked at head Contract-class: new-default. Today, homes that pin VISION:
One product point for the captain: secondmates are exempt and still re-read the pin (no-mistakes raised this too). Your reasoning is documented, and I'll include it when I present this. CI: this head's run (20:18Z) ran on the old ubuntu-26.04 image before main's runner pin. Serials 1, 3–7 and 9 failed and serials 2 and 8 were cancelled, all in the same watcher, timeout and remote-lifecycle tests main fails on 26.04. None of them are in the files you touched. Main's own CI is still red on our side, so this is waiting on our CI, not on you. Once main is green and this head has a green run, I'll put it to the captain as a merge-or-leave decision. |
|
Speaking as Kun's firstmate: a short update, @max-metaplanet. Nothing here needs anything from you. Main's CI is green again (green at |
|
Speaking as Kun's firstmate: a short update, @max-metaplanet. Nothing here needs anything from you. I closed and reopened this PR only to get a fresh CI run on current main ( |
[Low impact] The PR appears safe to merge; all three previous findings are addressed. Reviews (2) · Last reviewed commit: "fix/no-ticket(accounts): merge upstream ..." · Reviewed by Greptile |
|
Speaking as Kun's firstmate: thanks @max-metaplanet. The fresh run on current main is in. CI 40828588860 is green and the no-mistakes attestation still binds Greptile re-reviewed on the reopen (2/5) and left three P1s on the relaunch guard. I read them against the diff. They're gaps in the guarantee this PR adds, so this is waiting on you:
After that, please re-raise with |
|
Speaking as Kun's firstmate: thank you @max-metaplanet, this round answers all three points from my last note. What I checked (head
Greptile re-reviewed at 5/5 and no review threads are open. No-mistakes binds this head. Live validation is go (4 of 7). The open live gap is the real Pi replacement, since there's no Contract-class (my own read): new-default, unchanged. Homes that pin an account used to follow the current pin file on relaunch. Now they get a refusal, or keep the recorded account. VISION: One captain aligns (the refusal names both accounts and both ways forward). Authority aligns: a task isn't silently moved to another account, which strengthens a refusal path. Scripts aligns (deterministic guard). Restart aligns (the recorded account in the durable task record is carried forward). Delegation aligns (the outgoing worker's session state isn't stranded). Vendor aligns (Claude and Pi handled the same way; account choice stays with the captain). Scope aligns. Next step is ours, not yours. The "Full suite" check fails here only because outside PRs now need a maintainer |
|
Speaking as Kun's firstmate: thanks @max-metaplanet. The first full-suite run on head Nothing else has changed. The no-mistakes attestation still binds this head, and contract-class is still new-default. This is waiting on our CI, not on you. If the fresh run passes, it goes to the captain for a merge-or-leave call. |
|
Speaking as Kun's firstmate: thanks @max-metaplanet. The fresh full suite on head I've removed and re-added the |
|
Speaking as Kun's firstmate: thanks @max-metaplanet. The third full-suite run on head Every gate is green, so this is now with the captain for the merge decision. It is not waiting on you. The reason it needs the captain: on homes with a pinned account, a ship/scout relaunch now keeps the recorded worker account (or refuses) instead of following the current pin. That's a change to the default relaunch behaviour. |
Intent
Fix the three review gaps the upstream maintainer raised on #5498 (relaunch refuses or keeps the recorded worker account when the account pin changed), with a test that relaunches twice, and re-raise the existing PR through the no-mistakes pipeline as one push. Never merge upstream.
The maintainer's review (head 998f9c7, contract-class new-default) names three gaps in the guarantee the PR adds:
What Changed
fm_worker_account_relaunch_guardtobin/fm-worker-account-lib.sh. When a ship or scout recorded anaccount=at launch, it refuses the relaunch if the current Claude or Pi pin, or its removal, now selects a different account directory. Paths are compared physically. The refusal names the recorded account, the account now selected, and both ways forward. Secondmates, tasks with no recorded account, and relaunches onto a harness that reads the other pin file go through unchanged.fm_worker_account_selectnow takes the relaunch id plus the recorded harness, account and provider, and runs the guard on the same resolved selection it launches with. With no pin, it carries the recorded account forward after existence and sign-in checks, using the recordedaccount_providerwhen the Pi model doesn't name one. That way a second relaunch is still guarded. An unpinned Pi replacement now launches on its recorded root rather than the caller's or destination pane'sPI_CODING_AGENT_DIR.bin/fm-control.sh(before the old agent stops) andbin/fm-spawn.sh --relaunchboth pass the task record into this single selection.docs/configuration.md,docs/agent-control.md, the operational-home-layout skill and the script headers to describe the new relaunch rule. Added relaunch tests: pin moved, pin removed, never pinned, two relaunches after unpinning, a missing recorded root refused before stop, a Pi pane-environment case, and spawn using the same selection it checks. Also added guard unit tests intests/fm-worker-account.test.sh.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change makes the three narrow fixes the maintainer asked for. (1) An unpinned relaunch on the same account now carries the recorded account forward, and the carried account gets the existence and sign-in checks the user approved. (2) An unpinned Pi relaunch now names the recorded root explicitly, so neither the caller's environment nor the destination pane's can change the account. (3) The guard now runs inside fm_worker_account_select on the exact pin value the launch then uses. I traced the Claude, Pi, pi-signed, ordinary, secondmate and harness-switch paths through fm-control (before the old agent stops) and fm-spawn --relaunch and found no wrong result. New tests cover each path end to end, including the two-relaunch case and a pin rewritten right after it is read. The merge commits from upstream follow the recorded rebase decisions.
Testing
Checked that the published commit 998f9c7 is an ancestor of the candidate. Ran the worker-account suite (all passed) and the 11 relaunch account tests on HEAD (all passed). The full relaunch suite stops early at a concurrency race test that fails identically on the base commit, so it is an existing environment issue, not this change. Then I stood up a disposable lab home with a real signed-in claude agent on a private tmux socket and drove real fm-control/fm-spawn relaunches. An unpinned same-account relaunch kept account= and launched the replacement with CLAUDE_CONFIG_DIR set to the recorded account root. A later pin to a different account refused before stop with the agent PID and record unchanged. A no-pin relaunch under a different ambient account refused with the reworded message. A pin moved immediately after the launch owner's single read still launched on the guarded account. Pi could not run live because no pi binary is installed; its hermetic stubbed test passed. The lab was torn down. The result is go.
pibinary is on PATH and there is no repository-local copy, so a real Pi replacement could not be launched. Only the hermetic suite with a stub executable ran (test_unpinned_pi_relaunch_keeps_the…Evidence: Live relaunch 1: unpinned same-account relaunch carries account= forward
Source: Live relaunch 1: unpinned same-account relaunch carries account= forward
Evidence: Live relaunch 2: later pin to a different account refuses before stop
Source: Live relaunch 2: later pin to a different account refuses before stop
error: task acct1 was launched on account <seat>, but config/claude-account now selects account <lab>/acct-b; relaunching would move the task ... exit=1 agent pid before=1220467 after=1220467 task record unchangedEvidence: Live: no pin with a different ambient account refuses with the reworded message
Source: Live: no pin with a different ambient account refuses with the reworded message
Evidence: Live: pin rewritten after the single read still launches on the guarded selection
Source: Live: pin rewritten after the single read still launches on the guarded selection
Evidence: Replacement claude pane after relaunch 4
Source: Replacement claude pane after relaunch 4
Evidence: Relaunch account subset on HEAD (11/11 ok)
Source: Relaunch account subset on HEAD (11/11 ok)
Evidence: Worker-account suite
Source: Worker-account suite
Evidence: Race test also fails on base c9da552
Source: Race test also fails on base c9da5523
~/.no-mistakes/evidence/01M647JHD6VEERHQ8M5GX70900/scripts)Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
🔧 **Rebase** - 7 issues found → auto-fixed ✅
bin/fm-control.sh- merge conflict rebasing onto origin/mainbin/fm-spawn.sh- merge conflict rebasing onto origin/mainbin/fm-worker-account-lib.sh- merge conflict rebasing onto origin/maindocs/agent-control.md- merge conflict rebasing onto origin/maindocs/configuration.md- merge conflict rebasing onto origin/maintests/fm-control-relaunch.test.sh- merge conflict rebasing onto origin/maintests/fm-worker-account.test.sh- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Review** - passed
✅ No issues found.
tests/fm-control-relaunch.test.sh:493- test_relaunch_serializes_concurrent_durable_metadata_publication fails with 'relaunch did not reach trace delivery' on this host, so the full relaunch suite stops after 3 tests. It fails the same way on base c9da552 (race-test.base.log), so this change did not cause it. The host load average was around 40, and that test waits only 5s, which is a likely cause. CI owns the full-suite result.pibinary is on PATH and there is no repository-local copy, so a real Pi replacement could not be launched. Only the hermetic suite with a stub executable ran (test_unpinned_pi_relaunch_keeps_the…git merge-base --is-ancestor 998f9c7d55a221175f1bf4f76043548719717838 HEAD(ANCESTOR_OK)bash tests/fm-worker-account.test.sh(all passed, exit 0)bash tests/fm-control-relaunch.test.sh(stopped at test_relaunch_serializes_concurrent_durable_metadata_publication; run twice)Same race test alone on a clone of base c9da5523 (fails the same way)Targeted relaunch account subset on HEAD: test_signed_out_worker_account_pin_refuses_before_stop, test_worker_account_pin_moved_since_the_launch_refuses, test_worker_account_pin_on_the_recorded_account_relaunches, test_worker_account_pin_removed_refuses, test_worker_account_never_pinned_relaunches_unchanged, test_worker_account_survives_two_relaunches_after_unpinning, test_unpinned_relaunch_refuses_a_missing_recorded_root_before_stop, test_unpinned_pi_relaunch_keeps_the_recorded_root_in_a_different_pane_environment, test_spawn_relaunch_checks_the_same_pin_selection_it_launches, test_secondmate_account_pin_follows_relaunch_and_refuses_before_stop, test_same_harness_relaunch_keeps_identity_and_reuses_the_endpoint (11/11 ok)Live lab (bin/fm-lab-home.sh home,tmux -L fm-lab, realclaude):bin/fm-control.sh acct1 relaunchunpinned with the same ambient account, then with config/claude-account set to a different rootLive lab: relaunch with no pin and a different ambient CLAUDE_CONFIG_DIRLive lab: relaunch with a PATH perl shim that rewrites config/claude-account right after the launch owner's read; checked the pin read count, record, and the replacement process's /proc environ✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.