Skip to content

fix(bin): read owned PRs in bounded waves and report stuck reads - #8807

Open
Azd325 wants to merge 3 commits into
kunchenguid:mainfrom
Azd325:fm/fm-8795-read-wave
Open

Azd325 wants to merge 3 commits into
kunchenguid:mainfrom
Azd325:fm/fm-8795-read-wave

Conversation

@Azd325

@Azd325 Azd325 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8795

What Changed

  • bin/fm-pr-health.sh reads owned PRs in waves of READ_WAVE (4), in listed order. Each read gets the time left before the check timeout, with a floor of READ_FLOOR seconds. PRs the timeout leaves unreached stay pending for the next pass. PRs whose read failed are recorded in read_failed and listed after untried PRs, so one stuck PR cannot hold back the rest.
  • When a pass selects PRs and none of their reads settles, the script prints one line per cause (timeout, or no usable answer) for the PRs that newly fail. A PR prints again only after one of its reads completes. read_pr records a timeout cause, and read_failed entries are pruned when a PR is no longer owned.
  • docs/configuration.md describes the new read order, pending behavior and failure announcements. tests/fm-pr-health.test.sh adds coverage for these paths.

Risk Assessment

✅ Low: The round-2 fix keeps the 'announced' flag apart from demotion, which closes the silent stuck-PR path (A and B are read together, A settles, and B then prints when it fails alone); the updated docs and the new regression test match the code.

Testing

I ran the whole fm-pr-health test file twice. It drives the real bin/fm-pr-health.sh against a stubbed gh and a disposable home. Every case passed. That includes the wave, slow-forge, cannot-settle, stuck-PR and ordering cases. The docs match the new behavior. I did not run a real Herdr or Claude primary, because the monitor only talks to gh.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Four-PR waves in listed order all settle (local script, stubbed gh) ✅ pass live tests/fm-pr-health.test.sh: 'owned PR reads start together in waves of four and all settle'
Slow forge settles within the bounded wave (local script, stubbed gh) ✅ pass live 'a load-sensitive forge settles within the bounded wave'
A pass where no read settles prints one cannot-settle line (local script, stubbed gh) ✅ pass live 'a sweep that cannot settle any read says so once'
A stuck PR is listed after untried PRs so later PRs are read ✅ pass live 'a PR that cannot finish is listed after the PRs not tried, so later PRs are read'
A stuck PR prints once, and one that first fails beside a settled PR is still announced ✅ pass live 'a PR stuck on its answer prints once...' and 'a stuck PR first failing beside a settled PR is reported when it fails alone'

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed (2) ✅
  • ⚠️ bin/fm-pr-health.sh:584 - A slow PR in the first wave can block every later PR on every pass, and the monitor says nothing. Each read now gets the whole remaining deadline (READ_CAP=0, line 574). Each wave waits for all of its PRs (lines 584-587). Example: 8 owned PRs, and PR docs: polish README banner and repo housekeeping #2 has a paginated GraphQL or suite read that takes longer than ~20 s. Wave 1 uses up the deadline, the loop breaks at line 576, and PRs 5-8 stay pending. The next pass selects them in the same listed order, with PR docs: polish README banner and repo housekeeping #2 still pending ahead of them, so PRs 5-8 are never read. PRs 1, 3 and 4 settle, so settled>0 and the cannot-settle line never prints. Before this change, the 5 s cap let all 8 reads complete. The intent says an unreached PR 'stays pending for the next pass', but without rotation it never makes progress. Possible remedies: put unsettled or pending PRs after fresh ones, rotate the start offset, or keep a per-read cap below the full deadline. Each one changes the accepted ordering design, so the author must choose.
  • ⚠️ bin/fm-pr-health.sh:614 - The cannot-settle line repeats, with a wrong cause, when one PR can never settle but the forge is healthy. Examples: the suite list goes past the page bound (the changed test at tests/fm-pr-health.test.sh:820 now expects this line), or the repo returns 404/403 after access is lost. Sequence: pass 1 selects only stuck PR B and prints the line. Pass 2 gets a notification for PR A, A settles, and cannot_settle resets to false. Pass 3 selects only B (it is pending) and prints again. So the line prints again after every pass in which some other PR gets activity. Each time it says 'forge reads are slow or failing', but the reads were fast. That goes against the 'one line per new actionable condition' contract and the 'honest' wording in the intent. Possible remedies: track the stuck state per URL, or use a message that does not name forge slowness for a read that failed on content. The author must choose which behavior is correct.

