Skip to content

fix(bin): retry transient contribution observation failures before waking - #7944

Open
Vela3202019 wants to merge 1 commit into
kunchenguid:mainfrom
Vela3202019:fm/firstmate-pr6668-replacement
Open

Vela3202019 wants to merge 1 commit into
kunchenguid:mainfrom
Vela3202019:fm/firstmate-pr6668-replacement

Conversation

@Vela3202019

@Vela3202019 Vela3202019 commented Oct 29, 2026 •

Copy link
Copy Markdown

Intent

This PR is the replacement for #6668, carried onto current main, now scoped to the contributions retry fix: bin/fm-contributions.sh retries a failed forge observation once while the budget still covers a full observation reserve, so a transient forge failure or a head that moved mid-read no longer raises a false unavailable wake. The startup-beat half of the original change is dropped because upstream's #8025 already covers it.

What Changed

Replaces #6668, which could not be updated in place after upstream moved.

  • Add a single observation-level retry in bin/fm-contributions.sh: when a contribution observation fails and no failure episode is already open, retry it once while the budget still covers a full observation reserve, so a transient forge failure or a head that moved mid-read no longer produces a false unavailable wake.
  • Record the error and wake only on a second consecutive failure; skip the retry for URLs whose failure episode is already open, and keep the first genuine failure when the budget refuses the retry.
  • Extend tests/fm-contributions.test.sh with fixtures and assertions for transient retry, persistent failure, budget-cutoff, and open-episode paths, and update existing read-count and test-name expectations to match the observation-level retry.

Risk Assessment

✅ Low: The change is a well-bounded, single-purpose retry with budget and episode gating, backed by thorough behavioral tests; the only issues found are a minor header-comment inaccuracy and a misleading test-fixture label, neither of which affects runtime correctness.

Testing

Ran the focused contributions test file (75 assertions, all green) and then live-drove the actual bin/fm-contributions.sh poll command against a disposable forge fixture across six scenarios: transient retry, killed-read recovery, head-moved recovery, persistent wake, budget-cutoff, and open-episode. An A/B run against the base commit confirmed the change eliminates the false wakes from killed forge reads and mid-read head moves (base woke with exit-137 and 'head changed during observation'; target retries once and emits no wake) while genuine failures still wake once and persist their error.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Transient forge read failure is retried once and does not wake ✅ pass live transient-retry.txt
Externally killed forge read recovers on retry and does not wake ✅ pass live killed-read-recovers.txt
Head that moves mid-read recovers on retry and does not wake ✅ pass live head-moved-recovers.txt
Persistent failure still wakes once and records the error ✅ pass live persistent-wake.txt
Retry the budget cuts off keeps the first genuine failure and wakes once ✅ pass live budget-cut-keeps-first.txt
Already-open failure episode is not retried ✅ pass live open-episode.txt
Evidence: A/B regression proof: base wakes, target stays silent

Source: A/B regression proof: base wakes, target stays silent

--- base (pre-change) behavior ---
base-killed core_reads=1 wake='contributions: observation unavailable for https://github.com/o/r/pull/8 - core read exited 137 with 20s of budget left: '
base-head core_reads=1 wake='contributions: observation unavailable for https://github.com/o/r/pull/8 - head changed during observation'
--- target (post-change) behavior ---
target-killed core_reads=2 wake=''
target-head core_reads=2 wake=''

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ bin/fm-contributions.sh:87 - The new observation-level retry (lines 84-92) retries every failed observation once before waking, including a 404, but the header paragraph above it still states at line 75 that "Other failures are reported immediately, including a 404, which is how a lost login reads on a private repository." These two statements now contradict: a 404 is no longer reported immediately; it is retried once at the observation level before the unavailable line prints. The renamed test test_http_404_is_not_forge_retried (tests/fm-contributions.test.sh:985, now asserting 2 core reads for a 404) confirms the new behavior. Update the lines 73-76 wording so the read-level retry boundary (transient errors only, no 404 retry inside forge()) is described separately from the new observation-level retry, keeping the header accurate.
  • ℹ️ tests/fm-contributions.test.sh:876 - The retry-once (line 876) and fail-persist (line 885) fault handlers emit a bare 'HTTP 502' (no 'gh: ' prefix and no '(HTTP NNN)' parentheses). bin/fm-contributions.sh's forge_http_status does not match that bare form, so forge_error_summary classifies it as 'request failed' and forge_transient_error treats it as non-transient. Consequently test_transient_forge_failure_retries_once (line 1639) does not actually exercise a transient forge failure: the single retry it observes is the new observation-level retry of a non-transient (unclassifiable) failure, not forge()'s internal transient retry. The tests pass and the new observation-retry path is genuinely covered, so this is informational, but the name and the 'HTTP 502' text misrepresent what is exercised; a future reader expecting a transient 5xx to produce 4 core reads (forge retry x observation retry) will be misled.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Transient forge read failure is retried once and does not wake ✅ pass live transient-retry.txt
