Skip to content

fix(usage): count compressed Codex rollouts - #22590

Closed
Trench-Monster wants to merge 1 commit into
pingdotgg:mainfrom
Trench-Monster-Contribs:codex/count-compressed-codex-usage
Closed

Trench-Monster wants to merge 1 commit into
pingdotgg:mainfrom
Trench-Monster-Contribs:codex/count-compressed-codex-usage

Conversation

@Trench-Monster

Copy link
Copy Markdown
Contributor

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.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants