Preserve Codex cost usage window under byte pressure - #2825
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 13, 2026, 7:13 AM ET / 11:13 UTC. ClawSweeper reviewWhat this changesThe PR changes Codex cost-cache retention so byte-pressure cleanup preserves requested Spend Dashboard history and adds regression coverage for protected data. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain The current main branch still permits byte-budget deletion of requested-window cost data. This patch removes that path with focused SQLite regression coverage, but needs real-cache proof and explicit approval of the intentional best-effort storage-cap policy. Priority: P1 Review scores
Verification
How this fits togetherCodexBar scans local Codex cache files into a SQLite usage store that feeds Spend Dashboard history. Retention applies row and byte budgets before that stored history is read by the dashboard. flowchart LR
A[Codex cache files] --> B[Usage scanner]
B --> C[SQLite cost cache]
C --> D[Retention budgets]
D --> E[Requested report window]
E --> F[Spend Dashboard]
Decision needed
Why: The patch intentionally changes a data-storage behavior from preserving the cap to preserving displayed history, and VISION.md requires sign-off for that class of change. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Approve the fidelity-first policy only if allowing an over-cap local cache is acceptable, then retain this narrow safeguard and document the cap as best-effort behavior. Do we have a high-confidence way to reproduce the issue? Yes from source: current main passes Is this the best way to solve the issue? Unclear pending sign-off: changing the protection flag and removing the rebuild loop is the narrowest repair for lost displayed history, but accepting an over-cap database is a deliberate storage-policy choice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1f5bdb856e1d. 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 (6 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
502d123 to
166d5e0
Compare
Co-authored-by: Whiteknight07 <fiestyboxer@gmail.com>
166d5e0 to
8ee63cc
Compare
|
Rebased onto current Changes vs the previous head:
Proof: |
Summary
Root cause
The row-budget path protected the requested reporting window, but the byte-budget path explicitly disabled that protection. Deleting a file cascaded into
file_day_aggregates, so rebuilding global aggregates permanently removed older requested days from Spend Dashboard.The initial PR patch correctly enabled requested-window protection, but then fell back to
stripOldestRebuildableDetail. That reset protected files to incomplete, deleted their token/row/accumulator state, and marked catch-up pending. The next refresh would reconstruct the same detail, exceed the same cap, strip it again, and potentially repeat indefinitely.The maintainer revision uses a stable policy: delete only safe out-of-window completed files. Once every remaining file is protected, stop enforcement without mutating scan state. The current report and fork baselines remain authoritative, catch-up does not restart, and the database may remain above its best-effort byte cap.
Storage-policy decision
VISION.mdrequires explicit sign-off for data-storage behavior changes. This PR deliberately prioritizes requested-window report fidelity and stable refresh behavior over an absolute 256 MiB SQLite cap.Recommendation: approve the fidelity-first policy. A hard cap cannot be maintained for arbitrarily large requested windows without either deleting displayed history or introducing a larger durable aggregate-only storage design.
Validation
CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --filter CostUsageStoreTests— 60 tests passedCODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --filter CostUsagePerformanceGateTests— 25 tests passedmake check— passedCODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 make test— 834 selections in 70 groups passed; zero failures or retriesCostUsageStore/SQLite path and proves two consecutive over-cap enforcement passes retain in-window rows and report aggregates without setting catch-up pendingFixes #2823