Skip to content

Fix established-empty Codex history - #2978

Merged
steipete merged 5 commits into
mainfrom
fix/2932-established-empty-history
Aug 16, 2026
Merged

Fix established-empty Codex history#2978
steipete merged 5 commits into
mainfrom
fix/2932-established-empty-history

Conversation

@steipete

Copy link
Copy Markdown
Owner

Summary

  • merge and preserve @Yuxin-Qiao's established-empty history fix from fix(codex): preserve established-empty history #2932
  • report zero tokens and spend only after a completed zero-row Codex scan establishes the requested history coverage
  • keep incomplete files, catch-up-pending scans, buffered fork retries, expanded windows, root/timezone mismatches, and unpriced history unavailable
  • preserve Fix Codex spend availability after completed scans #2961's adjacent contract: an established partially priced scan retains its priced subtotal only when the aggregate matches priced days and missing costs have explicit unpriceable evidence

This supersedes #2932, which became conflicting after #2961 landed.

Reconciliation and review

The two contracts compose without weakening either invariant. The fetcher now preserves an established empty report through cache hydration, while the dashboard continues to gate zeroes and partial totals on established coverage and aggregate consistency. The empty report carries no synthetic summary values; zeroes are derived only at the coverage-gated token snapshot boundary.

Review found no blocking correctness issues. Added coverage proves that an LA-local midnight rollover invalidates a narrower empty cache, and direct dashboard tests distinguish established empty history from unestablished empty history. Cache hydration retains the native scan timestamp. Gatekeeper anchors were updated for the reconciled source layout.

Credit to @Yuxin-Qiao for the original fix and regression coverage.

Validation

  • make check
  • CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --disable-sandbox --filter 'CostUsageFetcherTests|CostUsageFetcherCacheSnapshotTests|CostUsageTokenSnapshotDaySelectionTests' — 46 tests in 3 suites passed
  • CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --disable-sandbox --filter 'SpendDashboardPartialCost|SpendDashboard' — 140 tests in 13 suites passed
  • source-blind CLI validation with isolated HOME, CFFIXED_USER_HOME, and CODEX_HOME: completed empty refresh and a separate no-refresh process returned established zeroes; widening from 1 to 7 days produced a new scan timestamp
  • structured autoreview: clean, no accepted/actionable findings

No Keychain, browser, web, or real-account tests were run.

Yuxin-Qiao and others added 2 commits August 15, 2026 00:04
Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@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: 5ca592ee18

ℹ️ 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".

? CostUsageTokenSnapshot.entry(in: daily.data, forLocalDayContaining: now, calendar: calendar)
: CostUsageTokenSnapshot.latestEntry(in: daily.data)
let hasHistoricalRows = !daily.data.isEmpty
let establishedEmptyHistory = historyCoverageIsEstablished && daily.data.isEmpty

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict established-empty zeroes to Codex

When Claude or Vertex returns an empty transcript report, loadLocalTokenScanResult unconditionally marks coverage established for every non-Codex provider; Bedrock likewise calls this helper with the default true. This shared predicate therefore converts those providers' existing “no data available” state into fabricated zero token and spend totals. Pass a Codex-specific established-empty flag instead of deriving zeroes from the generic coverage value.

Useful? React with 👍 / 👎.

@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: 🦐 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. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed August 16, 2026, 9:10 AM ET / 13:10 UTC.

ClawSweeper review

What this changes

Preserve a completed empty Codex local-history scan as known-zero usage and spend across refreshes and cache hydration.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open: the previous P2 finding remains on the current head, where an empty Claude or Vertex local scan is converted into known-zero usage and spend instead of remaining unavailable.

Priority: P2
Reviewed head: d82ef1ab03332783b3bd4dd854be6d1a2194b081

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The branch has focused local validation, but the unresolved provider-boundary defect blocks merge readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: Real-behavior proof is not a merge gate for this maintainer-authored PR; its body nevertheless reports isolated after-fix CLI validation without real-account access.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real-behavior proof is not a merge gate for this maintainer-authored PR; its body nevertheless reports isolated after-fix CLI validation without real-account access.
Evidence reviewed 5 items Shared zero conversion: The branch adds an established-empty path that returns zero session and history totals for any empty report whose coverage flag is true.
Non-Codex coverage is unconditional: The local-scan result marks every non-Codex provider as having established coverage, so an empty Claude or Vertex report reaches the new zero path.
Prior finding remains unfixed: The source file has no changes between the previously reviewed head and the current head, so the earlier P2 is still applicable rather than a late finding.
Findings 1 actionable finding [P2] Keep established-empty zeroes Codex-specific
Security None None.

How this fits together

CodexBar's cost-usage fetcher scans provider-local history and turns it into token and spend snapshots for the menu and dashboard. The snapshot layer must distinguish a completed Codex scan with no activity from an unavailable empty result from other providers.

flowchart LR
A[Provider local history] --> B[Usage scanner]
B --> C[Coverage assessment]
C --> D[Token and spend snapshot]
D --> E[Menu and spend dashboard]
Loading

Before merge

  • Keep established-empty zeroes Codex-specific (P2) - The prior P2 remains on this head: non-Codex local scans set coverage true at the caller, so an empty Claude or Vertex report reaches this new branch and returns zero usage and spend rather than unavailable values. Pass a Codex-only established-empty signal and cover those providers.
  • Resolve merge risk (P1) - Merging as written changes empty Claude and Vertex local-history results from unavailable to fabricated zero token and spend totals.
  • Complete next step (P2) - The remaining blocker is a narrow mechanical provider-boundary repair with clear source and regression-test locations.

Findings

  • [P2] Keep established-empty zeroes Codex-specific — Sources/CodexBarCore/CostUsageFetcher.swift:1097-1103
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Implementation and regression coverage core production +46 net; tests +237 net; changelog +1 The branch is test-heavy, but its shared snapshot change still lacks negative coverage for non-Codex providers.

Root-cause cluster

Relationship: canonical
Canonical: #2978
Summary: This PR is the intended reconciliation of the original established-empty implementation with the already-merged partial-cost work, but it still needs the provider-boundary repair.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Constrain known-zero history to Codex (recommended)
    Pass a Codex-specific established-empty signal into snapshot assembly and add empty Claude and Vertex regressions that remain unavailable before merging.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Restrict established-empty zero totals to completed Codex scans and add Claude and Vertex empty-report regressions that remain unavailable.

Technical review

Best possible solution:

Keep the established-empty invariant explicit and Codex-only, while all other providers retain unavailable results for empty local transcript scans.

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

Yes—source inspection provides a high-confidence path: an empty Claude or Vertex scan is marked established at the local-scan boundary and then enters the new empty-history zero conversion.

Is this the best way to solve the issue?

No—the generic coverage flag is too broad; a Codex-specific established-empty flag is the narrower solution and preserves existing non-Codex unavailable semantics.

Full review comments:

  • [P2] Keep established-empty zeroes Codex-specific — Sources/CodexBarCore/CostUsageFetcher.swift:1097-1103
    The prior P2 remains on this head: non-Codex local scans set coverage true at the caller, so an empty Claude or Vertex report reaches this new branch and returns zero usage and spend rather than unavailable values. Pass a Codex-only established-empty signal and cover those providers.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 361c9d679c99.

Labels

Label justifications:

  • P2: The branch would give incorrect usage and spend availability for empty local Claude or Vertex histories, with a bounded repair path.
  • merge-risk: 🚨 compatibility: Existing non-Codex empty-history behavior changes from unavailable values to visible zero totals.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Real-behavior proof is not a merge gate for this maintainer-authored PR; its body nevertheless reports isolated after-fix CLI validation without real-account access.

Evidence

Acceptance criteria:

  • [P1] make check.
  • [P1] make test.
  • [P1] swift test --filter 'CostUsageFetcherTests|CostUsageTokenSnapshotDaySelectionTests|SpendDashboardPartialCostTests'.

What I checked:

Likely related people:

  • steipete: Authored the reconciliation commit and the current PR over the shared cost-usage fetcher. (role: reconciliation author and recent area contributor; confidence: high; commits: 5ca592ee1844; files: Sources/CodexBarCore/CostUsageFetcher.swift)
  • Yuxin-Qiao: Authored the original established-empty implementation incorporated by this PR. (role: original fix author; confidence: high; commits: aef668ecb3b8; files: Sources/CodexBarCore/CostUsageFetcher.swift, Tests/CodexBarTests/CostUsageFetcherCacheSnapshotTests.swift)

Rank-up moves

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

  • Restrict the empty-history zero path to Codex.
  • Add Claude and Vertex empty-report regressions that assert unavailable totals.

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 (1 earlier review cycle)
  • reviewed 2026-08-16T12:24:34.681Z sha 4455dd9 :: needs changes before merge. :: [P2] Restrict established-empty zeroes to Codex

@steipete
steipete merged commit f082441 into main Aug 16, 2026
5 checks passed
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. P2 Normal priority bug or improvement with limited blast radius. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants