Skip to content

fix(billing): one user-facing remaining everywhere = spendable balance#36

Merged
WayforthOfficial merged 1 commit into
mainfrom
fix/unify-remaining-on-balance
Jun 21, 2026
Merged

fix(billing): one user-facing remaining everywhere = spendable balance#36
WayforthOfficial merged 1 commit into
mainfrom
fix/unify-remaining-on-balance

Conversation

@WayforthOfficial

Copy link
Copy Markdown
Owner

Closes the billing-display class.

(b) Removed the duplicate credits_remaining key 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/me already read balance.

Allotment-remaining (allotment − settled cycle spend) stays internal quota math onlycompute_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

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>
@WayforthOfficial WayforthOfficial merged commit 690e822 into main Jun 21, 2026
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