Skip to content

fix(bin): wait for a pane to be reading input before typing a launch command - #4598

Closed
bastotec wants to merge 10 commits into
kunchenguid:mainfrom
bastotec:fm/fm-launch-truncation
Closed

bastotec wants to merge 10 commits into
kunchenguid:mainfrom
bastotec:fm/fm-launch-truncation

Conversation

@bastotec

Copy link
Copy Markdown

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

  • The tmux literal send on the launch path now waits for the target pane's tty to leave canonical mode before typing (fm_tmux_pane_input_mode / fm_tmux_wait_pane_input_ready in bin/fm-tmux-lib.sh, bounded by the new FM_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, and bin/fm-spawn.sh now records a failed: status line naming the reason and exits nonzero instead of sending Enter on an undelivered command.
  • Added a recover-missing control 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 new fm_backend_tmux_recreate_session, when the session or server is gone - waits for the new shell to settle agent-free, then hands the launch to fm-spawn.sh --relaunch. It continues the recorded harness/model/effort (no config re-resolution, --harness/--model/--effort refused), 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.
  • Rewrote fm_pr_metadata_identity_parse to key off PR identity anywhere in the record rather than the file tail: exactly one canonical pr= line and every pr_head= valid, with unknown keys skipped instead of treated as tampering, so a later control_relaunch_tx=/decisions_reviewed= append no longer revokes an armed merge poll.
  • Docs and new coverage: 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, plus tests/fm-tmux-long-launch.test.sh and tests/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 -e already 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.sh CLI 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 real failed: 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.

  • Live validation: ✅ go - 8 of 9 scenarios driven live against the product
