Skip to content

M7: make /v1 rate limiting plan-aware - #26

Merged
man4ish merged 1 commit into
mainfrom
feature/v1-plan-aware-rate-limits
Oct 3, 2026
Merged

man4ish merged 1 commit into
mainfrom
feature/v1-plan-aware-rate-limits

Conversation

@man4ish

@man4ish man4ish commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

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_org reads gateway:v1:quota:{org_id}:ratelimit — nested under the existing quota:* 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 /v1 call 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 passed
  • ruff check . — 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), the lookup fails open on a Redis error

🤖 Generated with Claude Code

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>
@man4ish
man4ish merged commit cf7b565 into main Oct 3, 2026
1 check passed
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