Skip to content

feat(BA-7362): move the per-user API rate limit to the user resource policy - #13779

Draft
jopemachine wants to merge 5 commits into
feature/BA-7365-user-keyed-rate-limit-counterfrom
feature/BA-7362-user-policy-api-request-limit
Draft

feat(BA-7362): move the per-user API rate limit to the user resource policy#13779
jopemachine wants to merge 5 commits into
feature/BA-7365-user-keyed-rate-limit-counterfrom
feature/BA-7362-user-policy-api-request-limit

Conversation

@jopemachine

@jopemachine jopemachine commented Aug 14, 2026

Copy link
Copy Markdown
Member

📚 Stacked PRs

This PR is part of a 5-PR stack. Merge in order:

  1. ⬇️ feat(BA-7364): deliver the login user id in the auth response #13777feat(BA-7364): deliver the login user id in the auth response
  2. ⬇️ feat(BA-7365): key the rate limit counter by user id #13778feat(BA-7365): key the rate limit counter by user id
  3. 👉 feat(BA-7362): move the per-user API rate limit to the user resource policy #13779feat(BA-7362): move the per-user API rate limit to the user resource policy ← you are here
  4. ⬇️ feat(BA-7363): publish the per-user rate limit to the shared Redis DB #13784feat(BA-7363): publish the per-user rate limit to the shared Redis DB
  5. ⬇️ feat(BA-7365): add a per-user rate limit middleware to the web server #13771feat(BA-7365): add a per-user rate limit middleware to the web server

Only the final tip (#13771) is guaranteed to build / pass CI; intermediate PRs are logical slices for reviewability.

Summary

  • Add a nullable max_api_requests_per_window column to user_resource_policies (NULL means unlimited) and plumb it through the v2 stack: row, data type, creator/updater specs, filters and orders, v2 DTOs, GQL v2 node/mutation/filter types, the adapter, and the admin CLI.
  • The rate limiter reads the policy value instead of keypairs.rate_limit — the manager middleware from request["user"]["resource_policy"], and the auth response (which the web server stores in its session) from the policy resolved at login. The allowance now belongs to the user rather than to whichever keypair signed the request.
  • keypairs.rate_limit is deprecated, not removed: the column and its API fields are still written and returned, but nothing enforces them. The legacy GQL field carries a deprecation_reason and the v2 keypair DTO fields are marked deprecated=True.
  • AuthenticatedKeypair.rate_limit is dropped since the rate limiter was its only reader.

Existing deployments start with the new column NULL, which means unlimited — an operator must set the policy value to restore a limit.

Resolves BA-7362.


📚 Documentation preview 📚: https://sorna--13779.org.readthedocs.build/en/13779/


📚 Documentation preview 📚: https://sorna-ko--13779.org.readthedocs.build/ko/13779/

@jopemachine
jopemachine requested a review from a team as a code owner August 14, 2026 08:09
jopemachine added a commit that referenced this pull request Aug 14, 2026
@github-actions github-actions Bot added size:L 100~500 LoC comp:manager Related to Manager component comp:client Related to Client component comp:common Related to Common component comp:cli Related to CLI component require:db-migration Automatically set when alembic migrations are added or updated labels Aug 14, 2026
@github-actions github-actions Bot added the area:docs Documentations label Aug 14, 2026
@jopemachine
jopemachine marked this pull request as draft August 14, 2026 08:56
jopemachine and others added 4 commits August 14, 2026 23:08
…policy

The rate limiter now reads `user_resource_policies.max_api_requests_per_window`
instead of `keypairs.rate_limit`, so the allowance belongs to the user rather
than to whichever keypair signed the request. NULL keeps meaning unlimited.
The keypair column and its API fields are kept and marked deprecated: they are
still stored and returned, but no longer enforced.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
GraphQL Inspector treats a new input field without an `Added in X.Y.Z`
description as a breaking change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jopemachine
jopemachine force-pushed the feature/BA-7362-user-policy-api-request-limit branch from 457903a to 60d2e75 Compare August 14, 2026 14:11
@jopemachine
jopemachine changed the base branch from feature/BA-7365-webserver-user-rate-limit-middleware to feature/BA-7365-user-keyed-rate-limit-counter August 14, 2026 14:11
Co-authored-by: octodog <mu001@lablup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentations comp:cli Related to CLI component comp:client Related to Client component comp:common Related to Common component comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant