Skip to content

Price provider-qualified Codex models - #2946

Merged
steipete merged 4 commits into
steipete:mainfrom
Yuxin-Qiao:codex/opencodex-qualified-pricing
Aug 16, 2026
Merged

Price provider-qualified Codex models#2946
steipete merged 4 commits into
steipete:mainfrom
Yuxin-Qiao:codex/opencodex-qualified-pricing

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve provider-qualified Codex model IDs against their matching models.dev provider, including OpenCodex route aliases
  • keep unknown route prefixes unpriced instead of falling back to OpenAI rates
  • include supported route providers in pricing fingerprints and bump the affected cost formula versions
  • add regression coverage for paid, zero-cost, aliased, and unknown-prefix models

Why

OpenCodex records routed models such as opencode-go/deepseek-v4-flash, opencode-free/deepseek-v4-flash-free, kimi-coding/k3, and deepseek/deepseek-v4-flash. CodexBar's Codex cost resolver previously queried only the openai provider in models.dev, so these rows stayed unpriced and the dashboard treated the partially priced history as unavailable.

This change only fixes local estimate attribution through the existing models.dev catalog. It does not import OpenCodex's usage ledger or present provider estimates as account billing, avoiding duplicate counting and preserving the existing ownership boundary.

Validation

  • make check
  • make test (862 selections, 72 groups; all passed)
  • swift test --filter CostUsagePricingTests
  • swift test --filter ProviderArchitectureGatekeeperTests

After-fix local runtime evidence (2026-08-15)

Ran the built CLI against an isolated temporary CODEX_HOME containing two redacted local Codex JSONL sessions; no account files, cookies, or bearer tokens were present. The --refresh run fetched the public models.dev catalog and scanned the local records:

$ HOME=<isolated-home> CODEX_HOME=<isolated-codex-home> swift run --skip-build CodexBarCLI cost --provider codex --json --refresh --days 1 --no-color | jq -c '[.[] | .daily[] | .modelBreakdowns[] | {modelName,cost}]'
[{"modelName":"opencode-go/deepseek-v4-flash","cost":0.000007028000000000001},{"modelName":"unknown-route/deepseek-v4-flash","cost":null}]

This is after-fix local runtime evidence: the supported OpenCodex-qualified route is repriced after the on-demand catalog refresh, while an unknown route remains unpriced instead of inheriting an unrelated OpenAI rate. The output contains no credentials.

CI classification (2026-08-16)

  • Head d4232410af8fce36fd2c2c1f4921b4363f0ac08b has green Linux, lint, and change-detection jobs.
  • The aggregate lint-build-test failure is the repository's Draft-policy gate reporting that macOS Swift tests are deferred; it is not a pricing or parser failure.
  • The PR remains Draft and needs only maintainer review.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. 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: 🧂 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 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 2:06 AM ET / 06:06 UTC.

ClawSweeper review

What this changes

The PR resolves provider-qualified Codex model names through matching models.dev providers, refreshes missing qualified prices, invalidates affected local estimate caches, and adds regression coverage.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer review. The branch safely prices allowlisted provider-qualified routes, preserves unknown routes as unpriced, refreshes through the same mapping, and includes sufficient redacted CLI proof; current main still has the OpenAI-only lookup.

Priority: P2
Reviewed head: 8d19e17bfc82bc4d4973dc09bf977cc7cc4df9e0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and supported by real CLI evidence plus regression tests, with local-estimate recalculation the main merge consideration.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body contains a redacted after-fix CLI run showing a supported qualified route priced after refresh while an unknown route remains unpriced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body contains a redacted after-fix CLI run showing a supported qualified route priced after refresh while an unknown route remains unpriced.
Evidence reviewed 7 items Current main remains OpenAI-only: Current main resolves Codex models through the openai models.dev provider only, so qualified routes such as opencode-go/deepseek-v4-flash remain unpriced there.
Provider-bound resolver: The PR allowlists supported route prefixes, maps only documented aliases, and returns no lookup target for an unknown prefix, preventing fallback to unrelated OpenAI prices.
Refresh shares resolver targets: Unknown-price refresh requests are generated from the same qualified pricing targets and grouped by provider before retrying the catalog.
Findings None None.
Security None None.

How this fits together

CodexBar scans local Codex session records and converts model token counts into local cost estimates using a cached models.dev catalog. Those estimates feed the CLI and dashboard history without representing provider account billing.

flowchart LR
A[Local Codex sessions] --> B[Usage scanner]
B --> C[Qualified model resolver]
C --> D[models.dev catalog]
D --> E[Local cost estimates]
E --> F[CLI and dashboard history]
Loading

Before merge

  • Resolve merge risk (P1) - After upgrade, historical local estimates and exports will recalculate because the pricing fingerprints and formula versions change; provider account billing is unaffected.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Implementation and test coverage production +121/-39, tests +189/-29 across 9 files The larger test delta covers resolver, refresh, alias, unknown-route, and cache-invalidation behavior.

Merge-risk options

Maintainer options:

  1. Accept local estimate recalculation (recommended)
    Merge with the documented expectation that existing local estimates and exports recalculate while provider account billing remains unchanged.

Technical review

Best possible solution:

Merge the allowlisted provider-qualified lookup with its shared refresh and cache invalidation behavior, while retaining unrecognized route prefixes as unpriced.

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

Yes. Current main's OpenAI-only resolver leaves a supported qualified-route model unpriced; the PR supplies a redacted isolated CLI transcript and focused fixtures for that path.

Is this the best way to solve the issue?

Yes. The shared allowlisted target mapping keeps direct lookup and unknown-price refresh consistent, without cross-charging unknown providers.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: The change affects local historical cost estimates with limited blast radius.
  • merge-risk: 🚨 compatibility: Pricing-key and formula-version changes intentionally recalculate persisted local estimate history after upgrade.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body contains a redacted after-fix CLI run showing a supported qualified route priced after refresh while an unknown route remains unpriced.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains a redacted after-fix CLI run showing a supported qualified route priced after refresh while an unknown route remains unpriced.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Recent main history includes the Codex pricing resolver hardening and request-tier pricing work nearest this change. (role: recent area contributor; confidence: high; commits: 4befde4bbdf0, 917a2165229d; files: Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift, Sources/CodexBarCore/CostUsageFetcher.swift)
  • Yuxin Qiao: Merged main history includes recent Codex cost-total and OpenCode-related work in the affected area. (role: adjacent contributor; confidence: medium; commits: 34760e7e759c, 8060110e146c; files: Sources/CodexBarCore/CostUsageFetcher.swift, Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift)

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 (6 earlier review cycles)
  • reviewed 2026-08-15T05:21:49.901Z sha 728ca27 :: needs real behavior proof before merge. :: [P1] Route unknown-price refreshes through the qualified resolver
  • reviewed 2026-08-15T06:46:32.100Z sha 2371835 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-15T07:17:36.059Z sha 2371835 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T08:17:45.930Z sha d423241 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T18:55:08.100Z sha d423241 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T04:38:12.001Z sha d423241 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. proof: sufficient Contributor real behavior proof is sufficient. 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 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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 15, 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 Aug 15, 2026
@Yuxin-Qiao
Yuxin-Qiao marked this pull request as ready for review August 16, 2026 04:35
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 16, 2026
@steipete
steipete merged commit c615214 into steipete:main Aug 16, 2026
9 checks passed
steipete added a commit that referenced this pull request Aug 16, 2026
Finesssee added a commit to nesszer/Win-CodexBar that referenced this pull request Aug 18, 2026
…n-zero history, Antigravity dashboard lanes, Claude OAuth revoked detection

steipete#2946 Codex routed models pricing — codex_routed_provider() + strip_route_prefix()
    in cost_pricing.rs; deepseek/, kimi/, opencode/ routes price against
    matching models.dev provider; unknown provider/ prefixes return None.
steipete#2944 Codex auth.json read-only during refresh — codex_external_oauth_sources_allowed
    setting (default OFF); is_external_oauth + last_refresh fields on
    CodexCredentials; enforce_external_oauth_gate (8-day staleness window).
steipete#2932 Codex known-zero history — known_zero field on CostSummary; set in both
    cache-debounce and full-scan paths (history_coverage_established &&
    sessions_count == 0); knownZero JSON field + CLI text update.
steipete#2963 Antigravity dashboard lanes — quota-bucket dedup in parse_user_status;
    models sharing the same (remaining_fraction, reset_time) collapse to one
    lane.
steipete#2516 Claude revoked vs missing OAuth — ProviderError::OAuthRevoked variant;
    revocation detection (401/403 with revoked/invalid_grant/token_revoked);
    15-min CLI result cache (LazyLock<Mutex<Option<CachedCliResult>>>);
    fetch_via_auto returns cached CLI result when OAuth revoked, and stale
    cache when all live sources fail.
Finesssee added a commit to nesszer/Win-CodexBar that referenced this pull request Aug 18, 2026
…n-zero history, Antigravity dashboard lanes, Claude OAuth revoked detection

steipete#2946 Codex routed models pricing — codex_routed_provider() + strip_route_prefix()
    in cost_pricing.rs; deepseek/, kimi/, opencode/ routes price against
    matching models.dev provider; unknown provider/ prefixes return None.
steipete#2944 Codex auth.json read-only during refresh — codex_external_oauth_sources_allowed
    setting (default OFF); is_external_oauth + last_refresh fields on
    CodexCredentials; enforce_external_oauth_gate (8-day staleness window).
steipete#2932 Codex known-zero history — known_zero field on CostSummary; set in both
    cache-debounce and full-scan paths (history_coverage_established &&
    sessions_count == 0); knownZero JSON field + CLI text update.
steipete#2963 Antigravity dashboard lanes — quota-bucket dedup in parse_user_status;
    models sharing the same (remaining_fraction, reset_time) collapse to one
    lane.
