Repository navigation
Conversation
…its per-turn fields A Claude subscription with extra usage enabled spills into per-token "usage credits" once the plan allowance runs out (issue #12). The logs record no cut-over and no per-turn pool attribution, so this changes what Modelog says, never what it computes. detectBilling() now also reads oauthAccount.hasExtraUsageEnabled and yields a third mode, "subscription-extra", with copy stating plainly that the estimated/billed split is not knowable from disk. billingType alone was never stable enough to carry this: switching an account's payment method has been observed to flip it. Turn gains serviceTier (usage.service_tier — Anthropic's own field, distinct from Codex's OpenAI tier riding in `speed`) and fallbackCredit (usage.fallback_credit, the slot built for marking credit-billed turns; observed only as null, so a populated value is serialized verbatim for the day its shape is known). serviceTier joins the fail-closed modifier check: "standard" prices at 1x from a new service_tier table in pricing.json, and an unrecognised value — the card's Batch discount is real but its wire value unconfirmed — yields an unavailable cost rather than a wrong one. Verified against the real captured session: all 290 deduplicated turns carry "standard" and still price to the cost-state-exact $61.33 with zero unpriced. cost-state reconciliation ingestion (issue #12 item 3) is deliberately not here; it needs its own design pass. Assisted by Claude Code (Claude Fable 5).
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.
Summary
The detection-and-capture half of #12. A Claude subscription with extra usage enabled spills into per-token "usage credits" once the plan allowance runs out; the logs record no cut-over and no per-turn pool attribution, so this changes what Modelog says, never what it computes.
What changed
detectBilling()now also readsoauthAccount.hasExtraUsageEnabledand yields"subscription-extra", with dashboard and MCP copy stating plainly that the estimated/billed split is not knowable from disk.billingTypealone was never stable enough to carry this — switching an account's payment method has been observed to flip it. Precedence:prepaidstill wins (per-token billing is already real money). Themodelog.billingModesetting stays a binary override; only detection can land on the third state.TurngainsserviceTier(usage.service_tier— Anthropic's own field, distinct from Codex's OpenAI tier riding inspeed) andfallbackCredit(usage.fallback_credit, the slot built for marking credit-billed turns; observed only asnull, so a populated value is serialized verbatim for the day its shape is known, displayed nowhere, priced never).serviceTierjoins the modifier check:"standard"prices at 1× from a newservice_tiertable inpricing.json; an unrecognised value — the card's Batch discount is real but its wire value unconfirmed against a log — yields an unavailable cost rather than a wrong one.CAPTURE_VERSION3 so pre-capture rows report the gap honestly throughuncapturedFields.Validation
test/billing.test.tsmodeled on the realoauthAccountshape of the account that crossed into usage credits."standard"and still price to the cost-state-exact $61.33, zero unpriced — the new fail-closed modifier cannot regress existing data.Not in this PR
cost-statereconciliation ingestion (#12 item 3) — needs its own design pass; #12 stays open to track it.🤖 Generated with Claude Code