⏳ feat: Reset Balance Allowances Without Rollover - #16781
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Lighthouse CI failed. The last 80 log lines contain the measured budgets and assertion failures. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25f71a397f
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d72ba3d4ac
ℹ️ 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 Please review the current PR head 0bed6ae. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. Current policy now synchronizes inside direct admission, and reset intervals require positive integers. Mixed-version activation is explicitly staged: reset stays off until all replicas support it, as documented in the config example and the gated draft DPC rollout. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Weekly auto-refill adds credits only when a request would exhaust the balance, allowing unused credits to carry over. I added
balance.refillMode: resetto replace the balance with the configured allowance once the period is due, even when credits remain. A balance read or request applies the reset; inactive periods grant one allowance, and the next interval starts at the applied reset.How it works
This gives a $300 allowance and a 0–100% usage display. Once a week is due, the next balance read or admitted request replaces the balance with 300,000,000 credits. It does not add $300 to the remaining balance or accumulate missed periods. Reservations survive the reset, so in-flight requests continue to count against the allowance. No background job or database migration is required.
Related to #16762 and the development rollout in ClickHouse/data-plane-configuration#95589.
Type of change
Testing
Tested environments/configuration: Node on macOS; real
mongodb-memory-server; additive and reset modes; weekly reset with percentage display.Automated tests:
transaction.spec.ts: 79 tests, including due resets with remaining/excess/negative credits, concurrent reads and admissions, retained reservations, no repeated/missed-period accumulation, failed ledger replay, and configuration changes during the fenced write.balance.spec.tsandcheckBalance.spec.ts: 61 tests, including direct admission with changed/disabled/reset-to-add policy and concurrent holds, without visiting a balance route.service.spec.ts: 115 tests, including real-database policy synchronization before increased, decreased, unchanged, and disabled resets with held reservations.config-schemas.spec.ts: 164 tests.tsc --noEmitin data-provider and data-schemas.git diff --check.CI backend/client typechecks and Lighthouse pass on
0bed6aeee4. Local API/client full typechecks are blocked by unrelated missing/outdated agent exports. The full Summary suite has one existing ARIA assertion failure with the reused shared UI build; all new reset tests pass. Local ESLint/static checks and Lighthouse preparation are blocked by the missing@tsdown/css/@shadcn/lintdependencies; the local formatter also uses different class ordering from CI. CI static checks, client tests, API test shards, and Lighthouse pass with the complete installed dependency set.Screenshots / recordings
Not captured locally: the frontend build is blocked by missing shared UI dependencies. User-visible changes are localized reset wording and timing; layout and theme styles are preserved.
Risk / compatibility
Deploy this version to all server replicas before enabling reset mode. Older servers understand only additive refill. Existing records without
refillModeretain additive behavior. The reset replaces stored credits; existing reservations and charges from in-flight requests remain counted. The reset is applied on activity rather than by a wall-clock scheduler.Checklist
0bed6aeee4