Repository navigation
fix: keep OMP from going idle with pending wakes and replies - #323
Merged
Merged
Conversation
- session_stop continues once while the lock-owning session outside away mode still has main-owned wake rows, naming any provider refusal from the run; the bounded second stop warns the captain instead of ending silently. - The watch core records a settled main on terminal agent_end; a close behind an open fallback episode now forces a turn while main is idle instead of being suppressed until someone acknowledges. - runGuard ignores stdin EPIPE from a guard that exits before reading its payload. - ext-respond: a provider refusal never excuses silence; phrase briefs in the work's legitimate purpose. - Regression tests cover both paths; docs updated in turnend-guard.md and omp-supervision-branch.md.
…turn ends - The turn-end continuation counts Communication Officer requests still owed an answer (no reply, reply still delivering, or ack-only with no live task) through fm_ext_owed_requests, alongside unacknowledged main wake rows, and rides the supervision continuation when both apply. - The owed-work scan is bounded at 15 s, inside OMP's 30 s handler deadline; an unfinished scan counts as owed rather than clear. - Refusal tracking uses only typed stopDetails, makes no fallback claim, copies no provider text, and asks for an ack only when a request has no reply yet. - Settlement force-delivers the newest close coalesced during the ending run, once per batch newer than the last hand-off; the unread main_idle mirror field is gone. - A terminal agent_end with no preceding stop check raises a captain-visible warning when work is owed; forced recovery on that path is filed as fm-omp-terminal-recovery.
…scans - idle-close-suppressed-behind-inflight: the idle-episode bypass no longer requires an empty in-flight marker; it retires a staged but unconsumed wake (consumed by=idle-bypass) and force-sends the next close. - settlement-prefers-older-check: settlement delivers the newest coalesced close, matching docs/omp-supervision-branch.md. - settlement-lost-during-watcher-restore: a settlement that lands mid-restore is recorded and replayed when the delivery run completes. - timeout-drops-refusal-ack-instruction: an inconclusive owed-work scan keeps the refusal ack instruction and asks ext-respond to check reply state. - tests: test_native_omp_settlement_edges covers the first three; the owed-work test gains a timed-out-scan phase.
- owed-scan-can-interrupt-local-head-acceptance: the scan runs through the shared runCommandAsync with no kill timeout; the handler stops waiting after 15 s and treats it as inconclusive, while the scan (and any fm-crew-state.sh metadata write) finishes on its own. - remove-duplicate-omp-subprocess-runner: the local spawn runner is gone; a failed or malformed scan is inconclusive instead of clear. - owed-work-uses-stale-custody: lock ownership and away mode are rechecked after the scan before any continuation or warning. - remove-unconditional-warning-delivery-claims: both warnings drop their predictions about what will force a turn. - restore-replay-test-manufactures-branch-acceptance: the branch double accepts only offers the adapter marks eligible, with task metadata seeded per the dispatch contract. - refusal-tests-miss-visible-ack-contract: both refusal phases assert the visible-ack instruction. - settlement-can-miss-newest-main-close is declined into backlog item fm-omp-terminal-recovery per the captain's decision.
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.
Summary
Firstmate's OMP primary went idle for 17 minutes on 2026-11-20 with two Discord requests and their overdue reminders pending.
Two gaps let that happen: the turn-end hook only checked watcher health, and the main-fallback coalescing episode kept suppressing every later wake while main sat idle.
The owed-work scan is never killed: the handler stops waiting after 15 s (inside OMP's 30 s handler deadline) and treats the scan as inconclusive, because its live-task lookup can be recording task metadata.
Evidence
Each behaviour was proven by reverting its fix alone and watching its test fail, then restoring it.
test_native_omp_turn_end_with_unacked_wakes_continues_oncetest_native_omp_idle_main_hears_wake_behind_open_episodetest_native_omp_settlement_edgesOpen items (not fixed here)
AC2 is accepted with the captain's exception "2026-11-21 Discord: 2": a terminal
agent_endwith no stop continuation only warns; forced recovery there is follow-up backlog itemfm-omp-terminal-recovery.Review findings approved past review under the captain's decision "A" and tracked in that follow-up:
settlement-can-miss-newest-main-close: settlement skips while a wake staged after the lastturn_startis in flight, and a selected close can be re-offered to the branch.owed-scan-can-return-stale-clear: a Discord request arriving during the slow live-task lookup can read as clear.owed-scan-masks-helper-failures: a library load or count failure prints zeros instead of inconclusive.unrequired-terminal-refusal-annotation: the terminal warning carries a refusal note the intent did not ask for.Pre-existing CI failures, not touched (approved past the CI gate; each fails the same way on main):
Behavior tests (Herdr): raw launch commands not run in their panes, and a presentation-e2e teardown failure; maine89ec466run https://github.com/dnth/firstmate/actions/runs/44740623357 and maina037440crun https://github.com/dnth/firstmate/actions/runs/44210860449.Behavior portable serial 2(fm-watch-triagegtimeout descendant),serial 6(fm-omp-harnesscopied executable identity), andserial 9(fm-omp-secondmatecancelled at the 20-minute job timeout): main run https://github.com/dnth/firstmate/actions/runs/44740623357.Serial 3 (
fm-task-inbox), 5 (fm-backend-tmux-smoke), and 8 (fm-pi-watch-extension) failed on this PR's first CI run and passed on the second; locallybin/fm-test-run.sh tests/fm-pi-watch-extension.test.sh tests/fm-task-inbox.test.sh tests/fm-backend-tmux-smoke.test.shreportedtotal=3 failed=0on this head (inferred flaky).The one CI failure this PR caused, Stock macOS Bash 3.2 parsing an apostrophe in a test comment inside a command substitution, is fixed in
4f556a70.Merge Danger
Door: two-way.
The change is confined to the OMP primary adapter, the shared watcher core's OMP-only coalescing path, one read-only helper in the overdue library, docs, and tests; reverting the PR restores the previous behaviour.
Blast Radius: OMP-primary.
A wrong owed-work verdict costs at most one extra forced continuation per stop or one extra warning; the idle bypass and settlement send at most one forced wake per idle period or batch.
Other harnesses and the shared
bin/fm-turnend-guard.shpredicate are unchanged.Testing
The base runtime reproduced the silent stop, and the target passed every local OMP scenario with synthetic bridge data, the focused regression fixtures, and evidence from the live terminal and wake logs.
Evidence: Live OMP transcript with provider prompts, wake delivery records, and exit statuses
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
.omp/extensions/fm-primary-omp.ts:195- The intent says “A turn must not end silently with unacknowledged main wake rows or Communication Officer requests still owed an answer.” The scan counts rows at .omp/extensions/fm-primary-omp.ts:195 and snapshots the inbox at bin/fm-ext-overdue-lib.sh:52 before the potentially slow live-task lookup at line 59. Start with an empty queue and one acked request whose linked task is still live. If a second Discord request arrives during that lookup, intake can publish its inbox record and wake row before the scan returns. The scan still reports zero, so the first stop allows the turn to end and the second stop emits no warning. The same stale result suppresses the unchecked terminal warning at .omp/extensions/fm-primary-omp.ts:695. Recount main rows after the slow lookup and treat a newly arrived inbox record as inconclusive within the existing wait budget. The slow-lookup fixture at tests/fm-omp-primary.test.sh:3226 can exercise this by publishing a request while the lookup is blocked..omp/extensions/fm-primary-omp.ts:197- The scan converts shell failures into a successful zero count. If the overdue library fails to load while an unanswered inbox record exists and the wake queue is empty, lines 196–198 print0 0 0, so the scan is treated as clear. The same masking occurs for the wake-library load or count at line 195, a failed owed-request count at line 197, and failed inbox enumeration at bin/fm-ext-overdue-lib.sh:52. Propagate failures to the existing inconclusive-result path at .omp/extensions/fm-primary-omp.ts:211. A successfully scanned inactive bridge already has an explicit zero-result path..omp/extensions/fm-primary-omp.ts:700- The terminal warning’s separate “after a provider refusal” wording is outside the requested refusal behavior. The intent calls for a captain-visible owed-work warning here and a visible Discord ack instruction in the stop continuation. Remove the terminal warning’s refusal annotation and its local copy at .omp/extensions/fm-primary-omp.ts:689.✅ **Test** - passed
✅ No issues found.
python3 .live-validation/checks.py bounded base linked nonowner repair timeout custody terminal refusal idledrove the real OMP TUI in disposable tmux sessions with a loopback provider. The baseline replay substituted the three runtime files frome89ec466.python3 .live-validation/wakes.py settle restoredrove the real watcher and OMP TUI with synthetic overdue records and a newer task status signal.python3 .live-validation/acp.pydroveomp acpover stdio to exercise the unconsumed-wake hand-off.tests/fm-omp-primary.test.shtargeted selectorstest_native_omp_idle_main_hears_wake_behind_open_episode,test_native_omp_settlement_edges, andtest_native_omp_turn_end_with_unacked_wakes_continues_once. The initial selection also rantest_native_omp_launch_error_journalandtest_resolve_path_uses_node_when_readlink_f_is_unavailable.Captured live terminal output withtmux capture-pane, rendered both captain warnings to PNG, and verified that the disposable OMP, watcher, and tmux processes had exited.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.