feat(accounts): add per-account usage limits - #1528
Conversation
|
Regarding the UI design: Alternatively, it could possibly work like this: One potential problem that exists right now if the above is implemented: Also delayed telemetry or in-flight requests can cause some unpreventable overshoot with the current implementation. |
|
Triage note: this is a feature, so per the release train it queues behind the v1.23.0 stable cut (#1472) even once ready — no rush on your side. Meanwhile: (1) @Soju06, the author raised a concrete UI design question (always-visible enable toggle defaulting to 100% vs. the current clear-saved-limit control) that needs a maintainer call before the dashboard surface settles; (2) CI runs need maintainer workflow approval to start. Design looks aligned with the balancer-module ratchet (new app/core/balancer module, no selector hot-path DB I/O claimed) — we'll verify the app/core -> app/modules import boundary at review time. |
9720787 to
d3909d6
Compare
|
Rebased. When you have time, could you approve the CI workflow and let me know if we should change the UI or keep the current design from the screenshots? |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3909d647c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 091aa1515f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f969778d35
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6518cdc407
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe2833649c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7ec8519ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
8be2a95 to
ab6c3bd
Compare
|
Triage re-review after your 0818 push — this is now merge-ready on technical grounds except for one small fix: the migration reparent onto Answering the open 07-29 UI question explicitly since it was never closed out: the current set/clear control from your screenshots is accepted — no need for an always-visible toggle defaulting to 100%. Everything else verified: WS-harness blocker fixed, quota interaction correctly isolated from |
Summary
Adds an optional per-account usage cap so operators can reserve upstream quota for direct use. The cap applies across API keys and routing strategies.
The limit applies to both the 5-hour and weekly quota windows. Routing stops when either window reaches the configured percentage, making sure to preserve the remaining share.
Fixes #631
Type of change
feat:— new user-facing feature or capabilityOpenSpec
Change directory:
openspec/changes/add-account-usage-limits/Changes
Review notes
The selector uses standard usage rows already loaded into the cached selection snapshot; it adds no usage queries. Evaluation is linear in the candidate count.
Enabled limits fail closed when relevant telemetry is missing or older than
max(2 × refresh interval, 180 seconds). The API and dashboard expose this asdata_unavailable; fresh below-cap telemetry restores eligibility automatically.Simplicity
.env.example, or core navigation growth.Test plan
Screenshots / output
limit not set:


limit set:
current set limit disabled:
<img width="1389" height="309" alt="image" src="https://github.com/user-attachments/assets/d057afad-abfb-489d-b1ef-0888ddca91f6" /
Checklist
CHANGELOG.mdwas not editedSummary by CodeRabbit