fix(codex): preserve established-empty history - #2932
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 11:53 PM ET / August 15, 2026, 03:53 UTC. ClawSweeper reviewWhat this changesThe PR makes completed empty Codex local-history scans return zero token and cost totals after fresh scans and cache hydration, while incomplete scans remain unavailable. Merge readinessKeep open for normal merge review: current main still renders a completed empty Codex history as unavailable, while this focused patch preserves it as known zero and includes sufficient local after-fix proof. Priority: P2 Review scores
Verification
How this fits togetherCodexBar scans local Codex session files into a persistent usage cache, then derives token and cost snapshots for the dashboard and CLI. This change controls whether an empty scan result is presented as confirmed zero usage or unavailable history. flowchart LR
A[Codex session folders] --> B[History scanner]
B --> C[Usage cache]
C --> D{Coverage complete?}
D -->|Completed and empty| E[Known-zero snapshot]
D -->|Pending or incomplete| F[Unavailable snapshot]
E --> G[Dashboard and CLI]
F --> G
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge this narrow representation change once the current CI rerun confirms the focused cache behavior and aggregate workflow are green. Do we have a high-confidence way to reproduce the issue? Yes. Current main's empty-report path produces nil totals, while the supplied empty local-history fixture directly exercises the fresh-scan and cache-hydration paths the PR changes. Is this the best way to solve the issue? Yes. Representing only a completed, matching-scope empty scan as zero is the narrowest solution; the patch keeps pending, retry-buffered, and expanded-range states unavailable. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 844d3ece398b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
290bb3a to
aef668e
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Summary
User impact
This fixes the Codex usage/spend dashboard remaining unavailable after a completed local scan has established that the selected history is empty, without turning incomplete scans into fabricated zeroes.
Validation
swift test --disable-sandbox --filter 'CostUsageFetcherTests|CostUsageFetcherCacheSnapshotTests|CostUsageTokenSnapshotDaySelectionTests'git diff --checkVerification evidence
Redacted local fixture only; no Keychain, network, or real account was used.
CODEX_HOMEwithsessionsandarchived_sessionsdirectories.swift run --disable-sandbox CodexBarCLI cost --provider codex --format json --days 7 --refresh --json-only --no-colorreturnedsource=local,historyCoverageIsEstablished=true,sessionTokens=0,sessionCostUSD=0,last30DaysTokens=0,last30DaysCostUSD=0, anddaily=[].--refresh, returned the same zero fields andhistoryCoverageIsEstablished=true, demonstrating cache hydration of the established-empty result.