This repository was archived by the owner on Oct 20, 2026. It is now read-only.
Repository navigation
fix(watcher): stop per-poll stale runaway on a finished-and-parked crew - #1
Merged
Merged
Conversation
A crew that finished its pipeline (authoritative state done, e.g. a PR raised and monitoring for merge/close) and then appended a `paused: awaiting-decision` last line re-surfaced a stale wake on every poll. The suppressor-equal paused-last-line branch re-classified via pause_state_class, whose `none` verdict (crew_absorb_class maps done -> none) fell through to surface_nonterminal_stale with no cadence gate; surface then deleted the pause/wedge markers, so nothing could ever throttle it. Each wake exits the watcher and it re-arms, so a done and parked pane burned a supervisor turn every 20-30s. Add crew_reached_terminal (done or parked) and, on the already-surfaced (suppressor-equal) hash, route a terminal crew to handle_paused_stale for a long pause-cadence recheck while a genuinely stopped or unknown crew keeps surfacing. The first-sight arm is untouched, so the finish is still surfaced once; provably-working (kunchenguid#233) and declared-pause (kunchenguid#421) crews are unaffected. Regression tests cover the five cases in tests/fm-watch-triage.test.sh.
The terminal -> long-cadence recheck route never wrote the .paused-rechecked-<key> marker, so pause_state_class's zero-read fast path never engaged and every poll re-ran two authoritative fm-crew-state.sh reads (crew_absorb_class + crew_reached_terminal) for the crew's entire parked lifetime. Record the marker when the terminal route absorbs, restoring the first-sight-only read invariant; the read re-verifies on the existing STALE_ESCALATE_SECS cadence. Adds a call-counting regression test proving the read does not repeat per poll.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
The always-on supervision watcher entered a runaway false-alarm loop for a crew that had finished its pipeline but was parked awaiting a captain decision. Once such a crew reached authoritative state
done(for example, a PR raised and being monitored for merge/close) and appended apaused: awaiting-captain-decisionas its last status line, the watcher re-appended astale:wake on every poll (roughly every 15-30s), burning a full supervisor turn each time, for the crew's entire parked life.Root cause
In
bin/fm-watch.sh's stale poll loop, the suppressor-equal (already-surfaced hash) branch re-classifies a paused-last-line pane viapause_state_class. For adone/parkedcrew,crew_absorb_classreturnsnone, which fell through tosurface_nonterminal_stalewith no cadence gate.surface_nonterminal_stalealso deletes the pause/wedge markers, so neither the wedge timer nor the pause-recheck throttle could ever engage - the loop re-entered the samenone -> surfacepath every poll. The per-hash suppressor (.stale-<key>equal to the current hash) never suppressed, because the paused-last-line branch bypassed it.The fault is exposed only by a
done-and-parked crew in normal (non-away) supervision: an actively-workingcrew is absorbed on the working arm, a genuinelypausedcrew on the long pause cadence, and away mode uses a one-shot-per-hash branch.Fix
crew_reached_terminalinbin/fm-classify-lib.sh, true only for authoritative statedoneorparked. This is deliberately narrower thancrew_absorb_class'snone, which also covers failed/unknown/torn-down crews that carry no positive terminal confirmation.handle_paused_stale(re-check on the longFM_PAUSE_RESURFACE_SECScadence, since it was already surfaced once), while a genuinely stopped or unknown crew keeps surfacing viasurface_nonterminal_stale..paused-rechecked-<key>marker sopause_state_class's fast path absorbs subsequent polls without re-reading the authoritative crew state every poll - the costly read runs only on first sight perFM_STALE_ESCALATE_SECSwindow, honoring the classifier's stated invariant.Tests
Six regression cases in
tests/fm-watch-triage.test.sh, driving the realfm-watch.shpoll loop through the existing harness:Docs
docs/architecture.mdanddocs/configuration.mddescribe the new terminal-parked recheck behavior. Note: the pipeline's documentation step also added a couple of lines documenting the pre-existingFM_SPAWN_WORKTREE_POLL_TRIESknob (indocs/configuration.mdanddocs/herdr-backend.md); that knob landed earlier and was undocumented, so this only fills that gap - it is not part of the watcher change.Validation
Validated end-to-end through the local no-mistakes pipeline on a quiet machine: review, tests (full suite, 0 findings), document, and lint all passed. This fork runs no GitHub CI, so the local pipeline is the validation gate.