Skip to content

Let the fire slot serialize the metered review and nothing else - #47

Merged
kristofferR merged 1 commit into
mainfrom
feat/budget-gates-the-queue
Jul 26, 2026
Merged

Let the fire slot serialize the metered review and nothing else#47
kristofferR merged 1 commit into
mainfrom
feat/budget-gates-the-queue

Conversation

@kristofferR

Copy link
Copy Markdown
Owner

Roadmap item F2: the queue exists for one thing, and this makes the code say so.

The bug

Pump returned as soon as it had progressed the round holding the fire slot:

if slot := st.SlotRound(); slot != nil {
    return s.progressSlotRound(ctx, *slot)   // ← pump over
}

Further down, the bounded rescue scan guarded itself with

if decision.Verdict == engine.FireNo && (accountBlocked || !global.SlotFree) {

so it claimed to cover both starvation causes. The !global.SlotFree half had never executed
once — control cannot reach that line with the slot held. A summary-only round, whose CodeRabbit
review is never coming at all, therefore stayed queued for as long as an unrelated PR's review ran.

TestWaitResolvesSummaryOnlyWithoutTheQueue documented the short-circuit and routed around it in
Wait; nothing fixed it in the pump.

The rule

The fire slot serializes one account-metered review. The account window bounds that same
allowance. Neither has any authority over a round that spends no quota — a co-reviewer defer, a
dedupe, a summary-only round.

So progressing the slot round no longer ends the pump. It reloads state (progressing may have
released the slot) and sweeps the quota-free rounds behind it. A pump still never both progresses
and fires, because a quota-free verdict is not a fire, takes no slot, and posts no
@coderabbitai review.

The scan is now one sweepQuotaFree called from both paths that can starve, instead of a loop
inlined into the tail of the account-blocked case — which is how one of its two callers came to be
unreachable in the first place. The scan budget and the rotating start survive unchanged; they are
cost control, and the rotation still answers the case where the rounds behind the head all need
CodeRabbit.

Verification

TestPumpSweepsQuotaFreeRoundWhileTheSlotIsHeld stages it directly: an unrelated PR holds the slot,
a summary-only round is queued behind it, one Pump must move it. Confirmed to fail on main
(the summary-only round must move while the slot is held ... Phase:"queued") and pass here. It also
asserts the slot still belongs to the holder afterwards and that no CodeRabbit command was posted —
otherwise "it moved" could mean it moved by spending the very quota it must not.

gofmt -l . clean, go vet ./... clean, go test ./... -count=1 green across all six packages.

Ref #42

Pump returned as soon as it had progressed the round holding the fire
slot. The rescue scan further down said it covered "blocked or slot-busy"
starvation, and its condition tested both — but control never reached it
with the slot held, so the slot-busy half had never run. A summary-only
round, whose CodeRabbit review is never coming at all, therefore sat
queued for as long as an unrelated PR's review took.

The slot exists to serialize one account-metered review; the account
window bounds that same allowance. Neither has anything to say about a
round that spends no quota. So progressing the slot round no longer ends
the pump: it reloads, then sweeps the quota-free rounds behind it. A pump
still never both progresses and fires, because a quota-free verdict is
not a fire.

The scan is now one function used by both paths that can starve, rather
than a loop inlined into the tail of the account-blocked case, which is
how one of its two callers came to be unreachable.
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kristofferR, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8e0d25a1-40fd-407c-bd26-e6fa5624cb7c

📥 Commits

Reviewing files that changed from the base of the PR and between 03c7d2e and 3a7e271.

📒 Files selected for processing (2)
  • internal/crq/service.go
  • internal/crq/service_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/budget-gates-the-queue

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.

@kristofferR

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kristofferR
kristofferR merged commit 6e74eda into main Jul 26, 2026
2 checks passed
@kristofferR
kristofferR deleted the feat/budget-gates-the-queue branch July 26, 2026 16:18
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.

1 participant