Skip to content

GH#4412: fix(pulse): count all PRs for daily cap, not just open#4415

Merged
alex-solovyev merged 1 commit intomainfrom
bugfix/4412-fix-daily-pr-cap-count
Mar 13, 2026
Merged

GH#4412: fix(pulse): count all PRs for daily cap, not just open#4415
alex-solovyev merged 1 commit intomainfrom
bugfix/4412-fix-daily-pr-cap-count

Conversation

@alex-solovyev
Copy link
Collaborator

@alex-solovyev alex-solovyev commented Mar 13, 2026

Summary

  • Fix daily PR cap counter to query --state all instead of --state open, so merged and closed PRs created today are included in the count
  • Fix applies to both prefetch_state() (pulse-state.txt output) and calculate_priority_allocations() (product repo dispatchability check)
  • Increase --limit from 100 to 200 to match PULSE_PREFETCH_PR_LIMIT and avoid truncation on busy days

Root Cause

The daily PR cap counter reused the open-only PR JSON (gh pr list --state open), which excludes PRs created today that were already merged or closed. On a busy day with many merged PRs, the count showed e.g. 1/5 when the actual count was 30, allowing the pulse to dispatch workers far past the real cap.

Verification

  • ShellCheck: zero violations
  • Existing tests: all 7 pass (worker count + worker detection)
  • Manual review: both affected code paths now use --state all

Closes #4412

Summary by CodeRabbit

  • Bug Fixes
    • Updated daily pull request cap calculation to count all pull request states (open, merged, and closed) instead of only open ones, improving accuracy of capacity management and repository allocation decisions.

The daily PR cap counter in prefetch_state() and calculate_priority_allocations()
only queried open PRs (--state open), missing PRs that were created today but
already merged or closed. This caused stale/incorrect counts in pulse-state.txt
(e.g., showing 1/5 when the actual count was 30), allowing the pulse to dispatch
workers past the real cap.

Fix: use --state all for the daily cap query so merged and closed PRs created
today are included in the count. Also increase --limit from 100 to 200 to match
the prefetch PR limit and avoid truncation on busy days.
@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!

@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 13, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

The pulse-wrapper.sh script now counts all PRs created today (open, merged, and closed) using --state all for daily cap calculations, instead of counting only open PRs. A separate daily_cap_json data source replaces the previous approach, ensuring accurate cap tracking across multiple pulse sessions.

Changes

Cohort / File(s) Summary
Daily PR Cap Counting Logic
.agents/scripts/pulse-wrapper.sh
Updated prefetch_state to fetch PRs with --state all and count createdAt matches to today via daily_cap_json. Adjusted per-repo cap calculation to use daily_cap_json instead of pr_json. Modified calculate_priority_allocations PR counting to use --state all with 200-item limit instead of --state open with 100-item limit. Updated GH# references to #4412 and #3821.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bug

Poem

📊 PR caps were sleepy, counting dreams instead
Now --state all awakens, truth ahead
Open, merged, and closed all tallied right
Today's true count shines bright! ✨

🚥 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 title accurately describes the main change: switching daily PR cap counting from open-only to all PRs, matching the core fix in the changeset.
Linked Issues check ✅ Passed All objectives from GH#4412 are met: daily cap now queries all PR states, counts PRs created today correctly, and applies fixes in both prefetch_state and calculate_priority_allocations.
Out of Scope Changes check ✅ Passed All changes are directly scoped to GH#4412: daily cap counting logic, data source switching, and PR state query parameters align with requirements.
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/4412-fix-daily-pr-cap-count
📝 Coding Plan
  • Generate coding plan for human review comments

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

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Fri Mar 13 12:06:11 UTC 2026: Code review monitoring started
Fri Mar 13 12:06:11 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 413

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 413
  • VULNERABILITIES: 0

Generated on: Fri Mar 13 12:06:14 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@alex-solovyev alex-solovyev merged commit 66fe804 into main Mar 13, 2026
25 of 26 checks passed
@alex-solovyev alex-solovyev deleted the bugfix/4412-fix-daily-pr-cap-count branch March 13, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(pulse): daily PR cap count in pulse-state.txt is stale/incorrect

1 participant