CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Codex cost: day blanked by unresolvedRowGroups on 0.60.1 with Codex CLI 0.154 (priority rows + repeated token_count snapshots)

Open BUKOWSKIREAL opened this issue 2 months ago • 3 comments

Summary

On CodexBar 0.60.1 with Codex CLI 0.154.0, today's Codex cost is suppressed to — while the day's token count (198M) still displays. The day is also missing from the 30-day total and chart. The trigger appears to be the unresolvedRowGroups fail-closed path that #3150 explicitly left out of scope.

Environment

  • CodexBar: 0.60.1
  • Codex CLI: 0.154.0 (Codex desktop app sessions, multi-agent v2)
  • macOS, Apple Silicon

Evidence

For the affected day the local scan produces ~951 usage rows for model gpt-6-astra:

  • Canonical (deduplicated) day total: 198,456,263 tokens — displayed correctly.
  • Sum over retained per-file rows: ~448M tokens (~2.26x canonical) — fails the row-ownership checks, so the group is distrusted.
  • 628 rows carry pricingMode: priority — Codex 0.154 stamps service_tier: priority on Fast turns directly in the rollout rows.
  • With the rows distrusted, the group falls back to the aggregate path, which returns nil for this model (long-context tier — the same deliberate refusal as #2858), so the whole day's cost is suppressed while its tokens remain.

Two contributors to the row-sum inflation are visible in the raw rollouts:

  1. Repeated token_count snapshot rows (the #1062 mechanism): in one rollout, 2,162 token_count events include 167 rows where total_token_usage is unchanged from the previous row but last_token_usage is non-zero. Summing last across those rows alone adds ~53.4M phantom tokens.
  2. Fork/subagent rollouts (the #2754 mechanism): 14+ rollout files whose session_meta carries forked_from_id / source.subagent.thread_spawn appear to contribute copied-parent rows to the per-file mode-split maps.

CLI output for reference:

Today: — · 198M tokens
Last 30 days: $2,823.16 · 1.9B tokens

Expected behavior

The day should be priced from the trusted rows (or degrade to a priced partial estimate) rather than having the entire day's cost suppressed while its token count remains.

Related

  • #1062 — repeated token_count rows with unchanged total_token_usage
  • #2754 — mode-split cost path re-inflates deduplicated fork usage
  • #3150 — fixed the trace-only priority blanking; unresolvedRowGroups was noted as out of scope
  • #3524 — fork cumulative-total overcount (fixed in 0.60.x; canonical totals are now correct)

Screenshot

(screenshot of the menu card attached below — shows the quota lanes rendering fine, 今日 — next to 198M tokens, and the 30d total missing today's cost)

Image

BUKOWSKIREAL avatar Sep 13 '26 13:09 BUKOWSKIREAL

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed September 13, 2026, 9:18 AM ET / 13:18 UTC.

Summary Keep open: the screenshot demonstrates a current-release symptom, and the earlier priority fix explicitly excluded unresolved row ownership. Source confirms the suppression path, but does not establish why this dataset becomes inconsistent. Repository policy also prohibits automatic closure.

Reproducibility: unclear. end to end: source and existing tests establish the suppression path, but no minimized rollout/cache fixture establishes why this current-release dataset loses row ownership. No runtime reproduction was executed.

Ways to help us reproduce this

  • Add expected vs actual behavior.
  • Share version, platform, channel/provider, and relevant config details.

Next step Before dispatching a repair, obtain one sanitized failing file/day/model fixture with ordered token counters, fork boundaries, retained rows, canonical component totals, parser revision, and scan-completion metadata; exclude prompts, credentials, and private paths.

Review details

Best possible solution:

Recover canonical request-level pricing evidence while preserving fork deduplication and tier safeguards; any unresolved remainder should remain visibly incomplete.

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

Unclear end to end: source and existing tests establish the suppression path, but no minimized rollout/cache fixture establishes why this current-release dataset loses row ownership. No runtime reproduction was executed.

Is this the best way to solve the issue?

Unclear until the inconsistent rows are isolated. Repairing their ownership or cache derivation is safer than weakening the tested fail-closed guard or proportionally scaling mixed-tier costs.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • The supplied aggregate counts do not distinguish stale cached rows from a current parser or ownership-reconciliation defect.
  • Pricing a partial same-model group without explicit coverage semantics could present an understated amount as the complete daily estimate.

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

Label changes

Label changes:

  • add P2: The report affects local cost-estimate availability while token reporting and provider access remain usable.
  • add impact:other: Missing daily estimates make spend totals incomplete, a reporting impact outside the more specific impact categories.
  • add issue-rating: 🦐 gold shrimp: Current issue advisory state selects this label.
  • add clawsweeper:needs-info: Current issue advisory state selects this label.

Label justifications:

  • P2: The report affects local cost-estimate availability while token reporting and provider access remain usable.
  • impact:other: Missing daily estimates make spend totals incomplete, a reporting impact outside the more specific impact categories.
Evidence reviewed

What I checked:

  • Observed current-release symptom: The supplied screenshot visibly shows today's cost as a dash, 198M tokens, and a 30-day cost of $2,823.16. It corroborates the display symptom, but cannot establish row ownership or the claimed omitted amount.
  • Current reconciliation boundary: codexCanonicalPricingRows requires component-wise equality with canonical file/day/model totals. Its reconciliation accepts either all rows or an exact suffix; otherwise it records an unresolved group. The report unions these failures across files. (Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner+ReportReconciliation.swift:19, 62a7fa1c409c)
  • Suppression is deliberate: An unresolved group cannot use row pricing. Priority evidence independently disables aggregate fallback; without that evidence, aggregate pricing still refuses above-threshold totals for tiered models. Canonical tokens remain in the report. (Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner+ForkCoverage.swift:118, 62a7fa1c409c)
  • Repeated snapshots already have protection: handleTokenCount returns before recording usage when adjusted cumulative totals were already observed; accepted deltas feed both daily totals and retained rows. Merely finding repeated nonzero last_token_usage in raw logs therefore does not prove current scanner overcount. (Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner.swift:4463, 62a7fa1c409c)
  • Existing safety contract: The test 'codex report leaves threshold cost unavailable without exact request rows' explicitly expects 400,000 canonical tokens and nil cost when retained rows total 440,000. Existing alternating-snapshot coverage also expects repeated snapshots to add no rows. These tests were inspected, not executed. (Tests/CodexBarTests/CostUsageScannerForkSplitTests.swift:199, 62a7fa1c409c)
  • Related discussion narrows the remaining problem: Merged https://github.com/steipete/CodexBar/pull/3150 explicitly left genuinely unreconciled rows unresolved. Discussion on closed https://github.com/steipete/CodexBar/issues/2948 reports similar non-fork cache inconsistencies and successful selective reparsing. Open https://github.com/steipete/CodexBar/issues/3524 remains concerned with inflated canonical totals and awaits post-upgrade verification; it does not establish ownership of this cost-only failure.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • olddonkey: 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 13 '26 13:09 clawsweeper[bot]

A concrete cache-rescan cause of this symptom is now fixed on main in #3620, commit ea4d37a4e740b57107847612b71bf7f7e1c7af2c.

A normal rescan could replace canonical token totals while retaining obsolete request-pricing rows. SQLite could also retain a changed same-length history. The repair replaces rows within the scanned window, preserves matching pricing evidence and parser progress across partial scans/restarts, and adopts saved 0.60.1 history without rebuilding the database.

The native filesystem/SQLite regressions reproduced the missing-cost and partial-rescan failures before the respective fixes. Final validation passed 285 focused tests, the full 1,132-selection suite, and all exact-head CI checks: https://github.com/steipete/CodexBar/actions/runs/34772768731.

Keeping this issue open: these tests establish a real cache defect, but do not yet establish the cause of every inconsistent row in the reported day. Historical re-emitted-row recovery in #3618 remains distinct, and the existing safeguards for genuinely unresolved pricing evidence remain in place.

steipete avatar Sep 13 '26 18:09 steipete

Closing as solved: the producer/persistence defect that caused the re-emitted usage rows was fixed by @steipete in #3620 (merged in 0.60.x). The historical recovery proposal in #3618 has been withdrawn. Thanks for the fix!

BUKOWSKIREAL avatar Sep 18 '26 10:09 BUKOWSKIREAL