Repository navigation
Conversation
…rminal is gone (#1) * relaunch-missing operation for missing endpoints * no-mistakes(review): fix recover-missing endpoint, note rollback, meta locking and tests * no-mistakes(review): correct recovery refusals and drop untested herdr recreation * no-mistakes(document): document recover-missing in agent-control and recovery skills * fix(control): recover a task whose whole tmux session is gone, on its recorded profile recover-missing could only rebuild a task window inside a session that was still alive. fm_backend_tmux_create_task lists and then adds a window, so a task whose whole session (or whose whole tmux server) had gone read `missing`, passed every gate, and then died at `tmux new-window` with nothing recreated. That is the shape firstmate-account-slot-routing is in: it records window=oes-demo:fm-firstmate-account-slot-routing and oes-demo no longer exists. fm_backend_tmux_recreate_session brings the recorded session back, exactly and only when it is absent, before the window is created. A session that still exists is left as it is, so the missing-window shape is unchanged. A session that cannot be recreated refuses before the window, the durable record, or the instructions are touched, and a failure between the two still reads `missing`, so the verb stays retryable. recover-missing also no longer re-resolves config/secondmate-harness. It continues the same run in the same terminal, so every identity axis comes from the task's own durable record - which is what its header, its refusal of --harness/--model/--effort, and docs/agent-control.md already promised. A secondmate whose pin had since changed was being recovered onto a different harness with its model and effort silently reset. Picking a changed pin up is what relaunch is for. Coverage: both missing shapes on the success path, a surviving session proved untouched, the unrecreatable-session refusal, a recorded profile surviving a differing configured pin, and the spawn-leftover dirt exemption proved against real untracked work rather than left vacuous. * no-mistakes(test): wait for recreated terminal to settle before launch handoff * no-mistakes(document): document recreated-terminal settle wait in agent-control * fix(tests): pin the secondmate recovery fixture's commit identity tests/git-config-helpers.sh takes the host's global and system Git config away from every fixture, so a bare `git commit` inside one falls back to Git's own <user>@<hostname> guess. A developer machine supplies a qualified hostname and the commit lands; a CI runner whose hostname carries no domain gets `<user>@<host>.(none)`, which Git refuses. The secondmate case in tests/fm-control-recover-missing.test.sh was the only fixture commit in the suite without an identity. On CI its commit failed silently, `.fm-secondmate-home` and `AGENTS.md` stayed staged, and recover-missing then refused the home on its dirty-local-copy gate - so the case failed on a refusal instead of exercising the profile freeze. The gate is right and stays untouched: the staged pair is a fixture artifact, not something a real secondmate home can hold, since `.fm-secondmate-home` is gitignored there and `AGENTS.md` is committed. Give that commit the same inline identity fm_git_init_commit already uses, and fail loudly if it ever cannot commit again. * no-mistakes(review): Name recover-missing in rollback and kind refusals; map new suite * no-mistakes(document): note kind-adapter refusal for recover-missing in agent-control
…ord writes (#2) * fix(bin): keep an armed merge poll valid when the task record gains a later key The watcher re-authenticates a PR merge poll on every cycle, and part of that is a cross-check against the task's own durable record. That cross-check refused any key it did not recognise appearing after the record's `pr=` line, so an armed poll was revoked the moment a supported writer appended one: `bin/fm-control.sh relaunch` records `control_relaunch_tx=` at the tail, and `bin/fm-captain-hold.sh` appends `decisions_reviewed=` and `decision_keys=`. Arming could never see it. `bin/fm-pr-check.sh` rewrites the record so `pr=` and `pr_head=` are its last lines, so the refusal only ever surfaced later, in the watcher, as `check: rejected unauthenticated state checks` - the poll never ran, and the missing merge notification was indistinguishable from an unmerged pull request. State the guarantee as a property of the whole record instead of its tail: every non-blank line is a readable `key=value` record, exactly one `pr=` line carries a canonical URL, and at most one `pr_head=` carries a valid head wherever it appears. An unrecognised key carries no PR identity, so it is no longer treated as tampering. The content fingerprints and the file-identity bindings are unchanged. This is stricter than before on lines ahead of `pr=`, which the old tail-only rule never inspected, and it makes arming apply the same rule the watcher will, so a record that cannot be read is refused where an operator sees it. * no-mistakes(review): drop unreachable pr_head cap, report unreadable record at arming * no-mistakes(review): drop whole-record key strictness, restore test umask * no-mistakes(document): note armed merge poll coverage in relaunch suite docs * no-mistakes(lint): inline single-case loop flagged by SC2043 in PR-check security test * no-mistakes(document): refresh relaunch suite header for merge-poll and recover-missing
…command A launch command longer than the terminal's canonical-mode line limit was silently discarded and no worker started. A pane whose shell is still running something has its tty in canonical mode, where the kernel buffers the typed line itself and drops the whole line past MAX_CANON (1024 on macOS). Nothing downstream noticed, so recovery could only report later that no running agent could be confirmed. Splitting the text across several sends does not help: the limit applies to the accumulated line, not to each write. Measured at 400, 200, and 100 bytes per send, with and without pauses, the command was lost every time. Waiting for the pane to read input itself does work, and a ready pane takes 4088 bytes intact. fm_tmux_pane_input_mode and fm_tmux_wait_pane_input_ready read the pane's line discipline and wait, bounded, for it to leave canonical mode. The literal send and the submit core both gate on that. Succeeding is the normal path; a pane that never becomes ready refuses with the real reason, and fm-spawn.sh turns that refusal into a failed status line and a nonzero exit instead of sending Enter into a pane holding no command. The byte limit is deliberately not encoded anywhere: readiness is the same kernel fact on every platform, while the limit is not. BSD stty -f and GNU stty -F are both tried so the read works on macOS and Linux.
…ackend; map new suite
…iden suite selection
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
A Claude or Codex worker launch sometimes lands corrupted and the worker silently never starts. This is the long-standing report tracked upstream as bastotec/firstmate#4559, and the concrete cause has now been found.
The launch command is around 1117 characters. The terminal silently drops everything past 1024 bytes, which leaves the shell sitting on an unterminated quote, so the worker never starts. Recovery afterwards can only report that no running agent could be confirmed, which is why this looked like a mystery for so long rather than a truncation.
The workaround that was verified by hand: sending the identical command in roughly 400-byte chunks worked first time.
This was reported by the developer-tools domain on 2026-09-15 while recovering workers onto Claude. It also blocks the remote-home migration work, which will hit the same truncation.
What Changed
fm_tmux_pane_input_mode/fm_tmux_wait_pane_input_readyinbin/fm-tmux-lib.sh, bounded by the newFM_PANE_READY_TIMEOUT, default 5s). A pane measured as canonical buffers the line in the kernel and silently discards it past MAX_CANON, which is how a ~1117-byte launch command disappeared; an unreadable tty still counts as ready, so only a positively busy pane is ever held back. The gate refuses with status 2, andbin/fm-spawn.shnow records afailed:status line naming the reason and exits nonzero instead of sending Enter on an undelivered command.recover-missingcontrol verb (bin/fm-control.sh,bin/fm-control-lib.sh) for a task whose endpoint is authoritatively missing: it recreates the recorded tmux window - and the whole session first, via the newfm_backend_tmux_recreate_session, when the session or server is gone - waits for the new shell to settle agent-free, then hands the launch tofm-spawn.sh --relaunch. It continues the recorded harness/model/effort (no config re-resolution,--harness/--model/--effortrefused), requires--note, refuses a dirty worktree or a conflicting pool slot, and rolls the progress note back on failure. tmux only; other backends refuse before anything is touched.fm_pr_metadata_identity_parseto key off PR identity anywhere in the record rather than the file tail: exactly one canonicalpr=line and everypr_head=valid, with unknown keys skipped instead of treated as tampering, so a latercontrol_relaunch_tx=/decisions_reviewed=append no longer revokes an armed merge poll.docs/tmux-backend.md"Launch command delivery",docs/verification/runtime-backends.md"Pane input readiness" (including the sampled-not-held limitation),docs/agent-control.md,docs/configuration.md, plustests/fm-tmux-long-launch.test.shandtests/fm-control-recover-missing.test.sh.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is well-bounded and fail-permissive by construction - the gate only holds back a pane it positively measured as canonical, it sits on the single launch call site, the new spawn failure replaces an abort that
set -ealready caused, and the remaining gap is documented honestly as authorized containment rather than hidden.Testing
I stood up real tmux servers on private sockets and drove the change as an operator would. The reported failure reproduces exactly on the pre-fix path (the 1238-byte command vanishes from a busy pane, no worker starts) and the shipped readiness gate makes the same command land byte-identically and start a real process, three runs in a row. Driving the real
bin/fm-spawn.shCLI end to end confirmed both halves of the spawn-level wiring: a ready pane launched a worker whose argv was 2721 bytes of real brief, and a never-ready pane produced the named refusal, a realfailed: launch command not delivered: ...line in the task's status file, and a nonzero exit instead of a silent no-agent. The repo's own regression suite and the existing real-tmux backend smoke suite both pass repeatedly. Two adversarial checks came out on the change's side: short sends to a busy pane are still delivered, and the change's rejection of the reported chunking workaround reproduced - every split size lost the whole command on a busy pane while an idle pane took it in one send, with the boundary measured at exactly 1024 bytes. This change has no UI, HTML or rendered surface, so the reviewer-visible evidence is terminal transcripts and captured tmux pane output rather than screenshots. The non-tmux session backends could not be exercised here.repro-truncation.shcase A against a real tmux server, 3 runs: "NO WORKER STARTED - the command vanished silently", with the pane capture showing the echoed text that the kernel discardedrepro-truncation.shcase B, 3 runs: gated send returns 0, the launched process writes its own marker, andcmpshows the received payload identical to what was sentspawn-e2e.sh ok- realbin/fm-spawn.shagainst a real tmux server printsspawned e2e-ok-z1 ... window=firstmate:fm-e2e-ok-z1, and the launched process recordscodex really startedwith a 2721-…spawn-e2e.sh busywith FM_PANE_READY_TIMEOUT=2 - exit 1, both refusal lines on stderr naming the window and the reason, andstate/<id>.statuscontaining `failed: launch command not delivered: wind…tests/fm-tmux-long-launch.test.shcase 2 on a realcat > /dev/nullpane: status 2 for the gate refusal, status 1 for a send to a session that does not existtests/fm-tmux-long-launch.test.shcases 3 and 4 against a real tmux pane - an unresolvable target readsunknownand is treated as ready, and a pane at its prompt returns in under a second of a 5s…short-send-unaffected.sh-fm_backend_tmux_send_text_lineto a pane measured canonical returns 0 and the command runs once the pane frees upchunking-check.sh- 400, 400-with-pauses, 200 and 100-byte chunks all LOST on a busy pane across 3 repeats each, while an idle pane LANDED the same 1238-byte command in one send;canon-boundary.sh…Evidence: A/B repro: pre-fix send loses the launch command, gated send lands it
Source: A/B repro: pre-fix send loses the launch command, gated send lands it
launch command length: 1238 bytes (report says ~1117) == A: pre-fix path (plain tmux send-keys -l, no readiness gate) == pane tty line discipline at send time: canonical RESULT: NO WORKER STARTED - the command vanished silently == B: shipped path (fm_backend_tmux_send_literal, readiness gate) == pane tty line discipline at send time: canonical gated send returned status 0 RESULT: worker started (marker written by the launched process) RESULT: worker received the command byte-identical to what was sentEvidence: Real fm-spawn.sh end to end: worker started, and a never-ready pane refused loudly
Source: Real fm-spawn.sh end to end: worker started, and a never-ready pane refused loudly
=== MODE=ok --- fm-spawn.sh exit status: 0 spawned e2e-ok-z1 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-e2e-ok-z1 worktree=.../slot --- harness marker (written by the launched process itself): codex really started argv it received: 2721 bytes === MODE=busy FM_PANE_READY_TIMEOUT=2 --- fm-spawn.sh exit status: 1 error: pane firstmate:fm-e2e-busy-z1 was still busy after 2s and never started reading input; refusing to type 509 bytes it would silently discard error: task e2e-busy-z1's launch command was not delivered: ...; no agent was started, inspect window firstmate:fm-e2e-busy-z1 --- state/e2e-busy-z1.status: failed: launch command not delivered: window firstmate:fm-e2e-busy-z1 was still busy and never started reading input --- harness marker: (no worker started)Evidence: Chunking does not rescue a busy pane; an idle pane takes the whole command
Source: Chunking does not rescue a busy pane; an idle pane takes the whole command
tmux 3.6a on Darwin 25.6.0 arm64; one 1238-byte command, three repeats per row pane state / send shape result x3 busy pane, one send (the reported failure) LOST LOST LOST busy pane, 400-byte chunks (the claimed fix) LOST LOST LOST busy pane, 400-byte chunks with pauses LOST LOST LOST busy pane, 200-byte chunks LOST LOST LOST busy pane, 100-byte chunks LOST LOST LOST IDLE pane, one send (what the report measured) LANDED LANDED LANDEDEvidence: Canonical-mode line boundary measured at exactly 1024 bytes
Source: Canonical-mode line boundary measured at exactly 1024 bytes
1000 bytes: LANDED LANDED LANDED 1023 bytes: LANDED LANDED LANDED 1024 bytes: LOST LOST LOST 1025 bytes: LOST LOST LOST 1097 bytes: LOST LOST LOST 1238 bytes: LOST LOST LOST 2000 bytes: LOST LOST LOSTEvidence: Everyday short sends to a busy pane are still delivered, not refused
Source: Everyday short sends to a busy pane are still delivered, not refused
pane line discipline while the send is made: canonical fm_backend_tmux_send_text_line status on a busy pane: 0 (0 = not refused) result: short send delivered once the pane freed upEvidence: Repo regression suite against a real tmux server
Source: Repo regression suite against a real tmux server
ok - fm_backend_tmux_send_literal: a 1634-byte launch command starts a worker on a busy pane ok - pane that never becomes ready refuses loudly and names the reason ok - fm_tmux_wait_pane_input_ready: unreadable tty mode stays permissive ok - fm_tmux_wait_pane_input_ready: a ready pane returns without spending the budgetEvidence: Drivers used for the live runs (kept alongside the transcripts)
Source: Drivers used for the live runs (kept alongside the transcripts)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
.agents/skills/harness-adapters/SKILL.md- branch carries 2 commit(s) that exist on your local main branch but were never pushed to origin/main; these may be unintended bundled work (proposed PR changes 20 file(s)):Confirm these commits belong in this PR before approving, or manually separate the intended work onto origin/main before gating.
bin/fm-tmux-lib.sh:356- The readiness gate is applied at a second place beyond the launch path the intent describes. The intent is about the launch command, which reaches the terminal only through fm_backend_tmux_send_literal (bin/backends/tmux.sh:161, the single caller being bin/fm-spawn.sh:4210). Adding the same gate inside fm_tmux_submit_core changes behavior for every other tmux text send in the fleet: bin/fm-send.sh:1055, bin/fm-supervise-daemon.sh:1294, bin/fm-task-inbox-lib.sh:301, and bin/fm-control.sh:566 (the exit command). A pane those callers reach while its tty is canonical - a harness that handed the terminal to a foreground child, or a shell pane mid-command - now getssend-failedafter the full ready budget instead of the text being typed, and for fm-control.sh exit that turns into a harddie. No intent requirement needs this second gate; the narrower form that satisfies the stated goal is gating only fm_backend_tmux_send_literal. Recommend removing the fm_tmux_submit_core gate, or confirming the wider scope is wanted.bin/fm-tmux-lib.sh:244- fm_tmux_wait_pane_input_ready derives its budget as a poll COUNT (polls = timeout/poll = 100 for the 5s/0.05s defaults) and then spends, per iteration, onesleep $pollPLUS a command substitution that forkstmux display-messageandstty. The subprocess cost is not subtracted, so a pane that never becomes ready is held for roughly 2-4x the advertised budget - and both error strings still reportafter ${FM_PANE_READY_TIMEOUT:-5}s, which is simply not the elapsed time. Concretely: bin/fm-spawn.sh:4210 blocks ~10-15s before emitting thelaunch command not deliveredfailure it advertises as a 5s wait, and every fm_tmux_submit_core caller that hits a canonical pane pays the same overshoot per send (bin/fm-supervise-daemon.sh and bin/fm-task-inbox-lib.sh loop over tasks). Remedy: compute a deadline from the clock (the sameawk -v e= -v t=elapsed accumulation bin/fm-control.sh:wait_endpoint_settled already uses) and report that value in the message.bin/fm-tmux-lib.sh:349- fm_tmux_submit_core still readsbaseline_state=$(fm_pane_busy_state "$target")BEFORE the new readiness wait, so the baseline can now predate the typing by the whole ready budget instead of only the settle interval. If the pane reads idle while momentarily canonical, baseline_idle=1 is latched, the gate then waits seconds, and any unrelated work that starts during that wait lets fm_tmux_submit_enter_core convert anunknowncomposer read into theempty(delivered) verdict for text whose delivery was never proven. The window is narrow, but the comment above the baseline explicitly says it must predate our own typing and nothing else - moving the baseline read to just after the gate restores that and costs nothing.docs/verification/runtime-backends.md:160- The change records the opposite of a fact the intent states as verified. Intent: "The workaround that was verified by hand: sending the identical command in roughly 400-byte chunks worked first time." The change asserts and documents the reverse - "Measured on the same host with the same 1117-byte payload: 400, 200, and 100 bytes per send, each with and without pauses between sends, lost the whole command every time" - and the commit message repeats it. The change's reasoning is technically correct (MAX_CANON applies to the accumulated line, not the write, so chunking cannot help a canonical pane), and the likely explanation is that the hand test happened to run against a pane already at its prompt. But the two accounts cannot both be true, and the PR text will contradict the reporter's own observation. Confirm which account the change should carry before it is published.🔧 Fix applied.
3 issues (2 warnings, 1 info) still open:
bin/fm-spawn.sh:4210- The new failure block attributes every non-zero return from spawn_send_literal to the tmux readiness gate, but spawn_send_literal (bin/fm-spawn.sh:3054) dispatches to five backends and only the tmux one gained a gate. fm_backend_herdr_send_literal (bin/backends/herdr.sh:2965), fm_backend_zellij_send_literal (bin/backends/zellij.sh:437), fm_backend_cmux_send_literal (bin/backends/cmux.sh:475) and fm_backend_orca_send_literal (bin/backends/orca.sh:174) each return 1 for their own reasons - target-not-ready, CLI call failure, missing tool binary. Concrete sequence: a herdr spawn whose pane is gone by launch time makes fm_backend_herdr_target_ready fail, send_literal returns 1, and the spawn now writesfailed: launch command not delivered: window <T> was still busy and never started reading inputinto $STATE/$ID.status and prints the same sentence on stderr - a false cause for an operator reading the record, pointing at a kernel line-discipline problem that does not exist on that backend. (Aborting instead of continuing is itself an improvement: the return value was previously discarded, so those failures used to proceed to send Enter and report spawn success. Only the hardcoded reason is wrong.) Remedy: word the message from the actual condition, e.g. keep the readiness wording only when BACKEND is tmux and otherwise say the backend refused the literal send.bin/fm-test-run.sh:275- tests/fm-tmux-long-launch.test.sh is not added to family_for_basename, so it resolves to the unclassified catch-all. select_changed (bin/fm-test-run.sh:1650) only adds a script when family_for_basename equals a family that families_for_changed_path emitted, and no source path maps to unclassified. Concrete sequence: a later edit to bin/backends/tmux.sh selects familiesbackend-dispatchandorca(bin/fm-test-run.sh:1356); an edit to bin/fm-tmux-lib.sh selectspure-contract-unit(bin/fm-test-run.sh:1524); this new regression suite is in neither, sofm-test-run.sh --changednever runs it and the truncation regression it exists to catch can return unnoticed. It only runs under --all or when the test file itself is edited. The sibling commit on this same branch registered its own new suite exactly this way (fm-control-recover-missing.test.sh, added to the backend-dispatch list). Remedy: addfm-tmux-long-launch.test.shto the backend-dispatch family list alongside fm-backend-tmux-smoke.test.sh.bin/backends/tmux.sh:160- The gate proves readiness and then types, with nothing between the two. The spawn path buffers up to threeexportlines into the pane before the launch (bin/fm-spawn.sh:4160-4180), and on a busy pane those sit in the kernel input queue. When the busy command ends, bash flips to raw for readline, consumes one buffered line, flips back to canonical while the export runs, then back to raw for the next - so the tty oscillates while the queue drains. If fm_tmux_wait_pane_input_ready samples raw in one of those readline windows and the shell flips to canonical before the 1117-byte send lands, the command is discarded exactly as before. The canonical windows are microseconds wide (anexportruns and returns), so this is far narrower than the failure being fixed and the change is a genuine improvement; noting it because the invariant the fix relies on is "raw at the moment of the write" and only "raw one read earlier" is actually established. Closing it would mean verifying delivery after the send, which is new machinery beyond this change's scope, so no action is proposed.🔧 Fix applied.
3 warnings still open:
bin/fm-test-run.sh:1524- The round-2 fix mapped tests/fm-tmux-long-launch.test.sh into the backend-dispatch family (bin/fm-test-run.sh:363), which covers bin/backends/tmux.sh (line 1356) and bin/fm-spawn.sh (line 1497). It does NOT cover bin/fm-tmux-lib.sh, which is where the gate actually lives - fm_tmux_pane_input_mode, fm_tmux_clock_seconds and fm_tmux_wait_pane_input_ready are all in that file. bin/fm-tmux-lib.sh is matched by the case arm at bin/fm-test-run.sh:1524, which emits onlypure-contract-unit. select_changed (bin/fm-test-run.sh:1649-1655) adds a script only when family_for_basename equals an emitted family, so the new suite is not selected. Concrete sequence: someone edits fm_tmux_wait_pane_input_ready's deadline arithmetic in bin/fm-tmux-lib.sh and runsbin/fm-test-run.sh --changed; families_for_changed_path emits pure-contract-unit, the long-launch suite resolves to backend-dispatch, and the only regression test for the 1117-byte truncation never runs against the change that broke it. The user's round-2 instruction named this case explicitly ("so that changed-path selection actually runs it when bin/backends/tmux.sh, bin/fm-tmux-lib.sh, or bin/fm-spawn.sh change") and it is the one of the three that is still unmet. Remedy: addprintf '%s\n' backend-dispatchto the bin/fm-tmux-lib.sh arm, or split bin/fm-tmux-lib.sh out of that shared arm so it emits both families - the source-path map is documented as over-selecting rather than under-selecting, so widening it here is in keeping with the file's own policy.bin/fm-spawn.sh:4213- fm_backend_tmux_send_literal (bin/backends/tmux.sh:160-165) has two distinct non-zero returns: the readiness gate refusing, and the exit status oftmux send-keys -t "$1" -l "$2"on the line below it. The new case block collapses both into one sentence, so the second is reported with the first's cause. Concrete sequence: the tmux server dies (or the recorded session is killed) between window creation and the launch send - the exact loss the siblingrecover-missingcommit on this branch exists to repair. fm_tmux_pane_input_mode'stmux display-messagethen fails, which the helper deliberately maps tounknownand treats as ready, so the gate returns 0;tmux send-keysthen fails with "no server running"/"can't find session"; spawn writesfailed: launch command not delivered: window <T> was still busy and never started reading inputinto $STATE/$ID.status and prints the same line on stderr. An operator reading that record is pointed at a kernel line-discipline problem on a pane that no longer exists. This is the same defect class the round-2 instruction ruled out ("the reported reason must be true for whichever backend actually refused"), narrowed to within the tmux branch rather than removed. Remedy is mechanical and stays inside the existing block: give the gate its own exit status in fm_backend_tmux_send_literal (e.g.return 2for the gate, leavingtmux send-keys's own status as 1) and branch on it here, so the readiness wording is used only when the gate is what refused and a send failure says the send failed.bin/fm-tmux-lib.sh:235- fm_tmux_clock_seconds is a second definition of a concept the repository already owns once. bin/fm-timing-lib.sh:59 fm_timing_now_ms reads the same EPOCHREALTIME builtin, accepts the same locale-dependent./,separator, and degrades the same way on macOS's bash 3.2 - its header comment states that rationale in nearly the same words the new one does. The elapsed-time bound itself is required (it was the round-1 decision), but a new clock reader is not the narrower form that satisfies it: reusing fm_timing_now_ms gives integer milliseconds, which also removes the per-pollawkfork the current deadline check spends inside the wait loop (bin/fm-tmux-lib.sh:271-272) in favour of plain shell arithmetic. The tradeoff to weigh, and why this is a question rather than a mechanical fix: bin/fm-tmux-lib.sh is sourced by the backend adapter, the away-mode daemon and fm-crew-state.sh, so adding a. fm-timing-lib.shline widens what those three load, and fm-timing-lib.sh sets FM_TIMING_DETAIL_MAX at source time. Recommend deciding between reusing the existing owner and keeping the local copy deliberately, rather than leaving two undocumented owners of the same degradation rule.🔧 Fix applied.
4 issues (3 warnings, 1 info) still open:
bin/fm-control.sh:1030-recover-missingrefuses any worktree with uncommitted changes, which is the normal state of the worker it is meant to rescue, and no other verb can take over. Concrete sequence: ship taskt-42is mid-task withsrc/foo.tsmodified; its tmux server dies, so the endpoint classifiesmissing.bin/fm-control.sh t-42 recover-missing --note '...'reaches bin/fm-control.sh:1029-1030, whereCHECKPOINT_STATUS_RAWholdsM src/foo.ts, the exemption regex only skips?? .claude/and?? .fm-(grok|kimi)-turnend, sodirtyis non-empty and it dies with "worktree ... has uncommitted changes; refusing to recover rather than cleaning it". The fallback is not available either:relaunchroutes throughdo_exit, which dies on amissingendpoint at bin/fm-control.sh:527. The operator is left with no supported verb for a worker that has done any work at all. This is inconsistent with the sibling path it copies -do_relaunchruns the samesafe_checkpoint(bin/fm-control.sh:840) and deliberately does NOT refuse on dirty, because preserving uncommitted work is the documented contract (.agents/skills/stuck-crewmate-recovery/SKILL.md: "Preserve its uncommitted changes and commits"), andfm-spawn.sh --relaunchadopts the existing worktree without touching it in either case. The refusal message's own premise ("rather than cleaning it") does not hold: nothing on this path cleans the worktree. This is deliberate and pinned by tests/fm-control-recover-missing.test.sh:414 and :796, and docs/agent-control.md states it as a precondition, so it needs the author's call rather than a mechanical fix - either drop the dirty refusal so recovery preserves work the way relaunch does, or state in the docs which real loss the refusal prevents.bin/fm-spawn.sh:4213- The gate closes the measured cause but nothing proves the launch command actually reached the shell, so the reported failure mode - worker silently never starts - stays reachable. The change's own docs say so (docs/verification/runtime-backends.md, "Known limitation: readiness is sampled, not held": "a sample taken in one of those raw windows can be followed by a flip back to canonical before the text lands, and a long command can still be lost"). Concrete sequence: the pane is draining the threeexportlines sent at bin/fm-spawn.sh:4156-4168;fm_tmux_pane_input_modesamplesrawduring the shell's line-editor window, returns ready, and the shell flips back to canonical as the next queued line runs before the 1117-byte literal lands - the line is discarded,spawn_send_literalreturns 0,spawn_send_key "$T" Entersubmits an empty line, and spawn reports success with no agent. For the two harnesses the report names, claude and codex, there is no post-launch check at all: the readiness/delivery gates at bin/fm-spawn.sh:4227 (kimi), :4253 (rovo) and :4276 (agy) are harness-specific, so claude and codex fall straight through to the commit point at bin/fm-spawn.sh:4300. The remedy extends the change rather than correcting it - either capture the pane and compare the typed line against$LAUNCHbefore sending Enter, or add a post-launch alive gate for claude and codex in the shape the three harnesses above already use - so it needs authorization, not an auto-fix. Flagging because the intent frames this as a found-and-fixed root cause, and the remaining gap is the same silent loss.bin/fm-tmux-lib.sh:252- Simplification: the readiness wait introduces four configuration surfaces where the intent needs none - a[timeout-seconds]positional,FM_PANE_READY_TIMEOUT, a[poll-seconds]positional, andFM_PANE_READY_POLL(bin/fm-tmux-lib.sh:252). Neither poll spelling has any caller: the only production call site passes one argument (bin/backends/tmux.sh:165), and nothing in bin/, tests/ or docs/ readsFM_PANE_READY_POLLor passes a third argument. No intent requirement needs a tunable poll interval; the narrower form that satisfies the intent is a fixed 0.05s poll constant. The timeout pair is used, but only by the test (tests/fm-tmux-long-launch.test.sh:179 uses the env var, :207 uses the positional) - one of the two spellings would cover both, and the refusal message at bin/backends/tmux.sh:166 only ever reportsFM_PANE_READY_TIMEOUT, so a caller that passed the positional would get a message naming the wrong number. Recommend removing the poll knob outright and keeping a single timeout spelling.bin/fm-tmux-lib.sh:49- Sourcing bin/fm-timing-lib.sh to reusefm_timing_now_msalso executes its top-levelset -u(bin/fm-timing-lib.sh:45) in the sourcing shell, and it setsFM_TIMING_DETAIL_MAX. fm-tmux-lib.sh itself sets no shell options, and neither do the two libs it already sourced (fm-composer-lib.sh, fm-cursor-lib.sh), so this is newly global for every consumer - including bin/backends/tmux.sh, which is sourced lazily at runtime insidefm_backend_source(bin/fm-backend.sh:607), so the option flips mid-execution. I checked every transitive entry point and test that reaches fm-tmux-lib.sh and they all alreadyset -u, so I could not construct a concrete failure; noting it because the round-3 instruction reasoned about source cycles but not about inherited shell options, and the next consumer that does not set -u inherits it silently.🔧 Fix applied.
2 warnings still open:
bin/backends/tmux.sh:191- The delivery check accepts the probe being present ANYWHERE on the captured pane, so text left by an earlier send confirms a truncated new one. Concrete sequence, on the relaunch path the incident report describes:bin/fm-control.sh <id> relaunchrunsbin/fm-spawn.sh --relaunch, which adopts the recorded window (bin/fm-spawn.sh:2783-2791) and never clears it - there is noclear-history,clear, orC-lin bin/fm-spawn.sh, bin/fm-control.sh, or bin/backends/tmux.sh. When the dead harness left its alternate screen, tmux restored the primary screen, which still shows the previous launch command line. The claude template ends with"$(__OPINPUT__ encode launch-brief < __BRIEF__)"(bin/fm-spawn.sh launch_template) and every relaunch-specific difference is a PREFIX -unset TRACEPARENT;(bin/fm-spawn.sh:4126),CLAUDE_CONFIG_DIR=(:4100),env -u ...(:4089), the/usr/bin/env -i ... /bin/sh -cwrapper (:4202) - so the last 60 whitespace-stripped characters are byte-identical between the old and new launch. Now let the documented sampled-readiness race fire (docs/verification/runtime-backends.md, "Readiness is sampled, not held"): the new 1117-byte line is discarded by canonical mode, the capture at bin/backends/tmux.sh:186 still contains the OLD command's tail, the case at :190-192 matches,return 0, and bin/fm-spawn.sh:4227 sends Enter on a partial line. That is the original silent failure, now wearing a confirmation. Smallest honest remedy inside the same function: capture the pane BEFOREtmux send-keysand require the probe to be absent beforehand (or its occurrence count to increase), so the check proves THIS send landed rather than that the text is on screen.bin/backends/tmux.sh:195- The delivery check gives a successful send about 0.2s to render before it aborts the spawn. The loop at bin/backends/tmux.sh:185-196 captures immediately aftertmux send-keysreturns (which only queues the keys), fails, sleeps 0.2s once, captures again, then breaks toreturn 3. Concrete sequence: a spawn pane running the operator's login shell - zsh with zsh-syntax-highlighting, which re-highlights the whole buffer - receives a ~2000-byteLAUNCH(the/usr/bin/env -i ...wrapper at bin/fm-spawn.sh:4193-4202 roughly doubles the 1117-byte command); the echo plus rehighlight plus tmux's own screen update takes longer than 200ms, especially with severalfm-spawn-batchspawns competing on the host. The text DID land, but bin/fm-spawn.sh:4216-4223 recordsfailed: launch command not delivered: the command did not reach window <T> wholeand exits 1, so a spawn that used to work now fails and leaves the window and worktree allocated. Flagging as ask-user because the single retry was explicitly prescribed ("Allow one bounded retry of the CHECK"); widening it to a short elapsed-time-bounded poll - the samefm_timing_now_msdeadline shapefm_tmux_wait_pane_input_readyalready uses, on the order of 1-2s - changes when the refusal surfaces, which is the author's call.🔧 Fix applied.
4 issues (1 warning, 3 infos) still open:
bin/backends/tmux.sh:172- The delivery confirmation compares an occurrence COUNT taken before the send against counts taken after it, but both counts are read from a fixed-S -200window, so a successful send can be refused when typing the line pushes the baseline occurrence out of that window. Concrete sequence on the relaunch path:bin/fm-control.sh <id> relaunchadopts the recorded window without clearing it (bin/fm-spawn.sh:2783-2791), so the previous launch's tail is in the pane's primary-screen history. Say it sits 180 history rows above the top of screen - the dead harness printed a stack trace or banner output to the primary screen after it. Baseline capture covers 200 history rows plus the visible pane, so baseline=1. The gated send then types the ~2200-byte LAUNCH (the/usr/bin/env -i ...wrapper at bin/fm-spawn.sh:4193-4202 roughly doubles the 1117-byte command), which scrolls ~28 rows; the old occurrence is now at depth 208, outside-S -200, while the new one is on screen. Post-send count is 1,[ "$seen" -gt "$baseline" ]at bin/backends/tmux.sh:229 is false for the whole 5s budget, and bin/backends/tmux.sh:233 returns 3 - so bin/fm-spawn.sh:4216-4223 recordsfailed: launch command not delivered: the command did not reach window <T> wholeand exits 1 for a launch that actually landed, leaving the window and worktree allocated. The bad band is narrow (baseline depth between ~172 and 200) but it is reachable, and it is the one direction the count comparison is not robust in. Smallest remedy inside the same function: capture the whole history (-S -) for both the baseline and the confirmation instead of a fixed 200-row window, so the earlier occurrence cannot leave the compared region mid-check.bin/backends/tmux.sh:221-baseline=$(fm_backend_tmux_pane_probe_count "$1" "$probe") || baseline=0makes an unreadable pane default the baseline to 0, which re-opens exactly the hole the count comparison was added to close: with baseline 0, a single pre-existing occurrence of the probe (the byte-identical previous launch still on an adopted relaunch window) satisfies[ "$seen" -gt "$baseline" ]and confirms a send that was in fact discarded. The window is small - it needstmux capture-paneto fail whiletmux send-keyson the next line succeeds, which on an existing pane is close to unreachable - and the surrounding comment states the design reason (a target that is simply gone should be reported bysend-keys, not as an unconfirmed delivery). Noting it because the chosen default is the permissive one for the one check whose whole purpose is to be non-permissive: if the baseline cannot be read but the send succeeds, returning 3 (unconfirmed) rather than assuming 0 would keep the guarantee intact with no new machinery.bin/backends/tmux.sh:220-probe=${probe: -60}yields the EMPTY string, not the whole string, when the whitespace-stripped text is shorter than 60 characters - verified directly on this host against both bash 3.2.57 (env bashresolves here) and bash 5.3.9, so it is not a version-specific quirk. With an empty probe,fm_backend_tmux_pane_probe_countnever terminates:case "$seen" in *""*)always matches andseen=${seen#*""}removes nothing (confirmed: 100k iterations in 3s with no progress). That would hang the spawn inside the baseline read at bin/backends/tmux.sh:221 with no timeout around it. I could not make it reachable: the only production caller is bin/fm-spawn.sh:4214 with$LAUNCH, which is always well over 60 non-whitespace bytes, and every test passes a 1400-byte fixture - so this is a latent hazard in a new shared backend primitive rather than a live defect. One-line guard: clamp with something like[ "${#probe}" -le 60 ] || probe=${probe: -60}(or refuse an empty probe in the counter).docs/verification/runtime-backends.md:187- Flagging for visibility, not as a defect: the User intent states "The workaround that was verified by hand: sending the identical command in roughly 400-byte chunks worked first time", and this change explicitly rejects that account - docs/verification/runtime-backends.md's "Chunking the send does not fix this" section says the split was re-measured at 400, 200, and 100 bytes per send, with and without pauses, and lost the whole command every time, attributing the original success to an idle pane rather than to the split. The intent does not mark chunking as a required implementation (the required outcome is that the launch lands and the worker starts, which the readiness gate delivers), and the refutation is the author's own commit 92cf5a3 with recorded measurements, so there is nothing to resolve here. No action needed beyond confirming the superseding measurement is the one you want carried into the PR description, since it contradicts the incident report the ticket was filed on.🔧 Fix applied.
1 info still open:
bin/fm-tmux-lib.sh:254- A non-numeric, zero, or negative FM_PANE_READY_TIMEOUT silently becomes a 0 ms budget instead of the documented 5s default, and the guard written to catch a bad value cannot fire. Concrete trace: with FM_PANE_READY_TIMEOUT=0 (orabc, or-3), the awk at line 254 prints0(verified on this host for all three), so thecaseat line 255 sees all digits and leaves budget_ms=0; deadline_ms equals now, and the loop at 257-262 takes one sample, findscanonical, fails[ now -lt deadline ]and returns 1 on the first poll. bin/backends/tmux.sh:170 then refuses with a message that still reads "was still busy after 0s" via ${FM_PANE_READY_TIMEOUT:-5}, and bin/fm-spawn.sh:4221 turns that into afailed: launch command not deliveredstatus and exit 1 - so an operator who sets 0 or a negative expecting "don't wait / don't gate" gets the exact opposite: every launch into a momentarily busy pane hard-fails the spawn. NoteFM_PANE_READY_TIMEOUT=(set but empty) is fine, because:-catches it. Smallest fix, inside the same two lines: treat a budget the caller did not positively express as a positive number the same way the empty-awk case is already treated, e.g.case "$budget_ms" in ''|*[!0-9]*|0) budget_ms=5000 ;; esac, so the fallback matches the 5s the refusal message claims.✅ **Test** - passed
✅ No issues found.
repro-truncation.shcase A against a real tmux server, 3 runs: "NO WORKER STARTED - the command vanished silently", with the pane capture showing the echoed text that the kernel discardedrepro-truncation.shcase B, 3 runs: gated send returns 0, the launched process writes its own marker, andcmpshows the received payload identical to what was sentspawn-e2e.sh ok- realbin/fm-spawn.shagainst a real tmux server printsspawned e2e-ok-z1 ... window=firstmate:fm-e2e-ok-z1, and the launched process recordscodex really startedwith a 2721-…spawn-e2e.sh busywith FM_PANE_READY_TIMEOUT=2 - exit 1, both refusal lines on stderr naming the window and the reason, andstate/<id>.statuscontaining `failed: launch command not delivered: wind…tests/fm-tmux-long-launch.test.shcase 2 on a realcat > /dev/nullpane: status 2 for the gate refusal, status 1 for a send to a session that does not existtests/fm-tmux-long-launch.test.shcases 3 and 4 against a real tmux pane - an unresolvable target readsunknownand is treated as ready, and a pane at its prompt returns in under a second of a 5s…short-send-unaffected.sh-fm_backend_tmux_send_text_lineto a pane measured canonical returns 0 and the command runs once the pane frees upchunking-check.sh- 400, 400-with-pauses, 200 and 100-byte chunks all LOST on a busy pane across 3 repeats each, while an idle pane LANDED the same 1238-byte command in one send;canon-boundary.sh…bash tests/fm-tmux-long-launch.test.sh- the repo's own regression suite against a real tmux server, run 3x, all 4 cases green each timebash tests/fm-backend-tmux-smoke.test.sh- the existing real-tmux backend suite, to confirm the gate did not disturb the other send primitivesA/B repro driverrepro-truncation.sh- same 1238-byte launch command into the same busy pane, pre-fixtmux send-keys -lvs the shipped gated send, run 3x with identical resultsspawn-e2e.sh ok- the realbin/fm-spawn.shCLI spawning a ship task against a real tmux server on a private socket, with a stand-in harness binary that records that it actually startedspawn-e2e.sh busywithFM_PANE_READY_TIMEOUT=2- same real CLI onto a pane whose program never reads input, asserting the recordedfailed:status line and exit 1short-send-unaffected.sh-fm_backend_tmux_send_text_lineto a busy pane, confirming everyday short sends are not refused by the gatechunking-check.sh- 1238-byte command into a busy pane at 400/400+pauses/200/100-byte chunks and into an idle pane in one send, 3 repeats per rowcanon-boundary.sh- canonical-mode line boundary bisect at 1000/1023/1024/1025/1097/1200/1238/1400/2000 bytes, 3 repeats each✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.