Skip to content

Read retry history with fewer GitHub requests - #840

Merged
Eli Pinkerton (wallstop) merged 1 commit into
masterfrom
work/817-batch-attempt-jobs
Nov 25, 2026
Merged

Eli Pinkerton (wallstop) merged 1 commit into
masterfrom
work/817-batch-attempt-jobs

Conversation

@wallstop

Copy link
Copy Markdown
Collaborator

Why

The PR latency report requests job records separately for each retry. This spends API quota when a workflow has several attempts.

What changed

Use one combined listing for retried runs. Fall back to exact attempts when the listing cannot account for the observed history. Keep the final verdict and the first failed verdict tied to the same workflow snapshot.

How we know

The six-attempt control returns the same 18 ordered job records with one request instead of six. The focused tests cover a new attempt starting during collection and inconsistent records. All 1,502 Node and 154 Python tests passed.

Study and acceptance checks.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds validated bulk retrieval of jobs across workflow run attempts. When bulk history is incomplete or inconsistent, the code fetches jobs for each attempt separately. Collection and tests use and verify this behavior.

Changes: Workflow job history retrieval

Layer / File(s) Summary
Validate bulk history and fall back
scripts/pr_latency.py, scripts/__tests__/test_pr_latency.py
jobs_by_attempt accepts bulk results only when attempts and job records pass validation. Otherwise, it fetches each attempt separately. Tests check fallback for incomplete or inconsistent results.
Use attempt jobs during collection
scripts/pr_latency.py, scripts/__tests__/test_pr_latency.py
collect uses jobs_by_attempt for latest jobs and prior-attempt history. The rerun test checks the bulk request, retained failure history, and successful gate result.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant collect
  participant jobs_by_attempt
  participant JobsAPI
  collect->>jobs_by_attempt: Request jobs for a workflow run
  jobs_by_attempt->>JobsAPI: Request all jobs with filter=all
  JobsAPI-->>jobs_by_attempt: Return attempt-tagged jobs
  alt Bulk history is valid and complete
    jobs_by_attempt-->>collect: Return jobs grouped by attempt
  else Bulk history is invalid or incomplete
    jobs_by_attempt->>JobsAPI: Request jobs for each exact attempt
    JobsAPI-->>jobs_by_attempt: Return per-attempt jobs
    jobs_by_attempt-->>collect: Return per-attempt jobs
  end
Loading

Possibly related PRs

Merge Risk: Minimal · up to 80c4d

This change reduces GitHub API requests in the latency report for retried runs and falls back to exact per-attempt reads when the combined listing is incomplete or inconsistent. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: the PR latency report reads retry history with fewer GitHub API requests. This matches the summary, which adds jobs_by_attempt so one combined jobs listing replaces p…
Description check Passed The description follows the template sections: Why, What changed, How we know, and a Related Issue link. It explains the API quota problem, the single-listing approach with exact-attempt fallback, and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: the PR latency report reads retry history with fewer GitHub API requests. This matches the summary, which adds jobs_by_attempt so one combined jobs listing replaces per-attempt requests for rerun workflows.

Full details: Description check

Explanation

The description follows the template sections: Why, What changed, How we know, and a Related Issue link. It explains the API quota problem, the single-listing approach with exact-attempt fallback, and the test evidence. It omits the Related Issue closing reference (it links a study comment instead), the Type of Change selection, and the Checklist. The template asks for these, so they are incomplete. The core sections are complete, so the check passes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review details

Context from checks skipped due to timeout: 5

  • GitHub Check: CodeRabbit
  • GitHub Check: Script tests (ubuntu-latest)
  • GitHub Check: Script tests (macos-latest)
  • GitHub Check: Script tests (windows-latest)
  • GitHub Check: Unity 6000.5.2f1 all modes
Additional context used

Ruff (0.17.4)

scripts/__tests__/test_pr_latency.py

[warning] 84-84: Unused lambda argument: a

(ARG005)

[warning] 84-84: Unused lambda argument: kw

(ARG005)

[warning] 166-166: Unused lambda argument: a

(ARG005)

[warning] 166-166: Unused lambda argument: kw

(ARG005)

[warning] 166-166: Function definition does not bind loop variable responses

(B023)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DISCLOSURE: LLM-GENERATED TEXT

OpenAI review: 0 findings.

No defects found in the changes reviewed.

3864 in, 2968 out tokens. Comments only; this review never blocks a merge.

Copy link
Copy Markdown
Collaborator Author

Review readback for 80c4d31e: OpenAI reports zero findings, CodeRabbit approved, and the inline review thread list is empty. The CodeRabbit summary includes test-only lint notes. The mock callbacks deliberately accept unused pagination arguments, and the loop callback is invoked synchronously inside each subtest while its response fixture is in scope. No deferred callback or unresolved behavior finding remains. Normal required checks still apply.

@wallstop
Eli Pinkerton (wallstop) merged commit bd2c99c into master Nov 25, 2026
28 checks passed
@wallstop
Eli Pinkerton (wallstop) deleted the work/817-batch-attempt-jobs branch November 25, 2026 02:14
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