fix(claude): normalize anthropic model variants
Summary
- Normalize Anthropic-prefixed Claude model identifiers into the same grouping keys as canonical Claude model names.
- Add pricing aliases for Anthropic-prefixed Claude 4.5 and 4.6 variants so cost lookup resolves through existing canonical pricing.
- Add focused tests for grouping and pricing behavior across prefixed and canonical Claude model names.
Why
Some Claude usage sources report models as anthropic/claude-... while existing grouping and pricing paths expect canonical Claude names. Without normalization, equivalent Claude usage can split into separate model rows or miss known pricing aliases. This change keeps attribution consistent without changing parser behavior or token accounting.
Diff scope
crates/tokscale-core/src/lib.rscrates/tokscale-core/src/pricing/aliases.rscrates/tokscale-core/src/pricing/lookup.rs- Normalizes Anthropic-prefixed Claude variants for grouping.
- Adds pricing aliases for the supported prefixed Claude variant forms.
- No CLI flags, TUI behavior, database schema, package metadata, or release files changed.
Branch integrity
- Base branch:
main - Validated base SHA:
270d64c4d268d5bcc380690441d6a891687d6794 - Ahead/behind against
origin/main:0 behind / 1 ahead - Introduced commit:
5393e3d5037f41102936fa102cde0acade368be2 fix(claude): normalize anthropic model variants
Validation mode and proof
Mode 2 - narrow runtime change. The diff is isolated to model normalization and pricing alias lookup, with focused unit tests for the affected Claude paths.
Local validation on the final branch SHA:
cargo test -p tokscale-core test_normalize_model_for_grouping: PASScargo test -p tokscale-core anthropic_prefixed: PASScargo test -p tokscale-core claude: PASScargo test -p tokscale-core pricing::aliases: PASScargo fmt --all --check: PASSrustup run stable cargo clippy -p tokscale-core --all-targets -- -D warnings: PASSgit diff --check origin/main...HEAD: PASS, no outputgit diff --cached --check: PASS, no output
Ledger: not applicable - not required for this change family.
Version: not applicable - no package or release version changed.
Remote CI: Pending - not available until the pull request is opened.
Runtime safety
The change only maps recognized Anthropic-prefixed Claude model identifiers to existing canonical Claude names and aliases. It does not change token extraction, session parsing, aggregation math, persistence, or network behavior. Unknown model names still flow through existing fallback behavior. No invariant regression introduced.
Rollback plan
Rollback: revert this PR.
DB downgrade: not applicable.
Data repair: not applicable.
Operational caveats: reverting would restore split grouping or missing pricing for these Anthropic-prefixed Claude variant names.
Known residual risks
No known residual risks. Remote CI should validate the final PR SHA after the pull request is opened.
Summary by cubic
Normalize Anthropic-prefixed Claude model IDs to canonical names so usage groups correctly and pricing lookups use the right rates. Adds aliases for anthropic/claude 4.5/4.6 variants to reuse existing canonical pricing.
- Bug Fixes
- Map
anthropic/claude-<major>-<minor>-{opus|sonnet|haiku}toclaude-{family}-<major>-<minor>intokscale-coregrouping. - Add pricing aliases for
anthropic/claude-4-5-*andanthropic/claude-4-6-*so cost lookup matches canonical entries. - Add focused tests covering grouping and pricing for prefixed and canonical names.
- Map