steipete#2516 Claude revoked vs missing OAuth — ProviderError::OAuthRevoked variant;
    revocation detection (401/403 with revoked/invalid_grant/token_revoked);
    15-min CLI result cache (LazyLock<Mutex<Option<CachedCliResult>>>);
    fetch_via_auto returns cached CLI result when OAuth revoked, and stale
    cache when all live sources fail.
Finesssee added a commit to nesszer/Win-CodexBar that referenced this pull request Aug 18, 2026
* Port upstream 0.50.1: Cursor rename + Ollama cookie stripping (steipete#2951, steipete#2949)

* Port upstream 0.50.1: OpenCode Go session+weekly pace in CLI (steipete#2957)

* Port upstream 0.50.1: chart axis label centering (steipete#2974)

* Port upstream 0.50.1: Kiro re-authenticate via kiro-cli login (steipete#2340)

* Port upstream 0.50.1: serve identity follows app redaction per-request (steipete#2960)

* Port upstream 0.50.1: Codex routed pricing, auth.json read-only, known-zero history, Antigravity dashboard lanes, Claude OAuth revoked detection

steipete#2946 Codex routed models pricing — codex_routed_provider() + strip_route_prefix()
    in cost_pricing.rs; deepseek/, kimi/, opencode/ routes price against
    matching models.dev provider; unknown provider/ prefixes return None.
steipete#2944 Codex auth.json read-only during refresh — codex_external_oauth_sources_allowed
    setting (default OFF); is_external_oauth + last_refresh fields on
    CodexCredentials; enforce_external_oauth_gate (8-day staleness window).
steipete#2932 Codex known-zero history — known_zero field on CostSummary; set in both
    cache-debounce and full-scan paths (history_coverage_established &&
    sessions_count == 0); knownZero JSON field + CLI text update.
steipete#2963 Antigravity dashboard lanes — quota-bucket dedup in parse_user_status;
    models sharing the same (remaining_fraction, reset_time) collapse to one
    lane.
steipete#2516 Claude revoked vs missing OAuth — ProviderError::OAuthRevoked variant;
    revocation detection (401/403 with revoked/invalid_grant/token_revoked);
    15-min CLI result cache (LazyLock<Mutex<Option<CachedCliResult>>>);
    fetch_via_auto returns cached CLI result when OAuth revoked, and stale
    cache when all live sources fail.

* Port upstream 0.50.1: Mistral PAYG spend, cost-summary display style, per-provider accent color

Item 1 — Mistral PAYG current-month API spend (steipete#2821, steipete#2947):
- Add MonthlyPlan variant to MetricPreference enum
- Add currency_symbol field to CostSnapshot with with_currency_symbol builder
- Set currency_symbol from Mistral billing API response
- Add MonthlyPlan to bridge label/parse, tray selected_metric_percent (None = no bar)
- Show formatted cost amount in provider_status_label for MonthlyPlan
- Add format_cost_amount helper in bridge.rs
- Add Mistral monthly spend row in MenuCardDetails
- Add monthlyPlan option to MenuBarMetricSection for Mistral

Item 2 — Menu cost-summary display style per provider (steipete#2976):
- Add CostSummaryDisplayStyle enum (Compact/Detailed/Hidden) in types.rs
- Add cost_summary_display_style field to Settings + Default + RawSettings round-trip
- Add to SettingsSnapshot bridge + SettingsUpdate + apply in Tauri commands
- Add bridge label/parse functions
- Apply in MenuCardDetails: hidden hides cost section, compact shows used/limit only
- Update describeCard to filter hasCost for hidden style
- Add Select control in UsageSpendTab

Item 3 — Per-provider accent color override (steipete#2972):
- Add accent_color field to ProviderConfig
- Add brand_color(ProviderId) function in provider.rs (mirrors frontend registry)
- Add accent_color/set_accent_color/effective_accent_color accessors in Settings
- Add set/get/get_effective Tauri commands + normalize_hex_accent_color validator
- Add providerAccentColors map to SettingsSnapshot bridge
- Add setProviderAccentColor/getProviderAccentColor/getProviderEffectiveAccentColor to tauri.ts
- Create AccentColorSection component (hex input, color picker, reset button)
- Inject --provider-accent CSS variable on MenuCard article and ChartsSection
- Update menu-metric__bar-fill and chart colors to use --provider-accent fallback
- Update chartPalette providerCostColor/providerCreditsColor fallback chain
- Pass providerAccentColors through TrayPanel/PopOutPanel/ProvidersTab/ProviderDetailPane

Also:
- Add 11 new locale keys to all 7 .ftl files + keys.ts
- Add costSummaryDisplayStyle + providerAccentColors to all test mock SettingsSnapshot
- Update chartPalette tests for --provider-accent fallback

* Resolve merge conflicts and fix gate checks

* Thermo-nuclear: extract ollama cookies, codex pricing, simplify accent color

* fix: correct serde attribute placement on currency_symbol after rebase
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. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants