Skip to content

fix(bin): keep a live agent's declared pause on the bounded recheck cadence - #31

Merged
alandomio merged 3 commits into
mainfrom
fm/watch-paused-reflagged-as-stale
Sep 17, 2026
Merged

alandomio merged 3 commits into
mainfrom
fm/watch-paused-reflagged-as-stale

Conversation

@alandomio

@alandomio alandomio commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

Fixes the watcher's pause classifier in bin/fm-watch.sh so a still-alive worker's declared paused: status stays on the bounded long-cadence recheck even while its pane content changes on every poll (a ticking status-line clock, a live token counter). Previously, once the classifier's one-time "just surfaced" state expired, a live agent's declared pause fell back to an unclassified verdict on every hash change, so the stale-pane path bare-surfaced it again and again.

Why it matters: a worker genuinely waiting on an external dependency (an upstream release, a rate-limit reset) was getting flagged with an undecorated "stale" wake every few minutes instead of the intended once-per-cadence recheck - indistinguishable from a real wedge, and noisy enough to train the reader to ignore it.

Root cause: pause_state_class treated a live agent's aliveness as proof its declared pause needed re-confirming, and reset that confirmation to "unclassified" on every check regardless of whether the pause had already been recorded once. A pane whose last lines change on most polls (any live TUI footer) hits that reset constantly, so it never settled into the long recheck cadence a dead agent's or a secondmate's pause already used. Two fix shapes were possible: normalize the pane hash to ignore the footer, or fix the classifier. Hash normalization alone would not have been enough - the classifier would still discard its "already paused" state on the next occasion the hash happened to repeat across two polls, which is also part of the originally reported pattern. This MR takes the classifier-gate fix: liveness now only gates the first sighting of a declared pause (no prior record for that window); once recorded, only positive evidence that the crew resumed work lifts it. Dead agents and secondmates already worked this way - this brings a live agent's pause in line with them.

This is a self-contained classifier change: no config knobs added, no cadence defaults changed, and behavior for a dead agent, an actively-working run-step, and an undeclared idle pane is unchanged (pinned by existing tests).

Change
File Change
bin/fm-watch.sh pause_state_class: liveness no longer forces the pause to reset once a window has already recorded one; only the crew being provably back at work lifts it
tests/fm-watch-triage.test.sh New regression test driving a live agent through a churning pane hash across two recheck cadences, asserting only decorated rechecks and zero bare wakes
docs/architecture.md Updates the pause/captain-held cadence contract to describe the post-first-surface behavior
Validation
  • Reproduced the bug directly against the pre-fix classifier: a live agent with an already-recorded pause and a pane hash that changes every poll produced a bare stale: <window> wake; the same scenario against the fix produced only the decorated recheck wording, bounded to the cadence.
  • New test fails against the pre-fix classifier and passes against the fix (verified both ways).
  • Full tests/fm-watch-triage.test.sh suite green, including the pre-existing cases for a dead agent's pause, an actively-working run-step, and an undeclared idle pane.
  • bin/fm-lint.sh clean.
  • CI: all 13 required checks passing on this PR.
Follow-ups / out of scope
  • The bounded-cadence wording and the PAUSE_RESURFACE_SECS/STALE_ESCALATE_SECS defaults are unchanged by design; this is a classifier correctness fix, not a retuning.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ⚠️ tests/fm-watch-triage.test.sh:1163 - Intent criterion 4 requires 'Comments in changed code: max 3 lines each'. Two comments in the diff exceed it: the new test's header comment at tests/fm-watch-triage.test.sh:1163-1171 is 9 lines (a root-cause narrative that belongs in the PR description), and the modified pause_state_class header comment at bin/fm-watch.sh:489-492 is 4 lines. The remedy is trimming comment text only, but since it is a stated required criterion and the author chose this wording deliberately, flagging for confirmation rather than editing prose silently.
  • ℹ️ bin/fm-watch.sh:508 - The new comment at bin/fm-watch.sh:507-509 says 'only crew_absorb_class=working lifts the pause', but the fast path immediately below (known_paused=1 and .paused-rechecked younger than STALE_ESCALATE_SECS) returns paused without consulting crew_absorb_class at all. Concretely: a live crew already known-paused whose run-step starts working while its log still ends in paused: is reported paused for up to STALE_ESCALATE_SECS (240s default) after each recheck stamp before the caller at bin/fm-watch.sh:1244 can switch it to the wedge timer. This is the same bounded delay a dead crew or secondmate already had and is not a regression on the incident path, but the comment should say 'once per STALE_ESCALATE_SECS' rather than implying an unconditional check.

