Repository navigation
fix: defer stale wedge alarms for active crews - #14
Merged
Merged
Conversation
…dges A crewmate blocked on a long foreground call is idle by design: a `no-mistakes` gate call blocks synchronously against its own multi-thousand-second allowance, so its pane stays frozen far past the 240s wedge threshold. Both supervisors escalated on that threshold alone, so every pipeline gate produced a stream of possible-wedge alarms against healthy workers (three in one day on 2026-07-30, one of them 916s into a healthy call with a 3000s allowance). A warning that is usually wrong trains its reader to dismiss the one that is real. The threshold now selects re-examination, not alarm. On reaching it, the crew's current state is re-read once per threshold window; a crew still provably working is deferred for another window, and only a crew that stops verifying as working - or one that stays idle past the new FM_WEDGE_WORKING_ESCALATE_SECS allowance (default 3600s) - escalates. That is the disambiguation a supervisor otherwise had to perform by hand before believing the alarm. The real-wedge guarantee is preserved and documented: a crew that goes quiet surfaces within one threshold window of stopping, and a frozen pipeline that keeps reporting itself as running surfaces within the allowance. The deferral trades false alarms for latency, never for silence, and can be disabled with FM_WEDGE_WORKING_ESCALATE_SECS=0. bin/fm-classify-lib.sh owns the decision (wedge_escalation_deferred) for both the always-on watcher and the away-mode daemon; each consumer owns only its own verification marker, so the crew state is read at most once per threshold window per pane. Compatibility review: the changed code makes no harness- or backend-specific call. It consumes bin/fm-crew-state.sh's verdict, which already resolves the busy signature per recorded harness (claude, codex, opencode, pi, pi-signed, grok, kimi) and the endpoint per recorded backend (tmux, herdr, zellij, orca, cmux) through bin/fm-backend.sh; the daemon path additionally remains restricted to its existing tmux/herdr supervisor panes. Codex Desktop is not a spawn backend and has no stale marker, so it is not applicable here. Tests: tests/fm-watch-triage.test.sh and tests/fm-daemon.test.sh cover both directions - repeated threshold windows absorb a live in-contract call, while a stopped crew and a frozen pipeline past the allowance still escalate. Each escalation assertion was watched failing against deliberately broken variants (no ceiling; always-working verdict) before being kept.
These two tests assert that the away-mode supervisor guard treats Herdr's native `agent.get` idle verdict as conclusive and skips the regex-over-capture corroboration. That short-circuit was a fork-only change; the implementation it asserted was removed when bin/fm-supervise-daemon.sh was restored to match upstream exactly (c4ec3b2), leaving the tests behind and tests/fm-daemon.test.sh deterministically red on the default branch. This fork tracks upstream exactly and fork-only customizations are discarded, so the artifact to remove is the test, not the implementation: re-adding the short-circuit would recreate the drift the upstream match deliberately removed. Upstream behavior is unchanged - a non-`busy` native verdict still corroborates against the recorded harness's rendered busy signature before the supervisor pane is treated as idle. The rest of PR #2's away-mode work is untouched and still covered: the U+00A0 composer classification tests pass, as do the herdr busy-state, capture-fallback, and inject-dispatch tests. tests/fm-daemon.test.sh now runs to completion: 100 passing, 0 failing (previously it aborted at 90 with these 2 failures). Note for the PR body: this removal and its reason belong on their own line at merge review.
This was referenced Aug 7, 2026
knowttl
added a commit
that referenced
this pull request
Aug 7, 2026
…#18) Restores PR #14 (fc69527), which a later upstream sync dropped from the fork's default branch: the markers wedge_escalation_deferred and FM_WEDGE_WORKING_ESCALATE_SECS were absent from main, so the watcher and the away-mode daemon again alarmed every long in-contract call as a possible wedge. A crewmate blocked on a long synchronous foreground call is idle by design: a no-mistakes gate call blocks against its own multi-thousand- second allowance, so its pane stays frozen far past the 240s threshold. The threshold now selects re-examination, not alarm. On reaching it the crew's current state is re-read once per threshold window; a crew still provably working is deferred for another window, and only a crew that stops verifying as working - or one that stays idle past FM_WEDGE_WORKING_ESCALATE_SECS (default 3600s) - escalates. The deferral trades false alarms for latency, never for silence, and FM_WEDGE_WORKING_ESCALATE_SECS=0 disables it. bin/fm-classify-lib.sh owns the decision for both supervisors; each consumer owns only its own verification marker, so the crew state is read at most once per threshold window per pane. Re-integrated on top of the current code rather than reverted. The sync added BUSY_TURN_MAX_SECS, which routes a busy pane with no completed turn through the same wedge timer precisely because that pane's busy signal is no longer trusted. Since a busy pane is exactly what the deferral's re-verification reads, deferring there would re-affirm the discredited signal and silently extend the bound by the whole allowance, so wedge_timer_check takes a nodefer argument and the two busy-turn call sites pass it. Tests: the restored fc69527 coverage in tests/fm-watch-triage.test.sh and tests/fm-daemon.test.sh proves both directions - repeated threshold windows absorb a live in-contract call, while a stopped crew and a frozen pipeline past the allowance still escalate. A new watcher test pins the busy-turn exemption; it was watched failing with the nodefer argument removed, and the classifier assertions were watched failing against a wedge_escalation_deferred stubbed to never defer.
This was referenced Aug 14, 2026
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
Fix firstmate's stale/wedge escalation so a crewmate sitting inside a long IN-CONTRACT foreground call is not repeatedly escalated as a possible wedge.
Background: on 2026-07-30 the fleet produced three false possible-wedge alarms in one day against healthy workers. The supervision layer treats ~4 minutes of pane idleness (FM_STALE_ESCALATE_SECS, default 240s, shared by bin/fm-watch.sh's wedge timer and bin/fm-supervise-daemon.sh's away-mode housekeeping) as a possible wedge, but a crewmate blocked on a 'no-mistakes axi run'/'respond' gate call blocks synchronously against its own multi-thousand-second allowance and renders a frozen pane for far longer than that - one observed healthy call was 916s in against a 3000s allowance and was alarmed twice. Every pipeline gate tripped this fleet-wide. A warning that is usually wrong trains its reader to dismiss the one that is real. The supervising secondmate's manual workaround was to inspect the process table before believing the alarm; that disambiguation is what the alarm itself should do.
Chosen approach (from two the brief offered): make the threshold select RE-EXAMINATION rather than alarm, instead of the simpler 'one-shot per idle episode' fallback. On reaching FM_STALE_ESCALATE_SECS the crew's authoritative current state is re-read (bin/fm-crew-state.sh via crew_is_provably_working); a crew still provably working is deferred for another threshold window, and escalation fires only when it stops verifying as working or when it stays idle past a new FM_WEDGE_WORKING_ESCALATE_SECS allowance (default 3600s; 0 disables the deferral and restores the previous behavior). This deliberately keeps the real-wedge guarantee bounded and documented - a crew that stops surfaces within one threshold window, a frozen pipeline that keeps reporting itself as running surfaces within the allowance - so false positives are traded for latency, never for silence. Deliberate design decisions: the deferral is decided once per threshold window per pane, not every poll, by having bin/fm-classify-lib.sh own a pure decision (wedge_escalation_deferred, returning 0 defer-verified / 2 defer-cached / 1 escalate) while each consumer owns its own verification marker file; this respects firstmate's one-owner rule and keeps at most one bounded crew-state read per window. Escalating restarts the idle clock, so a still-working-looking frozen pane repeats at roughly the allowance rather than every 4 minutes, which is the intended noise reduction.
Existing tests that encoded the old 'provably-working stale escalates at 240s' contract were deliberately updated rather than deleted: their escalation phases now reach the ceiling backstop or model a crew that stopped mid-episode, which is what the new contract says. Per the brief's acceptance criteria, each escalation assertion was watched failing against two deliberately broken variants (allowance never expires; crew always reads as working) before being kept.
Docs follow firstmate's one-owner rule: docs/architecture.md owns the wake-classification contract and carries the new threshold semantics, docs/configuration.md lists the new tunable, the afk skill now points at that owner instead of restating it, and AGENTS.md's state inventory gained the new marker glob. Compatibility was reviewed across every supported primary harness (claude, codex, opencode, pi, pi-signed, grok, kimi) and runtime backend (tmux, herdr, zellij, orca, cmux): the changed code makes no harness- or backend-specific call, consuming fm-crew-state.sh's already harness/backend-aware verdict, and the daemon path keeps its existing tmux/herdr supervisor-pane restriction.
The branch also carries a second, separately-committed change the captain explicitly decided during this task: two fork-only Herdr native-idle daemon tests were REMOVED (not fixed by re-adding the implementation). They asserted that the away-mode supervisor guard treats Herdr's native agent.get 'idle' verdict as conclusive; that short-circuit was fork-only and its implementation was removed when bin/fm-supervise-daemon.sh was restored to match upstream exactly (c4ec3b2), leaving tests/fm-daemon.test.sh deterministically red on the default branch before this work. The captain's standing policy is that this fork tracks upstream EXACTLY and fork-only customizations are discarded, so the artifact to remove is the test, not the implementation - restoring the short-circuit would recreate the drift the upstream match deliberately removed. This removal and its reason must appear as its own line in the PR body for merge review. tests/fm-daemon.test.sh now runs to completion at 100 passing, 0 failing (it previously aborted at 90 with those 2 failures).
What Changed
FM_WEDGE_WORKING_ESCALATE_SECSceiling.Risk Assessment
✅ Low: The follow-up accurately documents the explicitly authorized difference between the repeating always-on watcher and the daemon's single durable advisory, with no new source risk found.
Testing
The supplied daemon baseline was independently confirmed alongside the focused watcher suite and direct CLI/persisted-state checks; an initial zsh-only evidence-wrapper variable error was corrected and rerun, all targeted checks passed, the headless behavior transcript was captured, and the worktree remained clean.
Evidence: End-to-end wedge behavior transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-supervise-daemon.sh:1024- The required contract says, “Escalating restarts the idle clock, so a still-working-looking frozen pane repeats at roughly the allowance.” Away mode instead callsstale_marker_removeafter its first escalation. Because the wrapped watcher emits only once per unchanged hash, no new daemon marker is created and the pane is never escalated again. Restart the daemon-owned stale clock here, clear only its verification marker, and update the ceiling test to assert a second escalation on the unchanged pane.🔧 Fix: Clarify away-mode stale escalation contract
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-watch-triage.test.shbash tests/fm-daemon.test.shProductionbin/fm-watch.shagainst controlled 916-second healthy, stopped-worker, 4000-second ceiling, and disabled-deferral fixturesSourcedbin/fm-supervise-daemon.shhousekeeping against healthy and stopped 916-second away-mode fixturesgit show --stat --oneline 6e9b923and its focused test diffgit status --short --branchandgit rev-parse HEAD✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.