GeezerVison is showing github.com — fix(usage): count compressed Codex rollouts by Trench-Monster · Pull Request #22590 · pingdotgg/t3code
Conversation
Codex Usage skips compressed .jsonl.zst rollouts because discovery accepts only .jsonl and the parser expects decoded JSONL. Stream native zstd decompression into the existing parser, reuse unchanged-file caches, and reparse changed compressed snapshots from the beginning rather than applying decoded byte offsets to compressed input.
This is a focused fix for the existing Usage capability under the small, obvious bug-fix exception in CONTRIBUTING.md. It changes no usage source identity, accounting contract, provider configuration, or UI. Archived-session discovery is already covered by #21664/#21666. Related #21795 fixes compressed session imports, which use a different reader.
Verification on macOS arm64, Node 24.21.0:
- Before the fix, all six new regressions failed. The service counted 17 output tokens instead of the expected 40 from plain 17 + compressed 23.
- After the fix, 77 tests passed:
vp test run apps/server/src/usage/usageTranscriptReader.test.ts apps/server/src/usage/UsageService.test.ts apps/server/src/provider/Drivers/codexUsage.test.ts apps/server/src/usage/usageScanCache.test.ts.
- Tests cover long UTF-8 lines, native/projected JSON parsing, state and malformed-record parity, incomplete JSONL tails, decoder errors, disabled byte resume, refresh, copied-rollout deduplication, rewritten snapshots, and persisted-cache restart.
tsc-rs --noEmit -p apps/server/tsconfig.json and scoped lint/format passed.
This uses Node's native zstd decoder. Its existing truncated-frame and concatenated-frame limitations are unchanged (nodejs/node#64592, nodejs/node#64741); verification covers ordinary single-frame snapshots. No desktop/mobile UI run is claimed for this current-main branch.
Written with GPT-6 in Codex.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
chatgpt-codex-connector[bot] and VendettaGhub reacted with thumbs up emoji
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-10-21T01:16:05.160762Z |
4577aa1 |
PR opened |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Approvability
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — This focused fix adds zstd transcript discovery and decompression so compressed Codex rollouts contribute to usage totals, with extensive regression coverage. Because it changes usage metering behavior, it requires human review under the applicable criteria.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
9068d1af-7b15-4e18-a341-71ce50008dff
📥 Commits
-
Reviewing files that changed from the base of the PR and between 08dbf83 and 4577aa1.
📒 Files selected for processing: 3
-
apps/server/src/usage/UsageService.test.ts
apps/server/src/usage/usageTranscriptReader.test.ts
apps/server/src/usage/usageTranscriptReader.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
-
The transcript reader now discovers and parses .jsonl.zst files. Compressed reads start at the beginning and report zero resume and guard offsets. Tests cover parser behavior, deduplication, persistence, and service restarts.
Changes: Compressed transcript support
| Layer / File(s) |
Summary |
Compressed transcript discovery and parsing apps/server/src/usage/usageTranscriptReader.ts, apps/server/src/usage/usageTranscriptReader.test.ts |
Discovery includes .jsonl.zst files. The reader decompresses compressed transcripts and reads them from the beginning. Tests cover plain and compressed parsing, discovery filters, repeated reads, and corrupt input. |
Usage aggregation and persistence apps/server/src/usage/UsageService.test.ts |
The integration test checks deduplication of plain and compressed sessions, updated totals after a compressed-file rewrite, and consistent buckets after persistence and restart. |
Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~15 minutes
Change: Bug fix
Suggested reviewers: t3dotgg, tris203
Merge Risk: ⚪ Minimal · up to 4577a
-
Compressed Codex transcripts can contribute to usage totals without an identified merge-blocking issue. The change is ready for normal checks.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title clearly identifies the primary change: fixing usage counting for compressed Codex rollout files. It is concise and uses a conventional commit format. |
| Description check |
 |
The description covers the problem, implementation, scope, related issues, verification commands, observed results, limitations, and agent attribution. It addresses the small obvious bug-fix exception… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Description check
-
Explanation
The description covers the problem, implementation, scope, related issues, verification commands, observed results, limitations, and agent attribution. It addresses the small obvious bug-fix exception and clearly states the unverified UI scope.
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Windows verification
Tested on Windows 11 (Node 25.8.0, not the packaged desktop build), on the PR head 4577aa1 and cherry-picked onto current main (43879d9, includes #22558).
- Focused suites (
usageTranscriptReader, UsageService, codexUsage, usageScanCache): 78 passed, 2 skipped on main + PR.
- Real data: ran
listTranscriptFiles + readTranscriptRecords with codexUsageFormat over a real ~/.codex (sessions + archived_sessions). 3,130 of 3,249 rollouts are .jsonl.zst; all decoded, no read failures.
- Impact: without the PR, Codex Usage counts 4,023 requests / 0.53B tokens from the 119 uncompressed rollouts (the last 7 days). With it, 140,333 requests / 16.3B tokens.
Heads-up: once older rollouts are read, the existing Codex parser flags 59 records in 52 rollouts from July as malformed, so the skipped-usage warning will reappear for long-time users. That comes from older counter shapes, not decompression, and could be a follow-up.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Note Written by gpt-6.1-sol on behalf of Maria
thanks @Trench-Monster. your streaming decoder, full-snapshot rereads and unchanged-file cache reuse are the right scoped fix. github denied my push to your fork with 403 despite reporting maintainer edits enabled, so i published a replacement: https://git.cafe/pingdotgg/t3code/pulls/25453.
i compared your original diff against the replacement. all three changed files and all regression cases are preserved; nothing was dropped or moved. the patch is applied to current main, and the commit credits Michael with the requested co-author trailer. this pr remains open.
verification: all six compressed regressions fail on current main, all 95 focused tests pass with the fix, and blacksmith vp run check:changed passes format, lint, knip, graphql, affected typechecks and 59 adjacent tests. two independent reviews found no code blockers. the running web app with matching synthetic files changes from 270 tokens / one session to 600 / two. real Codex-generated frames, installed desktop/mobile and other operating systems remain unverified.
@Trench-Monster, the older counter-shape warning reported in the windows verification is a separate parser follow-up; it does not block this decompression fix. node's existing truncated/concatenated-frame limits remain documented in the replacement.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Closing in favour of #25453, which makes the same change. Thanks for the work here!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:S
10-29 changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|