Skip to content

fix(bin): fail closed for blocked Pi composers - #2811

Merged
kunchenguid merged 1 commit into
kunchenguid:mainfrom
karotkriss:fm/fm-send-truth
Aug 23, 2026
Merged

kunchenguid merged 1 commit into
kunchenguid:mainfrom
karotkriss:fm/fm-send-truth

Conversation

@karotkriss

Copy link
Copy Markdown
Contributor

Intent

Close the remaining herdr-side hole in the "text delivered to a worker parked on an interactive prompt answers the prompt and is silently discarded" defect (upstream issue #2797, and its duplicate #1474, which reports the same defect from the stale-draft symptom).

Scope is deliberately narrow and was set after a shadow check of the open PR queue, so the diff is intentionally one behavioral line. Two open upstream PRs already cover this defect and must NOT be duplicated or re-implemented: #2439 (feat: preflight composers before steering) adds fm-send's pre-type refusal, which is backend-generic because it dispatches through fm_backend_composer_state "$TARGET_BACKEND"; #2800 (fix(tmux): refuse text dropped by composer) adds a post-type payload-append proof, which lives in bin/fm-tmux-lib.sh and is therefore tmux-only. This change is complementary adapter coverage that makes those mechanisms correct on herdr; it is not an alternative to either, and the PR body must say so plainly and reference both.

The verified gap: bin/fm-composer-lib.sh's _fm_composer_pi_verdict admitted blocked alongside idle and done as proof of an affirmatively empty composer. But blocked is exactly the native agent_status of a pi pane parked on an interactive prompt - a permission dialog, an AskUserQuestion menu, a trust dialog - where the agent is waiting on a human keystroke. Pi draws that menu ABOVE its separator pair, so the composer region between the two rules is blank and structure alone looks like a free composer. Classifying that screen through the herdr adapter on current main returned empty, which is the single verdict #2439's guard lets through and which #2800's tmux-only proof never sees. A Claude-style bordered permission dialog classifies as pending on the same path and so is already refused by #2439; it is specifically the pi separator shape that was admitted.

Why this matters on current main independently of either open PR: the same verdict is read by the away-mode injection guard in bin/fm-supervise-daemon.sh, which injects only into a confirmed-empty composer. So away mode will type an escalation straight into a parked pi prompt, the keys answer the menu instead of composing a message, the highlighted default is selected, the text is discarded, and the record attributes a decision to a human who never made it.

The fix, at the classifier that owns composer shapes and verdicts (adapters only contribute capture facts): blocked now falls through to unknown, which every consumer already treats as fail-closed. idle and done still prove an empty composer, so ordinary steering is unchanged and this does not regress delivery-truth for readable panes. Cursor is unaffected because its always-blocked panes never reach this pi-only branch (_fm_composer_pi_verdict returns unknown unless identity is exactly pi). Deliberately NOT introducing a new composer verdict value: adding one would ripple through every consumer of composer_state and collide with the two open PRs, while the existing unknown already carries the required fail-closed meaning.

Regression coverage was written first and confirmed RED against main at both levels, then green: tests/fm-composer-lib.test.sh gains a "blocked pi defers" assertion at the verdict owner (was: expected unknown, got 'empty'), and tests/fm-backend-herdr.test.sh gains test_composer_state_pi_parked_prompt_is_not_empty at the adapter (was: got 'empty'). Documentation was updated only where behavior changed: the authoritative composer-and-injection-safety section of docs/herdr-backend.md, plus the function and header comments in bin/fm-composer-lib.sh that stated the old idle/done/blocked rule.

Deliberately out of scope, already handled, and not to be re-opened by this change: upstream issue #2361 (fm-send falsely reports delivery unconfirmed for live idle herdr/pi panes) is ALREADY FIXED on main by merged PR #2647 and needs no code here. The PR must therefore close ONLY #2797 and #1474 with Fixes lines and must NOT reference #2361 as fixed.

Deliver as a pull request to upstream kunchenguid/firstmate from the karotkriss fork. Never merge it.

What Changed

  • Treat blocked Pi separator panes as unknown, preventing Herdr composer consumers from mistaking interactive prompts for empty input while preserving idle and done behavior.
  • Add classifier-level and Herdr adapter regression coverage, and document the fail-closed behavior.
  • Complement feat: preflight composers before steering #2439's backend-generic pre-type refusal and fix(tmux): refuse text dropped by composer #2800's tmux-only post-type proof without duplicating either change.

Fixes #2797
Fixes #1474

Risk Assessment

✅ Low: The well-bounded fail-closed classifier change closes the reachable blocked-Pi injection path while preserving proven idle, done, and pending behavior.

Testing

Diff inspection and a read-only Herdr 0.8.2 availability check established the test context. Both focused automated suites passed. The behavioral transcript reproduces the base defect (blocked returned empty), proves the target returns fail-closed unknown, and shows away-mode injection defers without sending while the idle control still sends. No screenshot was captured because this is a shell classifier and backend safety change with no rendered UI; the CLI transcript is the reviewer-visible product evidence.

Evidence: Herdr pi blocked-prompt safety transcript

Source: Herdr pi blocked-prompt safety transcript

base blocked verdict: empty target blocked verdict: unknown target idle verdict: empty target done verdict: empty target working verdict: unknown blocked prompt injection: deferred idle composer injection: sent

Herdr pi parked-prompt safety proof
===================================
base blocked verdict:   empty
target blocked verdict: unknown
target idle verdict:    empty
target done verdict:    empty
target working verdict: unknown

Away-mode injection boundary
guard log: inject deferred: supervisor composer not confirmed-empty (state=unknown: pending input, dead-shell prompt, or unreadable pane)
blocked prompt injection: deferred
send seam invoked
idle composer injection: sent

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • tests/fm-composer-lib.test.sh
  • tests/fm-backend-herdr.test.sh
  • Compared the base and target fm_composer_classify_screen behavior using the same parked pi prompt for blocked, idle, done, and working states
  • Exercised inject_msg through the herdr adapter seam for blocked and idle pi states
  • Confirmed HEAD is target commit 77e36fd709e617ba51d72e78e64188f8c4a85b34 and the worktree remained clean
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants