Repository navigation
fix(bin): fail closed for blocked Pi composers - #2811
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
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
blockedalongsideidleanddoneas proof of an affirmatively empty composer. Butblockedis 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 returnedempty, 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 aspendingon 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):
blockednow falls through tounknown, which every consumer already treats as fail-closed.idleanddonestill 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 existingunknownalready 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
unknown, preventing Herdr composer consumers from mistaking interactive prompts for empty input while preserving idle and done behavior.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 (
blockedreturnedempty), proves the target returns fail-closedunknown, 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: sentPipeline
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.shtests/fm-backend-herdr.test.shCompared the base and targetfm_composer_classify_screenbehavior using the same parked pi prompt for blocked, idle, done, and working statesExercisedinject_msgthrough the herdr adapter seam for blocked and idle pi statesConfirmedHEADis target commit77e36fd709e617ba51d72e78e64188f8c4a85b34and the worktree remained clean✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.