Incomplete Pi mirror scan hides an established Claude native spend total
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
- Leave the Pi provider disabled, with Pi/OMP session files on disk.
- Open Usage & Spend and share the overview for the last 30 days.
- 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.
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:
- Inclusive coverage: Current main combines native coverage with Pi scan completeness, so incomplete Pi history clears coverage even when Claude native history is established. (
Sources/CodexBarCore/CostUsageFetcher.swift:959, f79561136caa) - Missing partial marker: The inclusive snapshot receives the combined coverage flag, while the native projection is built separately; this call does not pass a partial-scan marker. (
Sources/CodexBarCore/CostUsageFetcher.swift:771, f79561136caa) - Dashboard effect: With coverage false and no partial marker, the dashboard has no cost coverage interval; shared text renders a nil provider estimate as “Spend unavailable.”. (
Sources/CodexBar/SpendDashboardModel.swift:1273, f79561136caa) - Existing partial-total contract: A focused test expects a truncated local scan with priced rows to retain its cost as a marked lower bound. (
Tests/CodexBarTests/SpendDashboardPartialCostTests.swift:113, f79561136caa) - Feature history: The merged Pi history feature commit describes incomplete-source evidence and adds native-projection tests. Older line-level blame could not be completed because missing Git objects returned HTTP 403; this establishes feature-area history, not introduction of the exact faulty line. (
Tests/CodexBarTests/PiNativeProjectionTests.swift:1, 81c8a1cbf9bb) - Vision fit: VISION.md favors bounded bug fixes and shared provider-driven spend UI. (
VISION.md:3, f79561136caa)
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-reviewcomments, 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-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto 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 explainto ask for more context, or@clawsweeper stopto stop active automation.