Repository navigation
Conversation
…ed keys, spawn failure
This was referenced Jul 21, 2026
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#805 at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Harden first-launch dialog handling for crews on the Herdr backend so Claude folder-trust and Bypass Permissions dialogs, plus Codex trust and hooks-review menus, no longer require manual intervention. Diagnose the recurring broken-pipe and silent send/readback paths, and make pre-agent TUI input reliable or fail loudly: classify only known dialog shapes, send one key at a time, re-read the pane to verify cursor or dialog movement, use bounded retries, never press Enter while a destructive No/exit choice is focused, and refuse unknown states. Corroborate visible dialogs with native agent state and allow only working to suppress a visible menu because live evidence records idle at a real displayed Claude trust dialog. Keep harness knowledge in the harness-adapters skill and mechanics in scripts, extend the existing fake-Herdr test runner, and record dated helper-isolated empirical evidence. The accepted live evidence is two real trust-dialog traversals with agent_status idle and clean teardown; document that the bypass variant is unreproducible because acceptance persists in Claude user state and do not reset that state. Preserve the smallest viable diff, require full lint and extended tests green, push the feature branch to remote fork, and update the PR against kunchenguid/firstmate main.
What Changed
bin/backends/herdr.shgainsfm_backend_herdr_handle_startup_dialogand its_dialog_classify/_dialog_drive_visiblehelpers: only four known menu shapes are recognized (Claude folder trust, Claude Bypass Permissions, Codex directory trust, Codex hooks review), focus is read from the dialog's own option rows so a composer glyph cannot be mistaken for the selection, each key is sent one at a time and verified by pane readback under bounded retries, Enter is never sent while a destructiveNo, exitrow is focused, and unknown or unverifiable states fail closed. Visible menus are corroborated againstagent get— onlyworkingsuppresses a dialog, since live evidence recordsidleat a real displayed trust dialog.Down/Upare added to key normalization, andfm_backend_herdr_events_capablenow pattern-matches the schema in-shell instead ofprintf | grep -q, removing the recurringprintf: write error: Broken pipeunder a caller'spipefail.bin/fm-spawn.shroutes claude/codex spawns on the herdr backend through that handler after the launch Enter; an unverified pane exits non-zero without printing thespawnedline, and the error names the id, window, and worktree because the task stays registered while the harness may be running.FM_BACKEND_HERDR_DIALOG_*tunables (capture lines, polls, poll sleep, key retries, key sleep) are documented indocs/configuration.md;docs/herdr-backend.mdadds the dated evidence block — two live Claude trust-dialog traversals, the livedownkey verification, the broken-pipe diagnosis, and a note that the bypass variant is unreproducible because acceptance persists in Claude user state — with the harness-level knowledge kept in theharness-adaptersskill. The fake-Herdr runner grows 18 cases covering classification, cursor-move-before-Enter, destructive-default refusal, retry bounds, stale/repainted frames, agent-state corroboration, and the two spawn wiring paths.Note: the pipeline's Test stage reported a non-zero exit for the full
tests/*.test.shsweep and Lint exited 127; both are unresolved on this branch as pushed.Risk Assessment
Testing
Completed 1 recorded test check.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/backends/herdr.sh:1367- fm_backend_herdr_dialog_drive_visible'sexpected=dismissedretry loop authorizes another Enter from a readback that this change's own docs call unreliable ("the recent source retains dismissed frames inside the capture window"). If Enter chore: initialize no-mistakes gate #1 dismissed the Claude trust dialog and Claude then rendered the Bypass Permissions warning focused on the destructiveNo, exit, a stale capture still classifies claude-trust:accept, agent_status is stillidle(the recorded live behaviour at a displayed dialog), and Enter docs: polish README banner and repo housekeeping #2 is delivered toNo, exit. That contradicts the required criterion "never press Enter while a destructive No/exit choice is focused". Consider not retrying Enter at all, or requiring the post-key capture to differ from the pre-key capture before concluding anything.bin/fm-spawn.sh:1264- This is the firstexit 1that runs after $STATE/$ID.meta is written, the worktree is acquired, the pane exists, and the harness is already launched - and HERDR_PROJECTION_ABORT_CLEANUP was disarmed two lines earlier, so spawn_abort_cleanup does nothing. A cold harness start that exceeds the 20s (40 x 0.5s) poll budget whileagent getstill reports agent_not_found fails the spawn, suppresses thespawned <id> ... window=...line, and leaves a registered, running crewmate behind. fm-spawn.sh:101 claims it "fails the spawn rather than leaving a crewmate parked", but both happen.bin/backends/herdr.sh:1330- A dialog that classifies to a known kind but whose focus cannot be parsed hits drive_visible's catch-all and fails the spawn on the very first poll, with no retry and no further polling - unlike theunknownkind, which polls to the bounded timeout. The first capture is taken with zero delay after the launch Enter, so a mid-repaint frame (options rendered, cursor row not yet) or transcript text quoting a dialog header plus both options kills the spawn ~0s after launch.bin/backends/herdr.sh:1234- The focus scan keeps the last❯/›line anywhere in the 80-line capture, but that glyph pair is the repo's own verified agent composer prompt (FM_BACKEND_HERDR_BARE_PROMPT_RE='^[❯›]'). A composer row rendered below an overlay menu therefore overrides the menu's selected item. Codex's hooks-review menu is the concrete risk: it has no live traversal in docs/herdr-backend.md, and the fake-CLI fixtures place no composer row after the menu, so an empty focus would fail every such spawn. Scoping the scan to the lines of the matched dialog block would remove the ambiguity.bin/backends/herdr.sh:1427- FM_BACKEND_HERDR_DIALOG_POLL_SLEEP and FM_BACKEND_HERDR_DIALOG_KEY_SLEEP go straight tosleepwhile FM_BACKEND_HERDR_DIALOG_POLLS and _KEY_RETRIES get numeric fallbacks. A malformed exported value makes every sleep fail, turning the 40-poll loop into a tight spin of ~80 herdr CLI calls plus stderr noise before the spawn fails. Add the samecase ... in ''|*[!0-9.]*) fallback ;;guard the other two tunables use.🔧 Fix: guard herdr dialog focus, Enter retries, and spawn failure
2 issues (1 warning, 1 info) still open:
bin/backends/herdr.sh:1288- The focus rewrite changed the codex-trustPress enter to continuefallback from "no selection glyph anywhere in the capture" (oldcodex-trust:empty-focus case) to "no row matched a recognized option", so it now also fires when a glyph row IS present but unrecognized. codex-trust's only reject pattern is*'No, quit'*, so a screen focused on e.g.❯ 2. No, exit and choose another folderleaves choice=unknown, the fallback flips it to accept, and drive_visible sends Enter onto the destructive row. That contradicts the required criterion "never press Enter while a destructive No/exit choice is focused", and codex's trust screen has no live traversal in docs/herdr-backend.md - only a glyph-free fixture. Restoring the old width means gating the fallback on aglyph_seen=0flag set inside the scan loop.bin/backends/herdr.sh:1435- The mid-repaint branch re-implements the loop tail (i=$((i + 1)); [ "$i" -lt "$polls" ] && sleep "$FM_BACKEND_HERDR_DIALOG_POLL_SLEEP"; continue) that already exists 27 lines below at line 1462. Two copies of the poll-advance logic will drift if the pacing ever changes; restructuring the branch to fall through to the shared tail (e.g. anunfocused=1guard around the drive call) removes the duplicate.🔧 Fix: gate codex trust Enter fallback on cursorless screen
1 info still open:
bin/backends/herdr.sh:1294-glyph_seenis set by any❯/›row anywhere in the 80-line capture, including the pane's own shell prompt and the typed launch line. On a machine whose shell prompt uses those glyphs (starship/pure/agnoster - the same set the repo records as FM_BACKEND_HERDR_BARE_PROMPT_RE), codex's cursorless trust screen would classifycodex-trust unknown, poll the full budget and fail the spawn rather than auto-accepting. This is fail-closed and is the same width the code had before round 2, so no action is required; noting it in case codex trust later needs to work in such a pane, where scoping the glyph scan to rows below the dialog header would recover the auto-accept.command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"docs/herdr-backend.md:979- The broken-pipe diagnosis and fix forfm_backend_herdr_events_capableis recorded inside docs/herdr-backend.md's "Guarded first-launch dialog handling" → "Live Claude trust-dialog traversal" subsection, even though the owner of that function's contract is the "Nativepane.agent_status_changedpush escalation" section further down. I resolved discoverability with a one-line pointer from the owner section plus a code comment at the call site rather than relocating the evidence, since moving a dated evidence block inside a 1150-line document is a restructure beyond this change's scope. Follow-up worth considering: move the pipefail paragraph and its lab transcript under the events-escalation section's empirical-evidence block and leave a pointer behind.✅ **Push** - passed
✅ No issues found.