Externally killed forge read recovers on retry and does not wake ✅ pass live killed-read-recovers.txt
Head that moves mid-read recovers on retry and does not wake ✅ pass live head-moved-recovers.txt
Persistent failure still wakes once and records the error ✅ pass live persistent-wake.txt
Retry the budget cuts off keeps the first genuine failure and wakes once ✅ pass live budget-cut-keeps-first.txt
Already-open failure episode is not retried ✅ pass live open-episode.txt
  • bash tests/fm-contributions.test.sh (full focused suite: 75 ok, 0 not ok, bounded by a background kill watchdog)
  • bash drive-poll-retry.sh (live-drove the real bin/fm-contributions.sh poll across six scenarios against a disposable forge fixture)
  • bash ab-false-wake.sh <basebin> (A/B: base commit vs target commit on killed-read and head-moved false wakes)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The current two-file change appears safe to merge.

Reviews (5) · Last reviewed commit: "fix(bin): retry a failed contribution ob..." · Reviewed by Greptile

Comment thread bin/fm-watch.sh Resolved
@Vela3202019
Vela3202019 force-pushed the fm/firstmate-pr6668-replacement branch from f68886a to da7587b Compare October 29, 2026 18:17
@Vela3202019 Vela3202019 changed the title fix(bin): stop false wakes from failed forge reads and slow watcher startups fix(bin): stop false wakes from failed forge reads and slow watcher startup Oct 29, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @Vela3202019 for carrying this over from #6668 and bringing it onto current main.

What I checked (head da7587b9 vs main c9da5523): I read the diff myself, including how the rebase merged main's fd-6 held-state check into exit_if_world_gone.

  • fm-contributions.sh re-reads a failed URL once, but only if the budget still covers a full observation. An open failure episode isn't retried. A retry the budget refuses keeps the first real failure.
  • fm-watch.sh takes the singleton lock before its startup recovery transitions. While they run, it writes state/.watcher-startup-beat, which names the watcher's pid. The beat and both lock waits share one deadline at the stall bound.
  • fm_watcher_beat_age only accepts the startup beacon for the live lock holder it names. The EXIT trap now ends the beat too, and that has a test.
  • Nothing touches workflows, credentials or new network surfaces; the only forge read is the existing one, retried once. You've had CI approved here before, but fork runs on a new head still need a maintainer click, so I approved CI and no-mistakes on this head.

No-mistakes binds da7587b9. Live validation is go: 7 of 8 scenarios were run live, and the one untested item is the test-harness heredoc fix. Greptile was 5/5 on the previous head.

Contract-class (my own read): new-default. This is the same call as on #6668. These are good fixes for false wakes, but every unconfigured home would behave differently: a background beat runs during watcher startup, the startup lock order changes, and a failed contributions read gets an extra retry. That makes it the captain's call, not an auto-merge. VISION: One captain aligns (fewer false "observation unavailable" and stale-watcher wakes; a persistent failure still wakes once). Authority aligns (no new grant). Scripts aligns (bounded, deterministic mechanics). Restart aligns (a wedged startup still goes stale and keeps its stale-lock evidence). Delegation aligns. Vendor is neutral. Scope aligns.

