ci(janitor): re-run CLA checks the spent GITHUB_TOKEN budget failed, once the budget is back

TE
25d ago
+320-0

The required checks CLA Assistant and CLA policy guard both run on the repository's GITHUB_TOKEN. When the installation budget runs out (2026-10-06, and since 21:10Z on 2026-10-25), both fail outright and stay red until someone re-runs them by hand, often while the budget is still spent. This currently blocks #25172 and #25302, among others.

Why CLA policy guard says "rejected the proposed policy" on PRs that touch no CLA file. validate-cla-policy.rb reads the PR, its reviews, its compare and snapshots through gh api. A failed read raises PolicyError ("GitHub API request failed…"), and the rescue at the end turns every PolicyError into the same generic annotation. So a quota 403 looks exactly like a policy rejection. That explains the pass-then-fail pattern on unrelated PRs.

Why the fix is not inside the two jobs. cla.yml and the guard are a trusted control plane. The guard requires an exact-head review from a trusted maintainer (TRUSTED_REVIEWER_IDS) for any change to cla.yml or to its own bytes (EXPECTED_GUARD_SCRIPT_DIGEST). In-job backoff is therefore a trust-policy change and is left to that review.

What this adds instead is a self-healing re-run in the janitor's scheduled sweep (every 10 minutes, no new schedule):

  1. One rate_limit read of GITHUB_TOKEN, which costs no quota. If less than 20% (minimum 500) is left, it stops: a re-run would fail the same way.
  2. Using the janitor's App token (its own budget, actions: write), it takes each PR head's newest run of each workflow, across all statuses. It acts only when that run failed at the head the PR still has.
  3. It re-runs a CLA Assistant failure whose job log shows the rate limit. A genuine "not signed" failure is left alone.
  4. It re-runs a CLA policy guard failure while its attempt is under 8, because the guard's reason is hidden. A genuine rejection is deterministic and stops there.
  5. Bounds per sweep: 12 log reads (rotated, so genuine failures can't starve the scan) and 8 re-runs, within 24 hours. The step never fails the sweep.

Cost: about 34 App calls per sweep at most, and 0 GITHUB_TOKEN calls.

Tests: tests/test_cla_quota_rerun.py, 7 cases against a fake GitHub, all pass. actionlint is clean.

Review: independent Codex (gpt-6-astra, xhigh). The first pass returned BLOCK with three findings (lost guard retries, scan starvation, replaying superseded runs). All three are fixed, and the second pass returned SHIP.

🤖 Generated with Claude Code

Agent session: agent session


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Bug Fixes
    • Recent CLA check failures caused by API rate limits can now be automatically rerun, helping eligible checks complete without manual intervention.
    • Reruns are limited to failures on the pull request’s current revision and are capped to avoid excessive retries. Other failures and outdated checks are excluded.