Repository navigation
fix(bin): address lab tmux servers by explicit socket so cleanup never hits the default server - #6902
mitchellderijcke wants to merge 1 commit into
Conversation
…ivate dir never falls back to the default server
|
Speaking as Kun's firstmate: thanks @mitchellderijcke, and sorry this bit the fleet. A missing I compared head What I checked: CI: this is a fork contribution whose runs were waiting on approval. I reviewed the diff first: lab scripts, brief text, and tests, with no workflow, secret, or network surface. Then I approved CI Contract-class: restore. VISION.md, rule by rule
Next step: waiting on CI only. Nothing is waiting on you or on Kun. If CI and no-mistakes come back fully green and the PR is still mergeable, I'll merge it on the next pass. |
|
I can confirm this on tmux 3.7b, and it bit us twice in one day on one machine. In a
|
|
Speaking as Kun's firstmate: thanks for the fresh confirmation, @LiamSarsfield — that matches the tip here, and it is a different bug from #1130 (that one is Re-check (tip CI: run Next: still nothing waiting on you. Auto-merge remains the path once serial 2 is green; if the ceiling keeps cancelling it, it falls under Firstmate's existing #7255 land-despite / raise-limit question rather than a new captain card for this PR alone. |
Intent
A firstmate test run wiped the shared tmux session that hosts every worker, stopping the whole fleet (2026-10-08 ~21:11). Cause found by the worker that ran it, with evidence in ~/Projects/OSS/firstmate/data/fm-startup-summary/tmux-kill-evidence.md: tests/fm-live-lab.test.sh cleanup (live_lab_cleanup, around line 26-30) runs
env -u TMUX TMUX_TMPDIR="$dir" tmux kill-serverfor lab socket dirs, some of whichfm-live-lab.sh downalready removed; tmux 3.6a ignores a TMUX_TMPDIR that does not exist and falls back to /tmp, so kill-server hits the default server. Fix it so no test or lab helper can ever address the default tmux server.The PR description must include this note, in plain words and without addressing anyone: this change was authored by Claude via Firstmate and has not been reviewed by a human, but it fixes a real bug hit in practice (live-lab test cleanup killed the default tmux server and the whole fleet with it).
What Changed
bin/fm-live-lab.shnow sends every lab tmux call, including the initialnew-session, to an explicit socket (tmux -S "$TMUX_DIR/tmux-<uid>/default") through a newlab_sockethelper. The helper refuses to return a socket when the private directory is missing. Before this, tmux treated a missingTMUX_TMPDIRas unset and fell back to/tmp, which is the user's default server.tests/fm-live-lab.test.shcleanup skips directories that are already gone, and itslab_tmuxhelper fails if the lab directory has been removed.tests/fm-gate-refuse.test.shstops the deep-path lab server with-S "$socket_path". Thefm-brief.shinstructions and thefm-lab-home.shheader now tell lab callers to kill their server withtmux -S ... kill-serverand not throughTMUX_TMPDIRalone.fm-live-lab.sh downon a lab whose tmux directory has been deleted. A tmux shim records any call that would fall back to the default server and sends it to a sentinel server instead. The test asserts that no fallback call happened and that the sentinel server is still running.This change was written by Claude via Firstmate and no human has reviewed it yet. It fixes a real bug that happened in practice: the live-lab test cleanup killed the default tmux server, and the whole fleet went down with it.
🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is small and focused: every lab tmux call in fm-live-lab.sh and the live-lab test helpers now names the socket explicitly with -S, or is skipped when the private directory is gone, so the default-server fallback can't be reached; a behavioral shim test reproduces the original failure.
Testing
I first reproduced the root cause on tmux 3.6a without touching the real default server. A removed TMUX_TMPDIR silently reached a /tmp probe server, while the new explicit
-Saddress failed with "No such file". The patched fm-live-lab and fm-gate-refuse tests both passed. Run against the pre-fix fm-live-lab.sh, the new regression test failed: the olddownsentkill-serverthrough the fallback, which the shim caught. I brought up a real Claude live lab withfm-live-lab.sh up; the primary answered its readiness probe, thencheckanddownsucceeded, and a repeateddownwas refused cleanly. I also ran the brief's cleanup recipe twice, the second time after its directory was removed. The real default tmux server kept the same pid through every step, and no temp dirs or worktree changes were left behind.downwith an already-removed private dir never touch the default serverfm-live-lab.sh up --harness claudestarts a lab on its private explicit socket; check and down work, and a repeated down is refused cleanlybash tests/fm-gate-refuse.test.shEvidence: tmux fallback repro and explicit-socket safety
Source: tmux fallback repro and explicit-socket safety
Evidence: fm-live-lab test run (patched)
Source: fm-live-lab test run (patched)
Evidence: Fail-before: new regression test against pre-fix fm-live-lab.sh
Source: Fail-before: new regression test against pre-fix fm-live-lab.sh
Evidence: Live Claude lab up
Source: Live Claude lab up
Evidence: Live lab check/pane/down/second down
Source: Live lab check/pane/down/second down
Evidence: Brief cleanup recipe, run twice
Source: Brief cleanup recipe, run twice
Evidence: Default server identity before/after
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
downwith an already-removed private dir never touch the default serverfm-live-lab.sh up --harness claudestarts a lab on its private explicit socket; check and down work, and a repeated down is refused cleanlybash tests/fm-gate-refuse.test.shRead-onlytmux -S /tmp/tmux-501/default display-message -p '#{pid}...', run before and after every step, to confirm the fleet server survivedRoot-cause repro with a uniquely labelled probe server in /tmp:TMUX_TMPDIR=<removed dir> tmux -L <label> has-sessionvstmux -S <removed dir>/tmux-501/<label> kill-serverbash tests/fm-live-lab.test.sh(includes the new removed-directory regression)Fail-before check: new tests/fm-live-lab.test.sh run against the pre-fix bin/fm-live-lab.sh (19fcbbd) in a /tmp git-archive copy, with a guard tmux shim that blocks any fallbackbash tests/fm-gate-refuse.test.sh(fm-lab-home private-socket deep-path test)Livebin/fm-live-lab.sh up --harness claude --supervision-host none --expect-host no, thencheck,pane,down, and a seconddownon the removed labRan the brief's EXIT-trap recipe on a disposable lab home (fm-lab-home create/tmux-dir,tmux -S $LAB_TMUX_DIR/tmux-$(id -u)/default kill-server, teardown), then ran it again after the directory was gone✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.