Scenario Result Live Evidence
The reported failure reproduces: a ~1.2KB launch command typed into a busy pane vanishes and no worker starts ✅ pass live repro-truncation.sh case 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 discarded
Same command through the shipped gated send starts a worker and arrives byte-identical ✅ pass live repro-truncation.sh case B, 3 runs: gated send returns 0, the launched process writes its own marker, and cmp shows the received payload identical to what was sent
An operator spawns a task and the real fm-spawn.sh actually starts the harness with the full launch command ✅ pass live spawn-e2e.sh ok - real bin/fm-spawn.sh against a real tmux server prints spawned e2e-ok-z1 ... window=firstmate:fm-e2e-ok-z1, and the launched process records codex really started with a 2721-…
A pane that never reads input makes the spawn fail loudly with a recorded failure, not a silent no-agent ✅ pass live spawn-e2e.sh busy with FM_PANE_READY_TIMEOUT=2 - exit 1, both refusal lines on stderr naming the window and the reason, and state/<id>.status containing `failed: launch command not delivered: wind…
The gate's refusal is distinguishable from tmux send-keys failing on its own ✅ pass live tests/fm-tmux-long-launch.test.sh case 2 on a real cat > /dev/null pane: status 2 for the gate refusal, status 1 for a send to a session that does not exist
An unreadable tty stays permissive and a ready pane does not spend the wait budget ✅ pass live tests/fm-tmux-long-launch.test.sh cases 3 and 4 against a real tmux pane - an unresolvable target reads unknown and is treated as ready, and a pane at its prompt returns in under a second of a 5s…
Everyday short sends to a busy pane are still delivered rather than refused by the gate ✅ pass live short-send-unaffected.sh - fm_backend_tmux_send_text_line to a pane measured canonical returns 0 and the command runs once the pane frees up
Adversarial: splitting the send into ~400-byte chunks does not rescue a busy pane, and an idle pane takes the whole command ✅ pass live chunking-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…
The launch-send refusal is reported correctly for the non-tmux session backends (herdr, zellij, orca, cmux) ⏸️ untested no herdr needs the guarded Herdr lab and its lifecycle credentials, and zellij, orca and cmux are not installed on this host. To cover it, install those session providers or grant access to the Herdr lab…
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 sent

tmux: tmux 3.6a   host: Darwin 25.6.0 arm64

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
   pane after the busy command finished, as an operator would see it:
     | fghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde
     | fghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde
     | fghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde
     | fghijabcdefghijabcdefghijabcdefghi

== 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 sent
Evidence: 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)

########## OK MODE ##########
=== MODE=ok   FM_PANE_READY_TIMEOUT=5
--- fm-spawn.sh exit status: 0
--- fm-spawn.sh output (what the operator sees):
    spawned e2e-ok-z1 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-e2e-ok-z1 worktree=/private/var/folders/zk/8g327wwn58x475n0vfwjlkph0000gn/T/fm-spawn-e2e.06k3MA/slot
--- state/e2e-ok-z1.status (what recovery and the crew board read):
    (no status file)
--- pane tail (what an operator sees in the window):
    bash-3.2$ export FM_TASK_ID=e2e-ok-z1
    bash-3.2$ env -u CURSOR_AGENT -u CURSOR_INVOKED_AS -u GEMINI_CLI codex --dangerously-bypass-approvals-and-sandbox -c "notify=[\"bash\",\"-c\
    000gn/T/fm-spawn-e2e.06k3MA/home/state/e2e-ok-z1.turn-ended'\"]" "$('~/.no-mistakes/worktrees/5a1fd3284f12/01M2KV11G8XX
    ief < '/var/folders/zk/8g327wwn58x475n0vfwjlkph0000gn/T//fm-spawn-e2e.06k3MA/home/data/e2e-ok-z1/launch-brief.md')"
--- harness marker (written by the launched process itself):
    codex really started
    cwd=/var/folders/zk/8g327wwn58x475n0vfwjlkph0000gn/T/fm-spawn-e2e.06k3MA/slot
    argv it received: 2721 bytes, first 90: argv: [--dangerously-bypass-approvals-and-sandbox] [-c] [notify=["bash","-c","touch '/priv
--- host ~/.treehouse untouched: 0 entries under the sandboxed HOME

########## BUSY MODE (pane never reads input) ##########
=== MODE=busy   FM_PANE_READY_TIMEOUT=2
--- fm-spawn.sh exit status: 1
--- fm-spawn.sh output (what the operator sees):
    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: window firstmate:fm-e2e-busy-z1 was still busy and never started reading input; no agent was started, inspect window firstmate:fm-e2e-busy-z1
--- state/e2e-busy-z1.status (what recovery and the crew board read):
    failed: launch command not delivered: window firstmate:fm-e2e-busy-z1 was still busy and never started reading input
--- pane tail (what an operator sees in the window):
    bastotecnologia@MacBook-Pro-2 project % treehouse get
    export GOTMPDIR=/tmp/fm-e2e-busy-z1/gotmp
    export FM_TASK_ID=e2e-busy-z1
--- harness marker (written by the launched process itself):
    (no worker started)
--- host ~/.treehouse untouched: 0 entries under the sandboxed HOME
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 LANDED

tmux 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 LANDED
Evidence: 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 LOST

Canonical-mode line boundary on this host (tmux 3.6a, Darwin 25.6.0 arm64).
Busy pane (interactive bash running `sleep 4`), one literal send of N bytes,
3 repeats each. LANDED = the command's own prefix ran and wrote a marker.

 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
 1200 bytes: LOST LOST LOST
 1238 bytes: LOST LOST LOST
 1400 bytes: LOST LOST LOST
 2000 bytes: LOST LOST LOST
Evidence: 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 up

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 up
Evidence: 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 budget

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 budget
Evidence: Drivers used for the live runs (kept alongside the transcripts)

Source: Drivers used for the live runs (kept alongside the transcripts)

#!/usr/bin/env bash
# Drives the REAL bin/fm-spawn.sh CLI against a REAL tmux server on a private
# socket. The tmux backend, the pane, its tty line discipline, the readiness
# gate and the launched process are all real; `treehouse` and the harness
# binary are stand-ins (real processes that put the pane in the shape the
# scenario needs and record that they ran).
#
#   MODE=ok    the pane reaches a prompt -> the long launch command must start the worker
#   MODE=busy  the pane never reads input -> spawn must fail loudly, not silently
set -u
ROOT=$1
MODE=$2
. "$ROOT/tests/fixtures.sh"

REAL_TMUX=$(command -v tmux)
SOCKET="fm-spawn-e2e-$$-$MODE"
TMP=$(mktemp -d "${TMPDIR:-/tmp}/fm-spawn-e2e.XXXXXX")
cleanup() { "$REAL_TMUX" -L "$SOCKET" kill-server >/dev/null 2>&1 || true; rm -rf "$TMP"; }
trap cleanup EXIT

# Redirect HOME and strip the host's own bin dirs from PATH so nothing here can
# reach the operator's real treehouse install or real home state.
export HOME="$TMP/fakehome"; mkdir -p "$HOME"
BASE_PATH="/usr/bin:/bin:/usr/sbin:/sbin"
HOME_DIR="$TMP/home"; PROJ="$TMP/project"; WT="$TMP/slot"
FAKEBIN="$TMP/fakebin"; mkdir -p "$FAKEBIN"
cat > "$FAKEBIN/tmux" <<SH
#!/usr/bin/env bash
exec "$REAL_TMUX" -L "$SOCKET" "\$@"
SH
chmod +x "$FAKEBIN/tmux"

if [ "$MODE" = busy ]; then
  # Leaves the pane in the isolated slot with NOTHING reading input - the
  # never-ready shape the gate exists to refuse.
  cat > "$FAKEBIN/treehouse" <<'SH'
#!/usr/bin/env bash
cd "$FM_FAKE_WT" || exit 1
exec cat > /dev/null
SH
else
  cat > "$FAKEBIN/treehouse" <<'SH'
#!/usr/bin/env bash
cd "$FM_FAKE_WT" || exit 1
exec /bin/bash --noprofile --norc -i
SH
fi
chmod +x "$FAKEBIN/treehouse"

# The harness a launch is supposed to start: a real process that writes its own
# evidence, so "marker present" means a worker actually ran.
cat > "$FAKEBIN/codex" <<'SH'
#!/usr/bin/env bash
{ printf 'codex really started\n'; printf 'cwd=%s\n' "$PWD"; printf 'argv:'; printf ' [%s]' "$@"; printf '\n'; } > "$FM_FAKE_MARKER"
exec sleep 300
SH
chmod +x "$FAKEBIN/codex"

fm_test_spawn_home "$HOME_DIR" codex
fm_git_worktree "$PROJ" "$WT" "slot-e2e"
ID="e2e-$MODE-z1"
fm_test_spawn_brief "$HOME_DIR" "$ID" "Drive the launch-truncation readiness gate end to end."

"$REAL_TMUX" -L "$SOCKET" new-session -d -s firstmate -x 200 -y 50 "/bin/bash --noprofile --norc -i" 2>/dev/null

export FM_FAKE_WT="$WT" FM_FAKE_MARKER="$TMP/harness-marker"
# New windows inherit the tmux SERVER's environment, not the client's, so the
# pane's PATH/HOME/fixture vars have to be set on the server explicitly.
for v in FM_FAKE_WT FM_FAKE_MARKER HOME; do
  "$REAL_TMUX" -L "$SOCKET" set-environment -g "$v" "$(eval printf '%s' "\$$v")"
done
"$REAL_TMUX" -L "$SOCKET" set-environment -g PATH "$FAKEBIN:$BASE_PATH"
: > "$FM_FAKE_MARKER"
unset TMUX TMUX_PANE
set +e
out=$(
  FM_ROOT_OVERRIDE='' FM_HOME="$HOME_DIR" \
  FM_STATE_OVERRIDE="$HOME_DIR/state" FM_DATA_OVERRIDE="$HOME_DIR/data" \
  FM_PROJECTS_OVERRIDE="$HOME_DIR/projects" FM_CONFIG_OVERRIDE="$HOME_DIR/config" \
  FM_SPAWN_NO_GUARD=1 FM_PANE_READY_TIMEOUT="${FM_PANE_READY_TIMEOUT:-5}" \
  PATH="$FAKEBIN:$BASE_PATH" \
  "$ROOT/bin/fm-spawn.sh" "$ID" "$PROJ" --mode no-mistakes --yolo off 2>&1
)
status=$?
set -e
echo "=== MODE=$MODE   FM_PANE_READY_TIMEOUT=${FM_PANE_READY_TIMEOUT:-5}"
echo "--- fm-spawn.sh exit status: $status"
echo "--- fm-spawn.sh output (what the operator sees):"
printf '%s\n' "$out" | grep -v '^warning: ' | cut -c1-220 | sed 's/^/    /'
echo "--- state/$ID.status (what recovery and the crew board read):"
sed 's/^/    /' "$HOME_DIR/state/$ID.status" 2>/dev/null || echo "    (no status file)"
i=0; while [ $i -lt 100 ]; do [ -s "$FM_FAKE_MARKER" ] && break; sleep 0.1; i=$((i+1)); done
echo "--- pane tail (what an operator sees in the window):"
"$REAL_TMUX" -L "$SOCKET" capture-pane -p -t "firstmate:fm-$ID" 2>/dev/null | grep -v '^$' | tail -4 | cut -c1-140 | sed 's/^/    /'
echo "--- harness marker (written by the launched process itself):"
if [ -s "$FM_FAKE_MARKER" ]; then
  head -2 "$FM_FAKE_MARKER" | sed 's/^/    /'
  echo "    argv it received: $(tail -n +3 "$FM_FAKE_MARKER" | wc -c | tr -d ' ') bytes, first 90: $(tail -n +3 "$FM_FAKE_MARKER" | head -1 | cut -c1-90)"
else
  echo "    (no worker started)"
fi
echo "--- host ~/.treehouse untouched: $(ls "$HOME/.treehouse" 2>/dev/null | wc -l | tr -d ' ') entries under the sandboxed HOME"

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⚠️ **Rebase** - 1 warning

Confirm these commits belong in this PR before approving, or manually separate the intended work onto origin/main before gating.

⚠️ **Review** - 1 info
  • ⚠️ 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 gets send-failed after the full ready budget instead of the text being typed, and for fm-control.sh exit that turns into a hard die. 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, one sleep $poll PLUS a command substitution that forks tmux display-message and stty. 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 report after ${FM_PANE_READY_TIMEOUT:-5}s, which is simply not the elapsed time. Concretely: bin/fm-spawn.sh:4210 blocks ~10-15s before emitting the launch command not delivered failure 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 same awk -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 reads baseline_state=$(fm_pane_busy_state &#34;$target&#34;) 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 an unknown composer read into the empty (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 writes failed: launch command not delivered: window &lt;T&gt; was still busy and never started reading input into $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 families backend-dispatch and orca (bin/fm-test-run.sh:1356); an edit to bin/fm-tmux-lib.sh selects pure-contract-unit (bin/fm-test-run.sh:1524); this new regression suite is in neither, so fm-test-run.sh --changed never 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: add fm-tmux-long-launch.test.sh to 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 three export lines 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 (an export runs 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 only pure-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 runs bin/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: add printf &#39;%s\n&#39; backend-dispatch to 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 of tmux send-keys -t &#34;$1&#34; -l &#34;$2&#34; 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 sibling recover-missing commit on this branch exists to repair. fm_tmux_pane_input_mode's tmux display-message then fails, which the helper deliberately maps to unknown and treats as ready, so the gate returns 0; tmux send-keys then fails with "no server running"/"can't find session"; spawn writes failed: launch command not delivered: window &lt;T&gt; was still busy and never started reading input into $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 2 for the gate, leaving tmux 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-poll awk fork 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.sh line 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-missing refuses 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 task t-42 is mid-task with src/foo.ts modified; its tmux server dies, so the endpoint classifies missing. bin/fm-control.sh t-42 recover-missing --note &#39;...&#39; reaches bin/fm-control.sh:1029-1030, where CHECKPOINT_STATUS_RAW holds M src/foo.ts, the exemption regex only skips ?? .claude/ and ?? .fm-(grok|kimi)-turnend, so dirty is non-empty and it dies with "worktree ... has uncommitted changes; refusing to recover rather than cleaning it". The fallback is not available either: relaunch routes through do_exit, which dies on a missing endpoint 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_relaunch runs the same safe_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"), and fm-spawn.sh --relaunch adopts 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 three export lines sent at bin/fm-spawn.sh:4156-4168; fm_tmux_pane_input_mode samples raw during 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_literal returns 0, spawn_send_key &#34;$T&#34; Enter submits 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 $LAUNCH before 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, and FM_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/ reads FM_PANE_READY_POLL or 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 reports FM_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 reuse fm_timing_now_ms also executes its top-level set -u (bin/fm-timing-lib.sh:45) in the sourcing shell, and it sets FM_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 inside fm_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 already set -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 &lt;id&gt; relaunch runs bin/fm-spawn.sh --relaunch, which adopts the recorded window (bin/fm-spawn.sh:2783-2791) and never clears it - there is no clear-history, clear, or C-l in 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 &#34;$(__OPINPUT__ encode launch-brief &lt; __BRIEF__)&#34; (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 -c wrapper (: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 BEFORE tmux send-keys and 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 after tmux send-keys returns (which only queues the keys), fails, sleeps 0.2s once, captures again, then breaks to return 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-byte LAUNCH (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 several fm-spawn-batch spawns competing on the host. The text DID land, but bin/fm-spawn.sh:4216-4223 records failed: launch command not delivered: the command did not reach window &lt;T&gt; whole and 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 same fm_timing_now_ms deadline shape fm_tmux_wait_pane_input_ready already 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 -200 window, 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 &lt;id&gt; relaunch adopts 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, [ &#34;$seen&#34; -gt &#34;$baseline&#34; ] 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 records failed: launch command not delivered: the command did not reach window &lt;T&gt; whole and 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 &#34;$1&#34; &#34;$probe&#34;) || baseline=0 makes 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 [ &#34;$seen&#34; -gt &#34;$baseline&#34; ] and confirms a send that was in fact discarded. The window is small - it needs tmux capture-pane to fail while tmux send-keys on 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 by send-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 bash resolves here) and bash 5.3.9, so it is not a version-specific quirk. With an empty probe, fm_backend_tmux_pane_probe_count never terminates: case &#34;$seen&#34; in *&#34;&#34;*) always matches and seen=${seen#*&#34;&#34;} 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 [ &#34;${#probe}&#34; -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 (or abc, or -3), the awk at line 254 prints 0 (verified on this host for all three), so the case at line 255 sees all digits and leaves budget_ms=0; deadline_ms equals now, and the loop at 257-262 takes one sample, finds canonical, 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 a failed: launch command not delivered status 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. Note FM_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 &#34;$budget_ms&#34; in &#39;&#39;|*[!0-9]*|0) budget_ms=5000 ;; esac, so the fallback matches the 5s the refusal message claims.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 8 of 9 scenarios driven live against the product
Scenario Result Live Evidence
The reported failure reproduces: a ~1.2KB launch command typed into a busy pane vanishes and no worker starts ✅ pass live repro-truncation.sh case 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 discarded
Same command through the shipped gated send starts a worker and arrives byte-identical ✅ pass live repro-truncation.sh case B, 3 runs: gated send returns 0, the launched process writes its own marker, and cmp shows the received payload identical to what was sent
An operator spawns a task and the real fm-spawn.sh actually starts the harness with the full launch command ✅ pass live spawn-e2e.sh ok - real bin/fm-spawn.sh against a real tmux server prints spawned e2e-ok-z1 ... window=firstmate:fm-e2e-ok-z1, and the launched process records codex really started with a 2721-…
A pane that never reads input makes the spawn fail loudly with a recorded failure, not a silent no-agent ✅ pass live spawn-e2e.sh busy with FM_PANE_READY_TIMEOUT=2 - exit 1, both refusal lines on stderr naming the window and the reason, and state/&lt;id&gt;.status containing `failed: launch command not delivered: wind…
The gate's refusal is distinguishable from tmux send-keys failing on its own ✅ pass live tests/fm-tmux-long-launch.test.sh case 2 on a real cat &gt; /dev/null pane: status 2 for the gate refusal, status 1 for a send to a session that does not exist
An unreadable tty stays permissive and a ready pane does not spend the wait budget ✅ pass live tests/fm-tmux-long-launch.test.sh cases 3 and 4 against a real tmux pane - an unresolvable target reads unknown and is treated as ready, and a pane at its prompt returns in under a second of a 5s…
Everyday short sends to a busy pane are still delivered rather than refused by the gate ✅ pass live short-send-unaffected.sh - fm_backend_tmux_send_text_line to a pane measured canonical returns 0 and the command runs once the pane frees up
Adversarial: splitting the send into ~400-byte chunks does not rescue a busy pane, and an idle pane takes the whole command ✅ pass live chunking-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…
The launch-send refusal is reported correctly for the non-tmux session backends (herdr, zellij, orca, cmux) ⏸️ untested no herdr needs the guarded Herdr lab and its lifecycle credentials, and zellij, orca and cmux are not installed on this host. To cover it, install those session providers or grant access to the Herdr lab…
  • 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 time
  • bash tests/fm-backend-tmux-smoke.test.sh - the existing real-tmux backend suite, to confirm the gate did not disturb the other send primitives
  • A/B repro driver repro-truncation.sh - same 1238-byte launch command into the same busy pane, pre-fix tmux send-keys -l vs the shipped gated send, run 3x with identical results
  • spawn-e2e.sh ok - the real bin/fm-spawn.sh CLI spawning a ship task against a real tmux server on a private socket, with a stand-in harness binary that records that it actually started
  • spawn-e2e.sh busy with FM_PANE_READY_TIMEOUT=2 - same real CLI onto a pane whose program never reads input, asserting the recorded failed: status line and exit 1
  • short-send-unaffected.sh - fm_backend_tmux_send_text_line to a busy pane, confirming everyday short sends are not refused by the gate
  • chunking-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 row
  • canon-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.

bastotec and others added 10 commits September 15, 2026 10:39
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant