Skip to content

fix(opencode): read v2 session usage - #1668

Merged
ryoppippi merged 3 commits into
mainfrom
codex/fix/opencode-v2-usage
Aug 30, 2026
Merged

ryoppippi merged 3 commits into
mainfrom
codex/fix/opencode-v2-usage

Conversation

@ryoppippi

@ryoppippi ryoppippi commented Aug 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #1644\n\nOpenCode v2 stores assistant usage in session_message.data instead of the legacy message table. This change:\n\n- reads nested assistant usage from session_message;\n- preserves legacy message loading;\n- supports session_v2 and current session aggregate schemas;\n- ignores non-assistant rows;\n- deduplicates shared message IDs;\n- avoids counting session aggregates when message-level usage exists.\n\nValidation:\n- OpenCode focused tests: 49 passed\n- rustfmt passed\n- clippy passed\n\nThe issue reporter is included as a commit co-author.


Summary by cubic

Fixes #1644. OpenCode v2 stores assistant usage in session_message.data instead of the legacy message table, so v2 usage was previously missing. This PR reads that usage and falls back to session_v2 or session aggregates when no message-level usage exists.

  • Deduplicates shared message IDs so the same message isn't counted twice.
  • Skips session aggregates when message-level usage exists for that session, across all configured directories.
  • Uses session aggregates only for unbounded Session reports, since cumulative totals can't be sliced to a date range.
  • Ignores non-assistant session_message rows.
  • Works with session_message schemas that lack a time_created column.
  • Parses reasoning tokens from v2 message data.

Written for commit 5592b88. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added support for importing usage data from OpenCode v2 sessions and messages.
    • Session-level usage information can now be imported when detailed message data is unavailable.
    • Improved recognition of model, provider, token, reasoning, and cost details across supported formats.
  • Bug Fixes

    • Prevented duplicate entries when messages appear in multiple sources.
    • Limited session-level fallback data to session reports.
    • Improved handling of missing timestamps, cost-only records, and bounded time ranges.
    • Preserved compatibility with legacy OpenCode databases.

Read assistant usage from OpenCode v2 session_message rows while preserving legacy message loading. Support historical session_v2 and current session aggregates, and avoid counting aggregate rows when message-level usage exists.

Co-authored-by: amirh-amini <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ccusage-guide 5592b88 Commit Preview URL

Branch Preview URL
Aug 30 2026, 10:56 AM

@coderabbitai

coderabbitai Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cee2b504-402f-40cd-82f8-dcd966ed0042

📥 Commits

Reviewing files that changed from the base of the PR and between 92fc162 and 5592b88.

📒 Files selected for processing (3)
  • rust/adapters/opencode/src/lib.rs
  • rust/adapters/opencode/src/loader.rs
  • rust/crates/ccusage-adapter-all/src/loader.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The OpenCode adapter now converts legacy and v2 usage data, including session aggregates. Aggregate fallback runs only for unfiltered Session reports. Message and aggregate entries are deduplicated across configured directories.

Changes

OpenCode report loading

Layer / File(s) Summary
V2 message and aggregate conversion
rust/adapters/opencode/src/parser.rs
The parser converts v2 messages and session aggregates into LoadedEntry values. It supports nested model references, reasoning tokens, and positive cost without tokens.
Report-scoped aggregate loading
rust/adapters/opencode/src/loader.rs
The loader collects entries across directories, deduplicates message and session data, and restricts cumulative aggregate fallback to unfiltered Session reports.
Report wiring and validation
rust/adapters/opencode/src/lib.rs, rust/adapters/opencode/src/loader.rs, rust/crates/ccusage-adapter-all/src/loader.rs
Report kind now reaches the OpenCode loader. Tests cover v2 loading, temporal filters, cross-directory suppression, report-specific fallback, and schema variants.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 5592b

This PR adds OpenCode v2 usage loading while preserving legacy data handling and preventing duplicate or inapplicable aggregate counts. No actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant ReportRunner
  participant OpenCodeLoader
  participant OpenCodeDatabase
  participant OpenCodeParser
  participant LoadedEntries
  ReportRunner->>OpenCodeLoader: request entries with report kind
  OpenCodeLoader->>OpenCodeDatabase: read message and aggregate rows
  OpenCodeDatabase-->>OpenCodeLoader: return source rows
  OpenCodeLoader->>OpenCodeParser: convert v2 messages and aggregates
  OpenCodeParser-->>OpenCodeLoader: return LoadedEntry values
  OpenCodeLoader->>LoadedEntries: deduplicate and append eligible entries
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 39.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 51 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: adding OpenCode v2 session usage support.
Linked Issues check ✅ Passed The changes satisfy issue #1644 by supporting session_v2 and session_message data, preserving legacy tables, parsing v2 usage payloads, filtering assistant rows, deduplicating message IDs, and prevent…
Out of Scope Changes check ✅ Passed The loader, parser, adapter integration, and focused tests all support the linked OpenCode v2 usage objectives. No unrelated code changes are identified.
Full details: Linked Issues check

Explanation

The changes satisfy issue #1644 by supporting session_v2 and session_message data, preserving legacy tables, parsing v2 usage payloads, filtering assistant rows, deduplicating message IDs, and preventing aggregate double-counting.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix/opencode-v2-usage

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.97.1)

Clippy execution failed


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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The aggregate fallback is currently emitted as a normal usage entry, which misattributes cumulative usage in daily, weekly, and monthly reports for sessions that cross reporting-period boundaries.

Reviewed changes

  • OpenCode v2 message loading — reviewed the new session_message query, assistant filtering, nested payload normalization, and ID deduplication alongside legacy SQLite and JSON sources.
  • Session aggregate fallback — reviewed the session_v2 and v2 session aggregate readers, model/cost parsing, date filtering, and conversion into report entries.
  • Compatibility coverage — reviewed the added fixtures for mixed schemas, missing time_created, duplicate IDs, date windows, and source detection. The focused adapter test suite passes with 50 tests.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Luna (free via Pullfrog for OSS) | 𝕏

Comment thread rust/adapters/opencode/src/loader.rs Outdated
@pkg-pr-new

pkg-pr-new Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

ccusage

npx https://pkg.pr.new/ccusage@1668

@ccusage/ccusage-darwin-arm64

npx https://pkg.pr.new/@ccusage/ccusage-darwin-arm64@1668

@ccusage/ccusage-darwin-x64

npx https://pkg.pr.new/@ccusage/ccusage-darwin-x64@1668

@ccusage/ccusage-linux-arm64

npx https://pkg.pr.new/@ccusage/ccusage-linux-arm64@1668

@ccusage/ccusage-linux-x64

npx https://pkg.pr.new/@ccusage/ccusage-linux-x64@1668

@ccusage/ccusage-win32-x64

npx https://pkg.pr.new/@ccusage/ccusage-win32-x64@1668

commit: 5592b88

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: 3824f7c14e26
Base SHA: ee74244517a7

This compares the PR package against the configured base package on the same CI runner.

Package runtime diagnostics

Compares 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
All rows run --offline --json, measured by hyperfine with 0 warmups and 1 runs. This isolates wrapper overhead from the installed native optional dependency and the workspace release binary built on the runner.

Command Runtime Input Median Throughput Samples
claude --offline --json Package wrapper 1.01 GiB 503.8ms 2.00 GiB/s 1
claude --offline --json Installed native binary 1.01 GiB 412.5ms 2.44 GiB/s 1
codex --offline --json Package wrapper 1.01 GiB 177.1ms 5.68 GiB/s 1
codex --offline --json Installed native binary 1.01 GiB 126.8ms 7.94 GiB/s 1

Committed fixture performance

Committed small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage.

