feat: implement issue #1994 — Rate-limited PR reviews wait up to ~7h after the limit resets — the retry relies on GitHub's best-effort cron, which fires far less often than every 15 min
Problem
Rate-limited PR reviews wait up to ~7h after the limit resets — the retry relies on GitHub's best-effort cron, which fires far less often than every 15 min
From the issue: When pr-review defers a PR because an advisory reviewer is rate-limited, it writes: <!-- pr-review-agent rate-limited v1 sha=<HEAD> status=rate-limited reset=<ISO> --> from scripts/lib/advisory-review-gate.sh (~L340). The only thing that re-dispatches the review after reset is pr-review-sweep.yml / scripts/sweep-stuck-reviews.sh (~L300).
Design choice and runner-minute cost
Choice: this PR uses a dispatched, sleeping one-shot workflow (pr-review-delayed-retry.yml). It does not shorten or duplicate the cron. When the sweep defers a PR whose reset falls within DELAYED_RETRY_HORIZON_SEC (default 3600s), it arms one retry for that PR and head SHA. The retry sleeps until reset plus DELAYED_RETRY_BUFFER_SEC (default 120s). It then re-checks that the PR is open, still at the same head, and still carries the marker, and hands the PR to the normal sweep path with ARM_DELAYED_RETRY=false.
Runner-minute cost: each armed retry uses at most ~62 runner-minutes of sleep (horizon + buffer = 3720s), plus about a minute of setup and the one-PR sweep. The job is capped at timeout-minutes: 70.
- Retries per PR: at most one per (PR, head SHA). A dedup check skips re-arming while one is queued or running, and the per-(PR, head) concurrency group cancels any duplicate.
- Total across PRs: bounded by the sweep's shared
MAX_DISPATCHbudget, since arms count against it. - Resets beyond the horizon: no retry is armed; the cron handles them.
Risk
Medium — changes GitHub Actions workflow behavior, which is exercised only post-merge; verify via the affected workflow runs.
Test plan
Tests added/updated: tests/test_delayed_rate_limit_retry.bats,tests/test_sweep_stuck_reviews.bats. Verification: bash scripts/dev-lead-lint.sh (shellcheck --severity=warning) ran pre-commit; the bats suite runs in CI.
Rollback
Revert this PR. No non-revertible side effects (no tags, migrations, or external state).
Monitoring
Watch the affected workflow run(s) in the Actions tab and this PR's Lint check for regressions.
Closes #1994