fix(spend): refresh independent history after token publications - #3239
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 27, 2026, 9:25 AM ET / 13:25 UTC. ClawSweeper reviewWhat this changesThe PR refreshes independent 365-day Usage & Spend histories when newer regular token publications arrive, with regression tests and documentation for the separate dashboard source. Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readinessThe refresh repair is focused and well-covered, but this owner-authored PR should remain open for maintainer flow; the exact-head macOS test shards are still running. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherCodexBar publishes short-window token snapshots for provider menus and separately scans local histories for the Usage & Spend dashboard. The new trigger makes the dashboard rescan its independent 365-day source after a newer regular publication. flowchart LR
A[Local provider history] --> B[Regular token publication]
B --> C[Dashboard freshness trigger]
C --> D[Independent 365-day scan]
D --> E[Dashboard data publication]
E --> F[Usage and Spend history]
B --> G[Coalesced later update]
G --> D
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the trigger-based refresh model, remove the release-owned changelog edit, and merge once the exact-head macOS shards pass. Do we have a high-confidence way to reproduce the issue? Yes—current-main source shows the independent history was considered current despite a newer regular publication, and the added deterministic fixture encodes the missed 365-day rescan. Is this the best way to solve the issue? Yes—the trigger is separate from dashboard data revisions, preserving the existing long-history authority and avoiding the short menu snapshot as a substitute. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d9e950e49c95. LabelsLabel justifications:
EvidenceAcceptance criteria:
What 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 (1 earlier review cycle)
|
|
Landed on main as e02e78d98274832305a72f4086bf4630edf83f77. Tested PR head: The original regression was executed before the fix: regular token publication advanced, but the populated independent dashboard stayed unchanged and omitted its next 365-day scan. The fix preserves full-history ownership, acknowledges only the regular revision captured before suspension, coalesces newer updates, and separates failure suppression from successful incorporation. Verification:
Commands executed: env -u CODEXBAR_ALLOW_TEST_KEYCHAIN_ACCESS CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 CODEXBAR_TEST_CODEX_FILE_ISOLATION=1 swift test --filter 'SpendDashboard|CostUsageScannerClaudeMemoTests|CostUsageScanExecutorTests|UsageStoreManualTokenRefreshTests|ProviderArchitectureGatekeeperTests|GrokXAISpendCatalogTests|GrokTokenSnapshotProjectionTests|CodexAccountScopedRefreshTests' --skip 'SpendDashboardScreenshotRenderTests'
env -u CODEXBAR_ALLOW_TEST_KEYCHAIN_ACCESS CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 CODEXBAR_TEST_CODEX_FILE_ISOLATION=1 swift test --skip-build --filter 'SpendDashboardFreshness'
env -u CODEXBAR_ALLOW_TEST_KEYCHAIN_ACCESS CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 CODEXBAR_TEST_CODEX_FILE_ISOLATION=1 make check
env -u CODEXBAR_ALLOW_TEST_KEYCHAIN_ACCESS CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 CODEXBAR_TEST_CODEX_FILE_ISOLATION=1 make test
git diff --checkThe new regressions use synthetic snapshots and temporary Claude JSONL/cache files with explicit dates, not real accounts or UI captures. The broader suite's discovered isolation gaps are not hidden by its successful retry result. The bot's package-manager setup failure occurred before Swift testing and is not a product test failure. The late bot P3 request to remove the changelog entry was not accepted: maintainer instructions require a one-line changelog entry for this user-facing fix. No accepted code or security finding remained at merge. No layout change, live provider/account/browser/Keychain/UI proof, real-midnight scheduler proof, or release is claimed. This does not close #3209 or #3176; the regular-menu Claude symptom still needs reporter details and a demonstrated cause. |
Summary
Regular token-history refreshes could leave an already-populated Usage & Spend dashboard unchanged: the regular publication advanced, but the independent dashboard configuration still compared equal. Adding the regular revision alone would not fix the refresh-missing decision and could let a short menu snapshot stand in for the dashboard's year of history.
Track the regular publication incorporated by each independent 365-day scan, separately from failed attempts and authoritative dashboard data revisions. Refresh only missing/outdated independent sources, coalesce publications arriving during a suspended scan, and preserve cancellation, ownership replacement, confirmed-empty, and stale-last-known behavior. Failed automatic attempts wait for newer data, relevant configuration changes, or explicit refresh rather than spinning.
Codex account-cache/catch-up and provider-derived spend ownership stay unchanged. The token-cost logging helper moves unchanged into its existing extension; architecture catalog edits only relocate existing anchors. Docs and changelog explain the behavior. Thanks @vinschger for the investigation context.
Verification
The regression was executed against the pre-fix implementation: four assertions failed because configuration stayed unchanged, loader calls remained
[365, 30]instead of[365, 30, 365], and the dashboard retained cost 12 instead of 15. It passes with this fix.make checkpasses with zero violations across 2,016 files;git diff --checkis clean.make testexits successfully: 945 selections across 79 groups. 77 groups passed first time; one cost-scanner group exceeded its 180-second group budget and all 12 selections passed in isolation, and a Gemini fake-fnm PID-file assertion passed on its group retry. These recovered failures are recorded, not presented as a first-pass clean run; their unchanged harness paths are queued for a separate repair.Maintainer review disposition: the bot's late P3 request to remove the changelog entry is not accepted. The maintainer instructions for this work require a changelog entry for user-facing fixes, and this is a maintainer-authored fix. The one-line entry stays. No code/security finding remains accepted or unresolved.
Commands:
The new freshness regressions use isolated test data; no live provider, account, browser, Keychain, or app UI proof is claimed. The broader suite exposed existing fixture-isolation gaps: some cost tests permit public pricing refreshes and default local trace/Pi paths. Those paths are unchanged by this patch and are queued for a fixture-only repair; the full-suite result is not a claim that every existing test is hermetic. There is no layout/rendering change. The new scanner clock and model projection use explicit fixture dates, not a real midnight scheduler test.
Investigated alongside #3209 and #3176, but does not close them: #3209's owner-confirmed screenshot is the regular provider-menu chart, not this independent dashboard, and its Claude root cause remains unproved. No claim to resolve #3194's quota/persistence issue or #3207's separate scanner fairness work.