Repository navigation
feat(quota): derive per-model allowance and expose boosted usage - #14
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsoncaptures that catalog (98 models, with source and capture date) and is embedded in the binary.BoostedForreturns, 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/accountsnow carries aboostedobject 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 ./...andgo vet ./....