fix(ratelimit): preserve bucket policy across runtime changes - #47
Merged
Conversation
|
ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing |
6 tasks
📝 WalkthroughWalkthroughThe token bucket now retains its active policy during elapsed-time calculations. Policy transitions refill under the previous policy, apply the new policy, and clamp tokens to the new burst capacity. Tests cover rate, burst, admission, and overflow behavior. ChangesToken bucket policy transitions
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
6 tasks
OnlineChef
added a commit
that referenced
this pull request
Aug 2, 2026
Includes the policy-transition safety fix from #47 before enabling runtime admission routing.
OnlineChef
added a commit
that referenced
this pull request
Aug 2, 2026
Includes the merged metrics lane and the #47 token-bucket policy-transition safety fix before final provider-security review.
This was referenced Aug 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PR #44 was merged with a reproduced P1: existing token buckets refilled their entire elapsed interval using the newest policy passed to
consume(). A low-to-high transition could over-admit, while a high-to-low transition could falsely deny.Fix
Regression coverage
tests/ratelimit-policy-transition.test.tscovers:Merge gate
This must land before PR #45 enables these primitives in runtime routes.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is enabled.Summary by CodeRabbit
Bug Fixes
Tests
Greptile Summary
This change preserves the policy governing a token bucket’s elapsed interval when runtime rate-limit settings change. It refills under the previous policy before applying the replacement policy, prevents burst increases from granting free requests, and clamps balances when burst capacity decreases. Focused runtime checks exercised low-to-high and high-to-low rate transitions, burst-capacity changes, and shared-overflow buckets; all tested paths behaved as intended.
Confidence Score: 5/5
What T-Rex did
Reviews (1): Last reviewed commit: "test(ratelimit): cover policy transition..." | Re-trigger Greptile