Skip to content

fix(codex): reconcile extra credit usage and balances - #3296

Merged
steipete merged 12 commits into
steipete:mainfrom
sf-jin-ku:fix/codex-extra-usage-credits
Sep 4, 2026
Merged

fix(codex): reconcile extra credit usage and balances#3296
steipete merged 12 commits into
steipete:mainfrom
sf-jin-ku:fix/codex-extra-usage-credits

Conversation

@sf-jin-ku

@sf-jin-ku sf-jin-ku commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Codex extra credits now show monthly spend/limit and a distinct purchased balance on account-scoped cards and menu-bar Extra usage. Monthly bars, reset dates, and their numeric details use the same selected cap; genuine 30-day quota bars keep their own meaning.

The maintainer revision preserves successful balance-read timestamps independently of cap timestamps. A newer confirmed zero clears stale purchased credits, while an unread balance retains the last successful value. This survives attachment and persistence, handles purchased-only depletion, and reconciles the legacy Credits display through a display copy without mutating stored transport snapshots or crossing account boundaries. Changelog and provider docs are updated; original contribution by @sf-jin-ku.

Validation: 121 focused tests passed, including dashboard conversion→attachment→projection→card, independent cap/balance ages, old/new Codable payloads, optional visibility, and CLI zero suppression. The signed native card test reproduces both stale-balance cases before the fix and passes after it. Formatting/lint and structured P0 review are clean. The full suite passed all 1,006 selections in 84 groups, with zero failures, retries, or timeouts.

Before (same synthetic account-paired inputs):

Before: a confirmed zero still displays the old purchased balance

After (zero clears; unread retains; purchased-only zero disappears):

After: balance freshness is preserved in the native cards

@clawsweeper

clawsweeper Bot commented Aug 30, 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 commented Aug 30, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T09:10:38.360250Z 00441b4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 0ea2fe845f

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBar/Providers/Codex/CodexConsumerProjection.swift
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 4:13 AM ET / 08:13 UTC.

ClawSweeper review

What this changes

The PR shows Codex extra-credit usage and purchased balances across cards, menu-bar metrics, and CLI output while reconciling their freshness independently.

Merge readiness

Ready for maintainer review

This remains useful beyond current main and v0.56.4. The current head addresses the earlier findings, and this review found no new blocking defect.

Priority: P2
Reviewed head: 4869e6aac97d493ae4ad54b24b94fb71067cbb84

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong real-behavior evidence, backward-compatible persistence, and focused regression coverage support the patch with no remaining actionable finding.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected real-account screenshots show corrected status text and monthly used/limit rendering; the captured signed native run exercises dashboard conversion through the production card for zero, unread, and depleted balances. The newer images could not be independently opened because of reviewer network failure.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Inspected real-account screenshots show corrected status text and monthly used/limit rendering; the captured signed native run exercises dashboard conversion through the production card for zero, unread, and depleted balances. The newer images could not be independently opened because of reviewer network failure.
Evidence reviewed 11 items Repository policy: Read the complete root AGENTS.md; no nested AGENTS.md or maintainer-notes directory was found. Applied account isolation, focused regression coverage, and credential-safe review guidance.
Verified review boundary: The local head matches the pinned original head. The test merge records the pinned main followed by that head as its parents; review used the introduced main-to-head delta across 34 files.
Still necessary on main: Current main lacks the Codex cost presenter and Extra usage metric support added here; its existing monthly-credit support does not provide this complete presentation and reconciliation.
Findings None None.
Security None None.

How this fits together

CodexBar combines account-matched credit readings from OAuth, CLI, PAT, and dashboard sources. Its presentation layer turns those readings into usage cards, menu-bar values, and CLI output.

flowchart LR
  A[Codex credit sources] --> B[Account-matched snapshots]
  B --> C[Select freshest monthly cap]
  B --> D[Select freshest successful balance]
  C --> E[Shared credit presentation]
  D --> E
  E --> F[Cards and menu bar]
  E --> G[CLI output]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta Production +416/-69; tests +1,103/-40 Production growth supports shared credit reconciliation and its consumers; most added lines cover regressions and native proof.

Technical review

Best possible solution:

Keep credit reconciliation centralized and account-scoped, with independent observation timestamps shared by all display consumers.

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

Yes for the addressed reconciliation cases: the supplied native scenarios and focused regressions identify concrete stale-balance and omitted-field triggers; this reviewer did not execute them.

Is this the best way to solve the issue?

Yes. Reusing shared cost presentation and reconciling account-paired observations avoids competing display rules while preserving existing preferences and legacy decoding.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 392310c66548.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded Codex credit-presentation improvement without evidence of a core-runtime or onboarding emergency.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Inspected real-account screenshots show corrected status text and monthly used/limit rendering; the captured signed native run exercises dashboard conversion through the production card for zero, unread, and depleted balances. The newer images could not be independently opened because of reviewer network failure.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected real-account screenshots show corrected status text and monthly used/limit rendering; the captured signed native run exercises dashboard conversion through the production card for zero, unread, and depleted balances. The newer images could not be independently opened because of reviewer network failure.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Inspected real-account screenshots show corrected status text and monthly used/limit rendering; the captured signed native run exercises dashboard conversion through the production card for zero, unread, and depleted balances. The newer images could not be independently opened because of reviewer network failure.

Evidence

What I checked:

Likely related people:

  • sf-jin-ku: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (21 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-31T10:04:46.557Z sha 827fffa :: needs real behavior proof before merge. :: [P2] Preserve a fresh zero purchased-credit balance
  • reviewed 2026-08-31T17:54:15.971Z sha 827fffa :: needs real behavior proof before merge. :: [P2] Distinguish a confirmed zero balance from an unavailable read
  • reviewed 2026-09-03T04:52:36.074Z sha 8478f5c :: needs real behavior proof before merge. :: [P2] Distinguish confirmed zero from an unavailable balance
  • reviewed 2026-09-03T09:20:03.664Z sha f72d4ee :: needs real behavior proof before merge. :: [P2] Keep Credits out of the currency display path
  • reviewed 2026-09-04T02:21:24.416Z sha 08ad99c :: blocked before merge. :: [P2] Preserve balances when cap-only responses omit the balance field
  • reviewed 2026-09-04T03:07:04.606Z sha 22a6235 :: blocked before merge. :: [P2] Mark cap-only source balances as unavailable
  • reviewed 2026-09-04T03:14:38.193Z sha 03233d8 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-04T07:56:41.219Z sha 4869e6a :: needs maintainer review before merge. :: none

@sf-jin-ku

Copy link
Copy Markdown
Contributor Author

The Web-source finding is fixed in 6e5af4aab, the review thread is resolved, and the branch is synced with current origin/main at 2096aeaf6. Local focused, full-suite, format, and lint verification all pass.

@codex review
@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 31, 2026

@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: 2096aeaf6e

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCore/Providers/Codex/CodexProviderDescriptor.swift Outdated
Comment thread Sources/CodexBar/Providers/Codex/CodexConsumerProjection.swift
@sf-jin-ku

Copy link
Copy Markdown
Contributor Author

Real-account behavior proof (menu bar text regression fixed)

While validating this PR against a live Codex account with per-member extra credits, the status item rendered the raw credit amount instead of a percentage:

status item before/after

Root cause. StatusItemController.extraUsageSpendDisplayText unconditionally ran the providerCost.used value through UsageFormatter.currencyString. That is correct for Claude extra usage and Cursor on-demand (real currency), but Codex extra usage is denominated in credits (CodexExtraUsageCost.currencyCode == "Credits"), so currencyString fell back to emitting the bare amount (2000.6633599996567) instead of a spend value.

Fix (eee9dc4): the credits currency code is rejected inside extraUsageSpendDisplayText itself, so every call site falls back to the existing percent text instead of each one special-casing Codex.

guard let cost = snapshot?.providerCost,
      cost.limit > 0,
      cost.used >= 0,
      // Codex extra usage is denominated in credits, not money: currency formatting would emit the
      // bare amount ("2000.6633599996567") instead of a spend value, so it keeps the percent text.
      cost.currencyCode != CodexExtraUsageCost.currencyCode
else {
    return nil
}

The menu card itself was already correct on the live account — used vs. limit plus the distinct purchased balance:

codex menu card

Verification

  • New regression test menu bar extra usage preference uses percent for Codex monthly credits in StatusItemExtraUsageMetricTests asserts menuBarDisplayText == "100%" for a Codex credits providerCost. It failed on the pre-fix tree (the currency path returned the bare amount, exactly the "before" screenshot above) and passes with eee9dc4.
  • Focused swift test runs on the extra-usage / status-item suites pass.
  • make check clean (swiftformat + swiftlint --strict).
  • Full make test (979 selections, 82 groups) running locally right now — I'll follow up here with the result. CI on eee9dc4 is in progress.
  • Gatekeeper anchors updated for the origin/main merge (CostHistoryChartMenuView.swift 1116 → 1115, SpendDashboardModel.swift 1089 → 1093); the CHANGELOG.md conflict keeps both entries.

Screenshots were captured from a freshly packaged bundle on a real account, then the original live configuration was restored.

@codex review
@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@sf-jin-ku

sf-jin-ku commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Full local suite result for eee9dc4, as promised above:

- Discovered selections: 979
- Selected groups: 82
- First-pass successful groups: 82
- First-pass failed groups: 0
- Full-group retries: 0 / Recovered: 0 / Timed out: 0
- Total seconds: 720.5

make test exit code 0, no retries needed. make check (swiftformat + swiftlint --strict) is clean. Remaining GitHub checks are still running.

@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: eee9dc4190

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBar/Providers/Codex/CodexConsumerProjection.swift Outdated
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. 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. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. proof: sufficient Contributor real behavior proof is sufficient. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 31, 2026
@sf-jin-ku

Copy link
Copy Markdown
Contributor Author

Addressed the P2 finding on CodexConsumerProjection in a41bfdc — details and the root-cause reasoning are in the thread.

Short version: .extraUsage selectability reads snapshot.providerCost while its interpretation read projection.extraUsageCost, which was derived from context.liveCredits alone. CodexExtraUsageCost.resolving(live:attached:) now reconciles the two at the projection — the only place that already holds the snapshot and the credits for the same account, so the fix cannot pair a dashboard cap with another account's credits the way a store-side self.credits overwrite could.

Full local suite on a41bfdc:

- Discovered selections: 979
- Selected groups: 82
- First-pass successful groups: 82
- First-pass failed groups: 0
- Full-group retries: 0 / Recovered: 0 / Timed out: 0
- Total seconds: 697.4

make test exit 0, no retries. make check clean. The selection count is unchanged from the previous run because a selection is a suite, not a test case — the four new cases land in two existing suites and are listed by swift test list.

@codex review
@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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: a41bfdcb61

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCore/Providers/Codex/CodexExtraUsageCost.swift Outdated
@sf-jin-ku

Copy link
Copy Markdown
Contributor Author

Second P2 addressed in 6125c7c — reasoning in the thread. CodexExtraUsageCost.resolving now picks the cap by updatedAt instead of assuming the live credits are the fresher side, which also covers the mirror case (a CLI/OAuth credits refresh landing after a dashboard attach).

Full local suite on 6125c7c:

- Discovered selections: 979
- Selected groups: 82
- First-pass successful groups: 82
- First-pass failed groups: 0
- Full-group retries: 0 / Recovered: 0 / Timed out: 0
- Total seconds: 819.8

make test exit 0, no retries. make check reports 0 violations across 2070 files. All four new cases are confirmed in the full run log, e.g. ✔ Test "menu bar extra usage preference uses the attached cap when live codex credits lack one" passed.

@codex review
@clawsweeper re-review

@sf-jin-ku

Copy link
Copy Markdown
Contributor Author

Rebased onto current origin/main (5996f7f) at 3028b08.

CHANGELOG keeps the 0.56.4 section intact and puts the Codex Extra-usage line under Unreleased after the existing Tailscale/Claude/Antigravity notes. The four Codex review threads are addressed on the rebased SHAs:

  • attached dashboard cap: 5eb85f9
  • fresher cap by timestamp: eb1cc4c
  • cap ages by limit.updatedAt: 3294d3d
  • attached balance plus confirmed-zero vs unavailable read, and Credits percent text: 5bc7f18 / 3028b08

The previous macOS shard failure on f72d4ee was StatusItemExtraUsageMetricTests expecting 100% but getting 2000.66; that path now rejects the Credits currency code and keeps the percent text. No new live screenshots for the zero-reconciliation case.

@codex review
@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
sf-jin-ku and others added 10 commits September 4, 2026 03:02
Surface per-member Codex extra credits as Extra usage, including used/limit and any distinct purchased remaining balance.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
The balance was decided once by freshness only on the attached-wins path; the
live-wins path returned the snapshot whole and dropped a dashboard balance that
live had no reading for. A nil balance is not a reading that the credits are
gone: CodexMonthlyCreditPreservation.merging stands a preserved cap up beside a
`remaining: 0` placeholder when the credits fetch fails, so the other side still
gets to supply it.

Decide the balance once, then apply it to whichever cap wins. On the live-wins
branch the selector always takes its first arm — the cap won, so
`cap.updatedAt >= attached.updatedAt`, and `providerCost` never stamps a cap
newer than the credits fetch carrying it, so `liveCredits.updatedAt >=
cap.updatedAt`. Not a dead branch, just a consistent simplification.
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
@sf-jin-ku
sf-jin-ku force-pushed the fix/codex-extra-usage-credits branch from 08ad99c to 22a6235 Compare September 4, 2026 03:03
Co-Authored-By: Claude Code <noreply@anthropic.com>
@sf-jin-ku

Copy link
Copy Markdown
Contributor Author

Addressed the remaining P2 (omitted balance treated as a confirmed zero) in 03233d814.

What was wrong. balanceReadSucceeded defaulted to true, but every Codex credits mapper builds its snapshot with remaining: balance ?? 0 while the raw balance field is optional. A cap-only response therefore produced a confirmed zero and cleared a valid attached purchased-credit balance — exactly the case you described.

Fix. The flag is now set from raw balance presence at each mapper, and preserved through every merge instead of falling back to the default:

  • CodexProviderDescriptor.mapCredits and CodexPATFetchStrategy.mapCredits: balanceReadSucceeded: balance != nil (CreditDetails.balance is Double?, so an omitted field stays nil).
  • OpenAIDashboardSnapshot.toCreditsSnapshot: balanceReadSucceeded: self.creditsRemaining != nil.
  • UsageFetcher.makeCredits (CLI): parseCredits substitutes 0 for a missing or unparseable string, so presence is decided by the raw field — $0.balance.flatMap(Double.init) != nil — not by the parsed value.
  • Merges that rebuild a snapshot now carry the flag: the CLI-limit merge keeps oauthCredits.balanceReadSucceeded, the spend-controls merge keeps $0.balanceReadSucceeded and marks its synthesized cap-only snapshot false, and CodexMonthlyCreditPreservation.merging keeps incoming.balanceReadSucceeded.

Coverage. a cap-only dashboard read leaves the purchased balance unread asserts both directions through toCreditsSnapshot and the resolver: an omitted balance keeps the attached 30, an explicit 0 clears it. a cap-only oauth response leaves the purchased balance unread drives the same distinction through CodexOAuthFetchStrategy._mapResultForTesting with a monthly cap present and balance omitted versus "0".

Also in this push: the earlier CI break is fixed — resolving uses an if expression for conditionalAssignment, and the ProviderArchitectureGatekeeperTests line anchors follow the shifted sources (CodexAccountUsageSnapshotStore 222/224, UsageFetcher 1510). All 402 anchors were re-validated against their files.

Not verified locally: this environment has no Swift toolchain, so make test / make check did not run here — GitHub CI is the verifier for this push. No new real-account captures for the cap-only reconciliation case.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Sep 4, 2026
Render account-paired extra usage and purchased balances consistently across cards and menu-bar projections. Preserve confirmed-zero balance observations separately from monthly cap age, including persisted snapshots and purchased-only credits.

Co-authored-by: sf-jin-ku <jin.ku@sendbird.com>
@steipete steipete changed the title fix(codex): show extra credit used versus limit fix(codex): reconcile extra credit usage and balances Sep 4, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 4, 2026
@steipete
steipete merged commit b07fd2e into steipete:main Sep 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants