ci(janitor): re-run CLA checks the spent GITHUB_TOKEN budget failed, once the budget is back
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):
- One
rate_limitread 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. - 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. - It re-runs a CLA Assistant failure whose job log shows the rate limit. A genuine "not signed" failure is left alone.
- 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.
- 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](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
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.