Fixtures: Claude apps/ccusage/test/fixtures/claude (0.00 MiB, 2 files), Codex apps/ccusage/test/fixtures/codex (0.00 MiB, 1 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published ccusage package from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 2 warmups and 7 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude daily --offline --json 0.00 MiB 39.9ms 35.6ms 1.12x 55.50 MiB 54.75 MiB 0.99x 0.04 MiB/s 0.04 MiB/s
claude session --offline --json 0.00 MiB 33.2ms 31.2ms 1.06x 55.00 MiB 55.00 MiB 1.00x 0.05 MiB/s 0.05 MiB/s
codex daily --offline --json 0.00 MiB 53.6ms 47.8ms 1.12x 55.00 MiB 55.00 MiB 1.00x 0.02 MiB/s 0.02 MiB/s
codex session --offline --json 0.00 MiB 61.3ms 49.3ms 1.24x 55.00 MiB 55.00 MiB 1.00x 0.01 MiB/s 0.02 MiB/s

Large real-world-shaped fixture performance

Generated 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published ccusage package from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude --offline --json 1.01 GiB 586.6ms 541.7ms 1.08x 950.85 MiB 946.84 MiB 1.00x 1.72 GiB/s 1.86 GiB/s
codex --offline --json 1.01 GiB 193.7ms 169.8ms 1.14x 441.18 MiB 433.16 MiB 0.98x 5.20 GiB/s 5.93 GiB/s

Artifact size

Artifact Base PR Delta Ratio
packed ccusage-*.tgz 19.59 KiB 19.59 KiB +0.00 KiB 1.00x
installed native package binary 4302.16 KiB 4324.22 KiB +22.06 KiB 0.99x

Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees.

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: 3824f7c14e26
Base SHA: ee74244517a7

This compares the Rust PR release binary against the configured base package on the same CI runner.

Package runtime diagnostics

Compares 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
All rows run --offline --json, measured by hyperfine with 0 warmups and 1 runs. This isolates wrapper overhead from the installed native optional dependency and the workspace release binary built on the runner.

Command Runtime Input Median Throughput Samples
claude --offline --json Package wrapper 1.01 GiB 391.9ms 2.57 GiB/s 1
claude --offline --json Installed native binary 1.01 GiB 332.2ms 3.03 GiB/s 1
codex --offline --json Package wrapper 1.01 GiB 124.8ms 8.07 GiB/s 1
codex --offline --json Installed native binary 1.01 GiB 98.9ms 10.18 GiB/s 1

Committed fixture performance

Committed small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage.

Fixtures: Claude apps/ccusage/test/fixtures/claude (0.00 MiB, 2 files), Codex apps/ccusage/test/fixtures/codex (0.00 MiB, 1 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published native ccusage binary from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 2 warmups and 7 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude daily --offline --json 0.00 MiB 38.5ms 8.2ms 4.69x 55.00 MiB 24.71 MiB 0.45x 0.04 MiB/s 0.19 MiB/s
claude session --offline --json 0.00 MiB 34.4ms 8.0ms 4.28x 55.00 MiB 24.71 MiB 0.45x 0.04 MiB/s 0.19 MiB/s
codex daily --offline --json 0.00 MiB 31.0ms 7.7ms 4.04x 55.00 MiB 24.70 MiB 0.45x 0.03 MiB/s 0.11 MiB/s
codex session --offline --json 0.00 MiB 29.5ms 7.9ms 3.72x 55.00 MiB 24.70 MiB 0.45x 0.03 MiB/s 0.11 MiB/s

Large real-world-shaped fixture performance

Generated 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published native ccusage binary from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude --offline --json 1.01 GiB 388.3ms 349.0ms 1.11x 930.85 MiB 962.84 MiB 1.03x 2.59 GiB/s 2.89 GiB/s
codex --offline --json 1.01 GiB 122.9ms 107.8ms 1.14x 437.18 MiB 431.16 MiB 0.99x 8.19 GiB/s 9.34 GiB/s

Artifact size

Artifact Base PR Delta Ratio
packed ccusage-*.tgz 19.59 KiB 19.59 KiB +0.00 KiB 1.00x
installed native package binary 4302.16 KiB 4324.22 KiB +22.06 KiB 0.99x

Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread rust/adapters/opencode/src/loader.rs Outdated
Avoid adding cumulative session aggregates until all message sources are loaded, so legacy JSON messages suppress matching aggregate rows.

Skip aggregate-only fallback rows for bounded reports because cumulative totals cannot be sliced accurately. Preserve message-level legacy and v2 loading.

Co-authored-by: amirh-amini <[email protected]>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new aggregate gate still allows cumulative fallback rows into the default period reports, so the original cross-period misattribution remains.

Reviewed changes

  • Separated message and aggregate results — reviewed the new result type and the handoff between message entries and aggregate fallback entries.
  • Restricted aggregate fallback to bounded loads — checked the new date-window gate and its interaction with the adapter's report pipeline.
  • Added fallback coverage — reviewed the tests for bounded windows, JSON-backed messages, and current session schemas.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Luna (free via Pullfrog for OSS) | 𝕏

Comment thread rust/adapters/opencode/src/loader.rs Outdated
@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: 92fc162cc3c6
Base SHA: ee74244517a7

This compares the PR package against the configured base package on the same CI runner.

Package runtime diagnostics

Compares 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
All rows run --offline --json, measured by hyperfine with 0 warmups and 1 runs. This isolates wrapper overhead from the installed native optional dependency and the workspace release binary built on the runner.

Command Runtime Input Median Throughput Samples
claude --offline --json Package wrapper 1.01 GiB 376.9ms 2.67 GiB/s 1
claude --offline --json Installed native binary 1.01 GiB 357.5ms 2.82 GiB/s 1
codex --offline --json Package wrapper 1.01 GiB 122.6ms 8.21 GiB/s 1
codex --offline --json Installed native binary 1.01 GiB 101.1ms 9.96 GiB/s 1

Committed fixture performance

Committed small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage.

Fixtures: Claude apps/ccusage/test/fixtures/claude (0.00 MiB, 2 files), Codex apps/ccusage/test/fixtures/codex (0.00 MiB, 1 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published ccusage package from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 2 warmups and 7 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude daily --offline --json 0.00 MiB 35.5ms 37.5ms 0.95x 55.25 MiB 55.00 MiB 1.00x 0.04 MiB/s 0.04 MiB/s
claude session --offline --json 0.00 MiB 32.3ms 34.0ms 0.95x 55.00 MiB 55.00 MiB 1.00x 0.05 MiB/s 0.05 MiB/s
codex daily --offline --json 0.00 MiB 35.3ms 28.9ms 1.22x 55.25 MiB 55.00 MiB 1.00x 0.02 MiB/s 0.03 MiB/s
codex session --offline --json 0.00 MiB 31.0ms 32.5ms 0.96x 55.00 MiB 54.75 MiB 1.00x 0.03 MiB/s 0.03 MiB/s

Large real-world-shaped fixture performance

Generated 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published ccusage package from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude --offline --json 1.01 GiB 379.0ms 348.4ms 1.09x 954.86 MiB 968.85 MiB 1.01x 2.66 GiB/s 2.89 GiB/s
codex --offline --json 1.01 GiB 126.2ms 125.6ms 1.00x 445.17 MiB 433.17 MiB 0.97x 7.98 GiB/s 8.02 GiB/s

Artifact size

Artifact Base PR Delta Ratio
packed ccusage-*.tgz 19.59 KiB 19.59 KiB +0.00 KiB 1.00x
installed native package binary 4302.16 KiB 4325.72 KiB +23.56 KiB 0.99x

Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees.

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: 92fc162cc3c6
Base SHA: ee74244517a7

This compares the Rust PR release binary against the configured base package on the same CI runner.

Package runtime diagnostics

Compares 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
All rows run --offline --json, measured by hyperfine with 0 warmups and 1 runs. This isolates wrapper overhead from the installed native optional dependency and the workspace release binary built on the runner.

Command Runtime Input Median Throughput Samples
claude --offline --json Package wrapper 1.01 GiB 367.3ms 2.74 GiB/s 1
claude --offline --json Installed native binary 1.01 GiB 356.9ms 2.82 GiB/s 1
codex --offline --json Package wrapper 1.01 GiB 126.7ms 7.95 GiB/s 1
codex --offline --json Installed native binary 1.01 GiB 102.3ms 9.84 GiB/s 1

Committed fixture performance

Committed small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage.

Fixtures: Claude apps/ccusage/test/fixtures/claude (0.00 MiB, 2 files), Codex apps/ccusage/test/fixtures/codex (0.00 MiB, 1 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published native ccusage binary from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 2 warmups and 7 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude daily --offline --json 0.00 MiB 37.0ms 8.1ms 4.54x 55.00 MiB 24.72 MiB 0.45x 0.04 MiB/s 0.19 MiB/s
claude session --offline --json 0.00 MiB 30.2ms 8.1ms 3.72x 55.00 MiB 24.72 MiB 0.45x 0.05 MiB/s 0.19 MiB/s
codex daily --offline --json 0.00 MiB 29.7ms 8.6ms 3.46x 55.00 MiB 24.71 MiB 0.45x 0.03 MiB/s 0.10 MiB/s
codex session --offline --json 0.00 MiB 27.9ms 7.6ms 3.68x 55.00 MiB 24.71 MiB 0.45x 0.03 MiB/s 0.11 MiB/s

Large real-world-shaped fixture performance

Generated 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published native ccusage binary from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude --offline --json 1.01 GiB 380.9ms 356.9ms 1.07x 944.85 MiB 974.86 MiB 1.03x 2.64 GiB/s 2.82 GiB/s
codex --offline --json 1.01 GiB 122.8ms 100.0ms 1.23x 441.18 MiB 447.16 MiB 1.01x 8.20 GiB/s 10.07 GiB/s

Artifact size

Artifact Base PR Delta Ratio
packed ccusage-*.tgz 19.59 KiB 19.59 KiB +0.00 KiB 1.00x
installed native package binary 4302.16 KiB 4325.72 KiB +23.56 KiB 0.99x

Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread rust/adapters/opencode/src/loader.rs Outdated
Allow cumulative session rows only for session reports and unbounded requests, so period reports cannot group session totals by creation date. Collect message session IDs across configured directories before adding aggregate fallbacks while preserving legacy and v2 message deduplication.

Co-authored-by: amirh-amini <[email protected]>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Propagated report kind — passed AgentReportKind through the OpenCode loader and unified adapter wiring so loading can distinguish session reports from period reports.
  • Restricted cumulative fallback — limited session/session_v2 aggregate rows to unbounded session reports while retaining message-level loading for daily, weekly, and monthly reports.
  • Added regression coverage — covered unbounded period reports, bounded session requests, cross-directory message suppression, and session-only aggregate fallback behavior.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Luna (free via Pullfrog for OSS) | 𝕏

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: 5592b887e87b
Base SHA: ee74244517a7

This compares the Rust PR release binary against the configured base package on the same CI runner.

Package runtime diagnostics

Compares 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
All rows run --offline --json, measured by hyperfine with 0 warmups and 1 runs. This isolates wrapper overhead from the installed native optional dependency and the workspace release binary built on the runner.

Command Runtime Input Median Throughput Samples
claude --offline --json Package wrapper 1.01 GiB 386.7ms 2.60 GiB/s 1
claude --offline --json Installed native binary 1.01 GiB 350.5ms 2.87 GiB/s 1
codex --offline --json Package wrapper 1.01 GiB 120.3ms 8.37 GiB/s 1
codex --offline --json Installed native binary 1.01 GiB 100.1ms 10.06 GiB/s 1

Committed fixture performance

Committed small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage.

Fixtures: Claude apps/ccusage/test/fixtures/claude (0.00 MiB, 2 files), Codex apps/ccusage/test/fixtures/codex (0.00 MiB, 1 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published native ccusage binary from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 2 warmups and 7 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude daily --offline --json 0.00 MiB 38.5ms 11.1ms 3.45x 55.25 MiB 24.71 MiB 0.45x 0.04 MiB/s 0.14 MiB/s
claude session --offline --json 0.00 MiB 33.7ms 15.4ms 2.18x 54.75 MiB 24.71 MiB 0.45x 0.05 MiB/s 0.10 MiB/s
codex daily --offline --json 0.00 MiB 30.9ms 8.1ms 3.83x 54.75 MiB 24.71 MiB 0.45x 0.03 MiB/s 0.11 MiB/s
codex session --offline --json 0.00 MiB 29.5ms 7.8ms 3.79x 55.00 MiB 24.71 MiB 0.45x 0.03 MiB/s 0.11 MiB/s

Large real-world-shaped fixture performance

Generated 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published native ccusage binary from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude --offline --json 1.01 GiB 388.6ms 339.8ms 1.14x 950.85 MiB 950.85 MiB 1.00x 2.59 GiB/s 2.96 GiB/s
codex --offline --json 1.01 GiB 143.2ms 104.2ms 1.37x 449.17 MiB 453.17 MiB 1.01x 7.03 GiB/s 9.66 GiB/s

Artifact size

Artifact Base PR Delta Ratio
packed ccusage-*.tgz 19.59 KiB 19.59 KiB +0.00 KiB 1.00x
installed native package binary 4302.16 KiB 4322.84 KiB +20.69 KiB 1.00x

Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees.

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: 5592b887e87b
Base SHA: ee74244517a7

This compares the PR package against the configured base package on the same CI runner.

Package runtime diagnostics

Compares 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
All rows run --offline --json, measured by hyperfine with 0 warmups and 1 runs. This isolates wrapper overhead from the installed native optional dependency and the workspace release binary built on the runner.

Command Runtime Input Median Throughput Samples
claude --offline --json Package wrapper 1.01 GiB 387.4ms 2.60 GiB/s 1
claude --offline --json Installed native binary 1.01 GiB 345.8ms 2.91 GiB/s 1
codex --offline --json Package wrapper 1.01 GiB 127.1ms 7.92 GiB/s 1
codex --offline --json Installed native binary 1.01 GiB 99.9ms 10.08 GiB/s 1

Committed fixture performance

Committed small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage.

Fixtures: Claude apps/ccusage/test/fixtures/claude (0.00 MiB, 2 files), Codex apps/ccusage/test/fixtures/codex (0.00 MiB, 1 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published ccusage package from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 2 warmups and 7 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude daily --offline --json 0.00 MiB 35.3ms 36.1ms 0.98x 55.00 MiB 55.00 MiB 1.00x 0.04 MiB/s 0.04 MiB/s
claude session --offline --json 0.00 MiB 30.1ms 35.2ms 0.86x 55.00 MiB 55.00 MiB 1.00x 0.05 MiB/s 0.04 MiB/s
codex daily --offline --json 0.00 MiB 30.2ms 29.7ms 1.02x 55.00 MiB 55.25 MiB 1.00x 0.03 MiB/s 0.03 MiB/s
codex session --offline --json 0.00 MiB 30.5ms 28.5ms 1.07x 55.00 MiB 55.00 MiB 1.00x 0.03 MiB/s 0.03 MiB/s

Large real-world-shaped fixture performance

Generated 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 /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published ccusage package from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude --offline --json 1.01 GiB 419.4ms 381.8ms 1.10x 964.86 MiB 958.86 MiB 0.99x 2.40 GiB/s 2.64 GiB/s
codex --offline --json 1.01 GiB 146.2ms 127.8ms 1.14x 443.17 MiB 453.17 MiB 1.02x 6.88 GiB/s 7.88 GiB/s

Artifact size

Artifact Base PR Delta Ratio
packed ccusage-*.tgz 19.59 KiB 19.59 KiB +0.00 KiB 1.00x
installed native package binary 4302.16 KiB 4322.84 KiB +20.69 KiB 1.00x

Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees.

@ryoppippi
ryoppippi merged commit 033d25e into main Aug 30, 2026
63 of 66 checks passed
@ryoppippi
ryoppippi deleted the codex/fix/opencode-v2-usage branch August 30, 2026 16:45
azidancorp added a commit to azidancorp/ccusage that referenced this pull request Sep 7, 2026
Upstream through 8841f92: official Antigravity SQLite adapter (ccusage#1677),
ZCode (ccusage#1675) and Grok Build CLI sources, Copilot session-state usage
(ccusage#1676), Codex originator breakdowns and cache-write token accounting
(ccusage#1663, ccusage#1674), date-window file skipping (ccusage#1665), session totals scoped
to the date window (ccusage#1664), OpenCode v2 session usage (ccusage#1668),
timestamp-aware DeepSeek V4 pricing (ccusage#1679), ETag-validated pricing cache
refreshes (ccusage#1672), and numeric-column preservation in narrow tables
(ccusage#1671).

Conflict resolutions per the personal divergence ledger:

- Antigravity: adopt the upstream native adapter wholesale; remove the
  personal heuristic adapter and the antigravity-analysis/ provenance
  directory.
- Codex: keep counting copied parent history (replay.rs stays deleted),
  keep tier changes applying at the following turn_context, keep the
  pre-v0.144.0 fast windows and the 2x fast-multiplier fallback, and keep
  the append-aware grouped cache with serde'd parser state. Integrate
  upstream cache-write tokens, originator sources, session_meta line
  detection, and filter_codex_usage_files date-window skipping. Bump the
  group, per-file event, and all-agent row cache discriminators.
- Claude: rewire the cached daily/session summary wrappers onto
  upstream's date-scoped loaders (ccusage#1664).
- OpenCode: keep WAL-signature cache signatures, the summary cache
  wrapper, and --no-cost -> Display mapping; take upstream's v2 session
  usage loading and split directory loader.
- Pricing: keep the explicit GLM-5.2 rates and 1,000,000-token context
  limit (now via put_builtin_entry for both GLM-5.1 and GLM-5.2); take
  upstream's DeepSeek V4 scheduled rates and catalog rules.
- Terminal: keep full dates whenever the minimum full-date layout fits
  and attached breakdown rows; take upstream's content-aware fallback
  minimums and numeric-column floors, adapting the 80-column regression
  test to the personal full-date policy.
- Presentation: keep the hidden-by-default Models column and the
  all-agent --with-models opt-in; regenerate zcode/copilot session
  snapshots under the wider first-column floor.
- Ledger: audit baseline updated to 8841f92; heuristic Antigravity and
  replay suppression recorded as retired divergences.
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.

fix(opencode): read OpenCode v2 usage from session_v2/session_message tables

1 participant