Skip to content

fix(bin): refuse empty text steers in fm-send - #4259

Merged
kunchenguid merged 2 commits into
kunchenguid:mainfrom
pablontiv:fm/msg-loss-investigation
Sep 15, 2026
Merged

kunchenguid merged 2 commits into
kunchenguid:mainfrom
pablontiv:fm/msg-loss-investigation

Conversation

@pablontiv

@pablontiv pablontiv commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Fix message loss: fm-send admits empty and whitespace-only marked text steers, silently dropping the instruction body while still marking and recording the message as delivered, which stalls downstream work with no visible cause. Refuse empty and whitespace-only text steers before marking, recording, or typing them. Refs Firstmate issue #4255.

What Changed

  • bin/fm-send.sh now rejects an empty or whitespace-only text steer with an explicit error before the message is marked, recorded, or typed, instead of silently delivering marker/correlation bytes with no instruction body.
  • tests/fm-send-inbox.test.sh adds test_empty_message_refused, covering a marked secondmate steer, an explicit empty-string argument, and a whitespace-only message, asserting a nonzero exit, no inbox record, no pending-reply expectation, and nothing typed.
  • Applies an ambient shfmt/Pi-lens autoformat pass across bin/fm-send.sh, bin/fm-backlog-handoff.sh, bin/fm-spawn.sh, and tests/fm-send-inbox.test.sh (indentation, brace/redirect spacing), with no behavior change beyond the fix above.

Risk Assessment

✅ Low: The behavioral fix (788358c) is an 8-line, correctly-placed guard in bin/fm-send.sh that refuses empty/whitespace-only text steers before any marking, recording, or typing occurs (verified by tracing MESSAGE usage: marking at line 772, inbox write at line 998, both after the new check at line 754-757), matches the required intent exactly, and is covered by new tests; the second commit (9d464d2) touches three additional files but is verified byte-for-byte equivalent to pure whitespace/formatting changes (semicolons to newlines, brace-block reflow, | spacing in case patterns, removed line-continuation backslashes, redirect joins) via whitespace-normalized token-stream diffing across all four changed files, with zero surviving semantic differences.

Testing

Ran the project's fm-send-inbox test suite (all 13 assertions pass, including the new empty-message case) and independently drove the real bin/fm-send.sh CLI against a hand-built stubbed-tmux harness (bypassing the gate-agent fleet-refusal guard the same way the test suite does) for empty-string, whitespace-only, and normal messages on both a plain target and a marked-secondmate target; all matched the intended behavior — refusal before marking/recording/typing for empty/whitespace input, normal delivery (including pending-reply minting) unaffected.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Empty-string text steer to a plain target is refused before typing/recording ✅ pass live manual invocation: bin/fm-send.sh t1 "" -> rc=1, stderr 'error: a text steer requires a nonempty message...', no t1.inbox dir created, send.log empty
Whitespace-only text steer to a plain target is refused ✅ pass live manual invocation: bin/fm-send.sh t1 $' \t \n ' -> rc=1, same refusal message, no inbox dir, nothing typed
Empty text steer to a marked secondmate target mints no marker-only record and no pending-reply expectation (the reported message-loss bug) ✅ pass live manual invocation with kind=secondmate meta: bin/fm-send.sh domain "" -> rc=1, refusal message, no domain.inbox dir, pending-replies count 0
Normal (nonempty) text steer still delivers and marks correctly, unaffected by the guard ✅ pass live control sends: plain target bin/fm-send.sh t1 "hello world" -> rc=0, inbox/001.msg + doorbell typed; secondmate target bin/fm-send.sh domain "please check status" -> rc=0, inbox created, pending-r…
--key lifecycle path is unaffected by the text-emptiness guard ✅ pass live bash tests/fm-send-inbox.test.sh test_empty_message_refused case 'keypath-after-refusal': run_send ... t1 --key Enter succeeds

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-spawn.sh - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Empty-string text steer to a plain target is refused before typing/recording ✅ pass live manual invocation: bin/fm-send.sh t1 "" -> rc=1, stderr 'error: a text steer requires a nonempty message...', no t1.inbox dir created, send.log empty
Whitespace-only text steer to a plain target is refused ✅ pass live manual invocation: bin/fm-send.sh t1 $' \t \n ' -> rc=1, same refusal message, no inbox dir, nothing typed
Empty text steer to a marked secondmate target mints no marker-only record and no pending-reply expectation (the reported message-loss bug) ✅ pass live manual invocation with kind=secondmate meta: bin/fm-send.sh domain "" -> rc=1, refusal message, no domain.inbox dir, pending-replies count 0
Normal (nonempty) text steer still delivers and marks correctly, unaffected by the guard ✅ pass live control sends: plain target bin/fm-send.sh t1 "hello world" -> rc=0, inbox/001.msg + doorbell typed; secondmate target bin/fm-send.sh domain "please check status" -> rc=0, inbox created, pending-r…
--key lifecycle path is unaffected by the text-emptiness guard ✅ pass live bash tests/fm-send-inbox.test.sh test_empty_message_refused case 'keypath-after-refusal': run_send ... t1 --key Enter succeeds
  • bash tests/fm-send-inbox.test.sh (all 13 cases incl. test_empty_message_refused)
  • manual: bin/fm-send.sh t1 '' against stub tmux -> rc=1, refusal message, no inbox dir, nothing typed
  • manual: bin/fm-send.sh t1 $' \t \n ' (whitespace-only) -> rc=1, same refusal, no inbox, nothing typed
  • manual: bin/fm-send.sh t1 'hello world' (control) -> rc=0, inbox/001.msg created, doorbell typed, payload never typed
  • manual: bin/fm-send.sh domain '' against a kind=secondmate meta -> rc=1, refusal, no domain.inbox, 0 pending-replies (the exact reported bug scenario)
  • manual: bin/fm-send.sh domain 'please check status' (secondmate control) -> rc=0, inbox created, 1 pending-reply minted
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@pablontiv pablontiv changed the title fix(bin): reject empty or whitespace-only text steers in fm-send fix(bin): refuse empty text steers in fm-send Sep 12, 2026
@pablontiv
pablontiv force-pushed the fm/msg-loss-investigation branch from 7a34956 to 4b54305 Compare September 12, 2026 07:25
@pablontiv

Copy link
Copy Markdown
Contributor Author

Ready for your review when convenient.

All 14 checks are green at head 4b54305f, and the branch has had an independent review against that exact head (different model family from the author) which came back clean with only non-blocking observations.

Contents, for context on the diff size:

  • e2077ed3 — the actual fix: fm-send.sh refuses empty and whitespace-only text steers before marking, recording or typing them, plus a regression test covering the empty, empty-string and whitespace-only cases. Fixes Marked secondmate request arrives with corr token but no body: fm-send accepts an empty message and reports success #4255.
  • 4b54305f — ambient editor autoformat, kept as its own commit so the fix stays reviewable on its own. It is the bulk of the line count. The review verified it is formatting-only via parse-tree, string-literal and token-stream comparison, each validated against injected defects. e2077ed3 is independent of it and applies cleanly alone if you would rather not carry the reformat.

No rush from our side — happy to rebase, split, or drop the autoformat commit if you prefer.

@pablontiv
pablontiv force-pushed the fm/msg-loss-investigation branch 2 times, most recently from 55675e4 to d88a710 Compare September 13, 2026 06:36
@pablontiv pablontiv changed the title fix(bin): refuse empty text steers in fm-send fix(bin): refuse empty and whitespace-only text steers in fm-send Sep 13, 2026
@pablontiv
pablontiv force-pushed the fm/msg-loss-investigation branch from d88a710 to 70a9c36 Compare September 14, 2026 22:54
@pablontiv pablontiv changed the title fix(bin): refuse empty and whitespace-only text steers in fm-send fix(bin): refuse empty or whitespace-only text steers in fm-send Sep 14, 2026
A marked secondmate request sent with an empty message delivered only
marker and correlation bytes and minted a pending-reply expectation the
parent could never see resolved, stalling the fleet with no loud error
(#4255). Fail closed on an empty or whitespace-only message on the text
path, mirroring the existing --resolve-key refusal.
Formatting-only edits produced by ambient Pi-lens autoformat during the
msg-loss investigation, kept separate from the behavioural change in
c23acba6 so the fix stays reviewable on its own.

AGENTS.md is deliberately excluded: its only autoformat edit stripped the
trailing space from the documented FM_OPERATIONAL_PREFIX value, which
bin/fm-operational-input.sh:28 defines as "FIRSTMATE_OP: " and line 11
records as permanent compatibility. Documenting that constant without its
trailing space makes the doc wrong about the contract, so that one line was
restored rather than retained.
@pablontiv
pablontiv force-pushed the fm/msg-loss-investigation branch from 70a9c36 to 9d464d2 Compare September 15, 2026 13:43
@pablontiv pablontiv changed the title fix(bin): refuse empty or whitespace-only text steers in fm-send fix(bin): refuse empty text steers in fm-send Sep 15, 2026
@kunchenguid
kunchenguid merged commit 2da3c5e into kunchenguid:main Sep 15, 2026
15 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @pablontiv — really appreciate you taking the time on this.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate — triage audit for the merge above:

Contract-class: restore. Empty/whitespace-only marked text steers were incorrectly accepted (MESSAGE=$* with no nonempty guard), delivering marker+corr with no body (issue #4255). Guard in bin/fm-send.sh refuses before mark/record/type; regression test_empty_message_refused. Companion commit is ambient shfmt/Pi-lens autoformat across send/handoff/spawn/tests (whitespace/brace layout); behavioral delta is the refuse + tests.

VISION.md per-rule (inspected refuse hunk + test; whitespace-normalized scan of spawn/handoff/send):

  • One captain, one interface — aligns (stops silent message-loss stalls).
  • Authority explicit — aligns (stricter refuse, no new autonomy).
  • Scripts own mechanics — aligns (deterministic nonempty check).
  • Restart non-event — n/a / aligns.
  • Delegation with spine — aligns (strengthens refusal path).
  • Fleet outlives vendor — aligns.
  • Scope — aligns.

Attestation MATCH; CI 34976833612 + NM 34976923798 SUCCESS; CLEAN. Auto-merged squash 2da3c5e2193cb725bf173b7dfcbf8b094c4b862d. Closed #4255.