CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Incomplete Pi mirror scan hides an established Claude native spend total

Open BUKOWSKIREAL opened this issue 2 months ago • 1 comments

Summary

On CodexBar 0.67.0, the shared usage overview shows Spend unavailable for Claude when the Pi/OMP session mirror is merged into Claude and that wider scan is incomplete. The Claude-native logs alone have an established history and a computed list-price estimate. The same token and cost totals are present on the merged snapshot; only historyCoverageIsEstablished flips to false, and the share card then drops the cost.

main still combines the flags the same way:

https://github.com/steipete/CodexBar/blob/main/Sources/CodexBarCore/CostUsageFetcher.swift#L959

Environment

  • CodexBar 0.67.0 (installed app / CodexBarCLI)
  • macOS
  • Claude provider enabled
  • Pi provider disabled

Pi being disabled is what selects the fallback merge. shouldIncludePiSessionsInTokenSnapshot returns true unless Pi is itself a cost source:

https://github.com/steipete/CodexBar/blob/v0.67.0/Sources/CodexBar/UsageStore%2BTokenCost.swift#L126-L134

Steps

  1. Leave the Pi provider disabled, with Pi/OMP session files on disk.
  2. Open Usage & Spend and share the overview for the last 30 days.
  3. Or reproduce the coverage flag with the CLI:
CodexBarCLI cost --provider claude --days 365 --format json
CodexBarCLI cost --provider claude --days 365 --format json --provider-native-only
CodexBarCLI cost --provider claude --days 30 --format json

The share overview does not use the 30-day window for the scan. SpendDashboardSource.scanDays is the all-time span (CostReportingPeriod.allTime.days).

Actual

Read historyCoverageIsEstablished Tokens List-price estimate
Claude, 365 days, default Pi merge false 519,876,325 $152.37
Claude, 365 days, --provider-native-only true 519,876,325 $152.37
Claude, 30 days, either mode true 519,876,325 $152.37

The merged 365-day scan has 5 daily rows; the native scan has 3. The share card then prints Claude: Spend unavailable, and the USD coverage line for that overview is 0/30 days.

A direct pi scan over 365 days is also historyCoverageIsEstablished: false. The persisted Pi cache window stays on the last complete span (here scanSinceKey 2026-08-28 through scanUntilKey 2026-09-28 in pi-sessions-v9.json). An incomplete expanded scan does not advance that window, so later all-time reads stay incomplete.

Expected

An incomplete Pi mirror should not blank a Claude native total that is already established. The merged row can be marked partial, or the overview can keep the native estimate. Spend unavailable should mean the cost was not computed.

--provider-native-only already returns the established native snapshot. The app also builds that native projection (PiSnapshotAccounting.includesPi), but the published inclusive snapshot is the one with coverage forced false, and historyScanIsPartial is left at its default false.

Code

v0.67.0 sets the inclusive coverage to native coverage AND Pi completeness:

historyCoverageIsEstablished: native.historyCoverageIsEstablished && piScanIsComplete

https://github.com/steipete/CodexBar/blob/v0.67.0/Sources/CodexBarCore/CostUsageFetcher.swift#L954

For Claude, native coverage starts out true (provider != .codex). The snapshot returned to the dashboard copies that inclusive flag and does not set historyScanIsPartial:

https://github.com/steipete/CodexBar/blob/v0.67.0/Sources/CodexBarCore/CostUsageFetcher.swift#L768-L779

coverageInterval then returns nil when coverage is unestablished and the scan is not partial, so every priced day is treated as invalid cost history and totalCost becomes nil:

https://github.com/steipete/CodexBar/blob/v0.67.0/Sources/CodexBar/SpendDashboardModel.swift#L720

https://github.com/steipete/CodexBar/blob/v0.67.0/Sources/CodexBar/SpendDashboardModel.swift#L1264-L1276

The share text maps a nil provider cost to Spend unavailable:

https://github.com/steipete/CodexBar/blob/v0.67.0/Sources/CodexBar/ShareStatsPayload.swift#L441

https://github.com/steipete/CodexBar/blob/v0.67.0/Sources/CodexBar/ShareStatsPayload.swift#L453

I have not isolated which Pi/OMP session file or directory keeps the expanded scan incomplete. The overview bug is the merge rule that hides the native Claude total once that flag is false.

The dollar amount above is a local API list-price estimate, not an Anthropic invoice.

BUKOWSKIREAL avatar Sep 27 '26 07:09 BUKOWSKIREAL

Codex review: this still needs some work. Reviewed September 27, 2026, 3:59 AM ET / 07:59 UTC.

Summary The reported spend display failure remains supported by current main: an incomplete Pi scan clears Claude’s inclusive coverage flag, while the dashboard requires either established coverage or a partial-scan marker to use priced rows. The reporter also supplied matching native and merged CLI results.

Reproducibility: yes. from source: merge an incomplete Pi scan with established Claude native history, then build the spend overview. The reporter supplied matching CLI observations; this read-only review did not execute them.

Next step Current main establishes a bounded coverage-metadata defect with a clear fetcher, dashboard, and test path.

Review details

Best possible solution:

Preserve the priced Claude subtotal with an honest partial-coverage indication when Pi scanning is incomplete, and cover the fetcher-to-share path with a focused regression test.

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

Yes, from source: merge an incomplete Pi scan with established Claude native history, then build the spend overview. The reporter supplied matching CLI observations; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. The existing partial-cost behavior provides a narrow way to retain a priced subtotal without claiming complete Pi coverage.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f79561136caa.

Label changes

Label changes:

  • add P2: A limited spend-view defect hides a computed estimate without stopping core usage.
  • add impact:ux-friction: The overview says spend is unavailable even though the local scan computed a price estimate.
  • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
  • add clawsweeper:source-repro: Current issue advisory state selects this label.
  • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
  • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

Label justifications:

  • P2: A limited spend-view defect hides a computed estimate without stopping core usage.
  • impact:ux-friction: The overview says spend is unavailable even though the local scan computed a price estimate.
Evidence reviewed

Acceptance criteria:

  • swift test --filter SpendDashboardPartialCostTests
  • make test
  • make check

What I checked:

Likely related people:

  • Yuxin Qiao: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
How this review workflow works
  • 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.

clawsweeper[bot] avatar Sep 27 '26 08:09 clawsweeper[bot]