Skip to content

Add DeepInfra usage provider#2238

Merged
steipete merged 8 commits into
steipete:mainfrom
billerickson:codex/deepinfra-provider
Jul 17, 2026
Merged

Add DeepInfra usage provider#2238
steipete merged 8 commits into
steipete:mainfrom
billerickson:codex/deepinfra-provider

Conversation

@billerickson

@billerickson billerickson commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add DeepInfra as an API-token provider
  • show prepaid balance, current-month spend, optional spending limit, and suspension status
  • convert the usage endpoint total_cost from cents to dollars
  • derive available funds from funded balance minus recent unbilled usage, with the remaining percentage scaled to the funded amount
  • add settings, environment, CLI, widget, icon, documentation, and mocked API coverage

Testing

  • env LC_ALL=C LANG=C make check
  • swift test --filter DeepInfra on Xcode 26.3 (passed)
  • universal arm64/x86_64 debug app packaging and ad-hoc signature verification (passed)
  • mocked DeepInfra request, parsing, authentication, balance, timeout, and menu-bar tests
  • live smoke test in the forked debug app confirmed authentication and exposed the billing-unit/balance semantics corrected here

Local make test is blocked because this Mac has Swift 6.0.3 while CodexBar and SweetCookieKit require Swift 6.2. The supported Xcode 26.3 fork workflow compiled the production and test targets successfully. No live API token is accessed by tests or CI.

@billerickson
billerickson marked this pull request as ready for review July 16, 2026 23:51
@billerickson

billerickson commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Live validation completed against a real DeepInfra account using a dedicated temporary API token:

  • DeepInfra billing dashboard: $95.81 prepaid credits, $3.94 monthly usage, no limit
  • CodexBar test build: $95.81 available, $3.94 spent this month, 96% left
  • Refresh completed successfully with the corrected billing units and balance calculation

The API token was not shared with tests or CI.

screenshot 1

screenshot 2

@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: 21bb74d801

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

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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. P2 Normal priority bug or improvement with limited blast radius. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed July 17, 2026, 5:20 PM ET / 21:20 UTC.

Summary
Adds DeepInfra API-token usage tracking across provider registration, billing fetch/parsing, token settings, menu and CLI presentation, documentation, icons, and focused tests.

Reproducibility: yes. in source: create a suspended DeepInfra snapshot whose detail begins with suspension text and call the automatic metric renderer; its $-prefix guard rejects the balance segment. This review did not execute the app because the checkout is read-only.

Review metrics: 2 noteworthy metrics.

  • Patch surface: 36 files affected; 937 added, 98 removed. The provider touches core fetching, credential paths, UI presentation, CLI output, docs, icons, and tests, so final review should consider it as a cross-surface integration rather than a parser-only change.
  • Billing endpoints: 2 new authenticated API requests. The provider depends on both billing-checklist and current-month usage responses to derive the displayed balance and spend.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Repair the suspended balance extraction and add regression coverage for suspended available and owed balances.
  • Obtain maintainer confirmation that DeepInfra should remain a core supported provider.

Risk before merge

  • [P1] Suspended DeepInfra accounts can show the exhausted 0% metric rather than their actual available or owed balance.
  • [P1] This adds a durable core provider surface, so merge should follow an explicit maintainer decision rather than treating the implementation alone as product acceptance.

Maintainer options:

  1. Decide the mitigation before merge
    If maintainers sponsor DeepInfra as a core provider, preserve the balance extraction for suspended snapshots and add focused coverage for both available and owed suspended states before merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] A narrow renderer-and-test repair can be prepared automatically while maintainer sponsorship decides whether the provider should land.

Maintainer decision needed

  • Question: Should CodexBar accept DeepInfra as a supported core API-token provider after the suspended-balance display defect is repaired?
  • Rationale: The patch adds a new provider rather than repairing an established contract; existing integration work and proof show it is viable, but they do not by themselves establish the permanent core-support boundary.
  • Likely owner: steipete — Recent branch integration commits make steipete the most relevant available owner for the core-provider scope decision.
  • Options:
    • Sponsor the core provider (recommended): Keep the DeepInfra provider in core after the focused suspended-balance repair and normal final review.
    • Decline core support: Close the provider addition if the project prefers not to expand its maintained provider catalog for this service.

Security
Cleared: The diff adds HTTPS billing requests and existing-style API-token resolution without new dependencies, workflow changes, broadened permissions, or concrete supply-chain concerns.

Review findings

  • [P2] Preserve suspended DeepInfra balances in the menu metric — Sources/CodexBar/StatusItemController+Animation.swift:957-958
Review details

Best possible solution:

If maintainers sponsor DeepInfra as a core provider, preserve the balance extraction for suspended snapshots and add focused coverage for both available and owed suspended states before merge.

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

Yes, in source: create a suspended DeepInfra snapshot whose detail begins with suspension text and call the automatic metric renderer; its $-prefix guard rejects the balance segment. This review did not execute the app because the checkout is read-only.

Is this the best way to solve the issue?

No, not yet: the overall provider approach fits the existing API-token architecture, but the menu-bar renderer must tolerate the documented suspension prefix and maintainers must explicitly accept the new core provider surface.

Full review comments:

  • [P2] Preserve suspended DeepInfra balances in the menu metric — Sources/CodexBar/StatusItemController+Animation.swift:957-958
    When toUsageSnapshot() prefixes the balance detail with Suspended…, this $ prefix check fails and the automatic metric falls back to the exhausted 0% window. Parse the embedded balance/owed segment instead and add a suspended-state regression test; this concern became visible in the latest review discussion after the prior review head.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The PR includes live-account screenshots and a stated dashboard-to-app comparison showing corrected prepaid balance and monthly spend after the implementation; the screenshots directly support this visible provider behavior.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a useful provider addition with a concrete display correctness defect, but the observed impact is limited to DeepInfra users.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The PR includes live-account screenshots and a stated dashboard-to-app comparison showing corrected prepaid balance and monthly spend after the implementation; the screenshots directly support this visible provider behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes live-account screenshots and a stated dashboard-to-app comparison showing corrected prepaid balance and monthly spend after the implementation; the screenshots directly support this visible provider behavior.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR includes live-account screenshots and a stated dashboard-to-app comparison showing corrected prepaid balance and monthly spend after the implementation; the screenshots directly support this visible provider behavior.
Evidence reviewed

Acceptance criteria:

  • [P1] swift test --filter DeepInfra.
  • [P1] swift test --filter StatusItemBalanceDisplayTests.
  • [P1] make check.

What I checked:

  • Current main lacks the requested provider: The PR adds the deepinfra case to the provider enum and registry; the current-main provider surface at the stated base SHA has no DeepInfra implementation, so this is not already implemented work. (Sources/CodexBarCore/Providers/Providers.swift:44, 0844c878a9bc)
  • Concrete suspended-account regression: The new balance renderer requires the selected detail segment to begin with $, while the new DeepInfra snapshot prefixes suspended balances with suspension text; the documented suspended path therefore falls back to the exhausted percentage display instead of the balance/owed amount. (Sources/CodexBar/StatusItemController+Animation.swift:957, fa2dc2add05b)
  • Real after-fix behavior proof: The contributor supplied a live DeepInfra account comparison showing dashboard values of $95.81 prepaid credits and $3.94 monthly usage matched by the CodexBar test build, with screenshots in the PR discussion. (21bb74d801c2)
  • Recent core-provider integration involvement: The branch history includes scope and merge-resolution commits by steipete around the provider-integration surfaces, making that person the strongest available routing candidate for the core-provider decision. (Sources/CodexBarCore/Providers/ProviderDescriptor.swift:94, 4ba1c7988410)

