Codex cost scan does not read `rollout-*.jsonl.zst`; history here starts 2026-10-01
Summary
On this Mac, ~/.codex/sessions/ and ~/.codex/archived_sessions/ hold 430 rollout-*.jsonl and 1,292 rollout-*.jsonl.zst files. Every rollout named for July–September is .jsonl.zst, and so are 285 named for October.
The Codex file listings in CodexBar 0.75.0's CostUsageScanner.swift keep only a jsonl extension or .jsonl suffix. With the files as they are on disk, codexbar cost --period all returns the same 10 October days as --period month-to-date, with historyCoverageIsEstablished: true. With the .jsonl.zst files decompressed, it returns 84 days starting 2026-07-01, with historyCoverageIsEstablished: false.
This morning the Codex month-to-date figures in the menu were below what I had seen there earlier; I did not capture the earlier values.
A comment on #4300 (6071589546, 2026-10-09) mentioned this and offered to open a separate issue. On main (052ded4136dd, checked 2026-10-14T14:13Z), the ledger's source and commit-message searches for zstd|zst\b|zstandard|libzstd|import\s+Compression|compression_decode match nothing. Issue and PR searches return #4300 for zst and jsonl.zst, and PR #3224 (OpenClaw) for zst. All results are in the ledger.
Comparison
Both columns use the same CLI on the same frozen copy of ~/.codex/sessions, ~/.codex/archived_sessions, state_5.sqlite and session_index.jsonl (taken 2026-10-14T13:10:38Z). The CLI is /opt/homebrew/bin/codexbar, which links to the app's CodexBarCLI and reports CodexBar 0.75.0.
- M is the copy as it was on disk.
- B was built from M by
cp -cR, then by decompressing each.jsonl.zstin place toNAME.jsonlwithzstd -q -d --rm. That gives 1,722rollout-*.jsonlfiles; mtime was unchanged on the three files checked.
Each value comes from the last --refresh pass, taken once coverage was established or totals repeated on three consecutive passes.
codexbar cost --provider codex --format json |
M: as on disk | B: .jsonl.zst decompressed |
|---|---|---|
--period all: days, first day |
10, 2026-10-01 |
84, 2026-07-01 |
--period all: totals.totalTokens |
4060539710 |
12057300041 |
--period all: totals.totalCost |
854.7406853999988 |
4736.557822819999 |
--period month-to-date: days |
10 | 13 |
--period month-to-date: totals.totalTokens |
4060539710 |
5852365486 |
--period month-to-date: totals.totalCost |
854.7406854000011 |
1219.5679654000016 |
historyCoverageIsEstablished (both periods) |
true |
false |
October days in B's month-to-date that are absent from M's, with B's values:
daily[].date |
totalTokens |
totalCost |
|---|---|---|
| 2026-10-02 | 232017725 |
57.66614760000003 |
| 2026-10-03 | 278882947 |
54.73677400000014 |
| 2026-10-05 | 213141280 |
43.39887519999999 |
Every run set HOME and CFFIXED_USER_HOME to a scratch directory; each run's cost-usage.sqlite is under its own directory. With no URL passed, the priority trace database resolves to homeDirectoryForCurrentUser/.codex/logs_2.sqlite (CodexPriorityDatabasePath.swift L7–19, CodexHomeScope.swift L51). The snapshot does not include that file, and I did not trace whether the cost scan passes a URL.
Both columns report provenance: listPriceEstimate, and coverage unpriced/estimated/unmetered = 0. A third copy, A, with the .jsonl.zst files deleted, gave the same daily dates and totalTokens as M for both periods. B's totals were identical on its last three passes.
The attached menu-card screenshot (account name erased; XMP CreateDate 2026-10-14T09:10:22-04:00) shows Month to date $853.44 and Month to date tokens 4.1B.
What is on disk
| Month in filename | .jsonl |
.jsonl.zst |
|---|---|---|
| 2026-07 | 0 | 180 |
| 2026-08 | 0 | 369 |
| 2026-09 | 0 | 458 |
| 2026-10 | 430 | 285 |
By root, sessions/ holds 179 .jsonl and 284 .jsonl.zst, and archived_sessions/ holds 251 .jsonl and 1008 .jsonl.zst. No name exists in both forms.
Decompressed, the .jsonl.zst files contain token_count events with non-null info: 19354 (July), 27086 (August), 24884 (September) and 15832 (October). The ledger quotes one such line with rate_limits removed.
openai/codex PRs describe Codex reading both forms. #51499 (merge a9bc7bebfa43) loads history "for both plain .jsonl and compressed .jsonl.zst files". #41357 (merge 1cc81ca89a0b) adds a reader "for plain and zstd-compressed files".
What the code does
Source is pinned at ed3c650e19e, the CodexGitCommit of the installed 0.75.0 (168).
docs/codex.md L379–381 lists the Codex sources as ~/.codex/sessions/YYYY/MM/DD/*.jsonl and ~/.codex/archived_sessions/*.jsonl. docs/providers.md L193 says the scan covers "sessions and sibling archived_sessions JSONL files".
Without a root override (L2235), the scanned roots are $CODEX_HOME/sessions (L2238–2240) and its sibling archived_sessions (L2247–2253). token_count lines are parsed at L3709 and L3777.
These are the Codex file filters in Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner.swift:
| Line | Function | Filter |
|---|---|---|
| 1472 | enumerateNextDirectory |
item.pathExtension.lowercased() == "jsonl" |
| 2604 | listCodexRecentlyModifiedFilesRecursive |
fileURL.pathExtension.lowercased() == "jsonl" |
| 2821 | listCodexSessionFilesByDatePartitionPage |
$0.lowercased().hasSuffix(".jsonl") |
| 2896 | listCodexSessionFilesByDatePartition |
item.pathExtension.lowercased() == "jsonl" |
| 2997 | advanceCodexCurrentWindow |
name.lowercased().hasSuffix(".jsonl") |
| 3388 | listCodexSessionFilesFlat |
item.pathExtension.lowercased() == "jsonl" |
| 3414 | listCodexLegacySessionFilesRecursive |
item.pathExtension.lowercased() == "jsonl" |
For rollout-….jsonl.zst, Foundation reports pathExtension as zst, and both predicates evaluate to false (checked with Swift 6.4). So none of these seven functions returns or enqueues a .jsonl.zst file. The pinned Sources and Package.swift have no match for zstd|zst\b|zstandard|libzstd|import\s+Compression|compression_decode.
Reproduction
Live, on this Mac: evidence/scripts/warm.zsh run against M and B, with the commands in the ledger, produced the comparison above.
Site survey
| Site | Reads | Effect on a .jsonl.zst |
How established |
|---|---|---|---|
CostUsageScanner.swift (the seven lines above) |
Codex sessions/ and archived_sessions/ listings |
filtered out | pinned source + Swift check |
CodexRequestLedger.swift:98 |
Codex session roots | filtered out by pathExtension == "jsonl" |
pinned source, not run |
Searched by: git grep -n -E 'pathExtension[^\n]*"jsonl"|hasSuffix\("\.jsonl"\)' ed3c650e19e -- Sources, which matched 16 sites. Eight sites not listed above were not examined: SettingsStore+TokenCost.swift:58, LocalAgentSessionScanner.swift:587 and AgentSession.swift:536, plus the Pi, Antigravity and Claude sites recorded in the ledger. Outside reach: callers that pass file lists into the scanner (for example enqueueCurrentFiles, L1485), which were not traced.
Environment
CodexBar 0.75.0 (168), CodexGitCommit ed3c650e19e (parent of tag v0.75.0, which changes only appcast.xml). codex-cli 0.162.1. macOS 27.0.1, arm64.
Evidence bundle
The attached evidence/ folder contains:
ledger.md: every command and its output, redacted as stated;scripts/warm.zsh;- the six CLI JSON captures for M, A and B (files named
mirrorare M), each with--period allandmonth-to-date, with.projectsremoved; - the screenshot and the pinned source files;
- a
README.mdmanifest with hashes.
Codex review: this still needs some work.
Summary This issue remains a source-proven accounting bug on current main, and an open PR explicitly owns the fix.
Reproducibility: Current discovery predicates necessarily reject .jsonl.zst files, corroborating the released-version reports; no live reproduction or attached-bundle validation was performed in this review.
Root-cause cluster
Relationship: canonical
Canonical: https://github.com/steipete/codexbar/issues/4523
Summary: This issue tracks compressed local-history omission, with one open PR proposing its repair.
Members:
fixed_by_candidate: https://github.com/steipete/codexbar/pull/4534 - The PR explicitly closes this issue and adds compressed-rollout decoding and discovery.partial_overlap: https://github.com/steipete/codexbar/issues/4300 - Its discussion corroborates compressed local-history omission, while its resolved central problem concerns cloud tasks without local records.
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Maintainer decision needed
- Question: Should the existing fix PR use its bundled zstd decoder and private full-transcript mirrors?
- Recommendation: Approve the bounded mirror design: Accept the codec and storage tradeoff, then complete review and integration of the existing PR.
- Why: The contributor explicitly requests this decision, and the repository requires confirmation before adding dependencies.
Next step Resolve the decoder and mirror-storage decision in https://github.com/steipete/CodexBar/pull/4534, then review and land that existing fix while keeping this issue open.
Review details
Best possible solution:
Include compressed rollouts through bounded, resumable decoding with accurate coverage and equivalent accounting across existing caches.
Do we have a high-confidence way to reproduce the issue?
Current discovery predicates necessarily reject .jsonl.zst files, corroborating the released-version reports; no live reproduction or attached-bundle validation was performed in this review.
Is this the best way to solve the issue?
The existing PR addresses the right boundary, but suffix changes alone cannot handle compressed bytes, logical offsets, resumed scans, and cache transitions.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
- The proposed fix's bundled decoder and storage of decompressed transcripts still need a maintainer decision.
- The reporter's decompressed comparison retains false coverage, so its stable totals do not establish complete historical accounting.
Codex review notes: model internal, reasoning medium; reviewed against 4654968e91f0.
Label changes
Label changes:
- add
clawsweeper:linked-pr-open: Current issue advisory state selects this label. - remove
clawsweeper:needs-maintainer-review: Current issue advisory state no longer selects this label.
Label justifications:
P2: Historical token and spend estimates omit valid local records, but provider access and original rollout data remain available.impact:other: The impact is understated financial estimates and misleading history completeness.
Evidence reviewed
What I checked:
- Current discovery excludes compressed rollouts: Both sessions and archived_sessions are scanned, but partition discovery accepts only names ending in .jsonl; flat and legacy discovery likewise require the jsonl extension. (
Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner.swift:2821, 4654968e91f0) - Coverage cannot account for excluded archives: Coverage evaluates cached file state and discovery progress; with no pending scan it can return true without including files rejected by discovery. (
Sources/CodexBarCore/Vendored/CostUsage/CostUsageStore+ReadView.swift:74, 4654968e91f0) - Accepting another suffix is insufficient: The reader opens a raw FileHandle and seeks byte offsets; no zstd decoder was found in current Sources or Package.swift. (
Sources/CodexBarCore/Vendored/CostUsage/CostUsageJsonl.swift:325, 4654968e91f0) - Open closing PR owns the repair: https://github.com/steipete/CodexBar/pull/4534 remains open and unmerged, explicitly closes this issue, and proposes bounded decompression into private cache mirrors; its author requests approval for the decoder dependency and disk footprint. (2914f1a6eaba)
- Independent corroboration and distinct earlier report: DevilVed corroborates missing compressed history on 0.76.0. In https://github.com/steipete/CodexBar/issues/4300, mjlens-spec separately identified compressed local rollouts; steipete closed that issue after establishing its central cloud-task usage had no local records.
- Feature-history routing: History identifies archived-root support in cf081b665eb0bec94df1153de36080d3f7cc4695, bounded fork accounting in 2920019bc16debacd299fbfbf555afda74ebed61, and paged discovery in 5cdc0171ea0c29d5e97c7ec8464cf09586307d88. Some historical blobs were unavailable locally, so REST commit patches supplied the relevant attribution. (
Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner.swift:2821, 5cdc0171ea0c)
How this review workflow works
- ClawSweeper keeps one durable marker-backed review comment per issue or PR.
- Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
- A fresh review can be triggered by eligible
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch. - PR/issue authors and users with repository write access can comment
@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto request a fresh review only. - Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
- Maintainers can comment
@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.
Reviewed October 22, 2026, 8:42 AM ET / 12:42 UTC.
Hitting this too on 0.76.0 (macOS), and it's pretty bad for me since most of my history is compressed now.
~/.codex/sessions has 33 plain .jsonl and 293 .jsonl.zst rollouts (~2.4 GB compressed). CodexBar only picks up the plain ones, so the scan reports 34 files / ~193 MB processed.
What I see in Usage & Spend → All for Codex: 136M tokens, ≥ $44.10
What's actually there: I ran a throwaway script that streams every rollout through zstd -dc and sums last_token_usage from the token_count events. That comes to ~1.46B tokens across 351 files (sessions + archived_sessions). By month:
2026/01 95K
2026/02 5.7M
2026/06 96M
2026/07 257M
2026/08 219M
2026/09 584M
2026/10 172M
archived 123M
Pricing those with the cached models.dev catalog (my own rough math, not CodexBar's) puts it at roughly $650. I remember the dashboard showing ~$380 a while back, so I think the numbers just dropped once Codex compressed the older rollouts.
The worst part is the dashboard still shows coverage as complete ("Coverage: 125 / 125"), so nothing hints that 90% of the tokens are missing. Even before zstd support lands, it'd help a lot if the scanner counted the .zst files it skipped and marked the history as partial.
Another data point on 0.80.0 (build 173, macOS). main is 0.80.1 and still has no zst anywhere under Sources/ or in Package.swift, so this should still apply.
Size of the gap, 30 days to 2026-10-24, Codex only
| Tokens | Requests | |
|---|---|---|
Ground truth (last_token_usage.input_tokens summed over both roots) |
15,365,163,897 | 107,468 |
CodexBar cost --provider codex --days 30 |
12,226,818,217 | 91,100 |
That is about 3.1 B tokens (20%) missing. The error follows the compression boundary exactly:
| Day | CodexBar / ground truth |
|---|---|
10-17, 10-19, 10-22 (still plain .jsonl) |
0.98 to 1.01 |
| 10-15 (compressed the same evening) | 0.61 |
| 09-28 | 0.40 |
| 09-25 to 09-27 | 0.00 |
What the cache looks like afterwards
- 4,389 tracked rollouts. 2,458 of them are recorded with
size = 0andscan_complete = 1and have notoken_snapshotsrows. 1,515 of those still exist on disk as.jsonl.zst. - Every
files.pathends in.jsonl. None ends in.zst. - Rollouts that were scanned before Codex compressed them keep their rows (171 of 291 for 10-15), so the loss looks partial rather than total.
Two questions for #4534 that this data raises
- Upgrade path for existing caches. These rows are keyed by the
.jsonlpath that no longer exists, and they are already marked complete. When the mirror replaces the plain file, are those rows re-scanned, or does the "complete, size 0" state keep them from ever being revisited? The PR's proof fixture starts from a cache that never saw the plain file, so it may not exercise this. - Until zstd lands, DevilVed's suggestion above would help: count skipped
.jsonl.zstfiles and mark history partial. Today the dashboard reports coverage as complete while about a fifth of the 30-day tokens are missing.
Smaller observation, not verified on 0.80.1: two rollouts (2.2 GB and 1.1 GB) sit at exactly parsed_bytes = 256 MiB in the cache. The per-file cap and per-refresh budget came in with #2452 and were revisited in #2823 and #3203, so this may already be handled; I have not checked against a current build.
Reproduce:
codexbar cost --provider codex --days 30 --format json | jq '.[0].totals'
sqlite3 "file:$HOME/Library/Caches/CodexBar/cost-usage/cost-usage.sqlite?mode=ro" \
"SELECT COUNT(*) FROM files WHERE size=0 AND scan_complete=1;"
ls ~/.codex/archived_sessions/*.jsonl.zst | wc -l
Fixed in #4534 (d7a61329135f). When Codex compresses a rollout it has already parsed into its .jsonl.zst sibling, CodexBar now keeps that rollout's cost history instead of dropping it, through parser updates, rescans, lookback changes and home switches. It reads no compressed content and keeps no decompressed copy, so history that was compressed before CodexBar ever parsed it is not backfilled (this is documented). It ships in the next release. Thanks for the report!