Repository navigation
M7: make /v1 rate limiting plan-aware - #26
Merged
Merged
Conversation
Part of M7 (design audit gap #7's first bullet: "one global configured rate rather than plan-specific rates"). The gateway's per-caller requests-per-minute check now reads an organization's plan-specific override before falling back to the configured global default. V1Store.rate_limit_for_org reads gateway:v1:quota:{org_id}:ratelimit -- deliberately nested under the existing quota:* prefix rather than a new ratelimit:* namespace, so the companion omnibioai-billing change (gateway_quota_sync_service.py now also publishes this) reuses its existing Redis ACL grant exactly as-is; no omnibioai-studio change needed for this PR. None of this platform's currently-seeded plans set an override (same "not an engineering decision" posture Pay-as-you-go's still-unseeded per-unit price already has in that repo), so every /v1 call keeps using the global default today; this activates automatically once an operator sets a real plan-specific value, no further gateway change needed. Tests: 360 passed. ruff clean. New coverage: override wins over the global default, falls back correctly when unset, a limit of exactly 0 is honored (not treated as unset -- `is not None`, not a truthiness check), and the lookup itself fails open on a Redis error. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
Part of M7 (design audit gap #7's first bullet: "one global configured rate rather than plan-specific rates"). The gateway's per-caller requests-per-minute check now reads an organization's plan-specific override before falling back to the configured global default.
V1Store.rate_limit_for_orgreadsgateway:v1:quota:{org_id}:ratelimit— nested under the existingquota:*prefix so the companion omnibioai-billing change (now also publishing this) reuses its existing Redis ACL grant exactly as-is; no omnibioai-studio change needed.None of this platform's currently-seeded plans set an override, so every
/v1call keeps using the global default today; this activates automatically once an operator sets a real plan-specific value.Depends on / pairs with: the companion omnibioai-billing PR that publishes this key.
Test plan
pytest— 360 passedruff check .— clean🤖 Generated with Claude Code