-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Regression in v0.48.0: Standard/Fast cost split re-inflates deduplicated fork usage #2754
Copy link
Copy link
Closed
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Summary
CodexBar 0.48.0 can preserve the correct canonical Codex token total for a day/model while the new Standard/Fast cost split re-inflates the same usage by summing physical per-file pricing rows, including copied fork/subagent prefixes.
This appears to be a report-layer regression related to, but distinct from, #2037 and #2108: canonical token ownership is already deduplicated, but the mode-split cost path bypasses that ownership when building the final report.
Environment
historyCoverageIsEstablished = truecodexScanCatchUpPending = falseVerified invariant violation
For one day/model (
2026-08-06,gpt-5.6-sol):For a single day/model,
standardTokens + priorityTokensshould not exceed canonicaltotalTokens.Observed cost before applying a local guardrail:
After constraining the split to the canonical owned total:
The corrected 90-day result also independently cross-checks against the canonical aggregate input/cached-input/output totals and published model rates (within about 0.06%).
These values are API-equivalent estimates, not a claim about an actual subscription bill.
Source-level cause
In
CostUsageScanner+CacheHelpers.swift:reportCache.days[day][model].codexNanosByDayModelandcodexIntByDayModelindependently sum the cached mode-split maps across every physicalcache.files.valuesentry.codexRows, which can retain copied parent rows for pricing/audit.buildCodexReportFromCacheprefers:over
cachedBaseCostand canonical-token fallback pricing, without checking that the split token count is consistent withtotalTokens.As a result, the main token totals can be correct while the displayed Standard/Fast costs are multiplied by copied fork rows.
Relevant current-main file:
Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner+CacheHelpers.swiftReproduction outline
codex-v11.json, compare each canonicaldays[day][model]token total with the sum of per-filecodexStandardTokensandcodexPriorityTokensfor the same day/model.No prompt text, responses, account identifiers, session IDs, filenames, or local paths are needed to reproduce the invariant failure.
Expected behavior
Local guardrail tested
A local guardrail normalizes the Standard/Fast split only when its token sum exceeds canonical
totalTokens, preserving the relative Standard/Fast pricing mix while scaling it back to canonical ownership.Validation completed locally:
make checkpassedCostUsageScannerPriorityTestspassedI can provide the small patch and regression tests if that direction is useful.