Repository navigation
Conversation
…ng to present A Cursor primary re-arms a watcher cycle at every turn end, and the fresh cycle reads the gap since the previous close as downtime. The pending recovery marker then said recover and resurface_after_downtime woke firstmate with check: rearm-resurface unconditionally, so the handling turn drained an empty queue (--ack-through 0) and did nothing. Five of those landed between 10:44 and 12:08 on 2026-09-02 alone. The generation is still consumed exactly as before (pending -> announced, same token grammar, same acknowledgement), but the wake is now gated on presentable work: an unacknowledged durable queue row, a still-open decision in a status log (the buried-decision case the recovery contract exists for), or a reclaimed stale lock from a watcher that died without cleanup. With none of those the cycle logs one "absorbed rearm-resurface" triage line and keeps supervising. bin/fm-watch-arm.sh hands the reused-pid clear to its child through FM_WATCH_LOCK_RECLAIMED so both stale-lock reclaim paths still announce. Tests: test_rearm_resurface_absorbed_when_nothing_to_present, test_rearm_resurface_delivered_for_queued_row, test_rearm_resurface_delivered_for_open_decision (tests/fm-watch-triage.test.sh); the malformed-marker arm test now seeds a durable row so its quarantine assertion still has a wake to observe.
A direct-PR worker opens its PR, appends "done: PR <url>", and idles waiting for review. Its TUI re-renders the idle footer now and then, so every new pane hash re-ran the terminal stale path and woke firstmate with another "stale: <window>" for the same finished worker: repeatedly all day on 2026-09-01 on one finished worker, and again at 11:42 on 2026-09-02 on another. The done: event already surfaced through the signal path and the PR poll owns the merge outcome, so that idle pane is an expected wait, not a wedge. When the last status event is a terminal done: (status_is_done, owned by bin/fm-classify-lib.sh) and the pane is idle, the stale path now takes the same bounded cadence as a declared paused: wait: absorbed on first sight, rechecked once per PAUSE_RESURFACE_SECS with a merge-authority wording, never fed to the wedge timer, and its pause bookkeeping survives a re-rendered idle footer. A new hash still lets an actively running run-step override the log exactly as the terminal path does, so a frozen validation started after the done: line keeps its wedge escalation. A done: worker whose pane is busy again, and every other terminal verb (needs-decision, blocked, failed) plus a working: line followed by silence, keep today's behaviour unchanged. Tests: test_done_idle_stale_takes_pause_cadence, test_working_idle_stale_still_wedge_escalates, test_done_busy_pane_keeps_turn_bound_escalation (tests/fm-watch-triage.test.sh). Two existing fixtures that relied on a done: line reaching the plain terminal surface now use blocked:, which keeps the path they exercise.
Confidence Score: 4/5The PR should not merge until the done-idle exemption is constrained to states that are genuinely awaiting a PR merge outcome. The verb-only branch suppresses ordinary stale supervision for local-only completion and the no-mistakes pre-validation handoff even though neither state has the PR poll assumed by the new behavior. Files Needing Attention: bin/fm-watch.sh, bin/fm-classify-lib.sh Reviews (1): Last reviewed commit: "fix(watch): give a done: worker's idle p..." | Re-trigger Greptile |
| printf '%s' "$h" > "$sf" | ||
| wake "stale: $w" | ||
| fi | ||
| elif status_is_done "$last"; then |
There was a problem hiding this comment.
Done exemption hides non-PR work
When a local-only worker writes done: ready in branch ... or a no-mistakes worker writes its preliminary done:, the verb-only branch moves its idle pane onto the long merge-wait cadence even though no PR poll owns that state. This suppresses ordinary stale and wedge handling until the long recheck and reports the misleading claim that a PR poll owns the outcome.
Knowledge Base Used:
Two small watcher fixes that remove two classes of pointless wake-ups, one commit each with its colocated tests.
Problem 1: empty
check: rearm-resurfacewakesObserved. On a Cursor primary every turn end re-arms a watcher cycle. The fresh cycle reads the gap since the previous clean close as downtime, the recovery marker says
recover, andresurface_after_downtimefiredwake "check: rearm-resurface"unconditionally. The handling turn then drained an empty queue (the drain printed--ack-through 0) and did nothing. The home's delivery log records nine of these between 10:44 and 12:08 on 2026-09-02 (10:44, 11:12, 11:12, 11:16, 11:57, 11:57, 11:59, 12:03, 12:08), at least five of which the handling turn drained as--ack-through 0, and ten more on 2026-09-01.Change (
bin/fm-watch.sh,bin/fm-watch-arm.sh,docs/watcher-continuity.md). The recovery marker is consumed exactly as before (pending:downtimetoannounced:downtime, same token grammar, same generation-bound acknowledgement, samerelease-lock/release-lock-existingcleanup). Only the wake is now gated on the drain having something to present:scan_open_decisions, the pure whole-file fold owned bybin/fm-classify-lib.sh, so the watcher never advances the drain's incremental cursors) - this is the buried-decision case the recovery episode contract indocs/watcher-continuity.mdalready names and the existingtest_rearm_resurfaces_durable_queue_and_remote_open_decisionalready requires, orFM_LOCK_RECOVERED_PIDfrom the lock library, orFM_WATCH_LOCK_RECLAIMED=1whichbin/fm-watch-arm.sh --restartnow hands to the child it starts after clearing a reused-pid lock, so both stale-lock reclaim paths keep announcing as the existing arm and lock tests assert).With none of those, the cycle writes one triage line,
absorbed rearm-resurface (queue empty, no open decisions), clears its in-process pending flag, and keeps supervising. A later append in that cycle reuses the announced generation and its drain acknowledges it, so no marker is left dangling; the next non-successor arm mints a fresh generation exactly as today.Guardrails preserved. No change to the marker state machine, token grammar, or ack/generation format. A queue with records always wakes. Handling successors still never re-announce.
UNREAD STATUSnotes are deliberately not part of the gate: they are not in thefm_recovery_*contract, and a status append during downtime is caught by the signal scan on the next cycle anyway.Tests (
tests/fm-watch-triage.test.sh):test_rearm_resurface_absorbed_when_nothing_to_present- empty queue +pending:downtimemarker: no wake across two full polls, no queue row, marker consumed toannounced:downtime:<same generation>, exactly one triage line.test_rearm_resurface_delivered_for_queued_row- one unacknowledged row + the same marker:check: rearm-resurfacedelivered, generation kept announced, row drained.test_rearm_resurface_delivered_for_open_decision- empty queue but a still-openneeds-decision [key=...]: wake still delivered.tests/fm-watch-arm.test.shtest_malformed_marker_is_quarantined_oncenow seeds one durable row, because a quarantined marker over an empty queue is now absorbed; its quarantine-exactly-once and no-loop assertions are unchanged.Problem 2: a worker that reported
done: PR <url>is waiting, not staleObserved. A
direct-PRship worker opened its PR, appendeddone: PR https://..., and idled for review. Its TUI re-rendered its idle footer now and then, so every new pane hash re-ran the terminal stale path and woke firstmate with anotherstale: <window>for the same finished worker. The home's delivery log shows this repeating on one finished worker's pane on 2026-08-31 (12:51, 13:56, 17:39) and 2026-09-01 (09:32, 09:54), and again at 11:42 on 2026-09-02 on another; the same log shows each reason was a plainstale: <window>re-surface on a new hash rather than a wedge escalation. Both workers'state/<id>.metarecordedpr=(corroborating, not required).Change (
bin/fm-watch.sh,bin/fm-classify-lib.sh).status_is_doneis a new verb predicate inbin/fm-classify-lib.sh, next tostatus_is_terminal_verb; the watcher uses it rather than re-parsing the log. When a task's last status event is a terminaldone:and its pane is idle (two identical hashes, no busy verdict), the stale path now classifies it like a declaredpaused:wait through the existinghandle_paused_stale: absorbed on first sight, rechecked once perPAUSE_RESURFACE_SECSwith a new wording (done <age>s, awaiting merge authority - ... the PR poll owns the merge outcome), never fed to the wedge timer. The pause bookkeeping (.paused-*, the re-surface throttle) now also survives a re-rendered idle footer, which is what made the noise repeat. Mirroring the terminal path, a NEW hash still lets an actively running run-step override the log and keep the wedge timer (crew_is_provably_working), so a frozen validation firstmate started after thedone:line still escalates, astest_stale_terminal_status_overridden_by_active_runcontinues to assert.Guardrails preserved. Anything that is not a terminal
done:keeps today's stale behaviour exactly:working:followed by silence surfaces at once and wedge-escalates pastSTALE_ESCALATE_SECS;needs-decision:,blocked:, andfailed:keep the immediate terminal surface. Adone:worker whose pane is busy again never reaches the exemption: the busy path,busy_turn_bound_check, and itsstatus_is_paused_or_captain_heldgate are untouched, and a busy pane still clears the pause bookkeeping. Secondmate and away-mode branches run before the new branch and are unchanged.Tests (
tests/fm-watch-triage.test.sh):test_done_idle_stale_takes_pause_cadence- done + idle with a 1s wedge threshold across several polls: no wake, no wedge timer, pause flag recorded; a re-rendered footer (new hash) stays silent; past the long cadence one recheck wordedawaiting merge authority, neverpossible wedge.test_working_idle_stale_still_wedge_escalates-working:+ idle: immediatestale: <window>, thenpossible wedgepast the threshold, no pause flag.test_done_busy_pane_keeps_turn_bound_escalation- done + busy pane pastBUSY_TURN_MAX_SECS: wedge timer starts and escalates as today, no pause flag.test_terminal_stale_surfaced,test_terminal_first_sight_drops_a_finished_write_deferral_chain) used adone:line to reach the plain terminal surface; they now useblocked:, which keeps the path they exercise.Docs
One sentence each at the single owner: the recovery-wake rule in
docs/watcher-continuity.md"Recovery episode acknowledgement", and the done + idle rule in thestale:reason description of thebin/fm-watch.shheader.AGENTS.mdand skills untouched (the guidelines' placement tree puts both rules at the mechanism owner).Maintainer verification (2026-09-02, macOS, stock
/bin/bash3.2.57(1)-release)Every test below ran under stock bash 3.2.57, which is the only
bashon the machine, so the whole run doubles as the 3.2 proof.bin/fm-lint.shpinned ShellCheck 0.11.0 (fm-lint.sh: ShellCheck 0.11.0 (pinned 0.11.0), full extended analysis).The 16
--allfailures were re-run against a pristinegit archive origin/maincopy in the same environment: 15 fail identically there (fm-wake-queuerelies onBASHPID, which bash 3.2 lacks;fm-lint-workflowsandfm-lintneedactionlint;fm-cursor-harness,fm-composer-lib,fm-muse-harness,fm-extension-binding,fm-gotmp,fm-on,fm-pending-reply,fm-public-followup,fm-teardown, the two remote-secondmate suites and the Herdr presentation e2e are host-environment failures unrelated to the watcher). The sixteenth,fm-bootstrap-network-parallel, passed onorigin/mainand passes on this branch when run alone (exit=0 duration_ms=13870); it failed only under the full-suite load and touches no file this PR changes. Every watcher-related suite (fm-watch-triage,fm-watch-arm,fm-watcher-lock,fm-watch-recovery-loop,fm-watch-checkpoint,fm-pr-check-security, thefm-wake-drain-*suites) passed on this branch. Tests were run against temporaryFM_STATE_OVERRIDEdirectories only; no watcher was run against a live home.Note for reviewers: the tests ran with Cursor's own
CURSOR_AGENTenvironment variables unset, because the harness-detection fixtures (fm-watcher-lock's guard banner test) otherwise read the test runner's host as a Cursor primary.