Skip to content

Port Atlas Cloud balance provider from v0.66.0 - #618

Draft
Finesssee wants to merge 5 commits into
codex/port-0.65-account-source-packfrom
codex/port-0.66.0-atlas-cloud
Draft

Finesssee wants to merge 5 commits into
codex/port-0.65-account-source-packfrom
codex/port-0.66.0-atlas-cloud

Conversation

@Finesssee

@Finesssee Finesssee commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the Atlas Cloud balance provider from upstream v0.66.0 using Win-CodexBar's native Rust/Tauri patterns. It reads account-wide available USD through ATLASCLOUD_API_KEY or the existing keyring path, validates the typed API response, and registers the provider in settings and the frontend catalog. It reports the returned balance without inventing quota, spend, or history semantics.

This draft is stacked on #620 (codex/port-0.65-account-source-pack). The Atlas patch remains a single commit on that validated provider/account stack.

Validation

  • The Atlas patch's focused Rust tests passed before restacking (6 passed); the original review also passed Rust Clippy and frontend tests/build.
  • After restacking: cargo fmt --all -- --check and git diff --check passed.
  • CircleCI Windows pr-check passed on head f9b60dfa.
  • Thermo-nuclear re-review of f9b60dfa against e0a4bdc2 found no actionable maintainability issues.

Remaining evidence

  • Fresh Windows-native CUA proof for the provider UI surfaces is still pending. Frontend tests/build do not replace that proof.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee
Finesssee force-pushed the codex/port-0.66.0-atlas-cloud branch from 060408e to f9b60df Compare September 25, 2026 05:40
@Finesssee
Finesssee changed the base branch from main to codex/port-0.65-account-source-pack September 25, 2026 05:42
@Finesssee

Copy link
Copy Markdown
Collaborator Author

Thermo-nuclear code-quality review

Verdict: FINDINGS. Reviewed head f9b60dfaa against its base codex/port-0.65-account-source-pack.

P1: A USD balance is modeled as an unformatted display string

parse_balance checks that available.currency == "usd" and that the value is a decimal, then throws both facts away. It returns the raw string, and the provider emits it as ProviderDisplayDetail::new("atlascloud-available", "Available", balance) (atlascloud/mod.rs:90). The user sees 12.3456 with no currency symbol. Because the value is untyped, it also can't reach Usage & Spend, the balance formatting, or the preferred-currency conversion in #609.

The codebase already has a typed carrier for this: CostSnapshot::new(0.0, "USD", "Atlas Cloud balance").with_balance(amount), used by neuralwatt/mod.rs:253, helmcode.rs, huggingface and Claude web. Parse to f64 and emit a CostSnapshot with with_balance. format_balance then handles the display. That also removes the need to return the string verbatim, which makes is_decimal (:182) plus the parse::<f64>() / is_finite() double-check reducible to a single parse with a finiteness check.

P2: Two dashboard URLs for the same provider, and they disagree

  • ProviderMetadata.dashboard_url: https://atlascloud.ai/dashboard (atlascloud/mod.rs:47)
  • api_keys.rs:407 dashboard_url: https://www.atlascloud.ai/console

#610 (6eec2e2f) adds a resolver that prefers metadata and falls back to the API-key catalog, so this mismatch is already reachable. Choose the correct URL and define it once. The metadata is the canonical home; the API-key catalog entry should reuse it or leave it out.

P3 (pre-existing): HAS_DASHBOARD duplicates backend metadata

TrayPanel.tsx:30 is a hand-maintained set that mirrors metadata.dashboard_url, and every new provider has to edit it. The provider catalog could carry hasDashboard, which would delete the set. Not a blocker for this PR.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Thermo review correction: negative balances

This corrects the P1 in my earlier thermo review on this PR, which suggested using CostSnapshot::with_balance for the Atlas Cloud balance.

The suggestion as written would lose negative balances. with_balance stores the value through finite_amount, which clamps to >= 0 (rust/src/core/usage_snapshot.rs, around line 600), so a balance of -3.25 would display as $0.00. Upstream's APIBalancePluginTests at v0.66.0 require "0.00" → $0.00 and "-1.250000" → -$1.25.

Suggested shape instead:

  • Parse available.value to f64 once, keeping the existing strict decimal validation.
  • Keep the typed balance via CostSnapshot::with_balance for the non-negative case, so it still reaches balance formatting and Usage & Spend.
  • Also emit the formatted, signed amount ($95.50, -$1.25) as the display row or informational primary, so a deficit stays visible. xai/mod.rs has a local precedent.
  • Add tests for -3.25, "-1.250000", "0.00", "", " ", NaN, 1e999, 0x10, and a non-numeric body. The error must not echo the body.

The other findings still apply. For the dashboard URL, upstream v0.66.0 uses https://www.atlascloud.ai/console, so that should be the single canonical value. Upstream also sets loginMethod = "API".

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Adversarial validation (lane-A) at c7eb659

Review verdict: no defects in A-618's own diff (single commit f9b60dfa, 10 files, +355/−2). Matches the 0.66.0 audit row 1a: endpoint GET https://api.atlascloud.ai/public/v1/balance, bearer ATLASCLOUD_API_KEY (keyring target codexbar-atlascloud), envelope checks object=="balance" / scope=="account" / available.currency=="usd", signed-decimal string validation, 401→auth / 403→permission / 429→rate-limit / 5xx→unavailable / other→API-failure, no redirects, 1 MiB body cap, Auto|OAuth sources with Web/CLI rejected. Registration path complete (ProviderId, factory, token_accounts None, icon catalog, TrayPanel HAS_DASHBOARD, providerCatalog, api_keys entry). Tests pass (6 at the old head).

Merge outcome: the branch absorbed the finished #620 chain (4663218, which fixes the #619 merge defects in build_fetch_context) and the #676 parity amend (7522ae1: typed USD CostSnapshot balance with clamped typed value + signed $95.50/-$1.25 display row so zero and negative survive, with_login_method("API"), single canonical dashboard URL https://www.atlascloud.ai/console, upstream icon SVG + registry svgPath, expanded tests). Merge commits 8926a75d (into #676) and c7eb6591 (into #618, resolving the provider-count and duplicate-amend seams) — zero conflicts, no new dependencies.

Checks at c7eb659 (CARGO_TARGET_DIR=W:\cargo-target\lane-a, jobs=4, RUST_TEST_THREADS=4):

Fast-forward pushed f9b60dfa..c7eb6591.

Finesssee added a commit that referenced this pull request Oct 2, 2026
… HEAD's monthly-block import, adds #676 provider labels; abacus keeps the #719 audited accent)
@Finesssee

Copy link
Copy Markdown
Collaborator Author

Adversarial validation passed at b49dc2b

Scope: Atlas Cloud typed balance provider (#618, upstream 0.66.0), validated as merged into release/v0.70.0 (merge b49dc2b = merge of c7eb659 into 9240e34).

Attacks (highest-risk semantics, from the merged tree):

  • Typed USD balance with a signed display row: balance_result builds an informational "Account balance" primary plus a signed USD row; CostSnapshot::with_balance clamps negatives to zero, so a deficit (-$1.25) stays visible ONLY through the display row — the audit's "negative values preserved" requirement, with the formatting test pinning $95.50/-$1.25 and the negative-rounds-to-zero no-sign rule.
  • Strict signed-decimal parsing: parse_balance requires object == "balance" and available.value as a signed decimal string, rejecting non-numeric values with the audit's exact message rather than defaulting to 0 — a hostile payload cannot fabricate a balance.
  • Bounded response + fixed origin: the fetch uses the fixed https://api.atlascloud.ai/public/v1/balance origin with a bounded body read, so no redirect replay and no unbounded download.
  • Integration seam: the audit notes Port upstream 0.66.0: Atlas Cloud typed balance and parity (stacked on #618) #676 provider labels folded in and abacus kept the Port upstream 0.70.0: refresh 16 provider brand accents #719-audited accent — both verified in the merged commit message and stat (atlascloud/mod.rs +226, tests +245, api_keys +11 registration).

No defects found. READY for the un-draft rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant