Repository navigation
Commit 44a3aa8
fix(codex): read Zstandard-compressed rollouts (#1890)
* refactor(adapter): collect usage files with a path predicate
Add collect_files_matching so an adapter can gather files that do not
share one extension, such as plain and compressed rollouts, in a single
directory walk. collect_files_with_extension now delegates to it.
Co-authored-by: Henry Teo <[email protected]>
* fix(codex): read Zstandard-compressed rollouts
Since the 2026-10-14 Codex update, cold rollouts under sessions/ and
archived_sessions/ are migrated to .jsonl.zst. The adapter only
discovered .jsonl, so compressed sessions were skipped and totals such
as codex monthly lost a large share of their tokens.
Discover both encodings in one walk and stream .jsonl.zst through the
zstd decoder into the existing parser, replay metadata probe, and
rewritten-burst detection. Session IDs and the cross-directory dedupe
key use the plain .jsonl path, so IDs stay stable and a rollout with
both a plain and a compressed copy is counted once. The plain copy
wins, matching Codex, which restores it before deleting the .zst when a
compressed session is resumed. If a file switches encoding between
discovery and open, the other encoding is read instead.
Fixes #1888
Co-authored-by: Henry Teo <[email protected]>
* docs(codex): document compressed rollout support
Note that Codex session logs are read as plain .jsonl or .jsonl.zst,
how duplicate encodings are resolved, and that session lookup accepts
the .jsonl.zst filename.
Co-authored-by: Henry Teo <[email protected]>
* fix(codex): date headless usage from the rollout actually opened
When a discovered rollout is compressed or restored before it is read,
the reader opens the other encoding, but the fallback timestamp for
timestamp-less headless usage still came from the vanished path and
fell back to 1970. Return the opened path from open_rollout_reader and
take the modification time from it.
Reported by cubic on #1890.
Co-authored-by: Henry Teo <[email protected]>
* docs(codex): clarify rollout precedence and data paths
Scope plain-over-compressed precedence to one directory and state that
sessions/ beats archived_sessions/ regardless of encoding. List every
recursive rollout path, and attribute ordered parallel reads to
loader.rs rather than ccusage-adapter-common.
Reported by cubic on #1890.
Co-authored-by: Henry Teo <[email protected]>
---------
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Henry Teo <[email protected]>1 parent fc21e2c commit 44a3aa8
17 files changed
Lines changed: 713 additions & 28 deletions
File tree
- docs/guide
- codex
- rust
- adapters
- codex
- src
- common
- src
- crates/ccusage
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
26 | | - | |
27 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
| 68 | + | |
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
0 commit comments