Likely related people:

  • steipete: Authored the branch's provider-scope and main-integration commits and is the strongest available history signal for whether this provider belongs in the core app. (role: recent area contributor; confidence: medium; commits: 4ba1c7988410, 6e82f86fb82c, fa2dc2add05b; files: Sources/CodexBarCore/Providers/ProviderDescriptor.swift, Sources/CodexBar/StatusItemController+Animation.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

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.
Review history (2 earlier review cycles)
  • reviewed 2026-07-17T00:31:20.441Z sha 21bb74d :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T19:17:03.566Z sha 4ba1c79 :: needs maintainer review before merge. :: none

steipete added 2 commits July 17, 2026 20:11
# Conflicts:
#	Sources/CodexBar/MenuCardView.swift
#	Sources/CodexBar/MenuDescriptor.swift
#	Sources/CodexBar/SettingsStore+MenuPreferences.swift
#	Sources/CodexBar/UsageStore.swift
#	Sources/CodexBarCore/Config/ProviderConfigEnvironment.swift
#	Sources/CodexBarCore/Generated/CodexParserHash.generated.swift
#	Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner.swift
#	docs/cli.md

@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: 4ba1c79884

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

guard
let detail = snapshot?.primary?.resetDescription?
.trimmingCharacters(in: .whitespacesAndNewlines),
detail.hasPrefix("$"),

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 Preserve suspended DeepInfra balance in menu bar

When DeepInfra reports a suspended account, DeepInfraUsageSnapshot.toUsageSnapshot() prefixes resetDescription with Suspended... before the $… available/owed text. This guard then fails because the detail no longer starts with $, so the automatic menu-bar metric falls back to the exhausted 0% window instead of showing the balance/owed amount for exactly the suspended accounts this code handles.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added 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. and removed 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. labels Jul 17, 2026
@steipete
steipete merged commit eb26164 into steipete:main Jul 17, 2026
13 of 15 checks passed
@steipete

Copy link
Copy Markdown
Owner

Merged after maintainer verification.

Security/API review:

  • Requests are limited to the official HTTPS api.deepinfra.com billing endpoints, with official status.deepinfra.com metadata. The API key uses standard Bearer authentication through CodexBar's provider transport/token resolution. No endpoint override, secret logging, or raw-response logging.
  • Verified DeepInfra's billing contract: /payment/checklist?compute_owed=true returns Stripe balance, recent unbilled amount, spending limit, and suspension state; /payment/usage?from=current returns total_cost in cents. The UI reports available/owed dollar balance and monthly spend. It does not invent a funded percentage; only a real configured spending limit supplies a percentage denominator.

Local proof on exact head fa2dc2add05b04878cf59e4616ec8a929e48b2f8:

  • swift test --filter 'DeepInfra|ProviderRegistryTests|ConfigurationDocsProviderIDTests': 22 tests across 6 suites passed.
  • swift test --filter StatusItemBalanceDisplayTests: 34 tests passed, including suspended-balance regression coverage.
  • make check: app/site locales, parser hash, SwiftFormat, and SwiftLint all passed.
  • Earlier full make test: 699 selections across 59 groups passed; one unrelated Kiro timing group recovered on the harness retry.
  • Source-blind synthetic behavior validation: 16 tests passed. Final maintainer autoreview found no actionable defects.

Live probe: unavailable because no maintainer-owned DeepInfra credential was authorized. The contributor's prior temporary-token screenshot on this PR showed the expected prepaid balance and monthly-spend presentation. Fresh maintainer proof used synthetic payloads, source-blind validation, and CI.

CI: run 29614208110 passed on the exact head: lint, Linux x64/arm64 builds and tests, both macOS shards, aggregate gate, and GitGuardian. One unrelated Kiro prompt-return timing assertion exceeded its 8-second ceiling by 0.62 seconds on the first macOS shard-1 attempt; the exact-head failed-job retry passed.

Merged as eb26164e0c3e60107f8aeaadd0e058ece16c85cf.

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: 🦐 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