Skip to content

fix(watcher): bound the pause resurface cadence for a live paused crew - #2539

Open
silveiraandre91 wants to merge 1 commit into
kunchenguid:mainfrom
silveiraandre91:fm/watcher-stale-pause-cadence
Open

silveiraandre91 wants to merge 1 commit into
kunchenguid:mainfrom
silveiraandre91:fm/watcher-stale-pause-cadence

Conversation

@silveiraandre91

Copy link
Copy Markdown

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

  • Fixed bin/fm-watch.sh so 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 configured FM_PAUSE_RESURFACE_SECS cadence instead of the 60-125s poll interval.
  • Extended tests/fm-watch-triage.test.sh with 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.
  • Updated docs/architecture.md to 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 churn
  • test_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
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant