Skip to content

fix(usage): correct replay and pricing accounting - #1437

Closed
camjac251 wants to merge 3 commits into
ccusage:mainfrom
camjac251:fix/pricing-aliases
Closed

fix(usage): correct replay and pricing accounting#1437
camjac251 wants to merge 3 commits into
ccusage:mainfrom
camjac251:fix/pricing-aliases

Conversation

@camjac251

@camjac251 camjac251 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Correct usage reports that can count inherited child-session history more than once, and fix several pricing paths involving speed tiers, default family aliases, and partial overrides.

Current child-session rollouts now establish an inherited baseline before counting the child's advancing usage. Unknown speed-tier rates retain standard pricing, while known aliases resolve to their documented default entries before fuzzy matching.

What Changed

  • exclude inherited parent-history prefixes from current child-session usage
  • retain timestamp-based compatibility handling for older replay formats
  • suppress repeated request deltas when cumulative totals do not advance
  • preserve usage produced by the child around the durable turn boundary
  • require an explicit multiplier before adjusting speed-tier costs
  • resolve known family aliases before fuzzy pricing and context lookup
  • preserve exact overrides and merge partial overrides onto canonical pricing
  • mark golden snapshots as text and remove obsolete timing-inference notes
  • add regression coverage for nested replay, legacy fallback, pricing, aliases, thresholds, and overrides

Notes

  • Report schemas and table layouts are unchanged.
  • Unknown speed-tier rates remain at the standard estimate until an explicit multiplier is available.
  • Exact pricing entries continue to take precedence over aliases and fuzzy matching.
  • All committed fixtures use synthetic identifiers, timestamps, paths, and token values.

Testing

  • nix --extra-experimental-features 'nix-command flakes' develop -c cargo test --manifest-path rust/Cargo.toml --workspace adapter::codex
  • nix --extra-experimental-features 'nix-command flakes' develop -c just test
  • nix --extra-experimental-features 'nix-command flakes' develop -c just typecheck
  • nix --extra-experimental-features 'nix-command flakes' flake check
  • git diff --cached --check
  • staged secret scan
  • local-data smoke comparison without committing source records

Related: #1434, #1436

Fast pricing previously doubled usage whenever a model lacked a known
multiplier, which turned missing rate data into an unsupported estimate.

Apply only explicit multipliers, keep unknown rates at standard pricing,
refresh the report snapshot, and remove the obsolete timing-inference
scratch plan.
A global package-file rule can classify Rust golden snapshots as binary,
hiding reviewable output changes.

Override that classification only under snapshot directories while leaving
actual package archives binary.
The unsuffixed family alias matched the longest sibling key and selected
the balanced tier rather than the documented flagship tier.

Preserve exact user overrides, resolve canonical aliases before fuzzy
fallback, and apply the same mapping to context limits and request-tier
thresholds. Partial overrides now inherit unspecified canonical rates.
@github-actions

Copy link
Copy Markdown
Contributor

This PR was auto-closed. Only contributors approved with lgtm can open PRs. Open an issue first.

Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.

If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

See CONTRIBUTING.md.

@github-actions github-actions Bot closed this Jul 12, 2026
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cde32c89-9920-4284-ba08-e8910d00df9a

📥 Commits

Reviewing files that changed from the base of the PR and between ba99c0d and 2500c5b.

⛔ Files ignored due to path filters (1)
  • rust/crates/ccusage/src/adapter/codex/snapshots/ccusage__adapter__codex__tests__snapshots_codex_reports_for_periods_sessions_costs_and_fallback_models.snap is excluded by !**/*.snap
📒 Files selected for processing (6)
  • .gitattributes
  • codex-speed-infer-plan.md
  • docs/guide/codex/index.md
  • rust/crates/ccusage/src/adapter/codex/mod.rs
  • rust/crates/ccusage/src/adapter/codex/report.rs
  • rust/crates/ccusage/src/pricing.rs

📝 Walkthrough

Walkthrough

Updated pricing alias resolution, Codex fast-pricing fallback behavior, related documentation and tests, snapshot attributes, and removed the Codex speed inference plan.

Changes

Codex pricing behavior

Layer / File(s) Summary
Pricing alias resolution and overrides
rust/crates/ccusage/src/pricing.rs
Exact pricing and context-limit keys now take precedence, aliases support overrides and long-context thresholds, and gpt-5.6 maps to gpt-5.6-sol with coverage tests.
Codex fast-pricing calculation
rust/crates/ccusage/src/adapter/codex/report.rs, rust/crates/ccusage/src/adapter/codex/mod.rs, docs/guide/codex/index.md
Fast pricing uses the configured model multiplier directly; tests and documentation cover fallback to standard pricing when no multiplier exists.
Snapshot attributes and plan cleanup
.gitattributes, codex-speed-infer-plan.md
Snapshot files are configured as LF text outputs, and the Codex speed inference plan is removed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: ubugeeei, pullfrog, ryoppippi

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@camjac251 camjac251 changed the title fix(pricing): correct speed rates and family aliases fix(usage): correct replay and pricing accounting Jul 12, 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.

1 participant