Skip to content

fix(composer): classify a Unicode-space-separated prompt glyph as an empty composer - #1995

Closed
mackcee wants to merge 4 commits into
kunchenguid:mainfrom
mackcee:fm/fm-composer-read-unreliable
Closed

mackcee wants to merge 4 commits into
kunchenguid:mainfrom
mackcee:fm/fm-composer-read-unreliable

Conversation

@mackcee

@mackcee mackcee commented Aug 9, 2026

Copy link
Copy Markdown

Intent

Fix a deterministic composer misclassification: fm_backend_composer_state returns pending for a claude composer that is affirmatively empty. pending means "real unsubmitted text is sitting there", so every caller that must not type over the captain's half-written message refuses to act. Observed cost: bin/fm-supervise-daemon.sh deferred every away-mode escalation for 8.3 hours overnight (2105 deferrals reading "composer not confirmed-empty" against only 3 genuine "pane busy"), leaving two finished pieces of work unshipped; bin/fm-send.sh reported "text not submitted (delivery unconfirmed; verdict=pending)" for a message that had visibly landed, inviting a duplicate steer.

ROOT CAUSE (accepted, and it SUPERSEDES the two hypotheses the original task brief proposed - the brief blamed either the prompt glyph's truecolor luminance sitting above the 128 ghost threshold, or the input area being drawn with horizontal rules instead of a boxed border; firstmate later instructed me to discard both). Claude renders the idle composer as U+276F followed by U+00A0 NO-BREAK SPACE. fm_composer_classify_content accepted a bare glyph and glyph+ASCII-space as empty, but not glyph+U+00A0, which fell through to pending.

The brief required establishing the cause by counterfactual rather than by reading the code and forming an opinion, changing one condition at a time and recording whether the verdict moved. I did that against the live panes and both original hypotheses were falsified: recolouring the glyph (including to the exact truecolor luminance suspected) did NOT move the verdict, and deleting the horizontal rules did NOT move it, while changing ONLY the separator did. It reproduces identically on tmux and herdr; on tmux the row is nothing but the glyph and the separator, and there the glyph is a 256-colour foreground that is never luminance-tested at all. Upstream filed the same finding as #1988 with the same proof; the fix is shaped to close it, and its "Suggested directions" 1 and 2 (normalise Unicode spaces generally rather than enumerating glyph+separator pairs; add a regression pinning glyph+U+00A0 to empty) are implemented.

REQUIRED APPROACH. Prefer normalising Unicode whitespace generally over enumerating more glyph+separator pairs, and fix the single-character strip too: ${content#??}/${content#?} assumed a one-character separator, which breaks on any multi-byte separator independently of the match (measured: it drops one BYTE under LC_ALL=C and one CHARACTER under a UTF-8 locale, leaving locale-dependent trailing bytes on a multibyte glyph). Distinguish the composer's own decoration from user content using the most structural signal available rather than another brightness number, and do not let a single vendor string be load-bearing - a rendered glyph and its colour are exactly what a harness release can change without warning.

HARD CONSTRAINT, deliberately chosen and central to review: do NOT weaken the predicate. This guard's entire purpose is to never type over text a human has half-written. empty must remain an affirmative verdict, real typed text MUST still read pending, and unknown must stay available for genuinely unreadable panes. Making it too permissive would make firstmate silently destroy the captain's unsent input, which is a worse and silent failure than the one being fixed. So the fix follows the Unicode White_Space=Yes property (a standards fact) rather than a brightness threshold or another observed string; whitespace-only content already classified empty when the whitespace was ASCII, and any non-whitespace character anywhere still classifies pending. The bare dead-shell-prompt refusal is unchanged with or without a separator.

DELIBERATE DECISIONS a reviewer reading only the diff would not know:

  • U+200B ZERO WIDTH SPACE is deliberately EXCLUDED from normalization because Unicode gives it White_Space=No; including it would substitute my own guess for the property the owner claims to follow. This boundary is pinned by a test asserting U+200B still reads pending.
  • The prompt glyphs were spelled out in three separate places, which bin/fm-composer-lib.sh's own header already flagged as a drift hazard ("must be listed in ALL THREE places"); they are now declared exactly once each and reached through helpers. This is behaviour-preserving.
  • The shared normalizing trim is applied in all four adapters (tmux, herdr, orca, cmux) so a non-ASCII space cannot defeat one adapter's structural row scan while another's still matches.
  • Normalization substitutes a space rather than deleting, so "foobar" is not silently joined into one token.
  • The live guard types its OWN marker, confirms the harness rendered it, clears it with C-u, and confirms it is gone before reading the empty composer - so empty is affirmative rather than assumed. It accepts a startup trust dialog with Enter ONLY after the pane has demonstrably not reflected typed input, so it can never submit a real composer or consume model tokens. It reports an absent harness explicitly and refuses a pass that checked nothing.

TESTS, both required by .agents/skills/firstmate-coding-guidelines "Harness-dependent checks":

  • A portable regression under tests/ extending existing scripts rather than adding a runner, pinning the real captured row shapes: the empty composer that must read empty, and a genuinely-typed-into one that must still read pending (the second matters more than the first). Because U+00A0 is invisible in any capture, the fixtures assert they still contain the separator so no case can pass vacuously. Also pins the whole White_Space property set and locale independence.
  • The env-gated, self-skipping live guard in the live-harness-optin family exercising every INSTALLED harness for real and failing by name and version, since a stub can only confirm the assumption written into it.
    Verified against real claude 2.1.226 on tmux 3.5a: the empty row is e2 9d af c2 a0, and both the portable regression and the live guard fail on that exact row when the fix is reverted. The dated per-harness result is recorded in docs/verification/runtime-backends.md as required.

SCOPE, explicitly bounded by the brief and reaffirmed by firstmate: the composer-state read and its callers only. Do NOT restructure away mode, do NOT change the wake queue, and do NOT touch the Stop-hook watcher path (that path works and is currently the only reliable way firstmate gets woken). Upstream issue 1988's directions 3 and 4 are away-mode changes and are deliberately NOT implemented here.

A third reported symptom - fm-send.sh --resolve-key <key> refusing with "no open decision or blocker with that key" while the wake drain listed that key open - was to be treated as possibly a SEPARATE defect and not folded in silently. I established it IS separate: a status line written as needs-decision: [key=slug] ... puts the key token AFTER the colon, while _fm_decision_key only parses it BEFORE the colon, so the decision silently degrades to key default. Different subsystem and different mechanism from the composer bug, and it already has its own task and branch (fm/fm-decision-key-position). It is deliberately excluded from this change.

Known pre-existing failures NOT caused by this change, each verified to reproduce on the unmodified tree: tests/fm-afk-inject-herdr-e2e.test.sh fails under LC_ALL=C with the fix reverted too; tests/fm-lint.test.sh needs the pinned shellcheck on PATH; tests/fm-test-run.test.sh needs LC_ALL=C collation. With the pinned shellcheck and LC_ALL=C, the full changed-selection suite is 71 scripts with only that pre-existing away-mode E2E failing.

What Changed

  • Added fm_composer_normalize_spaces_var / fm_composer_normalize_trim_var to bin/fm-composer-lib.sh, mapping every non-ASCII code point with the Unicode White_Space=Yes property (U+0085, U+00A0, U+1680, U+2000–U+200A, U+2028, U+2029, U+202F, U+205F, U+3000 — deliberately not U+200B, which is White_Space=No) onto an ASCII space before every trim, border strip, and glyph comparison, so claude's empty row ❯ + U+00A0 now classifies empty instead of pending. The predicate is not otherwise loosened: any non-whitespace character still reads pending, and a bare shell glyph still reads unknown. The same shared trim replaces the open-coded ASCII-only trims in the tmux, herdr, orca, and cmux structural row scans, where the same separator made a bordered composer read unknown.
  • Consolidated the prompt glyphs into single declarations (FM_COMPOSER_AGENT_PROMPT_GLYPHS, FM_COMPOSER_SHELL_PROMPT_GLYPHS) reached via fm_composer_leading_prompt_glyph_var / fm_composer_blank_leading_prompt_var, replacing the three inline copies in the classifier plus the drifted copy in fm_tmux_composer_geometry_spaces (which omitted muse's ⟩). The glyph strip now removes the matched literal instead of ${content#?}/${content#??}, which dropped one byte under LC_ALL=C and one character under a UTF-8 locale.
  • Added regression coverage pinning the captured e2 9d af c2 a0 row to empty and typed input to pending (tests/fm-composer-lib.test.sh, tests/fm-composer-ghost.test.sh, tests/fm-backend-herdr.test.sh, with fixtures asserting the separator is present so no case passes vacuously), plus a new env-gated live guard tests/fm-composer-harness-drift-live-e2e.test.sh that types and clears its own marker before reading each installed harness; bin/fm-test-run.sh routes bin/fm-composer* and bin/fm-tmux-lib.sh changes to the live-harness-optin family. Backend docs, the harness-adapters skill, and docs/verification/runtime-backends.md record the whitespace boundary and the dated per-harness table (claude 2.1.226 on tmux 3.5a; every uninstalled harness listed as unverified).

Risk Assessment

✅ Low: The change is well-bounded to the composer-state read and its four adapters, the predicate is verifiably not weakened in the dangerous direction (bare dead-shell prompts, ZWSP, and real typed text all still refuse), the Unicode table matches the standard property exactly, both fix rounds' claims check out against the current code, and the only outstanding item is a test-enumeration gap over data I verified correct.

Testing

I proved the intent end-to-end against the real harness rather than only in fixtures: driving bin/fm-supervise-daemon.sh's actual away-mode escalation guard against a live claude 2.1.226 composer on tmux 3.5a reproduced the reported "composer not confirmed-empty (state=pending)" deferral on the reverted classifier and showed the escalation accepted on the fix, against a composer the demo had itself emptied and whose bytes decode to e2 9d af c2 a0; the hard constraint holds on the same live pane, since real unsubmitted text still reads pending and still defers. The opt-in live drift guard passes on the fix and fails by name and version when reverted, and reports the seven uninstalled harnesses and the uncovered bordered path rather than reading as full coverage. All portable suites for the changed classifier and the four adapters pass, each new regression fails on base sources in both C and UTF-8 locales, and the test-runner change correctly selects 71 scripts including the new live guard. The one failure seen, the away-mode herdr E2E under LC_ALL=C, reproduces identically on the unmodified base tree and passes here in a UTF-8 locale, so it is pre-existing and not caused by this change. No visual artifact applies: the affected surface is a terminal composer read and a daemon log line, both captured as CLI transcripts, and the defect is invisible in any rendered capture because U+00A0 only appears once the bytes are decoded.

Evidence: Away-mode escalation guard against a live claude composer: before/after the fix, plus the safety half

== BEFORE THE FIX (composer classifier reverted to base commit 2d2be63) == -- claude version: 2.1.226 (Claude Code) -- marker cleared; the composer is now affirmatively EMPTY. Its raw bytes: e2 9d af c2 a0 (e2 9d af = U+276F '\xe2\x9d\xaf' ; c2 a0 = U+00A0 NO-BREAK SPACE) -- what fm_backend_composer_state reads off that live pane: pending -- running the real inject_msg() away-mode escalation guard: inject_msg -> DEFERRED (escalation withheld) -- daemon log: [2026-08-09T06:40:02+0000] inject deferred: supervisor composer not confirmed-empty (state=pending: pending input, dead-shell prompt, or unreadable pane) == AFTER THE FIX (worktree at deb3692) == -- what fm_backend_composer_state reads off that live pane: empty -- running the real inject_msg() away-mode escalation guard: inject_msg -> ACCEPTED (escalation would be delivered to the captain) -- daemon log: == AFTER THE FIX - SAFETY HALF: real unsubmitted text still blocks injection == -- marker deliberately LEFT in the composer (unsubmitted human text). Its raw bytes: e2 9d af c2 a0 7a 71 78 66 6d 67 75 61 72 64 64 65 6d 6f -- what fm_backend_composer_state reads off that live pane: pending -- running the real inject_msg() away-mode escalation guard: inject_msg -> DEFERRED (escalation withheld) -- daemon log: [2026-08-09T06:41:09+0000] inject deferred: supervisor composer not confirmed-empty (state=pending: pending input, dead-shell prompt, or unreadable pane)

### Away-mode escalation guard against a REAL claude 2.1.226 composer on tmux 3.5a
### (bin/fm-supervise-daemon.sh inject_msg; only the final send is stubbed, so no tokens are spent)

== BEFORE THE FIX (composer classifier reverted to base commit 2d2be63) ==
-- claude version: 2.1.226 (Claude Code)
-- pane with our typed marker still in the composer (the 'human is half-way through' case):
     ❯ zqxfmguarddemo
-- marker cleared; the composer is now affirmatively EMPTY. Its raw bytes:
      e2 9d af c2 a0 
     (e2 9d af = U+276F '\xe2\x9d\xaf' ; c2 a0 = U+00A0 NO-BREAK SPACE)
-- what fm_backend_composer_state reads off that live pane:
     pending
-- running the real inject_msg() away-mode escalation guard:
     inject_msg -> DEFERRED (escalation withheld)
-- daemon log:
     [2026-08-09T06:40:02+0000] inject deferred: supervisor composer not confirmed-empty (state=pending: pending input, dead-shell prompt, or unreadable pane)

== AFTER THE FIX (worktree at deb3692) ==
-- claude version: 2.1.226 (Claude Code)
-- pane with our typed marker still in the composer (the 'human is half-way through' case):
     ❯ zqxfmguarddemo
-- marker cleared; the composer is now affirmatively EMPTY. Its raw bytes:
      e2 9d af c2 a0 
     (e2 9d af = U+276F '\xe2\x9d\xaf' ; c2 a0 = U+00A0 NO-BREAK SPACE)
-- what fm_backend_composer_state reads off that live pane:
     empty
-- running the real inject_msg() away-mode escalation guard:
     inject_msg -> ACCEPTED (escalation would be delivered to the captain)
-- daemon log:

== AFTER THE FIX - SAFETY HALF: real unsubmitted text still blocks injection ==
-- claude version: 2.1.226 (Claude Code)
-- pane with our typed marker still in the composer (the 'human is half-way through' case):
     ❯ zqxfmguarddemo
-- marker deliberately LEFT in the composer (unsubmitted human text). Its raw bytes:
      e2 9d af c2 a0 7a 71 78 66 6d 67 75 61 72 64 64 65 6d 6f 
     (e2 9d af = U+276F '\xe2\x9d\xaf' ; c2 a0 = U+00A0 NO-BREAK SPACE)
-- what fm_backend_composer_state reads off that live pane:
     pending
-- running the real inject_msg() away-mode escalation guard:
     inject_msg -> DEFERRED (escalation withheld)
-- daemon log:
     [2026-08-09T06:41:09+0000] inject deferred: supervisor composer not confirmed-empty (state=pending: pending input, dead-shell prompt, or unreadable pane)
Evidence: Live harness drift guard on the fix (real claude 2.1.226, tmux 3.5a)

# claude 2.1.226 (Claude Code): startup row bytes 20 e2 9d af 20 31 2e 20 59 65 73 2c 20 49 20 74 72 75 73 74 20 74 68 69 73 20 66 6f 6c 64 65 72 # claude 2.1.226 (Claude Code): typed input was not rendered back; accepting a startup confirmation with Enter and retrying # claude 2.1.226 (Claude Code): composer reached through the bare-row path # claude 2.1.226 (Claude Code): EMPTY composer row bytes e2 9d af c2 a0 ok - composer drift: claude 2.1.226 (Claude Code) reads pending with real typed text and empty once cleared (via the bare-row path) # not installed on this machine: codex opencode pi pi-signed grok kimi muse # checked 1 installed harness(es) end to end # structural paths exercised: bare-row # no installed harness drew a BORDERED composer box, so the bordered structural path is unverified by this run (tests/fm-composer-ghost.test.sh pins it portably)

# claude 2.1.226 (Claude Code): startup row bytes  20 e2 9d af 20 31 2e 20 59 65 73 2c 20 49 20 74 72 75 73 74 20 74 68 69 73 20 66 6f 6c 64 65 72 
# claude 2.1.226 (Claude Code): typed input was not rendered back; accepting a startup confirmation with Enter and retrying
# claude 2.1.226 (Claude Code): composer reached through the bare-row path
# claude 2.1.226 (Claude Code): EMPTY composer row bytes  e2 9d af c2 a0 
ok - composer drift: claude 2.1.226 (Claude Code) reads pending with real typed text and empty once cleared (via the bare-row path)
# skip: codex is not installed on this machine, so its composer rendering is unverified here
# skip: opencode is not installed on this machine, so its composer rendering is unverified here
# skip: pi is not installed on this machine, so its composer rendering is unverified here
# skip: pi-signed is not installed on this machine, so its composer rendering is unverified here
# skip: grok is not installed on this machine, so its composer rendering is unverified here
# skip: kimi is not installed on this machine, so its composer rendering is unverified here
# skip: muse is not installed on this machine, so its composer rendering is unverified here
# not installed on this machine: codex opencode pi pi-signed grok kimi muse
# checked 1 installed harness(es) end to end
# structural paths exercised: bare-row
# no installed harness drew a BORDERED composer box, so the bordered structural path is unverified by this run (tests/fm-composer-ghost.test.sh pins it portably)
Evidence: Same live guard against base-commit sources — fails by name and version

not ok - COMPOSER DRIFT: claude 2.1.226 (Claude Code) has a composer this guard just emptied - the typed marker is gone from the rendered pane - yet it classifies 'pending' instead of 'empty', reached through the bare-row path. ... Decoded composer row: e2 9d af c2 a0 (U+00A0 NO-BREAK SPACE is the byte pair c2 a0 ...)

# claude 2.1.226 (Claude Code): startup row bytes  20 e2 9d af 20 31 2e 20 59 65 73 2c 20 49 20 74 72 75 73 74 20 74 68 69 73 20 66 6f 6c 64 65 72 
# claude 2.1.226 (Claude Code): typed input was not rendered back; accepting a startup confirmation with Enter and retrying
# claude 2.1.226 (Claude Code): composer reached through the bare-row path
not ok - COMPOSER DRIFT: claude 2.1.226 (Claude Code) has a composer this guard just emptied - the typed marker is gone from the rendered pane - yet it classifies 'pending' instead of 'empty', reached through the bare-row path. Every caller that must not overwrite unsubmitted input now refuses to act against this harness: away-mode escalations stop being delivered and steer confirmations report landed messages as unconfirmed. On the bare-row path a 'pending' verdict means the separator or prompt glyph this release renders is not one bin/fm-composer-lib.sh recognises (bare-row drift usually reads 'pending'; a bordered box whose blanked geometry no longer matches its border reads 'unknown'). Decoded composer row:  e2 9d af c2 a0  (U+00A0 NO-BREAK SPACE is the byte pair c2 a0; fm_composer_normalize_trim_var maps every Unicode White_Space=Yes code point, so a byte run outside that property is the thing to add).
Evidence: Harness script used for the live away-mode guard demo (evidence-only, outside the worktree)
#!/usr/bin/env bash
# Product-level demo: drive bin/fm-supervise-daemon.sh's real away-mode
# escalation guard (inject_msg) against a REAL, live, affirmatively-empty
# claude composer in a private tmux server, and show the daemon log line the
# captain would actually read.
#
# The only thing stubbed is the final send (fm_backend_send_text_submit), so no
# text is ever typed into or submitted to the real harness and no model tokens
# are consumed. Everything before it - pane-exists, busy-guard, composer-guard -
# is the real product code reading the real pane.
#
# usage: daemon-guard-demo.sh <tree-root> <label>
set -u
ROOT=$1
LABEL=$2

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

mkdir -p "$LAB/shim" "$LAB/wt" "$LAB/state"
cat > "$LAB/shim/tmux" <<SH
#!/usr/bin/env bash
exec "$REAL_TMUX" -L "$SOCKET" "\$@"
SH
chmod +x "$LAB/shim/tmux"
PATH="$LAB/shim:$PATH"; export PATH

MARKER=zqxfmguarddemo
TARGET="$SESSION:claude"

"$REAL_TMUX" -L "$SOCKET" new-session -d -s "$SESSION" -n control -c "$LAB/wt"
"$REAL_TMUX" -L "$SOCKET" new-window -d -t "$SESSION:" -n claude -c "$LAB/wt" -- "$(command -v claude)"
sleep 6

pane_has() { "$REAL_TMUX" -L "$SOCKET" capture-pane -p -t "$TARGET" 2>/dev/null | LC_ALL=C grep -qa "$MARKER"; }

# Prove the pane is really at a composer by typing our OWN marker and seeing the
# harness render it back; a startup trust dialog never takes it.
at_composer=0
for _ in 1 2 3; do
  "$REAL_TMUX" -L "$SOCKET" send-keys -l -t "$TARGET" "$MARKER"
  for _ in $(seq 1 20); do pane_has && { at_composer=1; break; }; sleep 0.5; done
  [ "$at_composer" = 1 ] && break
  "$REAL_TMUX" -L "$SOCKET" send-keys -t "$TARGET" C-u >/dev/null 2>&1 || true
  "$REAL_TMUX" -L "$SOCKET" send-keys -t "$TARGET" Enter >/dev/null 2>&1 || true
  sleep 4
done
[ "$at_composer" = 1 ] || { echo "ABORT: never reached a real claude composer"; exit 2; }

echo "== $LABEL =="
echo "-- claude version: $(claude --version 2>/dev/null | head -1)"
echo "-- pane with our typed marker still in the composer (the 'human is half-way through' case):"
"$REAL_TMUX" -L "$SOCKET" capture-pane -p -t "$TARGET" | grep -a "$MARKER" | tail -1 | sed 's/^/     /'

# Clear it, and confirm it is GONE from the rendered pane: the composer is now
# affirmatively empty, because we just emptied it. With CLEAR=0 the marker is
# deliberately LEFT in place, standing in for a captain's half-written message:
# the guard must still refuse, or firstmate would type over it.
if [ "${CLEAR:-1}" = 1 ]; then
  "$REAL_TMUX" -L "$SOCKET" send-keys -t "$TARGET" C-u >/dev/null 2>&1 || true
  cleared=0
  for _ in $(seq 1 40); do pane_has || { cleared=1; break; }; sleep 0.5; done
  [ "$cleared" = 1 ] || { echo "ABORT: composer did not clear"; exit 2; }
  sleep 2
  echo "-- marker cleared; the composer is now affirmatively EMPTY. Its raw bytes:"
else
  pane_has || { echo "ABORT: the marker vanished on its own"; exit 2; }
  echo "-- marker deliberately LEFT in the composer (unsubmitted human text). Its raw bytes:"
fi

row=$("$REAL_TMUX" -L "$SOCKET" capture-pane -p -t "$TARGET" | grep -a "$(printf '\xe2\x9d\xaf')" | tail -1)
printf '%s' "$row" | LC_ALL=C od -An -tx1 | tr -s ' \n' ' ' | sed 's/^/     /'
echo ""
echo "     (e2 9d af = U+276F '\xe2\x9d\xaf' ; c2 a0 = U+00A0 NO-BREAK SPACE)"

# Now the real daemon guard.
# shellcheck source=/dev/null
. "$ROOT/bin/fm-supervise-daemon.sh"
LOG="$LAB/daemon.log"; : > "$LOG"
FM_STATE_OVERRIDE="$LAB/state"; export FM_STATE_OVERRIDE
afk_enter "$LAB/state"
FM_SUPERVISOR_BACKEND=tmux
FM_SUPERVISOR_TARGET="$TARGET"
# Stub ONLY the final send so the demo never types into or submits to the real
# harness. Reaching this stub at all means every guard ahead of it passed.
fm_backend_send_text_submit() { echo "STUBBED-SEND" >&2; printf 'empty'; }

echo "-- what fm_backend_composer_state reads off that live pane:"
echo "     $(fm_backend_composer_state tmux "$TARGET")"
echo "-- running the real inject_msg() away-mode escalation guard:"
if inject_msg "two finished pieces of work are unshipped, come look" 2>/dev/null; then
  echo "     inject_msg -> ACCEPTED (escalation would be delivered to the captain)"
else
  echo "     inject_msg -> DEFERRED (escalation withheld)"
fi
echo "-- daemon log:"
sed 's/^/     /' "$LOG"

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ⚠️ bin/fm-tmux-lib.sh:190 - Intent conformance: the criteria state "The shared normalizing trim is applied in all four adapters (tmux, herdr, orca, cmux) so a non-ASCII space cannot defeat one adapter's structural row scan while another's still matches." For tmux that is not the case. The trim was applied to fm_tmux_composer_row_state (lines 132/134/141), but tmux's structural row scan - which bin/fm-composer-lib.sh's own header names as "tmux's visible-pane box scan" - still uses the raw ASCII-only trim at fm-tmux-lib.sh:190-192, and fm_tmux_composer_geometry_spaces:166/172-175 still tests the leftover bytes with [![:space:]]. Verified read-only against the changed code: fm_tmux_find_composer_box 1 with pane rows '╭────────╮' / '│ ❯<U+00A0> │' / '╰────────╯' returns "0 2 1" (geometry_ambiguous=1), while the identical pane with an ASCII space returns "0 2 0". fm_tmux_composer_state:342 converts that flag into 'unknown' even though fm_tmux_composer_row_state classifies the row 'empty' - so a bordered tmux composer separated with U+00A0 still never reads confirmed-empty, and every caller that must not overwrite unsubmitted input still refuses to act. That is the exact authorized failure this change fixes, surviving on the sibling path in the same file. herdr's ANSI tail scan and orca/cmux's read-screen scans were normalized, so tmux is precisely the "one adapter defeated while another matches" case the criterion says cannot happen. Earliest supported shared boundary: run each captured line through fm_composer_normalize_trim inside fm_tmux_find_composer_box's loop (and in fm_tmux_composer_geometry_spaces' probe) instead of the open-coded ${line#"${line%%[![:space:]]*}"} pair. Not proven live-reachable for claude today (its tmux composer is a bare glyph row, not a box), which is why this is a warning rather than an error - but it contradicts a stated deliberate coverage claim, so it is the author's call whether to close it here or as a follow-up.
  • ℹ️ bin/fm-composer-lib.sh:140 - _fm_composer_normalize_space_var is documented as replacing in place "so the wrapper below adds no subshell", but fm_composer_normalize_trim prints to stdout and all 12 call sites consume it via command substitution, so every call forks anyway - plus one heredoc temp file per call for the 19-entry mapping loop. The row loops are the cost: bin/backends/orca.sh:276 runs this once per captured line with FM_BACKEND_ORCA_COMPOSER_LINES defaulting to 200, where the previous code was pure parameter expansion with zero forks. Measured on this worktree: 200 command substitutions of fm_composer_normalize_trim take ~72ms versus ~1ms for the parameter-expansion form, per composer read, and composer_state is polled by bin/fm-supervise-daemon.sh and re-read inside the send-submit retry loops. Absolute cost is small, so this is informational: exposing the existing in-place form as a public fm_composer_normalize_trim_var <varname> and using it in the orca/cmux/herdr row loops would deliver the design the comment already describes.
  • ℹ️ bin/fm-tmux-lib.sh:169 - The change's stated deliberate decision is that the prompt glyphs "are now declared exactly once each and reached through helpers", and FM_COMPOSER_AGENT_PROMPT_GLYPHS does that for the classifier. fm_tmux_composer_geometry_spaces is a fourth place that still spells them out inline ('>' , '❯', '›') and is already drifted: it omits '⟩' (muse, U+27E9), which the classifier does recognise. Consequence on the bordered tmux path: a muse composer's content row keeps its multibyte glyph, sed 's/[!-~]/ /g' cannot flatten it, the [![:space:]] test at line 174 fires, geometry_spaces returns 1, and fm_tmux_find_composer_box sets geometry_ambiguous=1 - so an otherwise-empty muse box reads 'unknown' rather than 'empty'. Pre-existing rather than introduced here, and it is the same drift hazard the header comment was rewritten to eliminate; reaching FM_COMPOSER_AGENT_PROMPT_GLYPHS from this helper would close it.
  • ℹ️ bin/backends/herdr.sh:2708 - fm_backend_herdr_pi_separator_row still uses the open-coded ASCII-only trim and then requires the remainder be nothing but '─' ([ -z "${row//─/}" ]). A Pi rule padded or terminated with any non-ASCII space fails that test, so no complete separator pair is found, fm_backend_herdr_composer_state's 'separated' shape is never established, and the verdict degrades to 'unknown' - the same refuse-to-act outcome, reached through the structural half of the herdr adapter that the row loop at line 2782 normalized but this helper did not. No evidence any Pi release pads its rules that way today, so this is informational; routing this trim through fm_composer_normalize_trim like its sibling would make the herdr adapter internally consistent.

🔧 Fix: normalize Unicode spaces and glyphs in tmux/herdr structural scans
3 infos still open:

  • ℹ️ bin/fm-composer-lib.sh:31 - The fix round added a header claim that is not accurate: "An ADAPTER that needs to recognise a prompt glyph in its own structural scan - tmux's box-geometry probe is the one such caller - reaches the same declarations ... rather than becoming a fourth copy" (bin/fm-composer-lib.sh:30-35). herdr's adapter has a second such scan: FM_BACKEND_HERDR_BARE_PROMPT_RE at bin/backends/herdr.sh:2700 is '^(❯|›)', spelling out two of the three agent glyphs inline and omitting muse's '⟩'. It is the sole gate for the bare shape in fm_backend_herdr_composer_state (herdr.sh:2793-2799): a row that is neither '│''│' nor matched by that regex leaves found=0 and the verdict is unknown. So this is a second declaration of ❯ and ›, which also contradicts the accepted intent's deliberate decision that the glyphs "are now declared exactly once each and reached through helpers". I could NOT establish that the failure is live-reachable, and I am reporting that honestly rather than asserting it: the repo's two records disagree on muse's composer shape. .agents/skills/harness-adapters/SKILL.md:419 says "Bordered box whose prompt glyph is ⟩", in which case herdr's '│''│' case matches first and this regex never matters; docs/verification/muse.md:150-151 shows the actual tmux capture-pane -p -e rows as a border-free ⟩ line, in which case an empty muse composer on herdr never establishes a shape and reads unknown while the same pane on tmux reads empty. The code is pre-existing and unchanged by this diff (its alternation form has a documented locale rationale at herdr.sh:2691-2699, so it cannot simply become a bracket class), and it was not in the round-1 findings or the fix instructions. Author's call: either reach FM_COMPOSER_AGENT_PROMPT_GLYPHS when building that regex and reconcile the two muse records, or narrow the new header claim so it does not assert a uniqueness the tree does not have.
  • ℹ️ bin/fm-composer-lib.sh:169 - fm_composer_normalize_trim (the value-returning form) has zero callers after the fix round converted all twelve call sites to fm_composer_normalize_trim_var - I grepped every *.sh and *.md in the tree and the only hits are its own definition and the doc line in docs/verification/runtime-backends.md:184, which names the _var form. It is a public, untested function in a shared library, so nothing would catch it drifting from the _var form it wraps. Either drop it, or keep it and note it is currently unused; the comment at :165-168 already explains it is deliberately not the default, so a reader has no way to tell "reserved for future callers" from "leftover".
  • ℹ️ bin/fm-composer-lib.sh:403 - fm_composer_classify_content still does content=$(_fm_composer_strip_leading_prompt &#34;$content&#34;), a command substitution, immediately after the same file's comment at :165-168 argues the value-returning form is not the default precisely because "consuming it costs a subshell per call". _fm_composer_strip_leading_prompt is now a thin wrapper over fm_composer_leading_prompt_glyph_var, so the fork is removable in place with no new mapping and no behavior change: if fm_composer_leading_prompt_glyph_var glyph &#34;$content&#34;; then content=${content#*&#34;$glyph&#34;}; fi. Cost is small and bounded - the early returns above mean this line is only reached for rows that carry real content, and a tmux content row already forks three times (strip_ansi, strip_ghost, and the per-row sed -n Np in fm_tmux_composer_state:338) - so this is efficiency tidying, not a regression. Verified equivalence of the substitution while reviewing: fm_composer_leading_prompt_glyph_var only matches a glyph at the first non-whitespace position and classify_content trims before this line, so #*&#34;$glyph&#34; can never strip past the intended glyph.

🔧 Fix: drop dead trim wrapper, inline glyph strip, correct header claim
1 info still open:

  • ℹ️ tests/fm-composer-lib.test.sh:163 - test_unicode_whitespace_property_set_is_covered independently spells out 11 separators ('\302\205' 00A0 1680 2000 2007 200A 2028 2029 202F 205F 3000) but the implementation's FM_COMPOSER_UNICODE_SPACES holds 19. The eight unpinned entries are U+2001-U+2006, U+2008 and U+2009 - the interior of the one contiguous run in the table, and the run most exposed to a single-digit slip because the table is hand-transcribed octal ('\0342\0200\0201' .. '\0342\0200\0212' at bin/fm-composer-lib.sh:141-143). I decoded all 19 entries at runtime and they are byte-correct today, so this is a coverage gap and not a live defect; the point is that a future edit dropping or mistyping U+2003 would not fail anything, because the only other test that touches the set (test_every_declared_prompt_glyph_is_blankable_and_classified) iterates the glyph declarations, not the space table, and iterating the table against itself would pass with a wrong byte sequence in it. The intent states the portable regression 'pins the whole White_Space property set'; extending the existing literal loop to all 19 escapes (the assertions already in the test body need no change) is what makes that true. Independent literal spelling is the right shape here - do not replace it with a loop over FM_COMPOSER_UNICODE_SPACES, which would be self-referential.
✅ **Test** - passed

✅ No issues found.

  • FM_COMPOSER_HARNESS_DRIFT=1 bash tests/fm-composer-harness-drift-live-e2e.test.sh — live guard, real claude 2.1.226 on tmux 3.5a: passes (empty row e2 9d af c2 a0, bare-row path); same guard against base-commit sources fails with a named COMPOSER DRIFT error
  • Manual end-to-end: drove the real inject_msg() away-mode escalation guard in bin/fm-supervise-daemon.sh against a live claude composer emptied by the harness itself (marker typed, rendered back, cleared with C-u, confirmed gone), with only fm_backend_send_text_submit stubbed so no text was submitted and no model tokens spent — reproduced the reported inject deferred: supervisor composer not confirmed-empty (state=pending...) on reverted sources and ACCEPTED on the fix
  • Manual end-to-end safety half: same live pane with real unsubmitted text left in the composer — fm_backend_composer_state reads pending and inject_msg still DEFERS
  • LC_ALL=C bash tests/fm-composer-lib.test.sh (13 ok; White_Space property set, U+200B stays pending, locale independence across C/C.utf8/en_US.utf8, dead-shell refusal, all 7 declared glyphs blankable)
  • LC_ALL=C bash tests/fm-composer-ghost.test.sh (bordered + unbordered tmux paths, muse ⟩, ambiguous geometry still unknown)
  • LC_ALL=C bash tests/fm-backend-herdr.test.sh (new ❯+U+00A0 empty/pending cases and U+00A0-padded Pi separator cases)
  • Revert proof: ran tests/fm-composer-lib.test.sh and tests/fm-composer-ghost.test.sh against a tree with bin/fm-composer-lib.sh, bin/fm-tmux-lib.sh and the three adapters restored to 2d2be63 — both fail (got &#39;pending&#39;) in C and C.UTF-8
  • LC_ALL=C bash tests/fm-backend-orca.test.sh, tests/fm-backend-cmux.test.sh, tests/fm-backend.test.sh, tests/fm-test-run.test.sh — all pass
  • LC_ALL=C bash bin/fm-test-run.sh --changed --base 2d2be63 --list — selects 71 scripts and includes tests/fm-composer-harness-drift-live-e2e.test.sh, confirming the changed-file map wiring
  • LC_ALL=C bash tests/fm-afk-inject-herdr-e2e.test.sh on this tree and on a clean 2d2be63 checkout — fails identically on both (pre-existing); passes on this tree in the default UTF-8 locale
🔧 **Document** - 1 issue found → auto-fixed ✅
  • ⚠️ .agents/skills/harness-adapters/SKILL.md:419 - Two doc surfaces still contradict each other on muse's composer shape, and I could not resolve it here because muse is not installed on this machine. .agents/skills/harness-adapters/SKILL.md:419 records muse's composer as a "Bordered box whose prompt glyph is ⟩ (U+27E9)", while docs/verification/muse.md:150-151 shows a captured row with no box-drawing border - just ⟩ plus an ASCII space with a background fill. Which one is true decides whether herdr's FM_BACKEND_HERDR_BARE_PROMPT_RE (which spells out ❯ and › and omits ⟩) is reachable at all: if muse draws a bare row, an empty muse composer reads unknown on herdr while the same pane reads empty on tmux. This change's new comment in bin/fm-composer-lib.sh names the contradiction and defers the permissive regex fix to its own task; the doc side needs one live muse capture to settle which surface is stale, then a correction in the wrong one. Follow-up, not fixable in this change.

🔧 Fix: cross-reference muse composer shape contradiction on both surfaces
✅ Re-checked - no issues remain.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

kunchenguid commented Aug 10, 2026 •

Copy link
Copy Markdown
Owner

Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch.

When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again.

Noted for firstmate#1995 at ed2c271c.

@mackcee
mackcee force-pushed the fm/fm-composer-read-unreliable branch from ed2c271 to 04b709c Compare August 10, 2026 02:38
@kunchenguid kunchenguid removed the wheelhouse:pending-contributor-action Managed by Wheelhouse label Aug 10, 2026
kunchenguid added a commit that referenced this pull request Aug 10, 2026
…le matrix fixed

Consolidate every composer shape - bordered boxes (all families, geometry,
titled bottom borders), bare agent-glyph rows and their wrap regions,
opencode's left bar, and pi's identity-gated separator pair - into
fm_composer_classify_screen in bin/fm-composer-lib.sh. Adapters now
contribute only a capture and a declarative capability descriptor
(styled/cursor/identity/rows); capability differences change how confidently
a shape is judged, never what the shapes are, so a new harness shape is
teachable in exactly one place.

Correctness fixes landed as part of the consolidation (audit
data/fm-composer-consolidation-audit-s1):
- locale-safe Unicode-space normalization in the shared owner (closes the
  fleet-wide half of #1988; cmux's local byte-exact NBSP case deleted;
  naming converges with PR #1995's normalization primitive)
- muse's bare glyph joins the shared set, unbreaking muse on herdr/cmux/orca
- orca learns the borderless bare shape, drops its backward-paged composer
  window, and can no longer classify a stale startup banner as the composer
- tmux tolerates a titled bottom border, unbreaking grok steering
- the left-bar shape makes opencode readable on every backend
- zellij gets a real classifier through dump-screen --ansi, replacing the
  content-diff submit heuristic that could confirm an undelivered message
  and close a --resolve-key decision (the fleet's only false positive)
- fm-spawn's kimi launch-readiness regex (the fourth shape copy) now routes
  through the shared classifier

The strict blank-row posture applies fleet-wide (captain decision
blank-row-injection-posture): no positive container proof = unknown = defer,
replacing tmux's permissive blank-cursor-row rule. Away-mode injection was
re-validated end to end on real tmux (defer on partial input and unproven
rows, clean delivery with swallowed-Enter retry into proven-empty
composers). The tmux submit core gains a baseline-idle turn-started
conversion so pi steering stays confirmed while its working screen hides
the composer; busy conversion without that baseline remains forbidden.

Plain-capture backends now degrade a glyph row carrying trailing text to
unknown instead of a false pending, per the approved capability rule.

Portable regressions pin the full byte-capture matrix from the audit under
a UTF-8 locale and LC_ALL=C, the strict-vs-permissive divergence, and
deliberate signal separation; the opt-in live guard
(tests/fm-composer-matrix-live-e2e.test.sh) verified every installed
harness against the real classifier, recorded in
docs/verification/runtime-backends.md.
kunchenguid added a commit that referenced this pull request Aug 11, 2026
* refactor(composer): one shape owner behind thin capture adapters, whole matrix fixed

Consolidate every composer shape - bordered boxes (all families, geometry,
titled bottom borders), bare agent-glyph rows and their wrap regions,
opencode's left bar, and pi's identity-gated separator pair - into
fm_composer_classify_screen in bin/fm-composer-lib.sh. Adapters now
contribute only a capture and a declarative capability descriptor
(styled/cursor/identity/rows); capability differences change how confidently
a shape is judged, never what the shapes are, so a new harness shape is
teachable in exactly one place.

Correctness fixes landed as part of the consolidation (audit
data/fm-composer-consolidation-audit-s1):
- locale-safe Unicode-space normalization in the shared owner (closes the
  fleet-wide half of #1988; cmux's local byte-exact NBSP case deleted;
  naming converges with PR #1995's normalization primitive)
- muse's bare glyph joins the shared set, unbreaking muse on herdr/cmux/orca
- orca learns the borderless bare shape, drops its backward-paged composer
  window, and can no longer classify a stale startup banner as the composer
- tmux tolerates a titled bottom border, unbreaking grok steering
- the left-bar shape makes opencode readable on every backend
- zellij gets a real classifier through dump-screen --ansi, replacing the
  content-diff submit heuristic that could confirm an undelivered message
  and close a --resolve-key decision (the fleet's only false positive)
- fm-spawn's kimi launch-readiness regex (the fourth shape copy) now routes
  through the shared classifier

The strict blank-row posture applies fleet-wide (captain decision
blank-row-injection-posture): no positive container proof = unknown = defer,
replacing tmux's permissive blank-cursor-row rule. Away-mode injection was
re-validated end to end on real tmux (defer on partial input and unproven
rows, clean delivery with swallowed-Enter retry into proven-empty
composers). The tmux submit core gains a baseline-idle turn-started
conversion so pi steering stays confirmed while its working screen hides
the composer; busy conversion without that baseline remains forbidden.

Plain-capture backends now degrade a glyph row carrying trailing text to
unknown instead of a false pending, per the approved capability rule.

Portable regressions pin the full byte-capture matrix from the audit under
a UTF-8 locale and LC_ALL=C, the strict-vs-permissive divergence, and
deliberate signal separation; the opt-in live guard
(tests/fm-composer-matrix-live-e2e.test.sh) verified every installed
harness against the real classifier, recorded in
docs/verification/runtime-backends.md.

* no-mistakes(review): Fix Pi glyph ambiguity and complete profile matrix

* no-mistakes(review): Preserve bare verdict when Pi identity probe is absent

* no-mistakes(review): Harden composer structure and titled-border geometry

* no-mistakes(review): Require proven idle baseline and strict Zellij guard

* no-mistakes(review): Reject box bottom borders as composer input rows

* no-mistakes(review): Prove Zellij probe typing before classifier retries

* no-mistakes(review): Preserve Pi identity uncertainty and scan full left-bar drafts

* no-mistakes(review): Verify Zellij text lands before submitting

* no-mistakes(review): Scope Zellij typing verification to selected composer content

* no-mistakes(review): Verify Zellij pastes through composer-scoped content deltas

* no-mistakes(review): Prove wrapped bare Zellij pastes through composer extraction

* no-mistakes(review): Invalidate stale cursorless composers below dead shell prompts

* no-mistakes(review): Handle shell prompt placeholders in composer extraction

* no-mistakes(review): Classify cursorless bare continuation regions safely

* no-mistakes(review): Reject stale cursorless containers below live activity

* no-mistakes(review): Preserve prompt glyphs in wrapped Zellij pastes

* no-mistakes(review): Reject live shell rows during composer extraction

* no-mistakes(review): Preserve wrapped glyph continuations through submit retries

* no-mistakes(review): Scope idle placeholders to proven positions

* no-mistakes(review): Restore boxed placeholders and live prompt reanchoring

* no-mistakes(review): Fix Zellij placeholder and wrapped glyph paste proof

* no-mistakes(document): Align composer architecture documentation

* no-mistakes(lint): Fix ShellCheck warnings in composer refactor

* no-mistakes: apply CI fixes

* docs(verification): record the trusted-checkout live matrix rerun

The pipeline's isolated gate worktree is untrusted, so claude, grok, and
muse stopped at first-launch trust dialogs there (the guard refuses to
confirm them by design). This rerun from the trusted checkout at the final
validated head verified all six installed harnesses, the strict blank-row
deferral, and the hardened zellij false-positive probe live.

* no-mistakes(document): Align composer verification evidence

* no-mistakes: apply CI fixes

* no-mistakes(review): Restore proven box bottom-cursor classification

* no-mistakes(review): Preserve styled placeholder-like drafts as pending

* no-mistakes(document): Align composer safety and Zellij delivery documentation

* no-mistakes: apply CI fixes

* docs(verification): refresh the live matrix with the final-head trusted rerun

The post-validation rerun from the trusted checkout verified all six
installed harnesses at the branch's final head, including Claude 2.1.227
(auto-updated since the audit's captures) and Grok, which the untrusted
gate worktree could not verify past their first-launch trust dialogs.
…y composer

Claude 2.x separates its composer prompt glyph from the composer's content
with U+00A0 NO-BREAK SPACE rather than an ASCII space, so an affirmatively
empty composer renders as exactly `❯` U+00A0. Every trim and glyph
comparison in the shared classifier tested only POSIX `[[:space:]]`, which
bash excludes U+00A0 from under the C and UTF-8 locales alike, so that lone
separator survived as apparent typed content and the row classified
`pending` - the verdict meaning "a human's unsubmitted text is sitting
there". Every caller that must not overwrite unsubmitted input then refused
to act: away-mode escalation delivery deferred 2105 times across 8.3 hours
against an idle pane, and steer confirmation reported landed messages as
unconfirmed.

Established by counterfactual against the live panes rather than by reading
the code: varying the separator alone moved the verdict, while recolouring
the glyph (including to the truecolor luminance originally suspected) and
removing the input area's horizontal rules did not. Reproduced identically
on tmux and herdr, where the tmux row is nothing but the glyph and the
separator.

fm_composer_normalize_trim now maps every code point carrying the Unicode
property White_Space=Yes onto an ASCII space before any trim, border strip,
or glyph comparison. That is a standards property rather than one more
vendor-observed string, so it covers whichever space-like character a
harness switches to next, and it cannot make the predicate more permissive:
whitespace-only content already classified `empty` when the whitespace was
ASCII, and any non-whitespace character anywhere still classifies `pending`.
The bare dead-shell refusal is unchanged, with or without a separator.

The leading-glyph strip used `${content#?}`, which drops one byte under
LC_ALL=C and one character under a UTF-8 locale, leaving locale-dependent
trailing bytes on a multibyte glyph; it now removes the glyph as a literal
string. The prompt glyphs themselves were spelled out in three separate
places, which the file's own header flagged as a drift hazard, and are now
declared once each.

The four adapters route their structural row trims through the same shared
helper, so a non-ASCII space cannot defeat one adapter's row scan while
another's still matches.

Tests, per the harness-dependent-check rule:
- Portable regressions pinning the real captured rows in CI - the empty
  composer that must read `empty` and the typed-into one that must still
  read `pending` - asserting the fixtures still carry the invisible
  separator so no case can pass vacuously, and pinning the whole
  White_Space property set plus locale independence.
- tests/fm-composer-harness-drift-live-e2e.test.sh, env-gated and
  self-skipping, drives every installed harness for real: it types a
  marker, confirms the harness renders it, clears it, confirms it is gone,
  and only then reads the affirmatively empty composer. It fails naming the
  harness and version with the decoded row bytes, reports an absent harness
  explicitly, and refuses a pass that checked nothing.

Verified against real claude 2.1.226 on tmux 3.5a: the empty row is
`e2 9d af c2 a0`, and the guard fails on that exact row without this fix.
Dated per-harness evidence is recorded in docs/verification/runtime-backends.md.

Refs kunchenguid#1988
@mackcee
mackcee force-pushed the fm/fm-composer-read-unreliable branch from 04b709c to f689500 Compare August 11, 2026 02:12
abhi-sama added a commit to abhi-sama/firstmate that referenced this pull request Aug 12, 2026
…y livelock fix) (#9)

* docs: add project vision (kunchenguid#1997)

* docs: add firstmate vision

* no-mistakes(test): Classify VISION.md as public product documentation

* no-mistakes(document): Restore approved one-file vision diff

* no-mistakes: apply CI fixes

* fix(spawn): force regular Pi TUI for crews (kunchenguid#2005)

* fix(spawn): force regular Pi TUI for crews

* no-mistakes(document): Documented Pi regular TUI launch mode

* fix(cmux): classify borderless Claude composers (kunchenguid#2029)

* fix(cmux): classify borderless Claude composer

* no-mistakes(review): Normalize cmux NBSP prompts across locales

* no-mistakes(document): Document cmux borderless Claude composer classification

* docs(stow): generalize read-before-write in the public stow skill (kunchenguid#2091)

The public installer-facing stow skill scoped its classify-then-replace
discipline to TODO/BACKLOG items only, so findings routed to a memory file
had no stated rule against a blind append or a wholesale overwrite.

Step 6 now classifies every finding against the destination's current
contents as new, duplicate, superseding, or obsolete, and states the
considered replacement each classification implies. The outcomes follow the
tiered-memory contract already in the file: an obsolete entry is refreshed,
archived, or replaced in a way that preserves its fact, a duplicate folds
into the entry that already carries it, and a superseded body worth keeping
leaves through step 7's existing exits rather than a second recovery
mechanism.

* fix: resurface durable supervision work after re-arm (kunchenguid#2065)

* fix(watcher): resurface durable work after downtime

* no-mistakes(review): Make watcher rearm recovery durable and cursor-safe

* no-mistakes(review): Persist safe recovery markers across migration lock recovery

* no-mistakes(review): Retain stale lock when recovery marker publication fails

* no-mistakes(review): Preserve delivery-gap recovery and quarantine malformed markers

* no-mistakes(review): Serialize recovery consumption and report acknowledgment failures

* no-mistakes(review): Centralize recovery publication before clearing watcher evidence

* no-mistakes(review): Guarantee recovery evidence across queue and lock handoffs

* no-mistakes(review): Publish recovery evidence before durable wake commits

* no-mistakes(review): Replace recovery marker Perl dependency with Node

* no-mistakes(review): Keep interrupted wakes durable until handling acknowledgment

* no-mistakes(review): Add post-handling durable wake acknowledgements

* no-mistakes(review): Enforce post-handling acknowledgement across recovery and AFK return

* no-mistakes(review): Bind wake acknowledgements to recovery generations

* no-mistakes(review): Align wake regressions with generation-bound acknowledgements

* no-mistakes(document): Document durable re-arm recovery semantics

* no-mistakes(lint): Resolve ShellCheck warnings in recovery and watcher tests

* no-mistakes: apply CI fixes

* test(watcher): assert post-handling wake replay

* no-mistakes(review): Prevent successor loops and adopt legacy wake generations

* no-mistakes(review): Rearm durable wakes without recursive successor recovery

* no-mistakes(review): Align recovery tests with handling marker state

* no-mistakes(review): Delay handling transition until successor launch is established

* no-mistakes(review): Confirm wake handling only after successful prompt delivery

* no-mistakes(review): Acknowledge AFK wakes only after evidence publication

* no-mistakes(review): Prevent AFK wake loss before post-handling acknowledgement

* no-mistakes(document): Document durable wake acknowledgement semantics

* no-mistakes(lint): Suppress false positive for recovery action output

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* ci: measure Herdr automation on Windows runners (kunchenguid#2100)

* ci: add Windows Herdr automation spike

* ci: run Windows spike on its pull request

* fix: wait for Windows Herdr command output

* fix: run ANSI probe in pane shell

* ci: keep Windows Herdr spike manually triggered

* docs: clarify Windows Herdr spike verdict

* feat(ahoy): guide captains through open decisions (kunchenguid#2099)

* Add guided ahoy decision flow

* no-mistakes(document): Document guided Ahoy decision flow

* fix(stow): enforce startup-memory budget decisions (kunchenguid#2110)

* Harden stow memory budget policy

* Refine internal stow offload policy

* no-mistakes(review): Enforce shared-budget decisions and autonomous offload

* fix(spawn): refresh pooled worktrees from origin before launch (kunchenguid#2116)

* fix(spawn): refresh pooled worktree base

* no-mistakes(document): Document spawn base-freshness invariant

* no-mistakes: apply CI fixes

* fix(composer): unify safe classification across backends (kunchenguid#2102)

* refactor(composer): one shape owner behind thin capture adapters, whole matrix fixed

Consolidate every composer shape - bordered boxes (all families, geometry,
titled bottom borders), bare agent-glyph rows and their wrap regions,
opencode's left bar, and pi's identity-gated separator pair - into
fm_composer_classify_screen in bin/fm-composer-lib.sh. Adapters now
contribute only a capture and a declarative capability descriptor
(styled/cursor/identity/rows); capability differences change how confidently
a shape is judged, never what the shapes are, so a new harness shape is
teachable in exactly one place.

Correctness fixes landed as part of the consolidation (audit
data/fm-composer-consolidation-audit-s1):
- locale-safe Unicode-space normalization in the shared owner (closes the
  fleet-wide half of kunchenguid#1988; cmux's local byte-exact NBSP case deleted;
  naming converges with PR kunchenguid#1995's normalization primitive)
- muse's bare glyph joins the shared set, unbreaking muse on herdr/cmux/orca
- orca learns the borderless bare shape, drops its backward-paged composer
  window, and can no longer classify a stale startup banner as the composer
- tmux tolerates a titled bottom border, unbreaking grok steering
- the left-bar shape makes opencode readable on every backend
- zellij gets a real classifier through dump-screen --ansi, replacing the
  content-diff submit heuristic that could confirm an undelivered message
  and close a --resolve-key decision (the fleet's only false positive)
- fm-spawn's kimi launch-readiness regex (the fourth shape copy) now routes
  through the shared classifier

The strict blank-row posture applies fleet-wide (captain decision
blank-row-injection-posture): no positive container proof = unknown = defer,
replacing tmux's permissive blank-cursor-row rule. Away-mode injection was
re-validated end to end on real tmux (defer on partial input and unproven
rows, clean delivery with swallowed-Enter retry into proven-empty
composers). The tmux submit core gains a baseline-idle turn-started
conversion so pi steering stays confirmed while its working screen hides
the composer; busy conversion without that baseline remains forbidden.

Plain-capture backends now degrade a glyph row carrying trailing text to
unknown instead of a false pending, per the approved capability rule.

Portable regressions pin the full byte-capture matrix from the audit under
a UTF-8 locale and LC_ALL=C, the strict-vs-permissive divergence, and
deliberate signal separation; the opt-in live guard
(tests/fm-composer-matrix-live-e2e.test.sh) verified every installed
harness against the real classifier, recorded in
docs/verification/runtime-backends.md.

* no-mistakes(review): Fix Pi glyph ambiguity and complete profile matrix

* no-mistakes(review): Preserve bare verdict when Pi identity probe is absent

* no-mistakes(review): Harden composer structure and titled-border geometry

* no-mistakes(review): Require proven idle baseline and strict Zellij guard

* no-mistakes(review): Reject box bottom borders as composer input rows

* no-mistakes(review): Prove Zellij probe typing before classifier retries

* no-mistakes(review): Preserve Pi identity uncertainty and scan full left-bar drafts

* no-mistakes(review): Verify Zellij text lands before submitting

* no-mistakes(review): Scope Zellij typing verification to selected composer content

* no-mistakes(review): Verify Zellij pastes through composer-scoped content deltas

* no-mistakes(review): Prove wrapped bare Zellij pastes through composer extraction

* no-mistakes(review): Invalidate stale cursorless composers below dead shell prompts

* no-mistakes(review): Handle shell prompt placeholders in composer extraction

* no-mistakes(review): Classify cursorless bare continuation regions safely

* no-mistakes(review): Reject stale cursorless containers below live activity

* no-mistakes(review): Preserve prompt glyphs in wrapped Zellij pastes

* no-mistakes(review): Reject live shell rows during composer extraction

* no-mistakes(review): Preserve wrapped glyph continuations through submit retries

* no-mistakes(review): Scope idle placeholders to proven positions

* no-mistakes(review): Restore boxed placeholders and live prompt reanchoring

* no-mistakes(review): Fix Zellij placeholder and wrapped glyph paste proof

* no-mistakes(document): Align composer architecture documentation

* no-mistakes(lint): Fix ShellCheck warnings in composer refactor

* no-mistakes: apply CI fixes

* docs(verification): record the trusted-checkout live matrix rerun

The pipeline's isolated gate worktree is untrusted, so claude, grok, and
muse stopped at first-launch trust dialogs there (the guard refuses to
confirm them by design). This rerun from the trusted checkout at the final
validated head verified all six installed harnesses, the strict blank-row
deferral, and the hardened zellij false-positive probe live.

* no-mistakes(document): Align composer verification evidence

* no-mistakes: apply CI fixes

* no-mistakes(review): Restore proven box bottom-cursor classification

* no-mistakes(review): Preserve styled placeholder-like drafts as pending

* no-mistakes(document): Align composer safety and Zellij delivery documentation

* no-mistakes: apply CI fixes

* docs(verification): refresh the live matrix with the final-head trusted rerun

The post-validation rerun from the trusted checkout verified all six
installed harnesses at the branch's final head, including Claude 2.1.227
(auto-updated since the audit's captures) and Grok, which the untrusted
gate worktree could not verify past their first-launch trust dialogs.

* fix(spawn): gate Pi TUI mode by CLI capability (kunchenguid#2117)

* fix(spawn): gate Pi regular TUI flag by capability

* no-mistakes(review): Document conditional Pi TUI capability detection

* no-mistakes(review): Pin Pi probing and launch to one executable

* no-mistakes(review): Preserve literal pinned Pi paths and update documentation

* no-mistakes(review): Defer pinned Pi path insertion until final substitution

* no-mistakes(document): Document version-safe Pi launch probing

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* docs(vision): elevate experience, pain narrative, and distro virtues (kunchenguid#2147)

* docs(vision): elevate experience, pain narrative, and distro virtues

Fold the captain's public vision framing into VISION.md: peace of mind as a
primary goal, multi-session context-switch pain as the problem one interface
solves, clone-and-run setup ease, self-evolution including community, and
explicit harness/backend orthogonality. Reconcile experience-as-garnish into
experience-as-purpose and update aligns/resists accordingly.

* docs(vision): state the experience goal positively

Drop the negative "not a smart workflow / useful tool / impressive technology"
pretext. Lead straight into the positive experience north star.

* feat(bin): reconcile inactive terminal crew outcomes (kunchenguid#2167)

* fix: reconcile inactive terminal outcomes

* fix: stream secondmate summary inputs

* no-mistakes(review): Fix reconciliation locking and request delivery retries

* no-mistakes(review): Prevent retries after unknown request delivery

* no-mistakes(document): Clarify inactive reconciliation cadence and receipts

* no-mistakes(lint): Quote terminal status arguments in reconciliation tests

* refactor: simplify inactive outcome reconciliation

* no-mistakes(review): Bound inactive reconciliation scans with durable progress

* no-mistakes(review): Bound reconciliation and deduplicate recovery notices

* no-mistakes(document): Document inactive outcome reconciliation contracts

* no-mistakes(review): Reject relative local secondmate parent routes

* no-mistakes(review): Key terminal receipts by spawn incarnation

* no-mistakes(review): Stabilize legacy receipts and lock reconciliation snapshots

* no-mistakes(review): Fail closed on invalid secondmate identity markers

* no-mistakes(document): Document durable inactive-outcome reconciliation

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* ci: raise Herdr test timeout (kunchenguid#2191)

* fix: refresh stale Pi instructions after compaction (kunchenguid#2163)

* fix(session-start): refresh drifted instructions on stale rebuilds

* test(session-start): prove Pi instruction refresh end to end

* no-mistakes(review): Fix stale instruction refresh and baseline integrity

* no-mistakes(review): Preserve true-start baselines across Pi continuations

* no-mistakes(review): Correct Pi continuation classification and live expectation

* no-mistakes(review): Correct Pi continuation coverage documentation

* no-mistakes(review): Fix read-only refresh and exact Pi session restores

* no-mistakes(review): Classify Pi create-if-missing sessions correctly

* no-mistakes(review): Classify named Pi sessions using immutable headers

* no-mistakes(review): Correct Codex interactive coverage diagnostic

* no-mistakes(document): Document immutable Pi compaction instruction refresh

* no-mistakes(document): Correct Pi refresh documentation and validation claims

* feat: add deterministic condition-to-action watcher (kunchenguid#2200)

* feat(bin): add deterministic condition->action watch adapter on the process-event channel

Register a (condition, action) pair once with bin/fm-procevent-when.sh and the
existing process-to-event runner polls the condition tokenlessly, fires the
action at most once on a stable true, and wakes firstmate exactly once with the
captured outcome - instead of burning an agent turn per re-check.

The pair is stored privately under state/when/ and hash-bound by a trust record
the same way fm-check-register.sh binds a custom check, so a mutated spec is
refused without executing anything. A durable exclusive fired marker claimed
before the action makes restarts and re-polls unable to double-fire; every
failure path (mutated spec, condition error past budget, expired deadline,
failed action, uncaptured earlier fire) ends in a terminal captured outcome
that wakes firstmate rather than a silent retry. Eligibility stays a firstmate
judgment: only exact, safe, reversible actions may be bound, and judgment-
needing or destructive actions keep the wake-and-decide flow.

* no-mistakes(review): Harden when watcher concurrency, deadlines, timeouts, and output

* no-mistakes(test): Bind watcher actions to registered executable bytes

* no-mistakes(document): Correct condition-action watcher documentation

* no-mistakes(document): Clarify outcome wake re-announcement

* no-mistakes: apply CI fixes

* fix(bin): honor a decision key stated after the verb colon (kunchenguid#2202)

The open-decisions fold only recognized a [key=<slug>] token between the
verb and the colon (needs-decision [key=x]: note). The common worker
shape with the colon first (needs-decision: [key=x] note) silently
folded its stated key into the shared "default" bucket, so two open
decisions could collapse into one record and fm-send --resolve-key <x>
refused to close the decision it plainly named.

A complete token at the head of the note is now an equivalent stated-key
position for every keyed verb, shared by the whole-file and incremental
folds through the one _fm_decision_key owner. The documented
before-colon position wins when both are present, a token deeper in the
note stays prose, a bare keyless line still folds to "default", and a
stated-but-malformed slug is rejected rather than rewritten to
"default". A consumed note-head token is stripped from the note so both
positions yield identical records, and the incremental fold version is
bumped so persisted cursors folded under the old interpretation are
rebuilt from the authoritative log.

Fixes kunchenguid#2109

* fix(bin): prevent watcher recovery acknowledgement livelock (kunchenguid#2212)

* fix(bin): keep a recovery acknowledgement valid across republication

A watcher cycle that opened and closed while the model handled its drained
wakes minted a fresh recovery generation, which invalidated the exact
acknowledgement the drain had just printed. That acknowledgement then consumed
nothing, so the marker stayed pending and every later arm spent its whole cycle
re-announcing the same recovery instead of supervising - a livelock the home
could not leave on its own.

A downtime publication now reuses the generation of an outstanding handling
episode, so a close during the handling window cannot orphan the printed
acknowledgement. The acknowledgement itself separates its two facts: queue-row
consumption is bound to the monotonic --ack-through sequence and always
happens, while only retiring the episode is bound to --recovery-generation. A
generation that moved on is a non-fatal result that names its own remedy
instead of a refusal that consumes nothing.

* no-mistakes(review): Preserve recovery generations and consume stale acknowledgements safely

* no-mistakes(document): Document sequence-bound recovery acknowledgements

* feat(fmx-respond): consume Relay conversation chains (kunchenguid#2206)

* feat(fmx-respond): consume in_reply_to_chain conversation context

The relay's poll payload can carry in_reply_to_chain, an oldest-first
transcript of the surrounding conversation, but the mention-handling
procedure only ever read the immediate in_reply_to parent, so referents
like "this" in a standalone mention stayed unresolvable even when
context was delivered.

Teach fmx-respond to read the chain when present (optional and
backward-compatible: often absent today, kind label not required),
resolve referents against the whole transcript, and extend the
untrusted-content framing to every chain entry including the upcoming
kind=history entries. Document the field's wire shape in
docs/configuration.md as the firstmate-side owner.

* no-mistakes(document): Document Relay chain context ownership

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Roelof Blom <[email protected]>
spirispark added a commit to spirispark/firstmate that referenced this pull request Aug 13, 2026
* fix: preserve fleet state in truncated session-start digests (#1798)

* feat(session-start): order the startup digest for truncation safety and bound its bulk

The digest is delivered through a harness that truncates an oversized payload
from the tail, and it really has been truncated: a 70KB digest arrived as lines
1-435 of 578, cutting off eight lines before the live-task inventory. That
session took the helm without ever seeing which tasks were live or where their
endpoints were.

Three changes, one file's worth of composition:

- FLEET STATE is emitted before CONTEXT, so a truncated tail drops curated
  memory - stable session to session, already governed by a captain-set budget,
  recoverable with one targeted read - instead of live fleet identity. The
  LOCK/BOOTSTRAP/WAKE-QUEUE safety preamble keeps its order. The read-once
  contract moves out of the closing reminder into its own section ahead of both,
  and now names the condition that voids it: a stage the truncation banner
  reports as never emitted.

- Status-tail lines are capped per line, reusing the cut the wake digest's OPEN
  DECISIONS section already applies. An observed tail line ran 865 characters
  and nothing bounded it. The cut and its marker now live in one place,
  bin/fm-line-cap-lib.sh, so the two digests cannot drift apart; each task's
  full status log path is still printed beside its tail.

- The backlog listing is composed as a recovery input: done rows are never
  listed, every in-flight, held, and blocked row is shown in full with its hold
  and blocked-by metadata, and only the dispatchable-now listing is bounded -
  with an exact remainder count and the command that shows the rest.
  FM_SESSION_START_QUEUED_LIMIT (default 20) replaces
  FM_SESSION_START_BACKLOG_LIMIT, which bounded the whole listing
  indiscriminately and so could drop a held or blocked row.

Tests exercise the real digest output: section ordering with the preamble
pinned, the per-line cap and its marker, and the backlog composition including
the remainder counters on both the tasks-axi and manual paths.

* no-mistakes(document): Clarify digest source recovery comments

* feat(send): close answered decisions at answer time via --resolve-key (#1842)

A captain decision opened by a keyed needs-decision:/blocked: status line
orphaned as permanently open whenever the answer kicked off work: the
worker's next event is working [key=<workstream>] in a different key
namespace, so no resolved [key=<decision>] ever landed and the OPEN
DECISIONS fold kept listing the answered decision forever.

Remove the writer-dependency at its source: the answering firstmate
already holds the decision key when it sends the answer, so fm-send's new
--resolve-key flag (repeatable) appends the closing resolved line to this
home's own state/<id>.status after the submit is confirmed. The close is
a local ledger append for crewmates, local secondmates, and remote
secondmates alike - a remote mate's escalations reach this ledger through
the parent-replies ingest, so only the answer message crosses the
transport.

Safety: each named key must currently be open per the authoritative
status_open_decisions fold or fm-send refuses before sending; a failed or
unconfirmed send never closes a key; an append failure after a delivered
answer exits nonzero with the manual close command so the decision
re-surfaces instead of silently vanishing; a send without the flag closes
nothing, and working:/done: still never clear a captain decision.

Complementary fixes: the wake-drain OPEN DECISIONS section prints the
answer-with-close command hint at the moment of use; brief scaffolds
separate resolved's two duties (keyed-phase end vs decision closure) and
state that a done:/working: line never closes a decision even when the
answer started that work, keeping worker self-close for blockers that
clear without a firstmate reply; AGENTS.md and docs/architecture.md carry
the one-line pointers to the fm-send contract.

* fix(bin): seed remote secondmates from supplied origins (#1836)

* feat(secondmate): seed a remote home from a supplied project origin

Remote seeding required a local projects/<name> clone purely to read
`git remote get-url origin` into the provisioning manifest, so setting up
a remote second mate forced disposable clones and no-mistakes inits in the
primary home for projects that home has no reason to hold.

Firstmate now resolves the origin itself and names it as <project>=<origin-url>.
The seed validates and transports what it is given, and the receiving host
re-validates it rather than trusting the sender; bin/fm-project-origin-lib.sh
is the single owner of which URLs are accepted, refusing executable remote-helper
transports, option-shaped values, and unusable spellings at both ends. A bare
<project> still reads an already-present clone's origin, so nothing that works
today has to change. Registry consistency is unchanged: an unregistered or
local-only project is still refused.

A remote seed therefore creates nothing in the primary home beyond the route,
the charter, and its launch record.

The lifecycle test now seeds a registered project the primary has never cloned
and asserts the primary project tree is byte-identical afterwards, alongside
refusals for a missing origin, an unsafe origin, a local-only project, and an
unregistered project.

* no-mistakes(review): Clarify project origin documentation ownership

* no-mistakes(document): Document supplied-origin remote seeding contract

* feat(secondmate): accept project origins from any host or forge

Firstmate is a shared template, so a project origin must be able to name any
host: GitHub Enterprise on a private domain, GitLab hosted or self-hosted,
Bitbucket, Gitea, Codeberg, sr.ht, a bare IP, an SSH config alias, or a plain
server nobody else has heard of. The validator already decided on structure
rather than on a forge allowlist, and this makes that guarantee explicit and
closes the two gaps that a host-agnostic rule exposed:

- a bracketed IPv6 literal in the scp-like form is now accepted, so a host
  reachable only by address is not excluded
- a "/../" traversal inside a local or file: origin is now refused, because
  that names a path on the cloning host's own filesystem

The library is the single owner of the accepted forms, and its header says
plainly that there is no host, domain, or forge allowlist and there must never
be one. The skill keeps its distinct agent-operating lines (the agent resolves
and supplies the origin; a remote seed creates nothing in the primary home
beyond the route, the charter, and its launch record) and points at the library
for URL acceptance and at the operator doc for the rest.

The lifecycle test now drives Bitbucket, a self-hosted enterprise domain, a
self-hosted GitLab over ssh with a port, and a bare scp-like custom host through
the real seed, manifest, transport, and remote provisioning path in one seed,
asserting each URL reaches git unchanged and each clone carries its own origin's
content. The unit matrix leads with non-GitHub hosts for the same reason.

* no-mistakes(review): Validate project origin authorities safely

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix(tests): restore reliable fm-send backend parity coverage (#1851)

* fix(tests): copy the whole bin/ tree into the old-vs-new conformance shim

main went red on tests/fm-backend.test.sh's "fm-send --key: old vs new
exit code" assertion, which reads as an fm-send fail-closed regression from

build_old_bin enumerated by hand the sibling scripts it copied into the
synthetic pre-refactor tree. #1842 made bin/fm-send.sh source
bin/fm-line-cap-lib.sh (added by #1798) and the list never learned about it,
so the pinned old fm-send.sh aborted at `. "$SCRIPT_DIR/fm-line-cap-lib.sh"`
under set -eu and exited 1 before parsing a single argument, while the
current one delivered the key and exited 0. The parity check compared a
crashed process against a working one and reported a behavior divergence
that never happened - the more so because BASE_REF collapses to HEAD on
main, where both sides run byte-identical source and a genuine divergence is
impossible. fm-send's --key exit path is unchanged and its fail-closed
contract is intact.

Copy the tree whole instead of enumerating it. An enumerated list has to be
extended by hand every time an entrypoint gains a dependency and is the only
thing that knows; it has been patched a dozen times for exactly that. A
whole-tree copy has nothing to forget. Extracting a refactored entrypoint the
baseline does not have now fails loudly instead of writing an empty file.

Only old-vs-new parity covered that exit contract, and parity is near-vacuous
on main. Pin it directly: tests/fm-send-strict.test.sh drives delivery both
ways from one stub and asserts an undelivered key exits nonzero naming the
key, so swallowing that error fails the suite.

* no-mistakes(review): Materialize historical fixture dependencies from baseline

* no-mistakes(document): Clarify fm-send key regression scope

* fix(bin): mirror remote secondmate status streams (#1846)

* fix(bin): mirror the whole remote secondmate status stream

A remote secondmate's reply channel required corr=<16hex> on every line and
failed the entire delta when one line lacked it, so the cursor could never
advance past that line and the channel wedged permanently.

The charter tells a secondmate to report its own progress phases and to raise
new decisions with no correlation token, because correlation only answers a
marked parent request. Those lines were therefore unrepresentable on the remote
channel, while a local secondmate writes them straight into the parent's status
file.

Treat the channel as what it is: a mirror of the mate's status stream. A remote
mate now presents the same status and decision model as a local one, so a newly
raised needs-decision reaches the parent's open-decision fold identically, and
correlation goes back to being a per-line property that settles a pending
request rather than a gate on the stream.

Only what crossing a machine boundary genuinely adds stays behind: cursor
continuity, confined document fetch and rewrite, at-most-once append, and
control-byte normalization that rewrites bytes without ever dropping a line.
Line framing and size bounding already belong to fm-remote-delta-read.sh. A
document the remote reader refuses is named in one escalation instead of
stalling the stream, while an unavailable transport still leaves the delta for
the existing retry.

* refactor(bin): give the remote reply stream one append owner

Every line entering the parent status stream - a mirrored line, the continuity
escalation, and the undelivered-document escalation - now goes through one
at-most-once append, so the idempotence a replayed generation depends on is
stated once instead of copied at three call sites.

* no-mistakes(review): Keep local document transfer failures retryable

* no-mistakes(review): Isolate reply headers and normalize payload bytes

* no-mistakes(review): Correct remote reply mirror contract wording

* no-mistakes(review): Update remote reply script catalog description

* no-mistakes(document): Document remote status-stream mirroring

* docs(agents): describe the digest's fleet-state-before-context order (#1826)

* fix(bin): fail closed on NUL bytes in the durable parent binding (#1847)

fm_secondmate_parent_record_parse read the .fm-secondmate-parent record
with bash's read, which drops NUL bytes - and different bash generations
disagree on the result: 3.2 truncates the value at the NUL while 5.x
splices the surrounding bytes together. A NUL-bearing parent_home could
therefore resolve to a home the record's bytes never name contiguously,
and which home fm-teardown.sh's promised-public-reply resolution read
(registration, registry, relay state) - or whether that protection
engaged at all - depended on which interpreter ran the cleanup.
Reproduced end to end: the same NUL-bearing record cleaned up under bash
5.x by resolving the spliced-together registered parent, while bash 3.2
refused it as unresolved, and a literal truncated path refused under
both.

Reject any NUL byte in the record before field parsing, putting corrupt
records in the same fail-closed bucket as duplicate fields, malformed
local bindings, unsupported routes, and symlinked records. The
regression test drives the real bin/fm-teardown.sh over the proven
clean-cleanup fixture with a NUL spliced mid-path into the recorded
parent_home, so before the fix it reproduced the wrong-home cleanup and
now it must refuse with the explicit binding refusal.

* fix(skills): reconcile inherited secondmate plans with shipped state (#1853)

* docs(secondmate-provisioning): require record intake for an inherited domain

A new mate seeded for an existing or inherited domain previously pulled in
charter, inherited config, captain-shared preferences, project clones, and
queued backlog rows with zero instruction about the domain's shipped history,
so it assumed a greenfield domain. A live backlog keeps only the configured
recent Done entries, so an inherited queue structurally over-represents plans
and under-represents deliveries, and already-delivered work resurfaced as open.

Add a record-intake step to the creation/seed path: classify greenfield versus
existing or inherited, and for the latter reconcile every inherited plan
against origin/main plus the live deployment, take only genuinely open work
and still-live durable knowledge, never carry a plan row for shipped work, and
record what could not be reconciled. Greenfield domains are untouched.

The skill owns the procedure; the backlog handoff section carries a one-line
reinforcement at the point where plan rows actually move.

* no-mistakes(document): Clarify secondmate record-intake scope

* fix: move network checks off the session-start blocking path (#1860)

* perf(session-start): run every network check off the blocking path

The session-start digest runs on a session-open hook that blocks session
initialization, and every external-network call it made was individually
unbounded: `gh auth status`, secondmate liveness, secondmate convergence,
pending remote handoff delivery, and the fleet-sync fetch. One unreachable
remote secondmate could consume the whole FM_SESSION_START_TIMEOUT and
truncate the digest, so a slow network could cost the work queue itself.
Measured against a host hanging 25s per SSH connection, that startup took
1m18s.

The digest is now composed from local reads alone. bin/fm-startup-network.sh
runs the same checks concurrently in a bounded detached worker and the digest
harvests whatever finished, without ever waiting. Same fixture: 0.84s.

Nothing is dropped. fm-bootstrap.sh stays the single owner of every sweep and
still runs all of them, through a new FM_BOOTSTRAP_NETWORK phase split whose
`skip` and `only` halves are a partition of the unsplit run. Deferral is safe
because the sweeps are idempotent detectors, the result is durable and always
surfaces (inline, or as a `check: startup-network` wake), and the worker
re-verifies that the fleet lock still names the session that asked before it
mutates anything. While the worker is still running the digest names exactly
what is unconfirmed rather than implying it passed.

A relaunch performed by the deferred pass is now always reported, because the
digest that printed the superseded endpoint record is already out.

Also collapses the duplicate tasks-axi compatibility probe: the verdict is
computed once and handed to the bootstrap child for one process hop, then
consumed so it never reaches a spawned agent's environment. 10 tasks-axi
invocations per startup become 7.

Verified on Claude Code 2.1.222 that a worker detached by the session-open
hook survives the hook returning, the one vendor behavior this design needs
and no portable test can see.

Re-landed on current main, superseding PR #1845, which was cut from a
pre-#1842 base. The digest's section numbering in AGENTS.md section 3 now
states the emission order directly - supervision block and its read-once
contract, fleet state, network checks, then context - which keeps #1826's
fleet-state-before-context ordering. The old-bin test shim keeps main's
git-archive baseline from #1851, which already subsumes this branch's reason
for widening that shim.

* docs(verification): re-measure the deferred startup stage on the current base

Re-runs the unreachable-remote latency fixture against default-branch tip
8398d31 rather than the now-historical 345de4e, and records the sweep-result
comparison the deferral's safety argument rests on: the deferred worker's
published report is byte-identical to the three sweep lines the blocking
baseline printed, with the unreachable route preserved in both.

* no-mistakes(review): Fail deferred startup when report publication fails

* no-mistakes(document): Document deferred startup network behavior accurately

* fix(procevent): apply remote replies during capture (#1831)

* fix(procevent): apply a captured adapter result in code, not by instruction

A remote secondmate's reply was captured and announced, but never applied.
Nothing dispatched the reply adapter's `handle` on a `procevent remote-reply`
wake, and the handling instruction named only the generic acknowledgement, so
the wake was retired while everything it carried was dropped: the reply never
reached the secondmate's local status mirror, the request it answered kept
escalating as a missed report, and the relay - whose registration each capture
retires, and which only that same handling re-arms - was left dead until the
next session start armed it again.

Applying such a result carries no judgement, so it belongs in code. After
publishing, the runner now calls
`bin/fm-procevent-<adapter>.sh autohandle <source-id> <sequence> <result-file>`
and lets the adapter apply and acknowledge its own result, through the same kind
of seam that already owns the terminal verdict. It runs strictly after terminal
retirement, because a handling adapter re-arms its own next source and retiring
afterwards would drop that fresh registration. An adapter with no such command,
or one whose pass does not complete, leaves the result unacknowledged and
therefore still announced, so a handler receives it exactly as before.

Resolving the request was not enough on its own either. An escalation opens a
durable keyed decision in the parent status log, and nothing ever closed it, so
a request the remote had answered kept surfacing in every later open-decisions
fold. The pending-reply library now owns both ends of that decision: it opens
one under a per-request key rather than the shared default key, and closes it
once the record resolves, appending the closing line only while that exact
decision is still open in the fold so it can neither double-close nor clear an
unrelated decision that has since taken the same key.

The handling instruction still routes a wake to its adapter, now as the
idempotent confirmation of what the runner already did rather than as the
guarantee.

Verified end to end in a throwaway isolated home driving the real armed source,
blocking delta reader, runner, and wake queue, with the handler doing only the
generic acknowledgement and no part of the ingest stubbed: before, seven failed
observations reproducing the incident; after, none. Each half is independently
load-bearing - without the runner change the reply never reaches the mirror,
without the escalation close the settled request still surfaces as an open
decision.

* no-mistakes(review): Prevent legacy reply closure from masking decisions

* no-mistakes(review): Serialize pending reply resolution and escalation closure

* no-mistakes(review): Serialize pending reply escalation with resolution

* no-mistakes(review): Clarify guarded legacy escalation closure behavior

* no-mistakes(review): Guard legacy closure and reserve pending reply keys

* no-mistakes(review): Match pending reply escalations by construction

* no-mistakes(document): Document automatic remote reply resolution

* no-mistakes(lint): Fix unused concurrent escalation loop variable

* no-mistakes(lint): Fix unused concurrent resolution loop binding

* no-mistakes(review): Version fold cache and gate autohandle on publication

* no-mistakes(document): Clarify remote reply relay documentation

* feat(skills): port internal stow curation disciplines to the public skill (#1841)

Bring the public installer-facing stow skill up to the internal skill's
current curation behavior while keeping it fully standalone:

- Replace the total-capture thesis with the compact-operating-map framing.
- Add read-the-destination-before-writing with the inspect-then-update
  triad (supersedes what, one-sentence rewrite, delete stale now).
- Add the concrete prune list together with its unique-fact guard, as an
  accuracy discipline with no size-budget machinery.
- Curate every memory file the pass has open, not only the routed one.
- Add the standing-decisions sweep category.
- Add the stronger-owner pointer-over-copy test before filing.
- Add tool-agnostic task-note discipline (inspect, classify, considered
  replacement body, never blind-append) and blocked-on recording.
- Give .stow-notes.md a closed set of three exits.
- Forbid storing, creating, or editing a skill as a stow destination.
- Report per-file action verbs in the completion receipt.
- Consolidate the repeated local-vs-external and .gitignore prose and fix
  the second-person voice slip, so the file does not grow (11334 -> 11276
  bytes).

* chore(bootstrap): raise lavish-axi version floor to 0.1.46 (#1865)

* fix(bin): keep tracked Claude hook entries inert under grok 1.0.0 (#1917)

* fix(hooks): keep tracked Claude entries inert under grok 1.0.0 hooks

Grok loads Claude-compatible settings, so the tracked `.claude/settings.json`
hook entries also fire under Gr