fix(cost): preserve Pi session caches across Linux refreshes - #3446
Conversation
Follow the pricing-cache repair in #3444 by replacing the remaining redundant file swap with one atomic write. Preserve complete scan, pricing, timezone and provider state across repeated saves, and retain the best-effort persistence contract.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 5:09 AM ET / 09:09 UTC. ClawSweeper reviewWhat this changesThe PR makes Pi and OMP cost-cache saves use a single atomic write, adds repeated-save regression coverage, and updates cache documentation and release notes. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main and v0.56.6 retain the affected replacement sequence. No introduced correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherCodexBar scans Pi and OMP session logs into cached usage totals and scan checkpoints. Codex and Claude cost reports reuse that cache between scans. flowchart LR
A[Pi and OMP session logs] --> B[Session cost scanner]
B --> C[Usage totals and scan state]
C --> D[Atomic cache write]
D --> E[Version 8 cache file]
E --> F[Cached report reader]
F --> G[Codex and Claude cost reports]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Retain the existing version-8 cache contract while using one atomic destination write for both creation and refresh. Do we have a high-confidence way to reproduce the issue? Yes: repeatedly saving through the production Pi cache writer on Linux is a concrete reproduction path, and the body reports failure on save two before the fix. This read-only review inspected that path without executing it. Is this the best way to solve the issue? Yes: the single atomic write removes the redundant replacement step while preserving the existing serialized contract and failure behavior; no migration or competing implementation is introduced. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5e69a92232d8. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Pi-compatible session-cost caching had the same Linux replacement failure fixed for pricing catalogs in #3444: the second save could remove the cache file. A subsequent cached read then lost its saved scan state and totals and needed another scan.
This replaces the remaining temporary-write/replace sequence with one atomic destination write. The schema, cache path, timezone assignment, and best-effort save contract stay intact; an encoding failure also leaves the previous file untouched. Production is net −10 lines (2 added, 12 removed). The change includes a portable regression, an Unreleased changelog entry, and correction of the stale Claude documentation path to the existing v8 cache.
Validation:
make checkpasses, andmake testpasses all 1,026 selections across 86 groups on the first run without retries.This is a follow-up from auditing the remaining production use of
FileManager.replaceItemAt; it repairs the existing Pi/OMP history used by Codex and Claude cost reporting.