Preserve spend totals while local history catches up - #3051
Preserve spend totals while local history catches up#3051mauriciopolvora wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
a597df3 to
fa7c088
Compare
|
Codex review: needs real behavior proof before merge. Reviewed August 18, 2026, 11:48 AM ET / 15:48 UTC. ClawSweeper reviewWhat this changesThis PR preserves an established Codex local spend total in the menu and Spend Dashboard while a bounded history refresh is incomplete, then replaces it after convergence. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain Keep this draft PR open. Current main lacks the compatible established-snapshot retention proposed here, and the branch has focused coverage with no definite code defect found; it still needs after-fix real-behavior proof before merge. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherCodexBar scans local Codex session files into cost snapshots for the menu and Spend Dashboard. Bounded scanning can temporarily leave history incomplete, so this change chooses a compatible established snapshot for presentation while catch-up continues. flowchart LR
A[Local Codex session files] --> B[Bounded history scan]
B --> C{Coverage established?}
C -->|Yes| D[Current cost snapshot]
C -->|No| E[Compatible retained snapshot]
D --> F[Menu and Spend Dashboard]
E --> F
B --> G[Catch-up scheduler]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain only same-scope established totals during pending scans, preserve the scanner’s incomplete coverage signal, and attach a redacted after-fix terminal or app trace that shows stable retained spend followed by convergence. Do we have a high-confidence way to reproduce the issue? Yes—source fixtures establish a compatible cache, append an active local-session tail, impose a bounded scan budget, and verify retained presentation while coverage remains pending; this review did not execute the test. Is this the best way to solve the issue? Yes—the patch preserves the existing incomplete scanner signal while retaining only compatible established presentation state, rather than treating incomplete data as complete. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 01f8d603b917. LabelsLabel changes:
Label 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
|
Summary
Root cause
An incomplete bounded refresh is a successful scan result, not a hard failure. It correctly carries
historyCoverageIsEstablished == false, and the Spend Dashboard correctly excludes such rows from totals. However, that successful incomplete result replaced the previous established snapshot, so Codex disappeared from Usage & Spend while Cursor remained visible.The existing retained-history path covered scanner failures, but not successful exact-to-pending transitions during routine refreshes.
Safety invariants
Validation
XCODE_DEFAULT_TOOLCHAIN_OVERRIDE=/Library/Developer/CommandLineTools make check— passed, 0 violationsCostUsageFetcherCacheSnapshotTests|SpendDashboardCachedPresentationTests|UsageStoreCodexCostCatchUpTests— 35 tests passed in 3 suitesmake test— attempted, but this host has Command Line Tools only and the unmodified runner cannot discover tests without Xcode'sTestingmodule; the focused suites were run with local framework paths and the pull-request CI uses the repository's Xcode 26.2/26.3 matrixThe regression fixture proves an exact scan, an appended active tail, a bounded pending refresh, an unchanged retained total, and an eventual complete replacement. Additional tests cover dashboard presentation and cross-scope rejection.
No screenshot is included because this changes state retention, not visual styling, and the available reproduction contains private account information.
Refs #2815, #2628, #2520, #2918.