fix(billing): one user-facing remaining everywhere = spendable balance#36
Merged
Merged
Conversation
Closes the billing-display class.
(b) Removed the duplicate credits_remaining key in /account/credits — dropped the
earlier allotment-remaining assignment so the authoritative balance is
returned by design, not by dict-ordering luck.
(a) Every USER-FACING "remaining"/balance surface now reads the authoritative
spendable credits_balance (hold-aware), so users see one consistent number:
- GET /account/credits (credits_remaining + calls_remaining)
- GET /account/alerts (low-credit thresholds fire off balance; the
forecast's daily burn now uses the ledger)
- GET /account/analytics ("remaining" = balance; "used this cycle"
stays ledger-derived)
- GET /billing/settings (credits_remaining + calls_remaining)
- POST /execute (batch) (response credits_remaining = balance after run)
/billing/balance + /auth/me already read credits_balance.
Allotment-remaining (plan allotment − settled cycle spend) stays as INTERNAL
quota math only — compute_calls_remaining() is retained (ledger-derived) for
internal quota/warning logic and is no longer surfaced to users. It differs
from balance by in-flight reserve holds, which belong under the hood.
Removed the now-unused compute_calls_remaining imports from the display routers.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes the billing-display class.
(b) Removed the duplicate
credits_remainingkey in/account/credits— balance returned by design, not dict-ordering luck.(a) Every USER-FACING "remaining"/balance surface now reads the authoritative spendable
credits_balance(hold-aware) → one consistent number everywhere:GET /account/credits,GET /account/alerts,GET /account/analytics("remaining"; "used this cycle" stays ledger),GET /billing/settings,POST /execute(batch response)./billing/balance+/auth/mealready read balance.Allotment-remaining (allotment − settled cycle spend) stays internal quota math only —
compute_calls_remaining()retained (ledger-derived) for warning thresholds, no longer user-facing. It differs from balance by in-flight reserve holds, which belong under the hood. Removed now-unused imports.🤖 Generated with Claude Code