🔧 Fix applied.
4 issues (1 error, 3 warnings) still open:

  • ⚠️ bin/fm-pr-health.sh:584 - A slow PR in the first wave can block every later PR on every pass, and the monitor says nothing. Each read now gets the whole remaining deadline (READ_CAP=0, line 574). Each wave waits for all of its PRs (lines 584-587). Example: 8 owned PRs, and PR docs: polish README banner and repo housekeeping #2 has a paginated GraphQL or suite read that takes longer than ~20 s. Wave 1 uses up the deadline, the loop breaks at line 576, and PRs 5-8 stay pending. The next pass selects them in the same listed order, with PR docs: polish README banner and repo housekeeping #2 still pending ahead of them, so PRs 5-8 are never read. PRs 1, 3 and 4 settle, so settled>0 and the cannot-settle line never prints. Before this change, the 5 s cap let all 8 reads complete. The intent says an unreached PR 'stays pending for the next pass', but without rotation it never makes progress. Possible remedies: put unsettled or pending PRs after fresh ones, rotate the start offset, or keep a per-read cap below the full deadline. Each one changes the accepted ordering design, so the author must choose.
  • ⚠️ bin/fm-pr-health.sh:614 - The cannot-settle line repeats, with a wrong cause, when one PR can never settle but the forge is healthy. Examples: the suite list goes past the page bound (the changed test at tests/fm-pr-health.test.sh:820 now expects this line), or the repo returns 404/403 after access is lost. Sequence: pass 1 selects only stuck PR B and prints the line. Pass 2 gets a notification for PR A, A settles, and cannot_settle resets to false. Pass 3 selects only B (it is pending) and prints again. So the line prints again after every pass in which some other PR gets activity. Each time it says 'forge reads are slow or failing', but the reads were fast. That goes against the 'one line per new actionable condition' contract and the 'honest' wording in the intent. Possible remedies: track the stuck state per URL, or use a message that does not name forge slowness for a read that failed on content. The author must choose which behavior is correct.
  • 🚨 bin/fm-pr-health.sh:634 - The fix round made this regression. A stuck PR whose first failure falls in a pass where another PR settles is never reported. The final jq (lines 643-649) adds every failed URL to .read_failed, including in passes where settled > 0, and no line prints in those passes. Later, newly (lines 635-637) leaves out any URL that is already in .read_failed. Sequence: pass 1 is the first or a full sweep and selects A and B. A settles. B fails on the suite page bound, a 403/404, or a timeout. Nothing prints, and read_failed[B] is set. Pass 2 selects only B (it is pending). B fails and settled == 0, but B is not counted as new, so nothing prints. Every later pass is silent too. The intent requires one honest cannot-settle line when a pass's selected reads all fail, and before the fix round the line printed in pass 2. The same failure happens on a slow forge if one PR in a wave happens to settle. The new test test_one_stuck_pr_prints_once_across_other_activity misses this because B fails alone first. Fix: record that the line was printed for a URL separately from the demotion marker. One way is to store announced: true in read_failed[url] only when a line prints for that URL, and compute newly against that field. Demotion can still use read_failed as it does now. Add a test where A and B are first read together, A settles and B is stuck, and the next pass then prints for B.
  • ⚠️ docs/configuration.md:860 - The user docs still describe the behavior from before the fix round. They say the line 'prints it again only after a pass in which a read completed', and they do not mention demotion. The code now prints one line per cause (timeout, or no usable answer) for each PR that newly fails. A PR prints again only after one of its own reads settles. A PR whose read failed is listed after the PRs that were not tried. The script header comment (bin/fm-pr-health.sh:98-102) was updated, but this doc was not. Update lines 858-860 to match.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Four-PR waves in listed order all settle (local script, stubbed gh) ✅ pass live tests/fm-pr-health.test.sh: 'owned PR reads start together in waves of four and all settle'
Slow forge settles within the bounded wave (local script, stubbed gh) ✅ pass live 'a load-sensitive forge settles within the bounded wave'
A pass where no read settles prints one cannot-settle line (local script, stubbed gh) ✅ pass live 'a sweep that cannot settle any read says so once'
A stuck PR is listed after untried PRs so later PRs are read ✅ pass live 'a PR that cannot finish is listed after the PRs not tried, so later PRs are read'
A stuck PR prints once, and one that first fails beside a settled PR is still announced ✅ pass live 'a PR stuck on its answer prints once...' and 'a stuck PR first failing beside a settled PR is reported when it fails alone'
  • bash tests/fm-pr-health.test.sh (all cases ok, no non-ok lines)
  • Checked docs/configuration.md lines 858-860 against the new behavior
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325. Keeping one slow PR from starving the rest of the pass is a good fix. This is my first look at head aad0336c on main 326ba38e.

Diff review (stands in for Greptile while it's out): safe, no P1. bin/fm-pr-health.sh now reads owned PRs in waves of READ_WAVE (4), in listed order. Each read gets the time left before the stop instead of a fixed 5 s (READ_CAP=0), and no read starts with less than READ_FLOOR seconds left. PRs the stop leaves unreached stay in notifications.pending. read_failed (pruned to owned URLs) moves failed PRs after untried ones, and an announced bit makes the new "no PR read settled" lines print once per PR until one of its reads completes. Branch discovery keeps its 5 s cap. No workflow, credential or network-surface changes. One P3: newly and cause_count leak into the script's global scope.

Contract class: new-default. The wave and ordering part restores the documented bounded pass. The new "pr-health: no PR read settled this sweep ..." lines, though, are a new kind of output that wakes the owning task, and today only author-actionable states, conflicts and failing checks print. Since that's switched on under the existing monitor flag, it needs Kun's word. VISION, rule by rule: One captain: cannot tell (an honest failure line versus a new kind of noise is Kun's call) · Authority: aligns · Scripts: aligns · Restart: aligns (pending state persists) · Delegation: aligns · Vendor: neutral · Scope: aligns.

Gates: the attestation binds this head with no skipped steps; live validation is go (5 of 5, against a stubbed gh); quick checks pass; 0 threads; clean merge.

Where it stands: nothing is needed from you. This pass is at its cap on new full-ci labels, so the full suite runs next pass, and after a green run this goes to Kun for his merge-or-leave word.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: a correction to my note above, @Azd325. This PR is the fix for your #8795. When I labelled that issue ready-for-pr this morning, I already ruled that bounded waves, the remaining-deadline budget and one honest "cannot settle" line all stay inside the opt-in monitor (config/pr-health-monitor), whose contract is that silence never hides a failure. I should have applied the same ruling here.

Contract class: restore (opt-in monitor), not new-default. VISION: aligns on every rule, One captain included ("silence never hides a failure").

Where it stands: unchanged otherwise. Diff review safe, no P1 (P3: newly/cause_count globals). All gates hold, and nothing is needed from you. This pass is at its full-ci cap, so the full suite runs next pass, and as a restore it merges after a green run. It would help to add Fixes #8795 to the body.

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.

pr-health: no read settles when each gh call is slow, and the monitor stays silent

2 participants