Skip to content

pr-review never auto-approves when advisory bots are rate-limited/out-of-quota — advisory-gate blocks on bots that can't submit #657

Description

@don-petry

Summary

The pr-review agent is not failing — it is skipping auto-approval on green PRs with decision: skip, reason: waiting-for-advisory-bots, and the skip never clears. Result: clean, CI-green, rebased PRs sit at REVIEW_REQUIRED indefinitely because donpetry-bot never posts its org-leads approval.

Root cause: the advisory-review-gate waits for advisory bots to submit a review at head, but two of the four advisory bots are out of quota and cannot submit, and the gate does not degrade gracefully when a bot is rate-limited.

Evidence

pr-review run for PR #623 (review/review job 81223083427, run 27478909009):

[advisory-gate] Advisory bots detected: gemini-code-assist sonarqubecloud
[advisory-gate] WARNING: Only 2/4 advisory bots submitted so far (head age: ~60s, last submission: ~Ns ago)
[advisory-gate] WARNING: Will re-check when remaining bots submit their reviews
skip: advisory bots still reviewing (non-blocking, will re-check on bot submission)
{"pr":".../623","decision":"skip","reason":"waiting-for-advisory-bots"}

The two missing/non-responding advisory bots are out of quota — confirmed by their own comments across #479, #483, #516, #518, #520, #525, #550, #580, #621, #622, #623:

  • CodeRabbit: "Review limit reached … Your organization has used up its prepaid credits, and credit purchases are no longer available."
  • chatgpt-codex-connector: "You have reached your Codex usage limits for code reviews."

Root cause (code)

scripts/lib/advisory-review-gate.sh:

  • ADVISORY_BOTS (L32–37) = gemini-code-assist, copilot-pull-request-reviewer, sonarqubecloud, chatgpt-codex-connector.
  • check_advisory_reviews (L128–235) requires num_submitted == total_advisory_bots (all 4) or one of two timeout fallbacks: head-commit age > 1200s (L222) or quiescence > 600s (L224). Otherwise return 1 → pr-review skips (review-one-pr.sh L140–177, reason=waiting-for-advisory-bots).
  • In practice the gate rarely sees 4/4: Codex is permanently out of quota, and Copilot reviews only a subset of PRs. So approval depends entirely on the timeout fallbacks — which only re-evaluate on an event re-trigger (a bot submission) or the hourly stuck-review sweep. Every dev-lead push (e.g. a rebase) resets the head-age clock to 0, so freshly-rebased PRs restart the 20-min wait and keep skipping.
  • A RATE_LIMITED display state already exists (format_bot_status L110) but nothing ever sets itget_advisory_bot_states (L59–85) only maps a bot's literal review/comment state. So the half-built rate-limit handling never triggers.

Impact

This is the gate behind the current backlog of green-CI PRs stuck at REVIEW_REQUIRED (e.g. #479, #483, #516, #518, #520, #525, #550, #589, #620, #621, #622, #623). With CodeRabbit + Codex credits exhausted, the advisory reviews won't arrive, so the gate only clears via the 20-min/10-min fallbacks after a quiet period + a re-trigger — slow and fragile, and reset by any new push.

Recommended fix (pick, keep minimal + tests)

  1. Wire up RATE_LIMITED (preferred). In get_advisory_bot_states, detect a bot comment whose body matches the known rate-limit/usage-limit markers (CodeRabbit "Review limit reached"/"used up its prepaid credits"; Codex "reached your Codex usage limits") and emit state: RATE_LIMITED. Treat RATE_LIMITED (and UNSUPPORTED) bots as responded/non-participating so they don't hold the gate. This makes the gate degrade gracefully the moment a bot signals it's out.
  2. Shorten / decouple the fallback so a bounded wait reliably proceeds even without a re-trigger (pair with the sweep), and/or anchor head-age so a no-op rebase doesn't reset the clock.
  3. Config escape hatch: allow dropping a bot from the required advisory set (keep it advisory-only) via env, so an out-of-quota bot (Codex) can be removed without code change.

Separate (infra/billing — not code)

CodeRabbit and Codex have exhausted prepaid credits org-wide, so they aren't reviewing at all right now. Even with a perfect gate, restoring those credits (or accepting their absence via fix #1/#3) is needed for advisory coverage.


Filed from a triage of why pr-review wasn't approving green PRs. Evidence: run 27478909009 (#623) + rate-limit comments on the PRs listed above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug reportsdev-leadFor dev-lead agent pickup

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions