Repository navigation
fix(watcher): bound the pause resurface cadence for a live paused crew - #2539
Open
silveiraandre91 wants to merge 1 commit into
Open
silveiraandre91 wants to merge 1 commit into
silveiraandre91 wants to merge 1 commit into
Conversation
pause_state_class() demoted an already-paused verdict back to "none" whenever the underlying agent process was alive - but a live agent is the NORMAL case for a declared paused: status (AGENTS.md's contract is a live crew deliberately idling on a known external wait). Each freshly-stabilized pane hash (e.g. a churny retry counter) then fell through to the cadence-blind immediate-surface path instead of the bounded PAUSE_RESURFACE_SECS recheck, flooding the supervising session with a stale: wake roughly every poll instead of once per multi-hour window (live 2026-08 incident: iutubi-reprocessar-lote-18-07). Liveness now only PROMOTES an authoritative "none" verdict to paused (a captain-held/paused endpoint with no paused verdict of its own, confirmed dead), never demotes an already-paused one. Updates the matching docs/architecture.md paragraph and the existing "alive decision gate" test to the corrected behavior, and adds a regression test that churns a paused pane's content across several poll cycles and asserts the resurface wake never fires faster than PAUSE_RESURFACE_SECS.
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
The developer needed a bug fixed in bin/fm-watch.sh: a genuinely alive, actively-retrying crewmate that declared itself "paused" was firing stale wake notifications every 60-125 seconds instead of respecting the configured FM_PAUSE_RESURFACE_SECS cadence (multi-hour), spamming the supervising session. They wanted the root cause identified (suspected to be pause_state_class/clear_pause_tracking interaction deleting the throttle marker) and a proper fix applied at the code level, explicitly excluding the unrelated wedge-escalation path (STALE_ESCALATE_SECS/wedge_timer_check) from scope. They required new or extended test coverage in tests/ simulating a paused, alive, churny-pane window across multiple poll cycles to assert the resurface wake doesn't fire faster than the configured interval, following existing watcher test patterns. The change needed to be committed and validated through the no-mistakes pipeline (review, tests, lint, docs) before being pushed as a PR, with the developer restarting a stalled shared daemon and expecting eventual resolution of a push-permission error to complete delivery.
What Changed
bin/fm-watch.shso a live, actively-retrying crewmate that has declared itself "paused" no longer fires a stale wake on every pane-hash churn; wakes for paused-but-alive crews are now throttled to the configuredFM_PAUSE_RESURFACE_SECScadence instead of the 60-125s poll interval.tests/fm-watch-triage.test.shwith coverage simulating a paused, alive, churny-pane window across multiple poll cycles, asserting zero wakes while fresh and exactly one bounded resurface wake once the cadence elapses, plus a case for a live external-decision-gate pause that is absorbed on first sight and resurfaces exactly once on the bounded cadence.docs/architecture.mdto reflect the corrected pause resurface behavior.Risk Assessment
✅ Low: The fix is narrowly scoped to pause_state_class in bin/fm-watch.sh: it removes the liveness-based demotion of an already-paused verdict (the actual root cause of the churn-driven wake spam) and only promotes a "none" verdict to paused when the agent is confirmed dead, matching the documented AGENTS.md paused: contract; docs/architecture.md was updated to match, and a new test reproduces the exact churny-pane incident shape across multiple poll cycles plus verifies the resurface throttle survives a fresh watcher launch, alongside updated coverage for the pre-existing live-gate and exited-pause cases.
Testing
Ran the full tests/fm-watch-triage.test.sh suite (the smallest relevant scope covering bin/fm-watch.sh's pause_state_class/clear_pause_tracking logic); all 44 cases passed with exit code 0, including the two tests that directly exercise the reported bug — a live churny paused pane no longer fires stale wake notifications faster than the configured FM_PAUSE_RESURFACE_SECS cadence, and it no longer resurfaces immediately just because the underlying agent is alive. The working tree is clean, so no transient artifacts needed cleanup.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-watch-triage.test.sh (full file, exit code 0)test_nonterminal_stale_paused_churny_pane_bounded_cadence — asserts a live, actively-retrying paused crew across multiple poll cycles produces zero wakes while fresh and exactly one bounded resurface wake once FM_PAUSE_RESURFACE_SECS elapses, not a wake per pane-hash churntest_exited_declared_pause_is_bounded_but_live_gate_surfaces — asserts a live external-decision-gate pause is absorbed on first sight and resurfaces exactly once on the bounded cadence rather than surfacing immediately✅ **Document** - passed
✅ No issues found.
⏭️ **Lint** - skipped
✅ **Push** - passed
✅ No issues found.