Skip to content

[Codex cost] Completed scan shows Spend unavailable with grouping-dependent totals #2948

Description

@Atopoz

Summary

After a completed 30-day Codex history scan, Usage & Spend shows Spend unavailable for Codex even though token coverage is established and the CLI can still calculate non-null (but grouping-dependent) cost totals.

Restarting CodexBar does not recover the spend display. This appears to be a cost aggregation/completeness regression rather than an incomplete scan.

Environment

  • CodexBar 0.49.6 (120)
  • macOS 26.6.1 (25G76)
  • Apple Silicon (arm64)
  • Usage & Spend window: 30d
  • Codex history size: 820 JSONL files, approximately 21.4 GB parsed

Reproduction

  1. Enable local estimated Codex usage history.
  2. Let the 30-day history refresh complete.
  3. Confirm that the dashboard reports Coverage: 30 / 30.
  4. Quit and reopen CodexBar.
  5. Open Settings > Usage & Spend and select 30d.

Observed behavior

  • The dashboard shows:
    • Tracked tokens: 11B
    • Codex: Spend unavailable
    • Model breakdown unavailable
  • The state persists after restart and manual refresh.
  • The SQLite scan index is complete: 820 / 820 file rows have scan_complete = 1.
  • The ungrouped CLI result reports established history coverage and 28 daily rows, but 7 token-bearing daily rows have totalCost: null.
  • Cost output changes depending on grouping, while token totals remain identical:
Query Tokens Cost
Ungrouped 30-day result 11,021,656,248 $4,770.22
--group-by project top-level result 11,021,656,248 $6,434.50
Sum of project rows 11,021,656,248 $7,001.18

The project-grouped result contains 116 project/day rows; only 3 have a null cost, while the ungrouped result has 7 null daily costs.

Expected behavior

  • Cost availability and totals should not change solely because a grouping option is requested.
  • When history coverage is established and request-level pricing evidence is available through one aggregation path, the ungrouped path should preserve the same authoritative cost evidence.
  • If some rows genuinely cannot be priced safely, the UI should expose the incomplete/partial state without making the entire provider spend unavailable while another grouping path returns a total.

CLI evidence

Ungrouped:

$ CodexBarCLI cost --provider codex --days 30 --json-only
historyCoverageIsEstablished: true
last30DaysTokens: 11021656248
last30DaysCostUSD: 4770.2201546
daily rows: 28
token-bearing daily rows with totalCost == null: 7

Grouped:

$ CodexBarCLI cost --provider codex --days 30 --group-by project --json-only
historyCoverageIsEstablished: true
last30DaysTokens: 11021656248
last30DaysCostUSD: 6434.4966916
sum(project.totalTokens): 11021656248
sum(project.totalCost): 7001.1821246

Hypothesis

This may be an interaction between the request-level long-context tier preservation added after #2858 and the all-daily-rows-must-have-cost completeness policy added in 0.49.4. The project grouping path appears to retain pricing evidence that the ungrouped daily/model aggregation loses.

I have not attached the raw database or logs because they contain local paths, project names, and session identifiers. I can provide a minimized/redacted fixture or run a diagnostic build if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions