Skip to content

fix(source-control): retry the verdict reader's artifact listing on transient errors - #7738

Merged
kyle-sexton merged 5 commits into
mainfrom
fix/verify-listing-retry
Oct 17, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
fix/verify-listing-retry

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Refs: #7718

Summary

The pr-merge verdict reader (babysit_verify_evidence.py, added in #7718) lists every repository artifact once per gate run. Until now any failure of that listing refused the pull request verify:unreadable at once, so a single 502 or dropped connection held the candidate for that run. This reads the listing again when the failure is one that a retry can clear.

Fix

  • _actions raises _Transient (a subclass of _Unreadable) only for:
    • a 5xx, read through the shared babysit_gh.gh_http_status parse;
    • a failure with no HTTP status whose stderr names a fast network error (NETWORK_ERRORS: gh's "error connecting to", and Go net/http's connection reset/refused, i/o timeout, TLS handshake timeout, unexpected EOF).
  • Not retried, refused on the first read as before:
    • a gh timeout;
    • 429 and any rate-limit 403, since a fixed short wait outlasts neither a Retry-After nor an hourly reset, and more requests can extend a secondary limit;
    • any other 4xx;
    • missing credentials;
    • gh missing from PATH.
  • _read_listing reads, then retries after each of LISTING_WAITS = (2.0, 4.0). All reads and waits share one deadline: one gh timeout (babysit_gh.gh_timeout_seconds(), 60s by default) from the first read. Each retry's timeout_seconds is the time left after its wait, and no retry runs once none is left.
  • The sleep and clock are _listing_sleep and _listing_clock, patchable like babysit_merge._poll_sleep/_poll_clock.
  • The helper returns from inside the loop or after it, so no variable is left unbound.
  • After the last read the outcome is unchanged: the error is cached and every entry of the run refuses verify:unreadable without paging again. A retry never turns a failure into a pass.
  • Run-record reads use the same classification but are not retried; their handling is unchanged.
  • The module docstring and docs/conventions/pr-pipeline/README.md describe the retry.

Verification

  • tests/test_babysit_verify_evidence.py: 84 passed, 77 subtests. New class ATransientListingFailureIsReadAgain:
    • 502, 503, a connection error and a connection reset, each followed by success, read the verdict after one 2s wait;
    • a 502 on every read refuses verify:unreadable after 3 reads with waits [2.0, 4.0];
    • with a 60s timeout and the clock at 0, 1 and 20, the read timeouts are [None, 57.0, 36.0];
    • with the clock at 58.5 after the first failure, no retry runs;
    • a gh timeout, 404, 401, 422, Resource not accessible by integration (HTTP 403), 429, a secondary-rate-limit 403, a primary-rate-limit 403, the no-credential message and gh missing from PATH are each read once with no wait.
  • The renamed test_a_failed_listing_refuses_every_entry_and_is_not_read_per_entry expects 3 listing calls for its 502 outage: one listing per run, retried, never one per entry.
  • Whole babysit-prs suite: 1686 passed, 996 subtests.
  • scripts/check-affected.sh: 7 passed, 1 skipped over 4 changed files.
  • pyright (the repo's strict config) reports no unbound-variable diagnostic for the file. No CI step runs pyright over it: .github/standards/pyright/pyrightconfig.json appears only as a managed file in pr-check-managed-files-hosted.yml.

Latency arithmetic. pr-merge.yml runs the gate once per candidate, each with its own Reader, inside a 30-minute job (timeout-minutes: 30). gh's default timeout is 60s (babysit_util.DEFAULT_COMMAND_TIMEOUT_SECONDS).

Case Listing per candidate 100 candidates
Today, the read times out 60s 6,000s (100 min)
This PR, the read times out (not retried) 60s 6,000s (100 min)
This PR, any mix of 5xx and network errors at most 60s: reads and waits share one 60s deadline at most 6,000s
This PR, every read gets a fast 5xx about 6s of sleep, plus three short requests about 600s (10 min)

The retry never raises a candidate's listing worst case above today's single-read timeout. Rate limits are not retried.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01QRBud9mEJLtwtT71MG8bMB

kyle-sexton and others added 4 commits October 17, 2026 11:36
…ransient errors

A transient failure of the pr-merge verdict reader's artifact listing (no
HTTP response, a 5xx, a 429, or a 403 naming a rate limit) is read again,
three reads in all with 2s and 4s backoff, before it refuses
verify:unreadable. Any other failure refuses at once, and a listing that
fails every read refuses exactly as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QRBud9mEJLtwtT71MG8bMB
…retry timeouts

A 429 or rate-limit 403 now refuses on the first read, since a fixed short
wait outlasts neither a Retry-After nor an hourly reset. A failure with no
HTTP status counts as transient only for a gh timeout or a known network
error, so a missing gh or missing credentials are not retried. Each retry
read gets a 15s timeout; the first keeps gh's default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QRBud9mEJLtwtT71MG8bMB
A timed-out listing is no longer read again. Retries after a 5xx or a fast
network error share a deadline of one gh timeout from the first read, so
the listing's worst case per gate run stays at a single read's timeout.
The retry loop returns from a helper, so no variable is left unbound.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QRBud9mEJLtwtT71MG8bMB
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 17, 2026 17:04
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T17:06:53.110101Z 7ddb019 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 58s —— View job


Security review complete

  • Gather context (PR diff, changed files)
  • Run /review:security-review
  • Post findings

Scope reviewed: the 4 changed files (babysit_verify_evidence.py, its tests, the pr-pipeline doc, and the changelog fragment). No .github/workflows/** files are touched, so there is nothing in zizmor's Actions-hardening lane to defer.

Findings: none.

This PR adds a bounded retry (3 reads max, waits [2.0, 4.0], all inside the existing gh timeout deadline) around the artifact-listing read in the pr-merge verdict reader. I traced the trust-relevant properties:

  • No pass-from-failure path. _read_listing only returns on a successful read; after the final attempt, any error is still cached in _listing_error and every queued entry still refuses verify:unreadable exactly as before — a retry can only turn a hold into a pass by actually succeeding, never by exhausting attempts.
  • Classification is conservative. _transient (babysit_verify_evidence.py#L91-L98) retries only a parsed 5xx or a no-response network error; 429/403 rate limits, 4xx, missing credentials, and a missing gh binary still fail closed on the first read (verified against the NOT_TRANSIENT test cases).
  • Exception hierarchy stays sound. _Transient subclasses _Unreadable, so every existing except _Unreadable: / except (_Unreadable, ...) site (babysit_verify_evidence.py lines 226, 320, 495, 552) still catches it — the retry path doesn't silently escape error handling elsewhere (e.g. _run_state, which calls _actions directly and is correctly not retried per the PR description).
  • No new input surface. The retry only wraps an existing gh api repos/{repo}/actions/artifacts call; arguments are passed as an argv list (no shell interpolation), and the repo/token handling is untouched by this diff.
  • Bounded worst case. The deadline arithmetic (deadline = clock() + gh_timeout_seconds(), each retry's timeout_seconds = deadline - clock() - wait, raising instead of sleeping once timeout <= 0) keeps the total listing time within one gh timeout, matching the PR's own latency table — no retry-storm or amplified-DoS concern against GitHub's API from this change.

No instruction-surface deletions in this diff (the docstring and docs/conventions/pr-pipeline/README.md edits only add description of the new retry; nothing is removed or softened), so the instruction-exception-register lens doesn't apply.

claude-lane-summary: lane=claude-security-review sha=7ddb0195a754dba9f60112ea40686e0e79503fad run=39052164778

@claude

claude Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 3m 24s —— View job


Claude's review of PR #7738

  • Gather context (diff, changed files, custom instructions)
  • Invoke /review:code-review per instructions
  • Post inline findings (if any)
  • Post summary comment

Scope reviewed: babysit_verify_evidence.py's new _read_listing/_transient/_Transient retry logic, its call sites, the renamed/added tests in test_babysit_verify_evidence.py, and the doc/changelog updates.

Findings: none.

I traced the retry/deadline arithmetic in _read_listing (plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py#L232-L253) by hand against each new test case in ATransientListingFailureIsReadAgain (success-after-one-retry, exhausted-after-three-reads, the [None, 57.0, 36.0] timeout sequence, the no-time-left early exit, and each non-retried failure class) and it matches in every case: the shared deadline (deadline = _listing_clock() + gh_timeout_seconds()), the per-retry timeout computation, and the timeout <= 0 early-exit all line up with what the tests assert.

Other checks that came back clean:

  • _transient()'s classification (5xx via gh_http_status, else a NETWORK_ERRORS substring match) correctly excludes 429/secondary-rate-limit 403s, 4xx, gh timeouts, and missing-gh/missing-credential failures from retry, matching the PR's stated policy.
  • _run_state (line 289) still calls _actions directly and catches the broader _Unreadable, so run-record reads are unaffected by the new retry — consistent with the PR's "unchanged" claim.
  • The _listing_sleep/_listing_clock seam mirrors the existing babysit_merge._poll_sleep/_poll_clock pattern rather than introducing a second way to do patchable retry timing.
  • The module docstring and docs/conventions/pr-pipeline/README.md edits accurately describe the new behavior.
  • I was not able to execute the test suite myself in this sandbox (Bash tool calls required approval that isn't available in this lane), so the "84 passed / 1686 passed" counts in the PR description are author-claimed and unverified by me — my confidence instead comes from manually tracing the arithmetic against the test bodies, which I could read directly.

No inline comments were needed.

claude-lane-summary: lane=claude-review sha=7ddb0195a754dba9f60112ea40686e0e79503fad run=39052164424

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ddb0195a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review has reviewed this pull request through 1480ed2; a later push is reviewed from there.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

claude-review has reviewed this pull request through 1480ed2; a later push is reviewed from there.

…ckoff sleep

The retry timeout was derived before the sleep, so a late-returning sleep
let the retry run past the shared deadline. Read the clock again after the
sleep and skip the retry when the deadline has passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AfcE6qXwStK92XAx21MG43
@claude

claude Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 3s —— View job


Security review (incremental, since 7ddb019)

  • Read .claude-lane/incremental.diff
  • Review the retry-timeout recompute fix for logic/trust issues
  • Check updated tests
  • Post findings

Scope reviewed: only what changed since 7ddb019, per the incremental diff — _read_listing in babysit_verify_evidence.py and the new/changed tests in test_babysit_verify_evidence.py. This is exactly the fix for the Codex P2 comment on the prior commit: the retry timeout is now recomputed from the clock after _listing_sleep(wait) returns, instead of from the pre-sleep clock reading.

Findings: none.

What I checked:

  • No negative/zero timeout reaches gh. Both the pre-sleep guard (deadline - _listing_clock() - wait <= 0: raise) and the post-sleep guard (timeout = deadline - _listing_clock(); if timeout <= 0: raise) raise instead of handing _actions a non-positive timeout — a late-returning sleep now shortens the next read's timeout rather than silently exceeding the documented one-gh-timeout deadline for the whole listing read.
  • No path turns a failure into a pass just by running out of time. Every exit from _read_listing on exhaustion is a raise (propagating _Transient/_Unreadable), matching the "a retry never turns a failure into a pass" invariant from the parent PR; this commit only changes when the remaining budget is computed, not the fail-closed outcome.
  • No unbounded loop or extra gh calls. The loop body still runs at most len(LISTING_WAITS) tries before the final unguarded call after the loop; the new post-sleep check adds a raise exit but no new call path.
  • Traced the three new/changed tests (test_the_retries_share_one_read_timeout, test_a_late_sleep_shortens_the_retry_timeout, test_no_retry_when_the_sleep_ends_past_the_deadline) by hand against the new arithmetic — all three clock sequences produce the timeouts/call-counts they assert.
  • No change to argument construction, credential handling, or the trust boundary (gh api repos/{repo}/actions/artifacts, argv list, no shell interpolation) — untouched by this commit.
  • No instruction-surface (CLAUDE.md/AGENTS.md/rules/docs) files are in this incremental diff, so the instruction-exception-register lens doesn't apply here.

claude-lane-summary: lane=claude-security-review sha=1480ed221215d1aecbae4b29de407d289bed8424 run=39055656094

@claude

claude Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 57s —— View job


Claude's review of PR #7738 (incremental)

  • Gather context (incremental diff since 7ddb019, changed files)
  • Invoke /review:code-review per instructions
  • Post inline findings (if any)
  • Post summary comment

Scope reviewed: only what changed since 7ddb0195a754dba9f60112ea40686e0e79503fad, per .claude-lane/incremental.diff — the _read_listing retry-timeout recompute in babysit_verify_evidence.py and the three new/changed tests in test_babysit_verify_evidence.py. This is the fix for Codex's P2 finding on the prior commit ("Recompute the retry timeout after sleeping").

Findings: none.

I hand-traced _read_listing (babysit_verify_evidence.py#L232-L256) against each of the three new/changed test cases:

  • test_the_retries_share_one_read_timeout (clock [0.0, 1.0, 3.0, 20.0, 24.0]): deadline fixes at 60.0; each retry's timeout is now deadline - clock() read after _listing_sleep, giving [None, 57.0, 36.0] — matches.
  • test_a_late_sleep_shortens_the_retry_timeout (clock [0.0, 1.0, 30.0, 59.0]): the first wait's sleep "returns" at 30.0 instead of the expected ~3.0, so the second read's timeout is computed from that late reading (30.0), not the stale pre-sleep estimate (57.0) the prior commit would have used. The second retry's pre-sleep gate (60 - 59 - 4 <= 0) then correctly refuses to sleep again and raises — exactly closing the gap Codex flagged.
  • test_no_retry_when_the_sleep_ends_past_the_deadline (clock [0.0, 1.0, 61.0]): post-sleep recompute (60 - 61 = -1) raises immediately with no second gh call — fake.listings() == 1 confirms no over-budget retry is issued.
  • test_no_retry_once_the_timeout_is_spent (unchanged pre-sleep-gate case, clock [0.0, 58.5]): the pre-sleep gate (60 - 58.5 - 2 <= 0) still skips the sleep entirely when it's already hopeless — this keeps the documented worst-case bound (waits only run when they can still fit before the deadline), rather than always sleeping and recomputing after.

The two-gate structure (check-before-sleep to avoid wasting a wait when already doomed, recompute-after-sleep to not trust a stale pre-sleep estimate) is consistent and leaves no unbound-timeout path: the loop's trailing return self._actions(..., timeout) only runs after an iteration that already recomputed timeout and confirmed it's > 0.

I was not able to execute the test suite in this sandbox (Bash commands here require interactive approval that isn't available to this lane), so this is a manual trace against the test bodies, not an executed run — consistent with the confidence basis in this lane's prior review of the file.

No inline comments were needed.

claude-lane-summary: lane=claude-review sha=1480ed221215d1aecbae4b29de407d289bed8424 run=39055656092

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 17, 2026
Merged via the queue into main with commit 6900e06 Oct 17, 2026
27 checks passed
@kyle-sexton
kyle-sexton deleted the fix/verify-listing-retry branch October 17, 2026 18:04
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