Skip to content

GH#3821: Add daily PR creation cap to prevent CodeRabbit quota exhaustion#3822

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/daily-pr-cap
Mar 8, 2026
Merged

GH#3821: Add daily PR creation cap to prevent CodeRabbit quota exhaustion#3822
marcusquinn merged 1 commit intomainfrom
bugfix/daily-pr-cap

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Mar 7, 2026

Summary

  • Adds a configurable DAILY_PR_CAP (default 5) to pulse-wrapper.sh that counts open PRs created today (UTC) per repo during state prefetch
  • When the cap is reached, the pre-fetched state includes a clear DAILY PR CAP REACHED directive telling the pulse LLM not to dispatch new workers for that repo
  • Logs when the cap is hit for observability

How it works

  1. DAILY_PR_CAP config variable (env-overridable, validated as integer >= 1)
  2. During prefetch_state(), the existing PR fetch now includes createdAt (no extra API call)
  3. jq filters PRs whose createdAt starts with today's UTC date
  4. If count >= cap, the pre-fetched state output includes bold DO NOT dispatch text
  5. The pulse LLM reads this in its prompt and skips dispatching for capped repos

Changes

  • .agents/scripts/pulse-wrapper.sh — 30 insertions, 3 deletions (1 file only)

Closes #3821

Summary by CodeRabbit

Release Notes

  • New Features
    • Introduced a daily pull request cap (default: 5) to manage PR processing limits
    • Added visibility into daily PR count and remaining quota
    • Prevents new worker dispatch when daily cap is reached

… (GH#3821)

Add DAILY_PR_CAP (default 5) to pulse-wrapper.sh that counts open PRs
created today (UTC) per repo during prefetch_state(). When the cap is
reached, the pre-fetched state includes a clear 'DAILY PR CAP REACHED'
directive telling the pulse LLM not to dispatch new workers for that
repo. This prevents the supervisor from creating unlimited PRs per day,
which exhausts CodeRabbit's daily review quota.

Changes:
- Add DAILY_PR_CAP config variable with _validate_int validation
- Add createdAt to PR fetch fields in prefetch_state()
- Increase PR fetch limit from 20 to 100 for accurate daily counting
- Add Daily PR Cap section to pre-fetched state output per repo
- Log when cap is reached

Closes #3821
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2026

Walkthrough

Modified the pulse-wrapper script to enforce a daily PR creation cap of 5 PRs per repository. The script now retrieves PR creation timestamps during data collection, computes the remaining daily quota per repo, and signals when the cap is reached to halt worker dispatch.

Changes

Cohort / File(s) Summary
Daily PR Cap Rate-Limiting
.agents/scripts/pulse-wrapper.sh
Added DAILY_PR_CAP parameter (default: 5), extended PR fetch to include createdAt field and increased query limit from 20 to 100. Integrated cap-checking logic in prefetch_state to calculate daily PR counts, emit remaining quota, and log CAP_REACHED messages when quota exhausted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

bug

Poem

💫 Five PRs per day keeps the quota at bay,
Cap enforced with timestamps in hand,
No more marathons through the review-request land—
The pulse now breathes, the pipeline stands! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly and specifically addresses the main change: adding a daily PR creation cap to prevent CodeRabbit quota exhaustion, which matches the core implementation in pulse-wrapper.sh.
Linked Issues check ✅ Passed The PR fully implements the rate-limiting and quota-aware dispatch objectives from issue #3821: configurable daily cap (default 5), quota-aware dispatcher logic with 'DO NOT dispatch' directive, and cap-hit logging.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to pulse-wrapper.sh and directly address the PR objectives: DAILY_PR_CAP parameter, createdAt field inclusion, daily count logic, and dispatch prevention—no extraneous modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/daily-pr-cap

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Mar 7, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 125 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Mar 7 23:49:56 UTC 2026: Code review monitoring started
Sat Mar 7 23:49:57 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 125

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 125
  • VULNERABILITIES: 0

Generated on: Sat Mar 7 23:49:59 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 7, 2026

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.agents/scripts/pulse-wrapper.sh (1)

420-425: Consider adding timezone clarification to the output.

The cap logic correctly uses UTC (date -u), but the output message on line 433 says "today (UTC)" which is helpful. However, if a user is debugging near midnight in their local timezone, they might be confused why the count differs from their local perception of "today."

This is informational only — the current implementation is correct.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/pulse-wrapper.sh around lines 420 - 425, The output can be
clearer about which "today" is used: update the message that currently prints
"today (UTC)" to explicitly show both the UTC date and the local date to avoid
confusion; compute local_today with date +%Y-%m-%d (in the same scope where
today_utc and daily_pr_count are set) and include both today_utc and local_today
in the user-facing message that references "today (UTC)" so users see "UTC:
<today_utc>, Local: <local_today>" alongside daily_pr_count (variables to
update: today_utc, daily_pr_count and the output string that mentions "today
(UTC)").
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.agents/scripts/pulse-wrapper.sh:
- Around line 420-425: The output can be clearer about which "today" is used:
update the message that currently prints "today (UTC)" to explicitly show both
the UTC date and the local date to avoid confusion; compute local_today with
date +%Y-%m-%d (in the same scope where today_utc and daily_pr_count are set)
and include both today_utc and local_today in the user-facing message that
references "today (UTC)" so users see "UTC: <today_utc>, Local: <local_today>"
alongside daily_pr_count (variables to update: today_utc, daily_pr_count and the
output string that mentions "today (UTC)").

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ffaedaa5-4472-4d39-aa37-d3322baf0cc5

📥 Commits

Reviewing files that changed from the base of the PR and between a7a39aa and 2093c5d.

📒 Files selected for processing (1)
  • .agents/scripts/pulse-wrapper.sh

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.

fix: CodeRabbit daily quota exhausted — 15+ PRs blocked from formal review

1 participant