Status: waiting on the quick CI checks I just approved, which is on our side. After that, we run the full suite (the "Full suite" check needs a maintainer label for outside PRs, so a failure there now isn't on you). If it's green, this goes to the captain as a merge-or-leave decision. #6668 can stay open for now. Once one of the two lands, we'll close the other with thanks.

@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Oct 29, 2026
@Vela3202019

Copy link
Copy Markdown
Author

CI is green on lint, coverage, repo invariants and the no-mistakes check. The full suite is waiting for the full-ci label. This replaces #6668. Could a maintainer add it when convenient? Thanks!

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Vela3202019. We ran the full suite on head da7587b9 (run 40930260125, after the full-ci label). Two lanes failed, and one of them comes from this change.

Behavior portable serial 6, from this change. tests/fm-watcher-lock.test.sh (unchanged on main, passes there) fails with:

not ok - SIGSTOP watcher with a stale beacon was classified healthy

After that the lane hung until the job was cancelled about 13 minutes later. My read of the cause: the test SIGSTOPs the watcher just after watcher: started, ages .last-watcher-beat, and expects fm_watcher_healthy to say unhealthy. With this PR, the startup beat helper in bin/fm-watch.sh is its own background process. Its loop only checks fm_pid_alive "$WATCHER_PID", and a stopped pid still counts as alive. So the helper keeps touching .watcher-startup-beat, and fm_watcher_beat_age in bin/fm-wake-lib.sh takes that fresher age for the lock holder. The result is that a frozen watcher reads as healthy for up to the stall bound, which is the false-healthy case that test guards. The stop path never runs while the watcher is frozen, so the helper also outlives it, which probably explains the hang. Please treat this as my hypothesis, not a confirmed diagnosis. The fix is yours to choose, e.g. a beat that only advances with the watcher's own progress, or a reader that won't let the startup beacon vouch for a stopped holder.

Behavior portable parallel 1, not yours. tests/fm-pi-primary-types.test.sh hit npm error ETARGET (@aws-sdk/credential-provider-web-identity@^3.972.85 not found yet). That was a transient npm registry gap around 18:45Z that hit other PRs too. You don't need to do anything there.

Next step is with you: a fix for the serial 6 lane, pushed through git push no-mistakes so the attestation binds the new head. The full-ci label stays on, so your push will re-run the full suite. Contract-class is unchanged at new-default, so once it's green this goes to the captain for a merge-or-leave call.

@Vela3202019
Vela3202019 force-pushed the fm/firstmate-pr6668-replacement branch from da7587b to 7ece32e Compare October 29, 2026 23:06
@Vela3202019 Vela3202019 changed the title fix(bin): stop false wakes from failed forge reads and slow watcher startup fix(bin): stop false wakes from failed forge reads and slow watcher startups Oct 29, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Vela3202019 for the quick turnaround on the frozen-watcher problem. I read the new head 7ece32e3 (rebased onto b936f040). The separate beat process is gone: the watcher now beats state/.watcher-startup-beat only from inside its own bounded lock waits (fm_lock_acquire_wait_max). So a watcher stopped with SIGSTOP stops beating, and its beacon ages out. The exit trap clears the beacon, and a watcher only removes a beacon that names its own pid. There are new tests for the frozen and stopped cases. There are still no workflow, credential or network changes.

Your push re-ran CI on its own with the full-ci label still on, but as a fork run it needed a maintainer click. I've approved CI (40970818532) and the no-mistakes check on this head, and the full suite is running now. Nothing is needed from you while it runs. If it passes, this goes to the captain for the merge decision, because it changes watcher startup and forge-retry behaviour for every unconfigured home (new-default, same as #6668).

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Vela3202019. The full suite on head 7ece32e3 passed (40970818532, every lane green). The no-mistakes check passes on this head, Greptile is 5/5, there are no open threads, and your live evidence is 12/12.

Every gate is green, so this is now with the captain for the merge decision. It is not waiting on you. The reason it needs the captain: it changes watcher startup and forge-read retry behaviour for every unconfigured home (new-default, the same call as #6668).

A forge observation that fails is retried once while the budget still covers a full observation reserve, so a transient failure or a head that moved mid-read costs one extra read instead of a false unavailable wake. A URL whose failure episode is already open is not retried, and a retry the budget refuses keeps the first genuine failure.

Drops the startup-beacon half of the original change: upstream kunchenguid#8025 already bounds the watcher startup locks, publishes the lock identity early, and makes the arm wait for the identity, so that half is superseded.
@Vela3202019
Vela3202019 force-pushed the fm/firstmate-pr6668-replacement branch from 7ece32e to 9096e97 Compare November 3, 2026 18:23
@Vela3202019 Vela3202019 changed the title fix(bin): stop false wakes from failed forge reads and slow watcher startups fix(bin): retry transient contribution observation failures before waking Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants