fix(codex): resume interrupted warm cost scans - #3490
Conversation
Retain unvalidated file work and completed discovery when a timed warm refresh becomes catch-up work. Compatible same-day history requests keep the established scan range while rendering only their requested days. Preserve the separate exact-inventory publication gate and adopt the immediate predecessor parser fingerprint without rebuilding native rows. Refs #3411
|
🦞👀 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 8, 2026, 12:55 AM ET / 04:55 UTC. ClawSweeper reviewWhat this changesPreserve unfinished Codex cost scans across timed refreshes and compatible history windows, with regression tests and adoption of existing SQLite caches. Merge readiness✅ Ready for maintainer review This remains a useful repair: current main does not retain unfinished timed-warm scan work. No blocking defects were found, and the owner's final verification addresses resume behavior and cache compatibility. Priority: P2 Review scores
Verification
How this fits togetherCodexBar scans local Codex session files into a SQLite cost-history cache. Budgeted refreshes feed usage reports and the Spend Dashboard, which wait for validated inventory before publishing complete coverage. flowchart TD
A[Local session files] --> C[Budgeted cost scan]
B[Requested history window] --> C
C --> D{Work remains?}
D -->|Yes| E[Save pending work in SQLite]
E --> C
D -->|No| F[Validate exact inventory]
F --> G[Publish requested cost report]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Reuse the existing durable scan queue and cache-adoption mechanism while preserving requested report windows and exact-inventory publication. Do we have a high-confidence way to reproduce the issue? Yes: interrupt a populated timed warm scan after one file, then alternate compatible narrow and wide history requests. Current-main source explains the lost queue, and the owner reports reproducing it with production core and SQLite; this reviewer did not execute it. Is this the best way to solve the issue? Yes: extending the existing queue lifecycle is a narrow repair, and the patch preserves forced-scan behavior, byte-only scheduling, report filtering, and cache compatibility. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2a71b479a5d4. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
Maintainer verification complete on
Land-ready. Keep #3411 open for its broader managed-account report. Changelog is consolidated in #3491; no merge was performed here. |
A timed warm Codex cost refresh could validate one file, discard the remaining current-window cursor, and mark the cache pending. The next wider request then rediscovered and requeued already-validated files. On large histories this repeats catch-up work and delays spend publication.
Save the unvalidated candidates before the existing lookback completion logic removes successful work. Preserve completed discovery and use the established same-ending-day scan range when compatible timed requests alternate between shorter and wider reports. Each report still renders its requested interval. The separate exact-inventory pass remains mandatory before publication.
The generated parser fingerprint changes because the shared scanner is a hash input. Native parsing and stored-row semantics are unchanged, so the immediate predecessor fingerprint is adopted through the existing compatibility mechanism, with adoption, receipt-invalidation, and zero-head-parse regression coverage.
Related to #3411. This fixes the independently reproduced timed-warm-refresh path; it deliberately does not close the broader managed-account report Peter kept open. Thanks @kesslerio for the report.
Validation:
make checkpassed, including the regenerated parser hash.CostUsageBoundedProgressTestspassed. They cover the lost cursor, alternating windows, preservation of older coverage, requested-range filtering, and the exact-validation gate.make testpassed 1,033 selections across 87 groups, with one unrelated display-only settings group recovering on its single retry. Exact-head CI succeeded on1fb4f893155f4192ed630908b80d2df5823bf15a.9ca89383b9957b07; the new binary adopted it as7f00691fa96c78d1while every owned session file was chmod 000. Both returned established coverage, 56,430 tokens, and the same USD 0.177498 total. Modes were restored and fixtures removed afterward. This proves compatible rows survive without reparsing source files.The changelog line is collected in the batch's separate final notes PR.