- Accept agent_not_ready from herdr agent start to allow startup dialog handling without premature rollback, while preserving fail-closed behavior on dead process timeouts. - Match Claude fullscreen renderer upsell modal via 'Yes, try it' and dismiss with Escape to avoid dropping permission flags or deadlocking on idle /tui tips. - Add behavioral test suite in test_b19_headless_reconcile_fixes.py and cross-agent review reports.
7.2 KiB
Cross-Code Review Report — Job 825cb977
Reviewer: reviewer-cline-01 (Cline)
Changeset: .agents/skills/lib.sh (+12/−4), tests/test_b19_headless_reconcile_fixes.py (+106), FIX.md (new, 22 lines).
Scope: lint, behavior, and loss/orphan cross-review of the two lib.sh fixes + accumulated diff.
1. Are the targeted problems real? (discard gate)
The brief's stated "goal" text describes the original FIX.md intent (allow timed out waiting for agent startup + add generic fullscreen tokens). The actual diff does the corrected opposite on point 1 and a safer variant on point 2. Both addressed problems are real — this is not a discard candidate.
- Fix 1 — agent-start detection. Real problem: the prior code treated only
agent_startedas success, so herdr's documentedagent_not_ready("process up, blocked on a dialog") status caused rollback of a legitimately-starting agent that merely needed dialog handling. The fix promotesagent_not_readyto success (→wait_for_tui_ready) and classifies fatal CLI errors first. It also excludestimed out waiting for agent startupfrom success — correct, because that string is ambiguous (herdr returns it for a dead/bin/falsetoo), so promoting it would misclassify a dead process and waste the 30s readiness window. - Fix 2 — fullscreen renderer upsell modal. Real problem: Claude's fullscreen upsell modal (
Yes, try it) is a blocking dialog. The fix adds the modal-unique tokenYes, try itto_MAM_DIALOG_TOKENSand dismisses with Escape (reject). This is the safe choice: Enter would acceptYes, try itand restart the session without--dangerously-skip-permissions(permission-flag drop). The idle/tui fullscreentip (Try the new fullscreen renderer … · /tui fullscreen, with a❯prompt) is intentionally not matched — it is non-blocking, and a genericfullscreen renderertoken would false-match that ready idle screen and deadlockwait_for_tui_ready.
2. Lint
bash -n .agents/skills/lib.sh→ OK..venv/bin/python -m py_compile tests/test_b19_headless_reconcile_fixes.py→ OK.- Shell quoting/regex consistent with surrounding code: fatal-error
grep -qiE(case-insensitive ERE) first; successgrep -qE "agent_started|agent_not_ready"(literal alternation, no unescaped metachars); newYes, try ittoken is a literal with no ERE specials — safe insidegrep -Eq/grep -q. - No shellcheck-style issues introduced (no unquoted expansions, no word-splitting hazards in the added lines).
3. Behavior
- Fix 1 (lib.sh L546-556): fatal errors (
^usage:/^error:/etc.) break withsuccess=0→ downstreamif [ "$success" -ne 1 ](L562) →exit 1(fail-fast).agent_started|agent_not_ready→success=1; break→ proceeds towait_for_tui_ready. Timeout-only output → no match → retries (3 backoffs ≈3.5s) →exit 1(fast dead-process failure instead of a 30s wait). Thesuccessinit/check chain is intact. - Fix 2 (lib.sh L62, L1859-1862):
Yes, try itadded to_MAM_DIALOG_TOKENS(so_pane_dialog_opendetects the modal — also correctly gatessend_keys_safeagainst prompting under a modal) and tohandle_startup_dialogs(sends Escape). The branch is placed beforeYes, proceedand the readiness-token branch — correct ordering (modal must be dismissed before ready detection). After Escape the loop re-captures and returns 0 once the banner appears; bounded bytimeout(default 20s). The idle tip contains noYes, try it→_pane_dialog_openreturns false →wait_for_tui_readydetects the banner (no deadlock). - Tests: the 4 new tests are genuine behavior tests (stub
_pane_capture/_sks_herdr/sleep, source the reallib.sh, exercise real_pane_dialog_open/handle_startup_dialogs/wait_for_tui_ready)._LIB_SHusesPath(__file__).resolve()(CWD-independent). One source-string guard (test_agent_start_success_tokens_exclude_startup_timeout) asserts token membership + error-before-success ordering.
4. Loss / Orphan analysis
- lib.sh: the removed standalone
if grep -q "agent_started"; then success=1; break; fiis fully superseded by the combinedagent_started|agent_not_readycheck — no orphaned variable or branch.success=0init and the downstreamsuccess-ne-1 guard remain consistent. The newYes, try it→Escape branch is self-contained; no existing branch was orphaned. - Tests:
from pathlib import Pathis used by_LIB_SH; both_FULLSCREEN_TIP/_FULLSCREEN_MODALfixtures are used;_run_lib_helpersis used by 3 behavior tests. No unused imports or dead helpers introduced. - No lost functionality:
agent_not_readyis a superset-preserving addition (still proceeds towait_for_tui_ready); the timeout exclusion is an intentional, justified narrowing (ambiguous token), not a loss of needed behavior.FIX.mdis an accurate working note (untracked, expected to ship with the fix).
5. Test results
- Cited 4 suites (
test_b19_headless_reconcile_fixes.py,test_herdr_shim_contract.py,test_a4_adapter_contract.py,test_b8_send_keys_verification.py) → 29 passed. - Broader sweep
pytest tests/ -q: ~378 tests passed with 0 failures (full unit + component + tier1/2 + tier3 integration all green). The final tier4 e2e segment spawns real tmux/herdr subprocesses and hung at ~97% — environmental, unrelated to this surgical changeset (terminated to free resources). Zero failure lines in the output. - Regression-guard effectiveness (mutation-tested in the prior adjudication pass on this same diff, re-confirmed here by inspection): Escape→Enter on the modal makes
test_fullscreen_modal_is_rejected_not_acceptedFAIL; re-addingfullscreen rendererto_MAM_DIALOG_TOKENSmakestest_fullscreen_tip_is_not_a_blocking_dialogFAIL. Guards are non-vacuous.
6. Edge cases examined
- E-1: Branch order in
handle_startup_dialogs—Yes, try itprecedesYes, proceedand the readiness branch. The two dialogs are distinct (no token overlap); order is safe and correct (dismiss modal before ready). - E-2: Other consumers of
_MAM_DIALOG_TOKENS—send_keys_safegating via_pane_dialog_openalso treats the modal as a dialog (blocks prompting under a modal). Consistent and desirable. - E-3:
Yes, try itfalse-positive risk — specific affirmative phrase unique to the upsell modal; the tip fixture (containsTry the new fullscreen rendererbut notYes, try it) returnsDIALOG_CLOSED. Low risk; acceptable. - E-4: Fatal-error regex
^error:(case-insensitive) ordered first — if herdr ever emitted both an error line and a status, fatal wins (fail-safe). herdr success outputs are status lines, noterror:. No conflict. - E-5:
agent_not_ready→success thenwait_for_tui_ready— if the process is up but never shows a banner (unhandled dialog), the readiness loop is bounded (30s) → abort. No zombie. - E-6: Escape on the modal re-captures next iteration; if the banner appears → return 0; if the modal re-appeared (unlikely) it would Escape again, bounded by the 20s
timeout. Safe.
7. Verdict
Both targeted problems are real and correctly fixed. The changeset is surgical, lint-clean, behavior-tested with non-vacuous guards, and introduces no orphans or lost functionality. No design-level rework is required.
[VERDICT: PASS]