feat(model): support internal model aliases - #1313
Conversation
|
no API key found — this repo is configured to use To fix: add the key as a GitHub Actions secret (referenced from your workflow's Open repo secrets → · Configure model → · Setup docs → · Ask in Discord →
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a model-aliases module (env-configured) and applies canonical model-name resolution across pricing lookups, usage aggregation, adapters/blocks, Codex aggregation, and cost reporting, plus tests and a test helper for alias overrides. ChangesModel alias resolution integration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | 7184607 | Commit Preview URL Branch Preview URL |
Jun 13 2026, 10:04 PM |
Add a runtime model alias resolver backed by CCUSAGE_MODEL_ALIASES so local runs can map raw provider slugs to canonical model names without adding a public CLI option or config schema field. Apply the alias during pricing and context-limit lookup, summary/model breakdown aggregation, blocks output, Claude daily fast aggregation, and Codex group aggregation so raw aliases do not leak into reports while costs resolve against the canonical model. Cover delimited and JSON alias formats, pricing lookup, Codex model key aggregation, and shared summary breakdown merging.
Collapse the nested suffix alias lookup into a let-chain so the model alias resolver passes the repository clippy settings on the rebased Rust toolchain. Validation: nix develop --command cargo test --manifest-path rust/Cargo.toml -p ccusage model_aliases; nix develop --command just fmt.
44384c7 to
0917422
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
ccusage
@ccusage/ccusage-darwin-arm64
@ccusage/ccusage-darwin-x64
@ccusage/ccusage-linux-arm64
@ccusage/ccusage-linux-x64
@ccusage/ccusage-win32-x64
commit: |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
|
no API key found — this repo is configured to use To fix: add the key as a GitHub Actions secret (referenced from your workflow's Open repo secrets → · Configure model → · Setup docs → · Ask in Discord →
|
There was a problem hiding this comment.
3 issues found and verified against the latest diff
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
rust/crates/ccusage/src/model_aliases.rs (1)
14-26: ⚡ Quick winConsider adding a doc comment to
resolve_model_name.The
-fastsuffix handling is clever but undocumented. A brief doc comment would help future maintainers understand that aliasing"gpt-5"automatically applies to"gpt-5-fast"as well.📝 Suggested doc comment
+/// Resolves a model name to its canonical alias, if configured. +/// +/// Returns the aliased model name from `CCUSAGE_MODEL_ALIASES`, or the original +/// model name if no alias is configured. Also handles `-fast` variants: if +/// `model` ends with `-fast` and the base model has an alias, returns +/// `"{alias}-fast"`. pub(crate) fn resolve_model_name(model: &str) -> Cow<'_, str> {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust/crates/ccusage/src/model_aliases.rs` around lines 14 - 26, Add a doc comment to the resolve_model_name function describing its behavior: explain that it looks up a model name in the model_aliases map and returns an owned alias when present, and that it also treats names ending with "-fast" specially by resolving the base model (e.g., "gpt-5-fast") and appending "-fast" to the aliased base (so an alias for "gpt-5" will also apply to "gpt-5-fast"); mention that it returns a borrowed model name when no alias is found and note the use of Cow<'_, str> as the return type. Reference the resolve_model_name function (and optionally model_aliases) in the comment so maintainers can find the related code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/ccusage/package.json`:
- Line 18: The docs still reference the removed entrypoint string "node
apps/ccusage/dist/cli.js"; search for that exact string in the profiling docs
and update each occurrence to "node apps/ccusage/src/cli.js" so it matches the
package.json bin entry ("ccusage": "./src/cli.js"); ensure all instances are
replaced (the commands and any examples) so the docs invoke the new entrypoint.
---
Nitpick comments:
In `@rust/crates/ccusage/src/model_aliases.rs`:
- Around line 14-26: Add a doc comment to the resolve_model_name function
describing its behavior: explain that it looks up a model name in the
model_aliases map and returns an owned alias when present, and that it also
treats names ending with "-fast" specially by resolving the base model (e.g.,
"gpt-5-fast") and appending "-fast" to the aliased base (so an alias for "gpt-5"
will also apply to "gpt-5-fast"); mention that it returns a borrowed model name
when no alias is found and note the use of Cow<'_, str> as the return type.
Reference the resolve_model_name function (and optionally model_aliases) in the
comment so maintainers can find the related code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a70f2164-8b26-49bb-8562-5567e33fc8fa
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (18)
.github/workflows/ci.yamlapps/ccusage/AGENTS.mdapps/ccusage/justfileapps/ccusage/package.jsonapps/ccusage/src/cli.jsapps/ccusage/src/cli.test.tsapps/ccusage/tsdown.config.tsjustfilepnpm-workspace.yamlrust/crates/ccusage/src/adapter/claude/daily.rsrust/crates/ccusage/src/adapter/codex/aggregate.rsrust/crates/ccusage/src/adapter/codex/mod.rsrust/crates/ccusage/src/blocks.rsrust/crates/ccusage/src/cost.rsrust/crates/ccusage/src/main.rsrust/crates/ccusage/src/model_aliases.rsrust/crates/ccusage/src/pricing.rsrust/crates/ccusage/src/summary.rs
💤 Files with no reviewable changes (2)
- pnpm-workspace.yaml
- apps/ccusage/tsdown.config.ts
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🧹 Nitpick comments (1)
rust/crates/ccusage/src/model_aliases.rs (1)
14-26: ⚡ Quick winConsider adding a doc comment to
resolve_model_name.The
-fastsuffix handling is clever but undocumented. A brief doc comment would help future maintainers understand that aliasing"gpt-5"automatically applies to"gpt-5-fast"as well.📝 Suggested doc comment
+/// Resolves a model name to its canonical alias, if configured. +/// +/// Returns the aliased model name from `CCUSAGE_MODEL_ALIASES`, or the original +/// model name if no alias is configured. Also handles `-fast` variants: if +/// `model` ends with `-fast` and the base model has an alias, returns +/// `"{alias}-fast"`. pub(crate) fn resolve_model_name(model: &str) -> Cow<'_, str> {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust/crates/ccusage/src/model_aliases.rs` around lines 14 - 26, Add a doc comment to the resolve_model_name function describing its behavior: explain that it looks up a model name in the model_aliases map and returns an owned alias when present, and that it also treats names ending with "-fast" specially by resolving the base model (e.g., "gpt-5-fast") and appending "-fast" to the aliased base (so an alias for "gpt-5" will also apply to "gpt-5-fast"); mention that it returns a borrowed model name when no alias is found and note the use of Cow<'_, str> as the return type. Reference the resolve_model_name function (and optionally model_aliases) in the comment so maintainers can find the related code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/ccusage/package.json`:
- Line 18: The docs still reference the removed entrypoint string "node
apps/ccusage/dist/cli.js"; search for that exact string in the profiling docs
and update each occurrence to "node apps/ccusage/src/cli.js" so it matches the
package.json bin entry ("ccusage": "./src/cli.js"); ensure all instances are
replaced (the commands and any examples) so the docs invoke the new entrypoint.
---
Nitpick comments:
In `@rust/crates/ccusage/src/model_aliases.rs`:
- Around line 14-26: Add a doc comment to the resolve_model_name function
describing its behavior: explain that it looks up a model name in the
model_aliases map and returns an owned alias when present, and that it also
treats names ending with "-fast" specially by resolving the base model (e.g.,
"gpt-5-fast") and appending "-fast" to the aliased base (so an alias for "gpt-5"
will also apply to "gpt-5-fast"); mention that it returns a borrowed model name
when no alias is found and note the use of Cow<'_, str> as the return type.
Reference the resolve_model_name function (and optionally model_aliases) in the
comment so maintainers can find the related code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a70f2164-8b26-49bb-8562-5567e33fc8fa
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (18)
.github/workflows/ci.yamlapps/ccusage/AGENTS.mdapps/ccusage/justfileapps/ccusage/package.jsonapps/ccusage/src/cli.jsapps/ccusage/src/cli.test.tsapps/ccusage/tsdown.config.tsjustfilepnpm-workspace.yamlrust/crates/ccusage/src/adapter/claude/daily.rsrust/crates/ccusage/src/adapter/codex/aggregate.rsrust/crates/ccusage/src/adapter/codex/mod.rsrust/crates/ccusage/src/blocks.rsrust/crates/ccusage/src/cost.rsrust/crates/ccusage/src/main.rsrust/crates/ccusage/src/model_aliases.rsrust/crates/ccusage/src/pricing.rsrust/crates/ccusage/src/summary.rs
💤 Files with no reviewable changes (2)
- pnpm-workspace.yaml
- apps/ccusage/tsdown.config.ts
🛑 Comments failed to post (1)
apps/ccusage/package.json (1)
18-18:
⚠️ Potential issue | 🟠 Major🧩 Analysis chain
🏁 Script executed:
#!/bin/bash # Description: Find references to the old dist/cli.js entry point rg -n --type=md --type=sh 'apps/ccusage/dist/cli\.js' rg -n --type=md --type=sh 'ccusage/dist/cli\.js'Repository: ccusage/ccusage
Length of output: 41
🏁 Script executed:
#!/bin/bash # Find references to the old dist/cli.js entry point (all file types) rg -n --hidden 'apps/ccusage/dist/cli\.js|ccusage/dist/cli\.js' . # Check whether the old file exists in the repo test -f apps/ccusage/dist/cli.js && echo "FOUND: apps/ccusage/dist/cli.js" || echo "NOT FOUND: apps/ccusage/dist/cli.js"Repository: ccusage/ccusage
Length of output: 1051
Fix outdated profiling docs referencing the removed
apps/ccusage/dist/cli.jsentrypoint
.agents/skills/profile/references/typescript.mdstill invokesnode apps/ccusage/dist/cli.js(e.g., lines 14, 26, 48-49, 59-60, 67).apps/ccusage/dist/cli.jsdoes not exist in this repo, so update those commands to point at the new entryapps/ccusage/src/cli.js(matchingapps/ccusage/package.json’s./src/cli.js).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/ccusage/package.json` at line 18, The docs still reference the removed entrypoint string "node apps/ccusage/dist/cli.js"; search for that exact string in the profiling docs and update each occurrence to "node apps/ccusage/src/cli.js" so it matches the package.json bin entry ("ccusage": "./src/cli.js"); ensure all instances are replaced (the commands and any examples) so the docs invoke the new entrypoint.
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
… allocation - Resolve model aliases before building the Codex dedupe key so an event recorded under both the alias and canonical name dedupes to a single entry instead of passing the seen-set twice and double-counting. - In summary aggregation, look up the breakdown index with the borrowed Cow and only call into_owned() on the insert path, avoiding a per-entry heap allocation when the model already exists. Co-authored-by: Codesmith <[email protected]>
Previously an env value starting with '{' that failed JSON parsing returned an
empty map, silently clearing every configured alias. Try delimited parsing
instead so partial misconfiguration is recoverable.
Co-authored-by: Codesmith <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rust/crates/ccusage/src/model_aliases.rs`:
- Around line 12-25: The test-only global lock TEST_MODEL_ALIASES_LOCK doesn't
prevent concurrent readers, so make it an std::sync::RwLock<()> and use it to
block readers while tests override aliases: change TEST_MODEL_ALIASES_LOCK's
type to RwLock<()>, acquire a write lock inside
set_model_aliases_for_tests()/ModelAliasesGuard creation to hold exclusive
access while aliases are overridden, and acquire a read lock in
resolve_model_name() (held for the duration of the function) so readers are
blocked until the test guard is dropped; update ModelAliasesGuard to store the
write lock guard so dropping it releases the lock, and ensure
resolve_model_name() obtains the read guard before accessing MODEL_ALIASES and
before calling model_aliases().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e3bf15ec-9b40-4c3c-bc6b-8a8855bb625c
📒 Files selected for processing (9)
rust/crates/ccusage/src/adapter/claude/daily.rsrust/crates/ccusage/src/adapter/codex/aggregate.rsrust/crates/ccusage/src/adapter/codex/mod.rsrust/crates/ccusage/src/blocks.rsrust/crates/ccusage/src/cost.rsrust/crates/ccusage/src/main.rsrust/crates/ccusage/src/model_aliases.rsrust/crates/ccusage/src/pricing.rsrust/crates/ccusage/src/summary.rs
✅ Files skipped from review due to trivial changes (1)
- rust/crates/ccusage/src/adapter/claude/daily.rs
🚧 Files skipped from review as they are similar to previous changes (6)
- rust/crates/ccusage/src/main.rs
- rust/crates/ccusage/src/blocks.rs
- rust/crates/ccusage/src/cost.rs
- rust/crates/ccusage/src/summary.rs
- rust/crates/ccusage/src/adapter/codex/mod.rs
- rust/crates/ccusage/src/adapter/codex/aggregate.rs
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
rust/crates/ccusage/src/model_aliases.rs (1)
41-55:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFallback delimited parsing still keeps wrapper braces in aliases.
On Line 41 fallback parsing runs on the raw
{...text when JSON decode fails, so common malformed values can produce unusable keys (for example,{private-alpha), reducing real recoverability.Suggested patch
fn parse_model_aliases(raw: &str) -> BTreeMap<String, String> { let trimmed = raw.trim(); if trimmed.starts_with('{') && let Ok(parsed) = serde_json::from_str::<BTreeMap<String, String>>(trimmed) { return parsed; } - trimmed + let delimited = if trimmed.starts_with('{') { + trimmed.trim_start_matches('{').trim_end_matches('}') + } else { + trimmed + }; + + delimited .split([',', ';', '\n']) .filter_map(|pair| { let (from, to) = pair.split_once('=')?; let from = from.trim(); let to = to.trim(); (!from.is_empty() && !to.is_empty()).then(|| (from.to_string(), to.to_string())) }) .collect() }- assert_eq!( - aliases.get("{private-alpha").map(String::as_str), - Some("gpt-5.5") - ); + assert_eq!( + aliases.get("private-alpha").map(String::as_str), + Some("gpt-5.5") + );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust/crates/ccusage/src/model_aliases.rs` around lines 41 - 55, The fallback delimited parser is run on the original trimmed string (which may still include leading '{' or trailing '}') when JSON decoding fails; strip surrounding braces before splitting so keys like "{private-alpha" aren't produced. Update the block after the serde_json::from_str::<BTreeMap<String, String>>(trimmed) check to create a cleaned string (e.g., use strip_prefix('{')/strip_suffix('}') or trim_matches('{').trim_matches('}') carefully) from trimmed, then run the split/filter_map/collect chain on that cleaned value instead of trimmed; keep the existing split([',',';','\n']) and the pair.split_once('=') logic unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@rust/crates/ccusage/src/model_aliases.rs`:
- Around line 41-55: The fallback delimited parser is run on the original
trimmed string (which may still include leading '{' or trailing '}') when JSON
decoding fails; strip surrounding braces before splitting so keys like
"{private-alpha" aren't produced. Update the block after the
serde_json::from_str::<BTreeMap<String, String>>(trimmed) check to create a
cleaned string (e.g., use strip_prefix('{')/strip_suffix('}') or
trim_matches('{').trim_matches('}') carefully) from trimmed, then run the
split/filter_map/collect chain on that cleaned value instead of trimmed; keep
the existing split([',',';','\n']) and the pair.split_once('=') logic unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a4712191-b75e-4ee4-b79f-e99541dd3c15
📒 Files selected for processing (3)
rust/crates/ccusage/src/adapter/codex/aggregate.rsrust/crates/ccusage/src/model_aliases.rsrust/crates/ccusage/src/summary.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- rust/crates/ccusage/src/summary.rs
…allback
rustfmt wants the multi-line call form for the now-longer add_deduped_event_to_groups
call. Also strip the outer { } before falling back to delimited parsing so a
malformed JSON value like {a=b} resolves to a sensible alias instead of leaving
braces embedded in the keys.
Co-authored-by: Codesmith <[email protected]>
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
Use strip_prefix('{') + strip_suffix('}') so a malformed-JSON-shaped value loses
exactly one outer { } pair, instead of trim_*_matches eating every leading or
trailing brace. Aliases that legitimately start or end with { or } now survive
the delimited fallback unchanged.
Co-authored-by: Codesmith <[email protected]>
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
Normalize Codex model names before dedupe key generation so private slugs and their canonical aliases cannot double-count copied token events. Fall back to delimited alias parsing when JSON-shaped env input is malformed, and avoid unnecessary summary aggregation allocation for existing model breakdowns.
|
@coderabbitai review |
✅ Action performedReview finished.
|
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |

Adds an internal runtime model alias resolver so local runs can map raw model slugs to canonical model names without exposing a public CLI flag or config schema option.
The alias is applied to pricing/context lookup and report aggregation paths, including Codex grouped model keys, Claude daily aggregation, shared summaries, and blocks output.
Testing:
Need help on this PR? Tag
/codesmithwith what you need. Autofix is enabled.Summary by cubic
Adds a runtime model alias resolver so local runs can map provider slugs to canonical model names via
CCUSAGE_MODEL_ALIASES(supportsa=b,c=dor JSON; honors-fast).Aliases apply to pricing/context-limit lookup and all report paths (summaries, blocks, Claude daily, Codex groups), resolve before Codex dedupe keys to prevent double-counting, show canonical names in missing-pricing and model lists, and on malformed JSON fall back to delimited parsing while stripping a single outer brace pair; summary aggregation avoids extra allocations when a model already exists.
Written for commit 7184607. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
Tests