Repository navigation
fix(watch): bound stale alarms for delivered work whose merge poll is armed - #4449
Open
simonasposka wants to merge 1 commit into
Open
simonasposka wants to merge 1 commit into
simonasposka wants to merge 1 commit into
Conversation
… 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.
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.
The defect
A task whose last status line is
done: PR ...reachedbin/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-entitlementon 2026-08-17 andsubs-bulk-zero-delivery-priceon 2026-09-14, bothdone: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_boundbounds that repetition on the sharedFM_PAUSE_RESURFACE_SECScadence, 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
doneverb qualifies.A
blocked:orneeds-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 throughfm_pr_poll_artifacts_validrather 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_boundresolves the two bounds in one place so that only the matching bound's declaration survives inSTALE_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_stalealready reads the throttle before queueing anything, andtest_live_declared_wait_churn_honors_the_resurface_throttlealready pins it for bothpaused:andcaptain-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 realfm-watch.shsubprocess and arming the poll throughbin/fm-pr-check.shfor real rather than hand-writing a sidecar:test_armed_merge_poll_bounds_delivered_stale_churnpins 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_alarmspins the negative space: an unarmed delivery, an armedblocked:, and an armedneeds-decision:all keep alarming on every new hash.tests/fm-watch-triage.test.shpasses in full, as dofm-pr-check-security,fm-watch-arm,fm-watcher-lock, andfm-watch-recovery-loop.bin/fm-lint.shandbin/fm-doc-audience-check.share clean.Unrelated pre-existing failure
tests/fm-wake-queue.test.shfails onthe oversized unread status line was truncated or omittedwithgrep: out of memory.Verified it fails identically on pristine
036fec05with this branch stashed, so it is pre-existing and environmental, not from this change.🤖 Generated with Claude Code