Skip to content

fix(watch): bound stale alarms for delivered work whose merge poll is armed - #4449

Open
simonasposka wants to merge 1 commit into
kunchenguid:mainfrom
simonasposka:fm/fm-paused-stale-unthrottled-r2
Open

simonasposka wants to merge 1 commit into
kunchenguid:mainfrom
simonasposka:fm/fm-paused-stale-unthrottled-r2

Conversation

@simonasposka

Copy link
Copy Markdown

The defect

A task whose last status line is done: PR ... reached bin/fm-watch.sh's captain-relevant stale branch with nothing to bound it.
It is not provably working, because its worker has exited, and it is not captain-held unless the backlog happened to record a hold.
So every new pane hash on that idle, finished pane alarmed, which on the observed one-minute poll cadence is one supervision turn a minute for as long as the PR stays open.

Reproduced live twice: subs-gift-per-customer-entitlement on 2026-08-17 and subs-bulk-zero-delivery-price on 2026-09-14, both done: with an open PR and the merge poll armed, and firstmate holding nothing to do on either wake.

Nothing was watching that pane for a reason: the task's own armed PR merge poll is what is watching the PR, so a new hash on a finished pane had nothing to add.

The fix

merge_poll_stale_bound bounds that repetition on the shared FM_PAUSE_RESURFACE_SECS cadence, the same one an open captain call already takes.

The bound is deliberately a cadence and not an absolute silence.
The poll speaks only on a merge and is silent on every other outcome, including every error, so a PR closed unmerged, or one that simply sits, must not leave a finished task silent forever.
A merge retires the poll, which invalidates the artifacts and lifts the bound outright.

Only the done verb qualifies.
A blocked: or needs-decision: delivery needs firstmate whatever its PR is doing, and an unarmed delivery has nothing watching it, so both keep alarming on every new hash exactly as before.
Genuine wedge detection is untouched: a stuck worker writes no done: line, and an armed poll is validated through fm_pr_poll_artifacts_valid rather than inferred from metadata.

The throttle is scoped to the poll's own canonical PR beside the status-log signature, so a replacement PR armed for the same task starts its own window instead of inheriting the silence of the one before it.

terminal_stale_bound resolves the two bounds in one place so that only the matching bound's declaration survives in STALE_WAIT_DECLARATION.
A bound that matched but is due to alarm must keep its own scope for stale_wait_record; asking the next bound in turn would overwrite that scope with its own empty result, the alarm would record nothing, and the very next hash would alarm again.

The sibling defect was already fixed

The report also named an unthrottled hash-changed path for a declared pause with a live agent.
That one landed upstream before this branch: surface_nonterminal_stale already reads the throttle before queueing anything, and test_live_declared_wait_churn_honors_the_resurface_throttle already pins it for both paused: and captain-held:.
That test passes unchanged here, so the requested regression for that half is covered rather than duplicated.

Tests

Two new regressions in tests/fm-watch-triage.test.sh, driving a real fm-watch.sh subprocess and arming the poll through bin/fm-pr-check.sh for real rather than hand-writing a sidecar:

  • test_armed_merge_poll_bounds_delivered_stale_churn pins all three directions: the first sight still alarms, pane churn under the same delivery and armed poll is absorbed, and the elapsed window re-surfaces exactly once.
  • test_stale_churn_without_an_armed_merge_poll_still_alarms pins the negative space: an unarmed delivery, an armed blocked:, and an armed needs-decision: all keep alarming on every new hash.

tests/fm-watch-triage.test.sh passes in full, as do fm-pr-check-security, fm-watch-arm, fm-watcher-lock, and fm-watch-recovery-loop.
bin/fm-lint.sh and bin/fm-doc-audience-check.sh are clean.

Unrelated pre-existing failure

tests/fm-wake-queue.test.sh fails on the oversized unread status line was truncated or omitted with grep: out of memory.
Verified it fails identically on pristine 036fec05 with this branch stashed, so it is pre-existing and environmental, not from this change.

🤖 Generated with Claude Code

… armed

A task whose last status line is `done: PR ...` reached the captain-relevant
stale branch with nothing to bound it: not provably working (its worker has
exited), and not captain-held unless the backlog happened to record a hold. Every
new pane hash on that idle pane therefore alarmed, which on the observed
one-minute poll cadence is one supervision turn a minute for as long as the PR
stays open.

Nothing was watching that pane for a reason. The task's own armed PR merge poll
is what is watching the PR, so a new hash on a finished pane had nothing to add.

Bound that repetition on the shared FM_PAUSE_RESURFACE_SECS cadence, the same one
an open captain call already takes. The bound is deliberately a cadence and not an
absolute silence, because the poll speaks only on a merge and is silent on every
other outcome, including errors: a PR closed unmerged, or one that simply sits,
must not leave a finished task silent forever. A merge retires the poll, which
invalidates the artifacts and lifts the bound outright.

Only the `done` verb qualifies. A `blocked:` or `needs-decision:` delivery needs
firstmate whatever its PR is doing, and an unarmed delivery has nothing watching
it, so both keep alarming on every new hash exactly as before. Genuine wedge
detection is untouched: a stuck worker writes no `done:` line.

The throttle is scoped to the poll's own canonical PR beside the status-log
signature, so a replacement PR armed for the same task starts its own window
rather than inheriting the silence of the one before it. terminal_stale_bound
resolves the two bounds in one place so only the matching bound's declaration
survives in STALE_WAIT_DECLARATION - a bound that matched but is due to alarm
must keep its own scope for stale_wait_record, or the alarm would record nothing
and the very next hash would alarm again.

The sibling defect in this report, an unthrottled hash-changed path for a
declared pause with a live agent, was already fixed upstream and is pinned by
test_live_declared_wait_churn_honors_the_resurface_throttle; that test passes
unchanged here.
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