Repository navigation
Conversation
…ved override dirs
The lifecycle-hook assertions search for literal `$FM_ROOT`/`$SCRIPT_DIR` text, so annotate them with the SC2016 rationale, and the settle loop never reads its counter, so bind it to `_`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
lmansf
force-pushed
the
fm/crew-panes-gate-h4-r1
branch
from
August 3, 2026 05:12
9a5d792 to
e21076b
Compare
Owner
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#1189 at |
Owner
|
Speaking as Kun's firstmate: closing this as stale. It has been waiting on a contributor update for 14+ days with no author push or comment. Reopen if you want to pick it back up. |
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
Publish the zellij supervisor pane feature: push branch fm/crew-panes-gate-h4-r1, open the PR, and continue through CI.
What Changed
bin/backends/zellij.shgains a display-only supervisor surface:fm_backend_zellij_supervisor_reconcilebuilds onefm-supervisor-<home-label>tab per home with anfm-<id>pane for each active non-secondmate zellij crew, closes the tab when no such crew remains, and re-resolves the tab by name whennew-tabreports no id (closing supervisor-titled tabs it cannot pin to exactly one). Pane commands travel through an explicitenvallow-list that forwards the caller-resolvedFM_STATE_OVERRIDE/FM_DATA_OVERRIDE/FM_PROJECTS_OVERRIDE/FM_CONFIG_OVERRIDEso discovery and rendering read the same home.bin/fm-supervisor-panes.sh(discover zellij crews for the current session, then reconcile) andbin/fm-supervisor-pane-loop.sh(render header, run state, and boundedfm-peek.shoutput until the task metadata disappears, peeking withFM_GUARD_READ_ONLY=1). The loop keeps two cadences — cheap redraw/peek onFM_SUPERVISOR_REFRESH_SECSand the expensivefm-crew-state.shlookup onFM_SUPERVISOR_STATE_REFRESH_SECS, each stamped with its own timestamp. Reconcile is wired best-effort intofm-spawn.sh,fm-teardown.sh, and the locked path offm-session-start.sh; it no-ops for every other backend.FM_SUPERVISOR_REFRESH_SECS/FM_SUPERVISOR_STATE_REFRESH_SECS/FM_SUPERVISOR_PEEK_LINESknobs indocs/zellij-backend.md,docs/configuration.md,docs/scripts.md,docs/architecture.md, and the runtime-backends verification log; addedtests/fm-supervisor-panes.test.shplus new reconcile, tab-id recovery, and real-zellij smoke assertions in the existing zellij test suites.Risk Assessment
✅ Low: The final delta is a small, self-consistent display fix - the run-state stamp is captured in the same block that refreshes the line it labels, docs match the rendered output exactly, and the new test asserts the real cached-stamp invariant - on top of a feature that stays confined to the explicit-only zellij backend behind failure-tolerant lifecycle hooks.
Testing
Exercised the zellij supervisor pane feature end-to-end against a real zellij 0.44.3 server plus the three targeted automated suites, focusing on the hardening the previous round asked for. The unit and real-zellij smoke suites pass, including the new tests that cover the silent-new-tab recovery and the new smoke assertions that pin its root cause. The key evidence is a deterministic reproduction of the round-1 race run against both the pre-fix adapter and this branch: pre-fix leaves a silently broken partial supervisor tab (exit=1, one pane titled with the raw
env ...command, no pane for the still-active crew), while this branch recovers the tab id by name and produces a correct tab withfm-alphaandfm-bravopanes and live supervisor output, at exit=0. Reviewer-visible visual evidence is a PNG of a real attached zellij client showing both outcomes side by side. The happy-path lifecycle is unregressed and the failure did not recur across 21 race runs; one run left only a cosmetic stale pane title that the next reconcile heals, recorded as an informational note. The pre-existing fm-session-start tangle-diagnostic failure is unchanged and treated as unrelated per the author's instruction./tmp/no-mistakes-evidence/01KYMB64GSBTCNWNZ0W4PGW17D/torn-down-seed-race.png)Evidence: Rendered HTML version of the same before/after comparison
Evidence: Reconcile transcript under the race: pre-fix (2e51b48) vs this branch (842930f)
$ fm_backend_zellij_supervisor_reconcile <session> alpha bravo # with alpha.meta removed under it --- BEFORE (2e51b48, parent of the fix) --- exit=1 stderr: error: zellij supervisor tab did not return a numeric tab id for 'fm-supervisor-firstmate-81bfa1e2' (got '') tab 3 pane 3 title=env FM_ROOT_OVERRIDE=... bash .../bin/fm-supervisor-pane-loop.sh alpha RESULT(before): BROKEN - partial supervisor tab left behind (raw-command pane=1, fm-bravo panes=0) --- AFTER (842930f, this branch) --- exit=0 stderr: (none) tab 3 pane 3 title=fm-alpha tab 3 pane 4 title=fm-bravo RESULT(after): OK - no raw-command pane, and the surviving crew bravo has its supervisor paneEvidence: Real-zellij smoke assertions pinning the new-tab contract the recovery rests on
Evidence: Full pre-fix race run log (adapter pinned to 2e51b48)
Evidence: Full this-branch race run log
/tmp/no-mistakes-evidence/01KYMB64GSBTCNWNZ0W4PGW17D/supervisor-e2e-happy-path-at-head.log)Evidence: Race repeat stability, batches 1 and 2
/tmp/no-mistakes-evidence/01KYMB64GSBTCNWNZ0W4PGW17D/seed-rename-residual.log) - Evidence: Race reproduction harness (runs either adapter, captures a real attached client) (local file:/tmp/no-mistakes-evidence/01KYMB64GSBTCNWNZ0W4PGW17D/torn-down-seed-e2e.sh) - Outcome:Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 5 issues found → auto-fixed (2) ✅
bin/fm-supervisor-pane-loop.sh:31- The 5s default refresh makes each supervisor pane do heavy work continuously. Every cycle calls fm-crew-state.sh, which for kind=ship runsno-mistakes axi statusinside the crew worktree with a 10s timeout (bin/fm-crew-state.sh:459) plus severalgit rev-parse/merge-basecalls and a backend busy probe, and then fm-peek.sh, which runs fm-guard.sh (more git) and a zellijdump-screencapture. That is roughly 2 no-mistakes CLI invocations plus ~6 git and 2 dump-screen calls per crew per 5 seconds, indefinitely, and it keeps running even when no zellij client is attached (the docs themselves note a headless session reports no active tab). With a fleet of N crews this is ~12N no-mistakes invocations per minute against the same pipeline CLI the crews are validating with. Consider a much larger default (15-30s), or skipping the expensive run-state lookup on most cycles, rather than the peek-only path.bin/backends/zellij.sh:387- The pane env allow-list hardcodes FM_STATE_OVERRIDE=$FM_HOME/state (and the data/projects/config equivalents) instead of forwarding the values the caller actually resolved. bin/fm-supervisor-panes.sh:8 discovers task ids from ${FM_STATE_OVERRIDE:-$FM_HOME/state}, so when FM_STATE_OVERRIDE points anywhere other than $FM_HOME/state the reconciler builds panes for ids it found in the override dir while each pane loop looks for $FM_HOME/state/<id>.meta, fails thewhile [ -f "$META" ]guard on the first iteration, and exits; with --close-on-exit every pane closes the instant it is created, leaving an empty (or immediately drained) supervisor tab. Forward${FM_STATE_OVERRIDE:-$FM_HOME/state}etc. so discovery and rendering always agree. Only reachable in override-based harnesses today, which is why this is info rather than a blocker.bin/backends/zellij.sh:135- The pane-id shape validation added by commit 8299614 aborts reconcile with a specific stderr message, but all three call sites redirect stderr to /dev/null and swallow the exit status (bin/fm-spawn.sh:1543, bin/fm-teardown.sh:1235, bin/fm-session-start.sh:308). In production a new-pane that echoes something other than terminal_<id> therefore leaves a partially built supervisor tab (seed pane only, remaining crews silently absent) with no diagnostic anywhere; the validation is only observable from the tests. The tab is rebuilt on the next lifecycle event, so this is a diagnosability note rather than a defect - worth knowing if the tab is ever reported as incomplete.bin/backends/zellij.sh:424- Reconcile always closes the existing supervisor tab and recreates it from scratch, even when the active crew set is unchanged - e.g. spawning a tmux crew in a home that also has zellij crews, or the fm-session-start.sh locked path. Every rebuild restarts all pane loops and triggers a synchronized burst of per-crewno-mistakes axi status/ git / dump-screen calls, and discards whatever the operator had on screen. An early exit when the live pane titles already equal the expected fm-<id> set would make the common case a no-op. Deliberate simplicity tradeoff, noted rather than blocking.bin/backends/zellij.sh:436- Reconcile takes no lock, and zellij does not enforce unique tab names (documented at bin/backends/zellij.sh:312). Two overlapping lifecycle events (e.g. a watcher-driven teardown while an agent spawns) can both read list-tabs before either creates its tab, and each then creates its ownfm-supervisor-<hometag>tab with a full pane set - transiently doubling the supervisor tabs and the background pane-loop load. It self-heals on the next reconcile, since tabs_by_name closes every tab matching the name, so this is a transient-state note.🔧 Fix: split supervisor pane cadences and forward resolved override dirs
2 infos still open:
bin/fm-supervisor-pane-loop.sh:97- The pane prints a freshly-computedObserved: <now>line immediately above the run-state line, but after the cadence split that state line can be up to STATE_REFRESH_SECS (60s by default) old while the timestamp and the peek output below it are current. A reader naturally attributes the one timestamp to everything under it, so a crew that parked or hit needs-decision 50 seconds ago still reads asstate: workingunder a timestamp that says now. Cheap fix: stamp the state line when it is actually refreshed (capturedateinside theifblock at line 58 and render it with the line, e.g.… (as of HH:MM:SS)), or rewordObserved:so it clearly labels the peek only. Display wording is user-facing, so flagging rather than fixing.tests/fm-supervisor-panes.test.sh:155- The new cadence test runs the real loop in the background and asserts against wall clock: with FM_SUPERVISOR_REFRESH_SECS=1 it sleeps 3s and requires at least 2 peek calls (expected 3-4) and, in the second pass, at least 2 state calls. The exactstates = 1assertion is structurally deterministic (STATE_REFRESH=3600), but the-ge 2assertions have only ~1.5-2x headroom, so a heavily loaded runner could flake. It also adds roughly 6-16s of wall clock to the portable-serial lane across the two invocations. Acceptable as written - noted so the shape is a known suspect if this test ever goes intermittent.🔧 Fix: stamp supervisor run-state line separately from redraw
✅ Re-checked - no issues remain.
bin/backends/zellij.sh:434- Intermittent supervisor-tab reconcile failure observed once in 10 real-zellij reconcile cycles:zellij action new-tabechoed an empty tab id, so fm_backend_zellij_supervisor_reconcile printed "supervisor tab did not return a numeric tab id" and returned 1 before renaming the seed pane or creating the remaining panes. Because every call site runs the reconciler as>/dev/null 2>&1 || true, the captain sees no error - only a supervisor tab whose seed pane is titled with the rawenv FM_ROOT_OVERRIDE=... bash .../fm-supervisor-pane-loop.sh alphacommand line and no pane for the other active crew, until the next spawn/teardown/session-start reconcile heals it. Not reproducible on demand (9 subsequent cycles, including a dedicated 5-round teardown-race probe, were clean); it appeared under first-run cold-start load while two pane loops were doing real fm-crew-state/fm-peek work. Evidence: /tmp/no-mistakes-evidence/01KYMB64GSBTCNWNZ0W4PGW17D/observed-intermittent-reconcile-failure.log. Whether to add a retry/second-chance lookup for the tab id is a product call, not a test fix.tests/fm-session-start.test.sh:629- tests/fm-session-start.test.sh fails on "read-only bootstrap did not surface the tangle diagnostic". This is pre-existing and unrelated to this branch: the identical assertion fails when the same test is run from a clean export of base commit fa0d85d. Noting it so the failure is not attributed to the supervisor-pane change.bin/fm-test-run.sh tests/fm-supervisor-panes.test.sh tests/fm-backend-zellij.test.sh tests/fm-backend-zellij-smoke.test.sh(all pass, including the real-zellij smoke)bin/fm-test-run.sh tests/fm-session-start.test.sh tests/fm-teardown.test.sh(teardown passes; session-start's read-only tangle case fails)Re-ranbin/fm-test-run.sh tests/fm-session-start.test.shfrom a cleangit archive fa0d85dexport to confirm that failure is pre-existingManual end-to-end:supervisor-e2e.shagainst a live zellij 0.44.3 server on an isolated session - two real crew tabs viafm_backend_zellij_create_task, metas written, thenbin/fm-supervisor-panes.shzellij action list-tabs --json/list-panes --jsonto verify thefm-supervisor-<hometag>tab and itsfm-alpha/fm-bravopane titles, and that secondmate and tmux crews were excludedzellij action dump-screen --pane-id <id> --fullon each supervisor pane to read the live rendered panel (header, kind/backend/project, run-state line, crew peek output)Attached a real zellij client on a 150x44 pty (pty_capture.py) and captured the composed supervisor tab screen, rendered tosupervisor-tab-screenshot.pngCadence check: three timeddump-screenprobes showingPeek observedadvancing every ~3s while the cachedrun state as ofstamp held for the 30s state intervalLifecycle checks: removed one crew meta then reconciled (tab rebuilt with onlyfm-alpha), removed the last meta then reconciled (supervisor tab removed)probe-teardown-race.sh(5 rounds) andprobe-newtab-after-close.sh(5 rounds) to test the reproducibility of the one observed reconcile failure🔧 Fix: recover supervisor tab id when zellij new-tab prints none
1 info still open:
bin/backends/zellij.sh:528- Residual observed once in 21 real-zellij race runs: after the recovery path re-resolves the tab id, the best-effort seed-pane rename occasionally does not land, leaving that one pane titled with the rawenv ... fm-supervisor-pane-loop.sh <id>command. This is materially smaller than the round-1 finding and does not reproduce it: reconcile still returned exit=0, and the still-active crew's pane (fm-bravo) WAS built, so no live crew loses its supervisor pane. The stale title belongs to the crew that was already torn down, and a dedicated 8-round probe (seed-rename-residual.log) shows the next lifecycle reconcile rebuilds the tab cleanly. The rename is deliberately best-effort and documented as such in the adapter ("Cosmetic, so it is best-effort: a missing pane id or a failed rename never fails reconcile"), so this is informational - noting the observed frequency, not asking for a change before publishing. Evidence: /tmp/no-mistakes-evidence/01KYMB64GSBTCNWNZ0W4PGW17D/torn-down-seed-repeat.log (run 2) and seed-rename-residual.log.bash tests/fm-backend-zellij.test.sh— full adapter suite, including the newtest_supervisor_reconcile_recovers_a_silent_new_tab_idandtest_supervisor_reconcile_closes_the_partial_tab_when_the_id_stays_unresolvablebash tests/fm-supervisor-panes.test.sh— supervisor pane reconcile, lifecycle hooks, pane-loop cadences and guard read-only modebash tests/fm-backend-zellij-smoke.test.sh— real zellij 0.44.3 on an isolated throwaway session, including the two new assertions thatnew-tabechoes no id for an instantly-exiting command yet creates the tab, and thatfm_backend_zellij_supervisor_tab_candidatesexcludes just-closed tab idsManual e2e race reproduction against a real zellij server, run against BOTH adapters:bash torn-down-seed-e2e.sh before(adapter pinned to 2e51b48) andbash torn-down-seed-e2e.sh after(HEAD) — two real crew tabs,alpha.metaremoved, thenfm_backend_zellij_supervisor_reconcile <session> alpha bravoReal attached-client screen capture of the resulting supervisor tab for both variants on a 150x34 pty (pty_capture.py), rendered into a before/after PNGbash supervisor-e2e.shat HEAD — happy-path lifecycle: build supervisor tab with one pane per active crew, shrink to one pane after tearing one crew down, remove the tab once no zellij crew remains21 total race runs for stability:torn-down-seed-repeat.log(6),torn-down-seed-repeat-batch2.log(6), andprobe-seed-rename-residual.sh 8which also verifies the next lifecycle reconcile heals any residualbash tests/fm-session-start.test.sh— confirmed the only failure is the same pre-existingread-only bootstrap did not surface the tangle diagnosticassertion already accepted as unrelatedtests/fm-supervisor-panes.test.sh- tests/fm-supervisor-panes.test.sh is committed mode 100644 while every other tests/*.test.sh is 100755; bin/fm-test-run.sh invokes tests asbash "$script", so CI is unaffected, but direct invocation fails with 'Permission denied'. Out of scope for the documentation phase (executable-bit change, not docs) - flagging for the test-owning phase.bin/backends/cmux.sh:30- bin/backends/cmux.sh's header says 'docs/cmux-backend.md has the full evidence log', but that doc has no evidence log - the owner is docs/verification/runtime-backends.md, the same stale pointer I corrected in bin/backends/zellij.sh. Untouched by this change, so left alone rather than widening the diff; worth a one-line follow-up fix.✅ **Push** - passed
✅ No issues found.