Skip to content

Preserve spend totals while local history catches up - #3051

Merged
steipete merged 5 commits into
steipete:mainfrom
mauriciopolvora:fix-retained-spend-catch-up
Aug 25, 2026
Merged

Preserve spend totals while local history catches up#3051
steipete merged 5 commits into
steipete:mainfrom
mauriciopolvora:fix-retained-spend-catch-up

Conversation

@mauriciopolvora

@mauriciopolvora mauriciopolvora commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@mauriciopolvora
mauriciopolvora force-pushed the fix-retained-spend-catch-up branch from a597df3 to fa7c088 Compare August 18, 2026 15:44
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 5:31 PM ET / 21:31 UTC.

ClawSweeper review

What this changes

The PR retains established Codex spend totals during a same-scope bounded history refresh, records the exact retained report window, and safely migrates local cache metadata.

Regression provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No actionable correctness or security defect remains on the latest head. The PR resolves the earlier scope and retained-window concerns; keep it open for normal maintainer review once the running macOS checks finish.

Priority: P1
Reviewed head: b36c2ee1a1be6035844fd90c9f98466b26dfd807

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The current head has targeted regression coverage and sufficient proof; only the running macOS matrix remains before normal merge review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied PR context marks proof sufficient, and the current head includes focused after-fix cache, scope, and migration coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied PR context marks proof sufficient, and the current head includes focused after-fix cache, scope, and migration coverage.
Evidence reviewed 5 items Scope guard: Dashboard retention requires the same cached scope, which contains bucket time zone and history days, as well as the same account source identifier.
Retained report window: The retained report stores the actual request window and validates time zone, roots, and requested-window containment before reuse.
Upgrade handling: Compatible SQLite rows are adopted while retained-report payloads with old window semantics are cleared; focused tests cover both predecessor hashes.
Findings None None.
Security None None.

Live Verification

Command: swift test --filter SpendDashboardCachedPresentationTests

Result: FAIL (failed) — execution before step 1 run: sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz

sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz

Assertions:

  • FAIL expect_output: Test Suite

How this fits together

CodexBar scans local Codex session history into cached spend snapshots for the dashboard and CLI. During bounded catch-up, this change prevents an incomplete snapshot from replacing an established total unless its account, history window, and bucket time zone match.

flowchart LR
A[Local Codex session history] --> B[Cost usage scanner]
B --> C[SQLite spend cache]
C --> D{Coverage established?}
D -->|Yes| E[Publish new total]
D -->|No, same scope| F[Retain established total]
D -->|No, changed scope| G[Show incomplete result]
E --> H[Dashboard and CLI output]
F --> H
G --> H
Loading

Before merge

  • Resolve merge risk (P1) - Existing local SQLite caches adopt a new parser hash and selectively discard old retained-report payloads; the running macOS matrix is the remaining upgrade-path confirmation.
  • Complete next step (P2) - No mechanical repair remains; wait for the running macOS checks and complete normal maintainer merge review.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +125/-21, tests +340/-33, docs +4/-1 The cache and presentation changes have focused scope and migration regression coverage exceeding implementation growth.
Affected files 18 files affected The PR spans dashboard publication, scanner retention, SQLite adoption, documentation, and tests.

Merge-risk options

Maintainer options:

  1. Verify cache adoption before merge (recommended)
    Let the running macOS matrix complete on this head, especially the retained-report migration and scope-regression coverage.
  2. Pause for an upgrade regression
    Pause if the macOS cache-upgrade tests reveal a persisted database state outside the explicitly migrated predecessor hashes.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Wait for the macOS test matrix to pass on the current head, then merge if required checks remain green.

Technical review

Best possible solution:

Land the scoped retention and migration behavior after the current macOS matrix completes successfully.

Do we have a high-confidence way to reproduce the issue?

Yes: focused current-head tests create an established cached total, drive an incomplete Codex refresh, and assert retention only for the identical account, history window, and bucket time zone.

Is this the best way to solve the issue?

Yes: retaining only a previously established, scope-matched snapshot during bounded catch-up is the narrowest maintainable fix, with an explicit cache-version migration for older retained payloads.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 41d904fd6d88.

Labels

Label justifications:

  • P1: The PR fixes Codex spend totals that existing users may see during bounded local-history catch-up.
  • merge-risk: 🚨 compatibility: It changes existing SQLite cache adoption and displayed established-total behavior during upgrade.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied PR context marks proof sufficient, and the current head includes focused after-fix cache, scope, and migration coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied PR context marks proof sufficient, and the current head includes focused after-fix cache, scope, and migration coverage.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the latest head commit and has the largest observed contribution count on the cache-store path. (role: recent area contributor; confidence: high; commits: b36c2ee1a1be, 40297051639b; files: Sources/CodexBar/SpendDashboardController.swift, Sources/CodexBarCore/Vendored/CostUsage/CostUsageStore.swift)
  • Yuxin Qiao: Recent history includes Codex catch-up safety work and substantial spend-dashboard contributions. (role: recent adjacent contributor; confidence: high; commits: 75894c9fb983; files: Sources/CodexBar/SpendDashboardController.swift, Sources/CodexBarCore/Vendored/CostUsage/CostUsageStore.swift)
  • Alec Gutman, Chip: Merged history identifies this contributor on the shared Overview and dashboard spend-source integration. (role: feature-history contributor; confidence: medium; commits: 40297051639b; files: Sources/CodexBar/SpendDashboardController.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the running macOS test matrix to complete on the current head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-08-18T15:48:48.508Z sha fa7c088 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-19T09:39:21.955Z sha d3cf7c8 :: needs changes before merge. :: [P1] Guard retained totals by dashboard request scope
  • reviewed 2026-08-19T10:10:08.644Z sha 4a60d7f :: needs changes before merge. :: [P1] Preserve the existing cost cache across the parser-hash transition
  • reviewed 2026-08-20T10:12:43.781Z sha be8ca78 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-20T10:21:42.677Z sha be8ca78 :: needs maintainer review before merge. :: none

@mauriciopolvora
mauriciopolvora force-pushed the fix-retained-spend-catch-up branch from fa7c088 to d3cf7c8 Compare August 19, 2026 09:34
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 19, 2026
@mauriciopolvora
mauriciopolvora marked this pull request as ready for review August 19, 2026 09:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d3cf7c8ab1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner.swift
Comment thread Sources/CodexBar/SpendDashboardController.swift Outdated
@clawsweeper clawsweeper Bot added P1 Urgent regression or broken agent/channel workflow affecting real users now. and removed P2 Normal priority bug or improvement with limited blast radius. labels Aug 19, 2026
@mauriciopolvora
mauriciopolvora force-pushed the fix-retained-spend-catch-up branch from 4a60d7f to be8ca78 Compare August 20, 2026 10:08
@mauriciopolvora

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 20, 2026
Co-authored-by: Maurício Pólvora <mauricio.polvora@gmail.com>
@steipete
steipete merged commit 2613217 into steipete:main Aug 25, 2026
9 checks passed
@steipete

Copy link
Copy Markdown
Owner

Landed as 2613217 after rebasing onto current main and preserving contributor credit. Verified account-, history-window-, and time-zone-scoped spend retention with real session-log append/catch-up fixtures and real SQLite migration from the current production parser hash; existing usage rows survive without rebuilding while unsafe old retained reports are discarded. Full local suite: 931 selections across 78 groups, zero failures, retries, or timeouts. Formatting/lint, provider architecture gate, independent review, and hosted CI all passed. Thank you @mauriciopolvora!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants