Repository navigation
Hold missed and unreported pending-reply escalations quiet before waking - #53
Merged
Merged
Conversation
A missed or unreported pending-reply escalation woke the supervisor at once, though the mate had usually acknowledged or answered where main already saw it. Publish it as a self-announced decision (listed in OPEN DECISIONS, no wake) and wake once, with a reminder under the same key, only if it is still unresolved after FM_PENDING_REPLY_WAKE_HOLD_SECS (default 3600). Delivery-unknown and recovery-delivery escalations still wake at once.
uayyagari
marked this pull request as draft
October 26, 2026 18:01
uayyagari
marked this pull request as ready for review
October 26, 2026 20:55
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.
Problem
Fix
pending-reply-missedandpending-reply-unreportedescalations for a delivered request are now published with the home's own self-announced append: the keyedblockeddecision is in the log and lists in the next drain's OPEN DECISIONS, but does not wake.FM_PENDING_REPLY_WAKE_HOLD_SECS(default 3600, 0 restores the old behaviour), the tick appends one plain reminder under the same key. That wakes once. A reply inside the hold resolves the record and closes the decision with no wake.delivery-unknownandrecovery-deliveryescalations are transport faults and still wake at once. Resolve, close, recovery repost and the missed-report logic are unchanged.escalation_wake_due_epoch; tunable documented indocs/configuration.md.Worked example (web-perf, 2026-10-26): main steers web-perf, which answers
working:; 1800 s laterpending-reply-unreportedescalates.Proof
tests/fm-pending-reply.test.shpasses (new: quiet escalation lists but does not wake and a reply inside the hold resolves silently; wakes once after the hold, not on repeated ticks, and still closes on a reply; delivery-unknown still wakes at once). Existing cases run with the hold set to 0, so their wake assertions are unchanged. Also run and passing:fm-secondmate-result-delivery,fm-send-resolve-key;bin/fm-lint.shclean.usage.py 2026-10-26: main supervisor 841 calls, 21.0M weighted tokens, about 25k weighted tokens and 192k cache-read per call. At least one call per wake: 37 to 19 wakes is at least 18 fewer calls on 10-26.Replay script (python3 replay.py 3600 [day-prefix])
Fork footprint vs upstream main
Fork footprint vs upstream main
Intent
We are using way too much quota for the work given; anything to bring the wastage down. Measured 2026-10-26 (Claude transcripts, about 101.6M weighted tokens): workers 41%, no-mistakes final runs 20%, second mate supervisors 20%, main supervisor 19%. Main supervisor session: 759 calls at about 193k tokens of cache re-read per call; interview-recordings second mate: 517 calls at about 218k per call. Many supervisor turns were bookkeeping-only (pending-reply-missed or unreported wakes, 'Captain, shipshape.' no-ops). Each fix ships as its own PR with before/after numbers.
Risk Assessment
✅ Low: The quiet-escalation hold is small and self-contained, and the fix round closed both earlier findings without new defects. Before the reminder fires it now checks that the keyed decision is still open (round 1 finding 1). The reminder text now uses due minus escalated_epoch for the hold length (round 1 finding 2). Both new tests would fail without the fixes.
Testing
I drove the real bin/fm-watch.sh and bin/fm-wake-drain.sh in disposable lab homes made with bin/fm-lab-home.sh, with plain FM_HOME and the override variables unset. One flow was used throughout: second mate hibit acknowledges a request with
working [corr=...]and goes quiet. Baseline with hold=0 (the old behavior): the watcher woke within 2s. With the default 1h hold it stayed blocked for the whole 40s while the decision still showed as open. A 15s hold woke it once, with a "still unresolved" reminder under the same key. After a real drain and ack, no repeat came in the next 40s. A decision main had already closed got no reminder and no wake. A reply during the hold closed the decision, the only wake was for the reply itself, and no reminder followed. Delivery-unknown still woke at once. The focused pending-reply test file passes. The before/after number shown here is wakes per quiet escalation: one at once before, versus none, or one after the hold if still unresolved. Fleet token savings would need live measurement over time. Every lab home was removed afterward and the worktree is clean. There is no UI surface; the evidence is CLI transcripts.Evidence: Baseline: hold=0 wakes watcher at once (old behavior)
Source: Baseline: hold=0 wakes watcher at once (old behavior)
Evidence: Default 1h hold: escalation listed as open decision, watcher stays blocked 40s
Source: Default 1h hold: escalation listed as open decision, watcher stays blocked 40s
Evidence: Hold expires: one reminder wake, drain shows OPEN DECISIONS, no repeat after ack
Source: Hold expires: one reminder wake, drain shows OPEN DECISIONS, no repeat after ack
Evidence: Main closed the key before the hold: no reminder, no wake
Source: Main closed the key before the hold: no reminder, no wake
Evidence: Mate reply inside the hold: decision closes, no reminder afterward
Source: Mate reply inside the hold: decision closes, no reminder afterward
Evidence: Delivery-unknown still wakes at once despite the 1h hold
Source: Delivery-unknown still wakes at once despite the 1h hold
Evidence: Lab driver script used for all scenarios
Source: Lab driver script used for all scenarios
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
bin/fm-pending-reply-lib.sh:1499- The held-escalation reminder never checks whether the keyed decision is still open before it reopens it and wakes the supervisor. Example: hibit's request escalates quietly asblocked [key=pending-reply-<corr>]and shows up in the next drain's OPEN DECISIONS. Main handles it withfm-send hibit --resolve-key pending-reply-<corr> .... fm-send closes the decision with an operator-resolve-key note (fm-send.sh:607, fm_pending_reply_close_note_for_key), but the record stays phase=escalated with escalation_wake_due_epoch still set. Once the hold runs out, fm_pending_reply_tick calls fm_pending_reply_wake_held_escalation. try_resolve fails because there is no correlated report. fm_pending_reply_escalation_line (line 1248) still finds the original blocked line, because it matches text and ignores whether the decision is open. The plain append at line 1502 then reopens a decision main already closed and wakes the supervisor for a bookkeeping-only turn, which is the waste the intent sets out to remove. Fix: before appending, apply the same open-decision check _fm_pending_reply_close_escalation_locked uses (lines 1308-1316): scan status_open_decisions for the escalation's key and note, and when the key is no longer open, clear escalation_wake_due_epoch without appending. Related: when escalation_line returns empty (status file missing or replaced), the function clears the due epoch without waking. That contradicts the comment at line 1444 that 'a miss is never dropped', so that case should be handled on purpose too.bin/fm-pending-reply-lib.sh:1500- The reminder text 'still unresolved after $((hold / 60))m' reads FM_PENDING_REPLY_WAKE_HOLD_SECS when the reminder fires, not the hold that set the due time. If the env value changes between escalation and reminder (for example a restart with a new value, or 0), the label is wrong, e.g. 'after 0m'. A more accurate value is now minus escalated_epoch, both already in the record.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
drive-watch.sh quiet 0 25: real fm-watch.sh in a lab FM_HOME with FM_PENDING_REPLY_WAKE_HOLD_SECS=0 (old behavior baseline)drive-watch.sh quiet 3600 40: same request with the default 1h hold; watcher observed for 40sRESTART=40 drive-watch.sh quiet 15 60: 15s real-time hold expires, supervisor drains and acks via bin/fm-wake-drain.sh, then a re-armed watcher is observed for 40sdrive-watch.sh closed-by-main 15 45: main closes key pending-reply-<corr> with the fm-send --resolve-key close note before the hold ends; watcher observed past the holdRESTART=35 drive-watch.sh reply-in-hold 15 30: mate hibit writesdone [corr=...]inside the hold; drain, ack, and re-armed watcher observed past the holdUNKNOWN=1 drive-watch.sh quiet 3600 30: delivery-unknown record with the 1h holdbash tests/fm-pending-reply.test.sh(focused file, includes the 5 new quiet-escalation tests)✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.