Skip to content

fix(bin): keep a declared external wait from re-arming the stale alarm (#3942) - #3978

Closed
scfconnect wants to merge 2 commits into
kunchenguid:mainfrom
scfconnect:fm/fm-paused-stale-suppress-r1
Closed

scfconnect wants to merge 2 commits into
kunchenguid:mainfrom
scfconnect:fm/fm-paused-stale-suppress-r1

Conversation

@scfconnect

Copy link
Copy Markdown

Fixes #3942.

What was wrong

paused: is documented as a bounded external wait that must not be treated as a possible wedge, and the suppression path for it already existed. The defect was not a missing check: the path was being erased underneath itself.

A declared wait records a re-surface throttle, .paused-resurfaced-<key>, which is scoped to the DECLARATION rather than to the pane. Two branches of the staleness loop called clear_pause_tracking whenever a poll found the pane busy, and that deletes the throttle. A worker parked on a declared wait still renders its harness busy signature whenever it does anything at all, such as taking a steer or reacting to its background job, so one such poll handed the unchanged declaration a fresh window. The next idle sighting then read the absent throttle as a first sight and alarmed again, far inside FM_PAUSE_RESURFACE_SECS. Every blip cost one more stale: wake, which is how an operator ends up being told the work is paused while being paged that it is stuck.

Review of the first commit found the same defect reachable by a second, narrower route. bin/fm-crew-state.sh emits state: working source: pane before its paused: status-log fallback, and it takes its own pane capture a moment after the staleness loop already read that same pane idle. A parked worker that blips between those two captures therefore arrives as a working verdict, and the three sibling working arms retired the same throttle.

The change

  • The busy branches clear only the per-hash bookkeeping while the status line still declares a wait. Withdrawing a declaration keeps its single owner, the loop-top reconciliation.
  • The working arms still end pause mode, because an authoritative active run really is evidence the crew is not idle, but they hold back the re-surface marker. That is the same split surface_nonterminal_stale already makes, for the same reason.
  • The duplicated not-paused arm is dropped from both busy branches, which also removes a redundant window_to_task subprocess from the busy poll's hot path.

Bounded escalation is unchanged. An absorbed sighting never refreshes the throttle, so the window still elapses and a wait that never clears still re-surfaces once, and a crew that declared nothing keeps alarming on every new stale hash.

Verification

  • The regression drives the real bin/fm-watch.sh poll loop and asserts on the durable wake queue and the marker files. Both halves fail against unfixed code and pass with the change: the busy-pane blip and the racing working-verdict each reproduce the reported alarm on their own.
  • A disconfirming half asserts that an undeclared silent crew keeps alarming on every new stale hash, so the bound cannot swallow a genuinely stopped worker.
  • The full watcher-wake-lock family runs green, 18 suites with 0 failures, including the pre-existing tests that pin the authoritative-active-run and wedge-timer behavior. bin/fm-lint.sh is clean.

docs/architecture.md is updated to record that a provably-working verdict does not retire the throttle either, and why.

…rm (kunchenguid#3942)

A worker that declared `paused:` for a bounded external wait and ended its turn
was still alarmed as stale for the whole wait, while `bin/fm-crew-state.sh` read
`state: paused` the entire time. The documented mechanism for declaring a long
wait did not suppress the alarm it exists to prevent.

Pane-hash churn was already bounded (kunchenguid#3532). What re-armed the alarm was pane
BUSY state. Both busy-path branches of the staleness loop called
clear_pause_tracking, which deletes `.paused-resurfaced-<key>` - the re-surface
throttle that is scoped to the DECLARATION, not to the pane. A worker parked on
a declared wait still renders its harness busy signature whenever it does
anything at all, such as taking a steer or reacting to its background job, so a
single such poll handed the unchanged declaration a fresh window and the next
idle sighting alarmed again far inside FM_PAUSE_RESURFACE_SECS. Each blip cost
one more wake, which is why the captain was told the work was paused while being
paged that it was stuck.

Both branches now clear only the per-hash bookkeeping while the status line still
declares the wait, leaving retirement to the loop-top reconciliation that already
owns it. This is the rule the hash-change branch three lines away already stated:
the throttle bounds the declaration, and pane state is not a record of the wait.

Bounded escalation is unchanged. An absorbed sighting does not refresh the
throttle, so the window still elapses and the wait still re-surfaces once, and a
crew that declared nothing keeps alarming on every new stale hash. The single
first-sight surface for a live parked worker is also unchanged, so a worker
genuinely waiting on a decision is still never silenced.
…kunchenguid#3942)

Review of the first commit found the same defect still reachable by a narrower
route, and one duplicated arm worth removing. Both are fixed here.

A `working` verdict is authoritative about the run, not about the declaration.
`bin/fm-crew-state.sh` emits `state: working source: pane` before its `paused:`
status-log fallback, and it takes its OWN pane capture a moment after the
staleness loop already read that pane idle. A worker parked on a declared wait
that blips between those two captures therefore reports `working` here, and the
three sibling `working` arms called clear_pause_tracking / clear_pause_state,
retiring the declaration-scoped re-surface throttle while the `paused:` line
still stood. The next new pane hash then alarmed again - the reported symptom,
reproduced by a different race than the busy-pane one.

Those arms now keep the throttle while the status log still declares a wait.
They still end pause MODE, because an active run really is evidence the crew is
not idle and a regression pins that; only the re-surface marker is held back,
which is the same split surface_nonterminal_stale already makes for the same
reason. The wedge timer is left alone throughout, so a genuinely frozen run
keeps its running count instead of restarting it on every recheck.

The duplicated `! status_is_paused_or_captain_held -> clear_pause_tracking` arm
is dropped from both busy branches. Withdrawing a declaration has one owner, the
loop-top reconciliation, and `.paused-<key>` only survives to those branches
while that reconciliation still reads a standing wait. Removing it also drops a
redundant window_to_task subprocess from the busy poll's hot path.

Bounded escalation is unchanged on both routes: an absorbed sighting never
refreshes the throttle, so the window still elapses and re-surfaces once, and the
loop-top reconciliation still retires everything the moment the status stops
declaring a wait. The regression now drives the racing working verdict as well as
the busy poll, and each half fails against the un-remedied code on its own.
@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issues identified.

The changed cleanup paths preserve only declaration-scoped throttle state, while declaration-signature matching, loop-top withdrawal reconciliation, and the independent wedge timer retain the required alarm and escalation behavior.

Reviews (1): Last reviewed commit: "fix(bin): stop a racing working verdict ..." | Re-trigger Greptile

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Reviewed the tip be2e0592dd8aaea261ecb137aeebcfa4700ef990 on main b84e0e362face25f3dd8945297a3df1320d7668c. Diff is bin/fm-watch.sh + docs + regression in tests/fm-watch-triage.test.sh — no .github/workflows changes. This restores the already-documented paused: / captain-held re-surface throttle so a busy-pane blip or racing working crew-state verdict cannot erase .paused-resurfaced-* and re-arm stale: inside FM_PAUSE_RESURFACE_SECS. Fixes #3942 as claimed.

VISION.md (each rule)

  • One captain, one interface: aligns — stops paging the captain that a declared wait is both paused and stuck.
  • Authority is explicit: aligns — no new grant; bounded re-surface cadence unchanged.
  • Scripts own the mechanics: aligns — throttle ownership stays in fm-watch.sh.
  • A restart is a non-event: aligns — durable pause markers remain the source of truth.
  • Delegation with a spine: aligns — corrective to existing pause contract.
  • The fleet outlives any vendor: aligns — harness-agnostic watcher.
  • Scope: aligns — supervision command layer.

Contract-class: restore. Attestation: MISSING (no no-mistakes raise / attestation marker on tip). Fork CI+NM approved this pass (runs 34195553856 / 34195553968). Waiting on author for attestation MATCH and green CI/NM. Security: clean. Do not auto-merge yet.

mremond added a commit to mremond/firstmate that referenced this pull request Sep 25, 2026
… work is spent

Refs kunchenguid#4018

Limits, stated as limits:
- It closes nothing. Every forge call is a read, including in the opt-in
  --sweep mode: no issue is closed, labelled, or commented on, and no backlog
  is read or written. It is the evidence half of the claim problem, not the
  loop closure the triage also leaves open.
- A fix that cites the issue number nowhere - no PR body, branch, or title,
  no commit message, and no --symbol the caller supplies - stays invisible to
  every check.

bin/fm-issue-claim.sh runs five read-only checks per issue and prints an
inspectable verdict (open, claimed, partially-covered, fixed-on-main, or
unknown): timeline cross-references, maintainer triage stamps (OWNER, MEMBER,
or COLLABORATOR only; the existing-pr target PR is read for its current
state), the complete open-PR corpus fetched by paginated REST and checked
against the search API total, the issue author's fork branches (resolved to
the PR each heads), and main history since the issue opened (commit messages
citing the issue, plus optional caller --symbol pickaxe searches). Issue
numbers match only as whole numbers, so 4018 never matches 40181, and a
foreign owner/repo#N is not a citation. A failed or rate-limited read, a
short or unverified corpus, or a history ref that cannot be searched yields
unknown or an explicit disclosure, never open. One corpus is shared across
every issue in a run and can be saved and reused across runs with its
completeness verdict and age.

--sweep is opt-in and report-only: one disposition line per issue
(close-candidate, leave-open, no-action, undetermined) with link candidates,
judged only from durable evidence and never from titles, branches, PR checks,
reviews, or mergeability. An issue with a live PR stamped existing-pr is
always leave-open, and merged evidence with incomplete coverage is
undetermined rather than a close candidate.

Live proof against kunchenguid/firstmate, 2026-09-23, history ref
origin/main@9296f9b9, open-PR corpus 1261/1261:
- kunchenguid#4927 claimed, reproduced: PR kunchenguid#4943 and PR kunchenguid#4955 (timeline, corpus, fork,
  and the maintainer existing-pr stamp on kunchenguid#4955), plus kunchenguid#4026 named by the
  earlier stamp and still open.
- kunchenguid#3370 fixed-on-main, reproduced: commit baede47 (kunchenguid#4656), found only by
  the history check with --symbol 3370:rerecord_device, issue still open.
- kunchenguid#4412 partially-covered, reproduced: PR kunchenguid#4775 merged (landed as 9bc051f)
  and PR kunchenguid#4832 open.
- kunchenguid#4466 open, reproduced, with every check complete.
- Reporter's cases in one --sweep: kunchenguid#3966 claimed by PR kunchenguid#3977 and kunchenguid#3942
  claimed by PR kunchenguid#3978 (leave-open); kunchenguid#3928 (PR kunchenguid#3946) and kunchenguid#3926 (PR kunchenguid#3944)
  show fixed-on-main and have since been closed on the forge (no-action).
@opariffazman

Copy link
Copy Markdown

This branch now has a merge conflict with main, and the PR must be raised via no-mistakes check fails. The last triage comment (2026-09-08) says it waits on the author for a no-mistakes attestation on the tip and green CI.

Can the author rebase and raise it again through no-mistakes? Issue #3942 is still open, and our home hits the same class of repeat stale wakes. We have not run this branch.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: closing this as stale. Thank you @scfconnect for the careful fix and write-up. On 2026-09-08 we asked for a no-mistakes raise with an attestation on the tip, and since then (more than 14 days) there's been no author push or comment, so this has been waiting on a contributor update. You're very welcome to reopen it, or raise a fresh PR through no-mistakes, any time you want to pick it back up.

@opariffazman, thanks for the nudge and the field note. Issue #3942 stays open, so anyone can raise a fix for it through no-mistakes.

@kunchenguid kunchenguid closed this Nov 3, 2026
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.

Declared paused: external wait does not suppress the watcher's pane-based stale alarm

3 participants