Skip to content

fix: retry unsubmitted steering doorbells - #10

Merged
ryannmicua merged 13 commits into
mainfrom
fm/fm-pr8-doorbell-land-v2
Oct 6, 2026
Merged

ryannmicua merged 13 commits into
mainfrom
fm/fm-pr8-doorbell-land-v2

Conversation

@ryannmicua

@ryannmicua ryannmicua commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Supersedes

Supersedes #8 and carries its commit ("Retry exact pending steering doorbells", rebased onto current main); PR 8 can be closed once this merges.

Review decisions

  • Ring policy is unchanged from main: only an exact pending composer is never typed into, ambiguous verdicts (pending-unproven, unknown) still ring by design, and the new Enter-only recovery resubmits only a recognized own doorbell.
  • Whitespace-only variance around an exact own doorbell carries no foreign content; accepted by design.
  • Further rendered busy/idle detection findings (Codex status-row echoes, FM_BUSY_REGEX override for the Codex row) are deferred to follow-up inbox-busy-detection-redesign.
  • The OpenCode idle-stuck recognition gap is recorded as a follow-up in docs/verification/runtime-backends.md; the live guard now defaults to Codex.

Intent

Take on the problem that PR 8 identified. Take over development of this problem.

Context: PR 8 #8 (branch fm/stuck-input-doorbell-fix on this fork, targeting main) was opened directly, without no-mistakes, by another firstmate instance. The problem: a steered worker, seen five times in one day on Codex workers, sits idle with firstmate's steering doorbell line still unsubmitted in its input box, so the durable inbox message stays unhandled, stale alarms fire, and the operator has to press Enter by hand. Root cause per the PR: fm_task_inbox_ring typed the constant doorbell, tried Enter once and discarded the verdict; when the composer read pending it skipped without checking whether the pending text was its own doorbell, and the watcher's re-ring ladder reused that path, so the stuck reminder was never resubmitted. The PR's fix recognizes only the exact doorbell text (or repeated copies), retries Enter with a small bounded budget without retyping, treats a pending Enter on a working pane as queued delivery through fm_composer_queued_enter_verdict, defers the unread-instruction stale wake while working and raises it after retries are exhausted on an idle pane, and leaves foreign composer text untouched. Its own gaps, stated in the PR: Tab-to-queue was left out as unverified live, and live mid-turn recovery on Codex was not exercised, only portable tests. This home's own records add two observations. One: a Codex worker mid-turn shows the doorbell in its composer with "tab to queue message", and sending Tab queued it to run at turn end (verified 2026-09-30). Two: an idle Codex composer on Herdr kept the doorbell after failed rings until Enter was sent by hand (2026-10-03). The PR's required "PR must be raised via no-mistakes" check fails, and two Pi Calm behavior shards fail from unrelated Pi 1.0 test breakage that a separate task (fm-pi1-ci-compat) is fixing on main.

What Changed

  • Recognize when a composer contains only its own steering doorbell and retry submission with bounded Enter-only presses, preserving other pending text.
  • Let the watcher send one Enter for a recognized doorbell on a working pane without spending a re-ring attempt.
  • Add inbox regression and opt-in live coverage, and document runtime results including the known OpenCode idle-stuck recognition gap.

Risk Assessment

⚠️ Medium: The Codex recovery is covered, but a busy accepted send can be queued twice and the matcher still aliases meaningful payload whitespace; the optional live guard also includes a knowingly failing OpenCode case.

Testing

The focused inbox regression and all live Codex/Herdr checks passed. The terminal composer was evidenced through rendered pane text and live transcripts rather than a GUI screenshot. An explicit prepare-then-provision setup attempt hit the helper tripwire; using its provision path succeeded, and all lab sessions were torn down.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
An idle Codex worker whose initial Enter is swallowed recovers the durable steer and acknowledges it. ✅ pass live Codex doorbell recovery on Herdr
An idle worker with its own unsubmitted doorbell gets an Enter-only retry and handles the inbox message. ✅ pass live Codex doorbell recovery on Herdr
A working Codex worker queues its doorbell and handles the message after the active turn. ✅ pass live Codex doorbell recovery on Herdr
A second busy poll does not send another Enter while the same doorbell remains visible. ✅ pass live Busy Enter claim prevents repeat
A doorbell beside unrelated draft text is protected; the ring returns pending and leaves the composer unchanged. ✅ pass live Foreign composer draft preserved
The watcher preserves the retry ladder and defers the stale wake during a working turn, then queues exactly one wake when the worker is idle. ✅ pass live Watcher defers stale wake while busy
Running the live guard without a harness override selects Codex and passes its recovery phases. ✅ pass live Codex-only guard default on Herdr
Evidence: Codex doorbell recovery on Herdr

