Repository navigation
fix(bin): keep test and lab tmux cleanup off the operator's server - #6703
Open
PabloAraya6 wants to merge 4 commits into
Open
PabloAraya6 wants to merge 4 commits into
PabloAraya6 wants to merge 4 commits into
Conversation
…ux server A suite launched from a worker's pane inherits TMUX naming the server every live worker runs in, and a bare tmux kill-session there takes the whole session. A lab tmux call made after its private directory is gone must refuse instead of letting tmux fall back to /tmp/tmux-<uid>. Both cases fail today.
tests/fm-live-lab.test.sh's exit cleanup ran `TMUX_TMPDIR=<lab dir> tmux kill-server` for every lab it had built, after fm-live-lab.sh down had already removed those private directories. tmux treats a missing or empty TMUX_TMPDIR as absent and falls back to /tmp/tmux-<uid>, so each call killed the operator's default server and every live worker in it. Both fleet-wide crashes landed at that cleanup. bin/fm-lab-home.sh now owns addressing the lab server as well as its directory: `tmux <dir> <args>` names the socket explicitly and refuses while no private directory exists. fm-live-lab.sh, its test, the deep-path lab test, and the herdr-lab brief text use it instead of TMUX_TMPDIR. tests/lib.sh also gives every suite a private TMUX_TMPDIR and drops an inherited TMUX and TMUX_PANE, so a suite started from a worker's pane can no longer reach that pane's server with a bare tmux command.
|
…ndoned tests/lib.sh mints a /tmp/fmt.* tmux socket directory for every suite and releases it from fm_test_cleanup, but a suite that replaces the EXIT trap without calling fm_test_cleanup, such as fm-tmux-submit-busy.test.sh, left that directory behind on every run, and the orphan sweep never looked there. The directory now carries the same ownership marker as a fixture root, and the orphan sweep also scans /tmp/fmt.* and stops any tmux server still listening in a directory before removing it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
«si si es algo que le pasa a todos», en respuesta a: «¿Abro un PR con este arreglo en el firstmate oficial (kunchenguid/firstmate)? Sería público, a tu nombre.»
El arreglo: la limpieza de salida de tests/fm-live-lab.test.sh ejecutaba
tmux kill-servercon su directorio privado de terminales ya borrado; con TMUX_TMPDIR ausente o vacío tmux cae a /tmp/tmux-/default, el servidor real del operador, y lo mata con todas las sesiones de los workers. Pasó dos veces el 2026-10-06 en esta máquina. El fix es local en los commits 2c125285 (test: pin that suites and lab cleanups cannot reach the operator's tmux server) y 9fbc00e8 (fix: never let tests or lab cleanups address the operator's tmux server):bin/fm-lab-home.sh tmux <dir> <args>es el único camino para direccionar el servidor del laboratorio, nombra el socket explícitamente y se niega sin directorio privado; cambian también bin/fm-live-lab.sh, bin/fm-brief.sh, tests/lib.sh y tres tests.What Changed
bin/fm-lab-home.shadds atmux <dir> <args...>subcommand as the single safe way to address a lab's server: it validates the marked lab home, names the private socket explicitly (-S), strips inheritedTMUX/TMUX_PANE, and refuses when no private tmux directory exists.tmux-dirandteardownnow share the same record-validation helper.bin/fm-live-lab.shandbin/fm-brief.shroute every lab tmux call through that subcommand instead ofTMUX_TMPDIR, andtests/lib.shmints each suite a privateTMUX_TMPDIR(unsets inheritedTMUX/TMUX_PANE) with cleanup that kills only servers on its own sockets.Risk Assessment
✅ Low: The change is well-bounded, fail-closed, and covered by behavioral tests: the lab helper names the socket explicitly and refuses without a validated private directory, all in-repo lab/tmux cleanup paths route through it or an explicit -S/-L, and the global tests/lib.sh private TMUX_TMPDIR removes the ambient fallback that caused the original operator-server kill.
Testing
Drove the lab/test tmux-isolation product live: ran the four targeted behavior suites that real-socket tmux servers back, plus an independent manual scenario script and a regression reproduction against a private stand-in operator server. Confirmed the pre-fix
tests/lib.shlets an inheritedTMUXkill the operator server while the fix prevents it, thatfm-lab-home.sh tmuxrefuses once no private directory exists (before tmux-dir and after it is removed) without ever invoking tmux, and that it addresses only the lab's private socket when one exists. The emitted--herdr-labbrief carries the corrected addressing guidance. No rendered UI exists, so no screenshot/HTML artifact applies; CLI transcripts are the reviewer-visible evidence. All scenarios passed and the real operator fleet stayed intact.tmux kill-serverand the operator's tmux server plus all its windows survivesbash tests/fm-test-fixtures.test.sh-> 'ok - a suite that inherits the operator's TMUX cannot address that tmux server' (evidence/01M48NYWAGD5AZF7MXW5TPM6HS/test-fixtures.out); manual-lab-tmux.out s…bin/fm-lab-home.sh tmux <lab> kill-serverrefuses when no private tmux directory exists (before tmux-dir and after it is removed), never invoking tmux, and leaves any operator/inherited server alivebash tests/fm-gate-refuse.test.sh-> 'ok - fm-lab-home tmux reaches only the lab's private server and refuses once no private directory exists'; manual-lab-tmux.out scenarios B (exit=1) and D (priva…bin/fm-lab-home.sh tmux <lab> ...with a private directory reaches only the lab's private socket server even when the caller's TMUX names the operator server, and stopping it leaves the operator ser…has-session/kill-serverreach only the private socket; stand-in operator session still present); manual-lab-tmux.out…bash tests/fm-test-fixture-cleanup.test.sh-> 'ok - the orphan sweep reaps an abandoned private tmux directory and its server' (evidence/01M48NYWAGD5AZF7MXW5TPM6HS/fixture-cleanup.out)bin/fm-live-lab.shdrives its lab tmux server only throughfm-lab-home.sh tmuxon the private socket, with readiness/teardown still workingbash tests/fm-live-lab.test.sh-> 30/30 ok including 'down stops only recorded lab processes...' and 'up launches primary after worker status...' (evidence/01M48NYWAGD5AZF7MXW5TPM6HS/live-lab.out)--herdr-labbrief emits the corrected lab-tmux addressing contract (usefm-lab-home.sh tmux, never address the server throughTMUX_TMPDIRalone)FM_HOME=<tmp> bash bin/fm-brief.sh brief-lab-guidance firstmate --mode no-mistakes --herdr-lab; emitted brief lines at evidence/01M48NYWAGD5AZF7MXW5TPM6HS/brief-lab-tmux-guidance.txtEvidence: Four targeted suites pass (gate-refuse, test-fixtures, fixture-cleanup, live-lab)
Evidence: Independent live drive of fm-lab-home.sh tmux against a stand-in operator server
Source: Independent live drive of fm-lab-home.sh tmux against a stand-in operator server
A. suite inherits operator TMUX, then bare tmux kill-server -> operator server survived B. fm-lab-home.sh tmux with no private dir -> exit=1, operator server intact C. fm-lab-home.sh tmux with private dir -> reached only the lab server, operator intact D. private dir removed then kill-server -> exit=1, operator server intact ALL MANUAL SCENARIOS PASSEDEvidence: Regression reproduction: pre-fix lib.sh kills the inherited server, fixed lib.sh protects it
Source: Regression reproduction: pre-fix lib.sh kills the inherited server, fixed lib.sh protects it
Evidence: Real operator tmux fleet window list, unchanged before/after (18 windows)
Source: Real operator tmux fleet window list, unchanged before/after (18 windows)
Evidence: Emitted --herdr-lab brief lab-tmux addressing guidance
Source: Emitted --herdr-lab brief lab-tmux addressing guidance
Evidence: fm-gate-refuse suite transcript
Source: fm-gate-refuse suite transcript
Evidence: fm-test-fixtures suite transcript
Source: fm-test-fixtures suite transcript
Evidence: fm-test-fixture-cleanup suite transcript
Source: fm-test-fixture-cleanup suite transcript
Evidence: fm-live-lab suite transcript
Source: fm-live-lab suite transcript
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.
tmux kill-serverand the operator's tmux server plus all its windows survivesbash tests/fm-test-fixtures.test.sh-> 'ok - a suite that inherits the operator's TMUX cannot address that tmux server' (evidence/01M48NYWAGD5AZF7MXW5TPM6HS/test-fixtures.out); manual-lab-tmux.out s…bin/fm-lab-home.sh tmux <lab> kill-serverrefuses when no private tmux directory exists (before tmux-dir and after it is removed), never invoking tmux, and leaves any operator/inherited server alivebash tests/fm-gate-refuse.test.sh-> 'ok - fm-lab-home tmux reaches only the lab's private server and refuses once no private directory exists'; manual-lab-tmux.out scenarios B (exit=1) and D (priva…bin/fm-lab-home.sh tmux <lab> ...with a private directory reaches only the lab's private socket server even when the caller's TMUX names the operator server, and stopping it leaves the operator ser…has-session/kill-serverreach only the private socket; stand-in operator session still present); manual-lab-tmux.out…bash tests/fm-test-fixture-cleanup.test.sh-> 'ok - the orphan sweep reaps an abandoned private tmux directory and its server' (evidence/01M48NYWAGD5AZF7MXW5TPM6HS/fixture-cleanup.out)bin/fm-live-lab.shdrives its lab tmux server only throughfm-lab-home.sh tmuxon the private socket, with readiness/teardown still workingbash tests/fm-live-lab.test.sh-> 30/30 ok including 'down stops only recorded lab processes...' and 'up launches primary after worker status...' (evidence/01M48NYWAGD5AZF7MXW5TPM6HS/live-lab.out)--herdr-labbrief emits the corrected lab-tmux addressing contract (usefm-lab-home.sh tmux, never address the server throughTMUX_TMPDIRalone)FM_HOME=<tmp> bash bin/fm-brief.sh brief-lab-guidance firstmate --mode no-mistakes --herdr-lab; emitted brief lines at evidence/01M48NYWAGD5AZF7MXW5TPM6HS/brief-lab-tmux-guidance.txtbash tests/fm-gate-refuse.test.sh(includes newtest_lab_home_tmux_reaches_only_the_private_server)bash tests/fm-test-fixtures.test.sh(includes newtest_suite_cannot_reach_inherited_tmux_server)bash tests/fm-test-fixture-cleanup.test.sh(includes newtest_orphan_sweep_reaps_abandoned_tmux_dir)bash tests/fm-live-lab.test.sh(lab_tmux now driven throughbin/fm-lab-home.sh tmux)bash manual-lab-tmux-scenario.shindependent live drive ofbin/fm-lab-home.sh tmuxagainst a private stand-in operator serverbash regression-repro.shbaseline (pre-fix lib.sh) vs fixed lib.sh kill-server behaviorbin/fm-brief.sh brief-lab-guidance firstmate --mode no-mistakes --herdr-labemitted brief inspectionoperator tmux fleet window-list snapshot before/after every scenario (tmux list-windows -t firstmate)tmux server lifecycle verified withtmux -S <stand-in socket> has-sessionandtmux list-sessions✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.