🔧 Fix: trim pause classifier comments to 3 lines, fix cadence wording
1 info still open:

  • ℹ️ bin/fm-watch.sh:521 - The new known_paused -eq 0 guard treats any existing .paused-<key> as proof the window already took its one-time live-agent surface, but handle_paused_stale also primes that flag from the busy-pane path (busy_turn_bound_check at line 470, for a paused: crew whose busy pane crossed BUSY_TURN_MAX_SECS). Concrete trace: live crew declares paused:, pane stays busy past the bound -> .paused-<key> written with no surface; agent finishes the call and the pane goes idle-stable -> pause_state_class now returns paused (liveness never read) instead of the pre-fix none bare surface. The captain still gets the decorated recheck on the PAUSE_RESURFACE_SECS cadence anchored on status mtime, so nothing rots invisibly and no wedge is silenced (a declared pause was already exempt from wedge escalation). Noting the tradeoff only; it is consistent with the intent's 'liveness gates the first sight (no .paused-<key> yet)' definition and needs no change.
✅ **Test** - passed

✅ No issues found.

  • test_nonterminal_stale_paused_live_churning_hash_uses_bounded_cadence (new test) on target 18c59cc: pass
  • test_nonterminal_stale_paused_live_churning_hash_uses_bounded_cadence run against a git archive of base c0974ec's bin/fm-watch.sh: fails (round 1 (churning hash) never rechecked the declared pause - base silently clears the pause marker instead of rechecking)
  • Existing pins on target: test_exited_declared_pause_is_bounded_but_live_gate_surfaces, test_nonterminal_stale_paused_absorbed_then_resurfaced, test_nonterminal_stale_not_working_surfaced, test_paused_authoritative_working_preserves_wedge_timer, test_busy_declared_pause_is_rechecked_not_wedge_escalated, test_nonterminal_paused_rechecks_authoritative_state, test_secondmate_paused_resurfaces_in_normal_mode, test_secondmate_nonpaused_stale_remains_suppressed, test_afk_paused_changed_pane_hands_off_plain_stale: all pass
  • Manual incident repro: real fm-watch.sh subprocess with fake tmux whose pane footer ticks every 4 polls, live claude pane command, paused: status, pre-seeded .paused-&lt;key&gt;; base wakes with bare stale: test:fm-churn, target wakes with the decorated paused Ns, awaiting external - declared pause, rechecked on a long cadence not a wedge; confirm the wait still holds reason (wording unchanged), verified in both stdout and the durable wake queue via fm-wake-drain.sh
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Alan Domio and others added 3 commits September 14, 2026 14:18
…adence

pause_state_class forced `none` whenever an ordinary crew's agent was
alive, even after .paused-<key> already proved this window took its
one-time live-agent surface. A ticking harness footer changes the raw
pane hash on most polls, so once the fast-path recheck window expired
the classifier fell back to `none` again, and the stale path bare-
surfaces that verdict and re-primes .paused-<key> for the very next
churn cycle - repeating forever. Liveness now only gates the FIRST
sight of a declared pause; once known-paused, only crew_absorb_class
returning `working` lifts it, matching the dead-agent and secondmate
cases that already used the bounded PAUSE_RESURFACE_SECS cadence.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@alandomio
alandomio merged commit 21c3d3f into main Sep 17, 2026
14 of 15 checks passed
alandomio added a commit that referenced this pull request Sep 26, 2026
…hourly (#37)

* fix(bin): stop re-surfacing a declared pause whose situation has not changed

A declared pause re-surfaced "confirm the wait still holds" every
FM_PAUSE_RESURFACE_SECS forever, although nothing about the worker had
changed, and a busy turn on a paused worker re-fired its one-time
live-agent surface for the same pause line.

The watcher now records the pause's situation at each surface - the
status log's size:mtime, the agent's liveness (never read for a
secondmate), and a digest of the pane tail with digits and blanks
removed - and compares it at each due recheck. An unchanged situation is
absorbed into the triage log until FM_PAUSE_REMIND_SECS (default one
day) has passed since the last surface; an exited agent, new pane text
such as a dialog, or a new status line surfaces at that recheck with the
change named. The same pause line no longer takes a second one-time
surface after a busy turn. #31's guarantee is kept: a live agent's
declared pause never falls back to wedge detection.

* no-mistakes(review): Keep surfacing dead paused workers on every recheck

* no-mistakes(document): Align architecture wake inventory with absorbed pause rechecks

---------

Co-authored-by: Alan Domio <[email protected]>
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