Source: Codex doorbell recovery on Herdr

ok - codex (codex-cli 0.160.0) on herdr idle-send: Enter swallowed=yes; handled via idle-ring(rc=0)
ok - codex (codex-cli 0.160.0) on herdr idle-stuck: recognized and resubmitted with Enter only; handled after its own submit
ok - codex (codex-cli 0.160.0) on herdr mid-turn: Enter swallowed=yes; handled via busy-enter(rc=0)
ok - live stuck-doorbell guard: 1 harness/backend pair(s) recovered a doorbell left in the composer
Evidence: Codex-only guard default on Herdr

Source: Codex-only guard default on Herdr

ok - codex (codex-cli 0.160.0) on herdr idle-send: Enter swallowed=yes; handled via idle-ring(rc=0)
ok - codex (codex-cli 0.160.0) on herdr idle-stuck: recognized and resubmitted with Enter only; handled after its own submit
ok - codex (codex-cli 0.160.0) on herdr mid-turn: Enter swallowed=yes; handled via busy-enter(rc=0)
ok - live stuck-doorbell guard: 1 harness/backend pair(s) recovered a doorbell left in the composer
Evidence: Foreign composer draft preserved

Source: Foreign composer draft preserved

PASS: real Codex/Herdr ring returned rc=1 and preserved the unsubmitted composer draft.
Composer text:
: Firstmate instruction waiting: list '/tmp/fm-doorbell-foreign.i5MFgk/fm-home/state/t1.inbox'/*.msg and, in numeric order, read and act on each, then mv each handled file to '/tmp/fm-doorbell-foreign.i5MFgk/fm-home/state/t1.inbox'/ handled/. and preserve this unrelated draft exactly as written.
Evidence: Busy Enter claim prevents repeat

Source: Busy Enter claim prevents repeat

PASS: real Codex/Herdr working pane claimed 001.msg; busy polls sent 1 Enter, then rc=4 with no additional key.
Evidence: Watcher defers stale wake while busy

Source: Watcher defers stale wake while busy

Observed during turn: ladder=[001.msg	1	1791247471], stale wake=none.
PASS: idle recovery exhausted its one attempt; while Codex worked the ladder stayed unchanged with no stale wake; on idle the watcher queued one stale wake and suppressed the next duplicate.
1791247500	1	stale	fm-lab-doorbell-stale-805620-28467:w1:p1	stale: fm-lab-doorbell-stale-805620-28467:w1:p1 (unread firstmate instruction: /tmp/fm-doorbell-stale.hTswJo/fm-home/state/t1.inbox/001.msg still unhandled after 1 doorbell delivery attempts with an idle pane; inspect the worker)
- Outcome: 🔧 2 issues found → auto-fixed → no changes applied ✅ across 3 runs (2h8m26s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 3 warnings
  • ⚠️ bin/fm-task-inbox-lib.sh:449 - When the normal type-and-submit path returns empty because Enter was accepted while the pane is busy, this returns before recording the per-message busy Enter claim. The doorbell can still be visible; the next busy watcher poll recognizes it and presses Enter again, potentially queueing the same steer twice. If the accepted-queued verdict leaves this record’s doorbell visible, preserve the busy result and claim it before returning. The same invariant applies at bin/fm-send.sh:1087 (local steer), bin/fm-remote-secondmate-control.sh:291 (remote steer), bin/fm-procevent.sh:806 (process-event steer), and bin/fm-watch.sh:513 (watcher retry).
  • ⚠️ bin/fm-composer-lib.sh:1642 - This comparison normalizes Unicode whitespace inside the doorbell payload. For a valid record under a path such as /tmp/run box/state, a draft that substitutes a non-breaking space in the quoted path is normalized to the expected ASCII space, recognized as Firstmate’s doorbell, and submitted with Enter; the worker then receives a different path. Preserve payload character distinctions and normalize only confirmed renderer padding. The conversion affects extracted content at bin/fm-composer-lib.sh:1597 and the comparison input at :1648-1649.
  • ⚠️ tests/fm-task-inbox-stuck-doorbell-live-e2e.test.sh:51 - The live guard’s default matrix covers every listed harness on both backends, beyond the intent’s Codex recovery requirement. The changed runtime evidence records that this default coverage fails the idle-stuck case on OpenCode 1.18.33 and 1.18.34 (docs/verification/runtime-backends.md:825,838). Remove non-Codex harnesses from the default matrix; retain the environment override for explicitly requested broader runs.

🔧 Fix applied.
3 warnings still open:

  • ⚠️ bin/fm-task-inbox-lib.sh:449 - When the normal type-and-submit path returns empty because Enter was accepted while the pane is busy, this returns before recording the per-message busy Enter claim. The doorbell can still be visible; the next busy watcher poll recognizes it and presses Enter again, potentially queueing the same steer twice. If the accepted-queued verdict leaves this record’s doorbell visible, preserve the busy result and claim it before returning. The same invariant applies at bin/fm-send.sh:1087 (local steer), bin/fm-remote-secondmate-control.sh:291 (remote steer), bin/fm-procevent.sh:806 (process-event steer), and bin/fm-watch.sh:513 (watcher retry).
  • ⚠️ bin/fm-composer-lib.sh:1642 - This comparison normalizes Unicode whitespace inside the doorbell payload. For a valid record under a path such as /tmp/run box/state, a draft that substitutes a non-breaking space in the quoted path is normalized to the expected ASCII space, recognized as Firstmate’s doorbell, and submitted with Enter; the worker then receives a different path. Preserve payload character distinctions and normalize only confirmed renderer padding. The conversion affects extracted content at bin/fm-composer-lib.sh:1597 and the comparison input at :1648-1649.
  • ⚠️ bin/fm-task-inbox-lib.sh:324 - The earlier 1bb4bea fix round added this Codex-specific check but bypassed the documented FM_BUSY_REGEX override (docs/configuration.md:1211). With a configured Codex busy pattern, the tmux submit core can accept Enter as queued while the doorbell remains visible, yet this branch returns unknown and the latest F1 fix does not record the busy-Enter claim. On the next watcher poll, Codex's unverified semantic state and the same fallback can leave busy status unknown, so own-doorbell recovery may send Enter up to three times on a working pane. Honor the override while retaining the default active-row guard. The latest F1 claim and recovery paths that depend on this classification are bin/fm-task-inbox-lib.sh:428-431, :451, :462-465 and bin/fm-watch.sh:489, :499, :513.
🔧 **Test** - 2 issues found → auto-fixed → no changes applied ✅
  • 🚨 bin/fm-composer-lib.sh:1667 - Live Codex 0.160.0 on Herdr left this inbox's doorbell visible in the composer, but the rendered wrap dropped a separator space. The own-doorbell recognizer returned false, so the idle retry path treated the message as foreign and left the inbox record unhandled. The exact row comparison returns false at the mismatch here; this conflicts with the accepted renderer-whitespace behavior.
  • 🚨 live validation verdict: no-go (3 of 4 scenarios were driven live against the product); failed: An idle Codex worker with its own unsubmitted steering doorbell is re-rung and handles the inbox message
  • Live validation: ❌ no-go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
An idle Codex worker with its own unsubmitted steering doorbell is re-rung and handles the inbox message ❌ fail live Live own-doorbell recognition result; Idle Codex pane with the unrecovered doorbell
A Codex worker already executing a long turn acts on and acknowledges a steering message ✅ pass live Mid-turn live interaction results; Codex pane after the mid-turn steer was acted on
A watcher leaves unrelated text in Codex's composer unsent ✅ pass live Foreign-draft guard results; Codex pane with the foreign draft preserved
A busy-pane queued Enter that leaves the own doorbell visibly pending is claimed so the next poll does not submit it again ⏸️ untested no I called the real ring while Codex CLI 0.160.0 reported a live Herdr pane as busy, and the worker later acted on and acknowledged the message. That run did not produce captured evidence of the accepte…
  • TMPDIR="$PWD/.test-tmp" bash tests/fm-task-inbox.test.sh
  • FM_STUCK_DOORBELL_LIVE=1 FM_STUCK_DOORBELL_LIVE_BACKENDS=herdr FM_STUCK_DOORBELL_LIVE_HARNESSES=codex bash tests/.fm-task-inbox-stuck-doorbell-short.test.sh using a disposable workspace-local scratch root
  • TMPDIR="$PWD/.live-tmp" FM_HERDR_LAB_STATE_DIR="$PWD/.live-tmp/herdr-lab-state" CODEX_HOME="$PWD/.live-codex-home" bash .live-tmp/foreign-composer-e2e.sh
  • TMPDIR="$PWD/.live-tmp" FM_HERDR_LAB_STATE_DIR="$PWD/.live-tmp/herdr-lab-state" CODEX_HOME="$PWD/.live-codex-home" bash .live-tmp/midturn-composer-e2e.sh
  • Captured live Herdr pane output for the stuck-doorbell, mid-turn, and foreign-draft scenarios.
  • bin/fm-herdr-lab.sh run fm-lab-final-check session list

🔧 No changes applied.
2 errors still open:

  • 🚨 bin/fm-composer-lib.sh:1667 - The live Codex 0.160.0 run on Herdr failed all three recovery phases. The idle-send phase left the doorbell visible and unhandled after repeated rc=1 retries; idle-stuck did not recognize the doorbell as its own; and mid-turn remained unhandled after the 51-second tool call completed. The live composer showed the wrapped doorbell text, but the own-doorbell matcher rejected it at this comparison, reproducing the reported stuck-inbox behavior.
  • 🚨 live validation verdict: no-go (3 of 4 scenarios were driven live against the product); failed: An idle Codex worker recovers its own visible steering doorbell and acknowledges the inbox message, An idle Codex worker resubmits an unsubmitted doorbell with Enter only, A working Codex worker queues its own doorbell and handles it after the active turn
  • Live validation: ❌ no-go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
An idle Codex worker recovers its own visible steering doorbell and acknowledges the inbox message ❌ fail live Codex on Herdr live doorbell recovery
An idle Codex worker resubmits an unsubmitted doorbell with Enter only ❌ fail live Codex on Herdr live doorbell recovery
A working Codex worker queues its own doorbell and handles it after the active turn ❌ fail live Codex on Herdr live doorbell recovery
A foreign Codex composer draft remains untouched when a steer is attempted ⏸️ untested no I provisioned a named Herdr lab with a temporary empty CODEX_HOME, but Codex never reached a classified empty composer within 90 seconds (state=unknown), so no foreign draft was entered. Using the…
  • FM_STUCK_DOORBELL_LIVE=1 FM_STUCK_DOORBELL_LIVE_HARNESSES=codex FM_STUCK_DOORBELL_LIVE_BACKENDS=herdr FM_STUCK_DOORBELL_LIVE_TIMEOUT=240 bash tests/fm-task-inbox-stuck-doorbell-live-e2e.test.sh
  • Provisioned and tore down a named Herdr lab for the foreign-composer check using a temporary CODEX_HOME; the composer readiness check remained unknown.

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

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
An idle Codex worker whose initial Enter is swallowed recovers the durable steer and acknowledges it. ✅ pass live Codex doorbell recovery on Herdr
An idle worker with its own unsubmitted doorbell gets an Enter-only retry and handles the inbox message. ✅ pass live Codex doorbell recovery on Herdr
A working Codex worker queues its doorbell and handles the message after the active turn. ✅ pass live Codex doorbell recovery on Herdr
A second busy poll does not send another Enter while the same doorbell remains visible. ✅ pass live Busy Enter claim prevents repeat
A doorbell beside unrelated draft text is protected; the ring returns pending and leaves the composer unchanged. ✅ pass live Foreign composer draft preserved
The watcher preserves the retry ladder and defers the stale wake during a working turn, then queues exactly one wake when the worker is idle. ✅ pass live Watcher defers stale wake while busy
Running the live guard without a harness override selects Codex and passes its recovery phases. ✅ pass live Codex-only guard default on Herdr
  • FM_STUCK_DOORBELL_LIVE=1 FM_STUCK_DOORBELL_LIVE_BACKENDS=herdr FM_STUCK_DOORBELL_LIVE_HARNESSES=codex FM_STUCK_DOORBELL_LIVE_TIMEOUT=240 bash tests/fm-task-inbox-stuck-doorbell-live-e2e.test.sh
  • env -u FM_STUCK_DOORBELL_LIVE_HARNESSES FM_STUCK_DOORBELL_LIVE=1 FM_STUCK_DOORBELL_LIVE_BACKENDS=herdr FM_STUCK_DOORBELL_LIVE_TIMEOUT=240 bash tests/fm-task-inbox-stuck-doorbell-live-e2e.test.sh
  • bash bin/fm-test-run.sh tests/fm-task-inbox.test.sh
  • Drove fm_task_inbox_ring against real Codex composers for foreign-draft protection and repeated busy-poll claims.
  • Drove the production inbox_steer_check against a working and then idle Codex/Herdr task; checked the persisted retry ladder and stale-wake queue.
⚠️ **Document** - 1 warning
  • ⚠️ docs/verification/runtime-backends.md:851 - OpenCode 1.18.33+ still fails to recognize its idle-stuck doorbell on tmux and Herdr; the documented follow-up remains open.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@ryannmicua
ryannmicua merged commit b43267e into main Oct 6, 2026
20 checks passed
@ryannmicua
ryannmicua deleted the fm/fm-pr8-doorbell-land-v2 branch October 6, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant