Skip to content

feat(quota): derive per-model allowance and expose boosted usage - #14

Merged
peach0x33a merged 2 commits into
peach0x33a:masterfrom
HardeNNN:pr/boosted-allowance
Nov 16, 2026
Merged

peach0x33a merged 2 commits into
peach0x33a:masterfrom
HardeNNN:pr/boosted-allowance

Conversation

@HardeNNN

Copy link
Copy Markdown
Contributor

Two related quota fixes.

1. Truthful monthly allowance. The upstream scales its credit windows to the model in use (GOAT reports 14/35 on a $70-allowance model and larger windows on a $100 model), so the static plan cap and the window overrides from the plan mapping were wrong for most models. The allowance is now remaining credits + billing-period spend, the upstream window caps are left untouched, and the plan mapping stays only as a fallback when the usage aggregate is unavailable.

2. Boosted-usage data. Command Code publishes a monthly allowance per model (the "boosted usage" deals), all charged from the same credit pool. internal/app/allowances.json captures that catalog (98 models, with source and capture date) and is embedded in the binary. BoostedFor returns, per plan, the boosted models with their advertised allowance, the multiplier against the account's credit pool, and the remaining USD estimate derived from the account's remaining credits (plus 5-hour/weekly estimates). The tracker is skipped when the usage aggregate is missing (the pool would be a static estimate) and remaining credits are clamped to the pool; every USD figure is an estimate, credits stay authoritative.

GET /admin/api/accounts now carries a boosted object per account. Admin responses also localize the quota snapshot consistently.

No WebUI changes in this PR (a separate UI PR can follow). Tested with go test ./... and go vet ./....

HardeNNN and others added 2 commits November 14, 2026 19:18
The upstream reports credit windows scaled to the model in use, so a static
plan cap misreports them; derive the monthly allowance from remaining credits
plus billing-period spend and keep the upstream window caps. Add the captured
Command Code per-model allowance table and expose a boosted view per account
(allowance, factor, remaining and window estimates), labelled as estimates.
Replace the hand-maintained JSON with cmd/gen-allowances, which reads the
Next.js RSC payload of the pricing page (the `models` array with
planAllowanceUsd) and writes a compact catalog: one JSON object per line,
still a single valid document, so the app parser is unchanged.

The file drops from 790 to 101 lines, and a model change is a one-line
diff. Regenerate with `go generate ./internal/app`; the generator leaves
the file and its capture date alone when the upstream data is unchanged.
The model set also picks up qwen-4-max, which was published after the
snapshot was taken.
@peach0x33a
peach0x33a merged commit 492e416 into peach0x33a:master Nov 16, 2026
3 checks 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.

2 participants