Skip to content

feat(common): add ComputeBroker variant to CloudProvider enum#439

Open
epappas wants to merge 1 commit into
mainfrom
feat/compute-broker-cloud-provider
Open

feat(common): add ComputeBroker variant to CloudProvider enum#439
epappas wants to merge 1 commit into
mainfrom
feat/compute-broker-cloud-provider

Conversation

@epappas
Copy link
Copy Markdown
Contributor

@epappas epappas commented Apr 27, 2026

Summary

Prerequisite for the upcoming basilica-compute-broker service (basilica-backend #326). Adds CloudProvider::ComputeBroker so the SDK can deserialize GpuOffering rows with provider=\"compute-broker\" once the backend ships.

Single file change (+62 lines) following the precedent set by Denvr (20d3b983), Shadeform (738f6e27), and MassCompute (683ba3fe).

Why this PR ships before any backend change

basilica-sdk re-exports GpuOffering directly from basilica-common (crates/basilica-sdk/src/types.rs:541). GpuOffering.provider is the strongly-typed CloudProvider enum. If a backend deployment shipped provider=\"compute-broker\" on the wire before every CLI/SDK had this variant, the entire Vec<GpuOffering> response from /secure-cloud/gpu-prices would fail to deserialize on the client side — not just the broker rows.

This is the same regression mode documented in the Shadeform onboarding architecture doc (basilica-backend docs/architecture/SECURE-CLOUD-PROVIDER-ONBOARDING-ARCHITECTURE.md §6) and the reason Phase P1 of #326 must merge and release before Phase P3 ships.

Wire form

The architecture doc's offering ID format is compute-broker-<backend>-<product_id>-<region> (e.g. compute-broker-contabo-V92-EU), so the wire form is \"compute-broker\" with a hyphen.

The default #[serde(rename_all = \"lowercase\")] on CloudProvider would have produced \"computebroker\"; this PR overrides with #[serde(rename = \"compute-broker\")] on the variant.

FromStr accepts case-insensitive aliases: compute-broker, compute_broker, computebroker, ComputeBroker.

Tests

All in crates/basilica-common/src/types.rs::cloud_provider_tests (12 tests pass; clippy clean):

  • test_cloud_provider_as_str — extended with compute-broker
  • test_cloud_provider_from_str_compute_brokernew, covers all 5 alias spellings
  • test_cloud_provider_serde_all_variants — extended with the new variant
  • test_gpu_offering_with_compute_broker_providernew, deserializes a GpuOffering whose id matches the offering-id format the broker will emit (compute-broker-contabo-V92-EU); this is the exact regression probe for the SDK-break-on-unknown-provider class

Verification

```
cargo test -p basilica-common --lib types::cloud_provider

12 passed; 0 failed; 0 ignored

cargo clippy -p basilica-common --all-targets -- -D warnings

clean

cargo build -p basilica-sdk -p basilica-cli

clean

```

What this PR does not do

  • Does not bump basilica-cli / basilica-sdk / basilica-sdk-python versions — that's a follow-up release PR (P1b in feat(hyperstack): update rate limit defaults for production usage #326's plan), opened after this merges, that publishes the new variant to PyPI / crates so basilica-backend can then ship the broker without breaking existing clients.
  • Does not implement any backend logic — the variant is inert until basilica-backend #326 Phase P3/P4 lands.

Merge note

Per project convention (feedback_never_squash), this should be merged with --merge, not --squash.

References

  • Tracking issue: basilica-backend #326
  • Companion architecture doc (private repo): `docs/architecture/COMPUTE-BROKER-ARCHITECTURE.md` — §16.1 offering-id format, Appendix A Phase-0 findings
  • Onboarding pattern this PR follows: `docs/architecture/SECURE-CLOUD-PROVIDER-ONBOARDING-ARCHITECTURE.md` §6 cross-repo release choreography
  • Precedent commits in this repo: Denvr 20d3b983, Shadeform 738f6e27, MassCompute 683ba3fe

Test plan

  • cargo test -p basilica-common --lib types::cloud_provider — 12 / 12 pass
  • cargo clippy -p basilica-common --all-targets -- -D warnings — clean
  • cargo build -p basilica-sdk -p basilica-cli — clean (downstream consumers compile)
  • New regression probe test_gpu_offering_with_compute_broker_provider deserializes the exact offering-id format the broker will emit

Summary by CodeRabbit

  • New Features

    • Added ComputeBroker as a supported cloud provider with full parsing and serialization support.
  • Tests

    • Extended test coverage to validate ComputeBroker provider handling and GPU offering deserialization with the new provider format.

Prepares CLI/SDK for the upcoming basilica-compute-broker service
(basilica-backend #326). Without this variant, any GpuOffering with
provider="compute-broker" returned from /secure-cloud/gpu-prices
fails to deserialize on every Rust SDK consumer — and because
GpuOffering.provider is a strongly-typed enum, the entire Vec
fails, not just the broker rows.

basilica-sdk re-exports GpuOffering directly from basilica-common
(crates/basilica-sdk/src/types.rs:541), so the fix lives entirely
in this crate.

The wire form is "compute-broker" (with hyphen) per the architecture
doc's offering-id format compute-broker-<backend>-<product_id>-<region>.
The default #[serde(rename_all = "lowercase")] on CloudProvider would
produce "computebroker"; we override with #[serde(rename =
"compute-broker")] on the variant.

FromStr accepts case-insensitive aliases: compute-broker,
compute_broker, computebroker, ComputeBroker.

Tests cover the enum-string roundtrip + GpuOffering deserialization
with the offering-id format the broker will actually emit
(compute-broker-contabo-V92-EU). Matches the precedent set when
Denvr was added (20d3b98), Shadeform before that (738f6e2), and
MassCompute (683ba3f).

Refs: basilica-backend#326
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2927570f-37d2-4bf8-bb2a-fe05d6a6344c

📥 Commits

Reviewing files that changed from the base of the PR and between 76782bd and 32ba753.

📒 Files selected for processing (1)
  • crates/basilica-common/src/types.rs

Walkthrough

A new ComputeBroker variant was added to the CloudProvider enum with serde mapping to "compute-broker". The as_str() and FromStr implementations were updated to handle the new variant, and tests were expanded to validate parsing, serialization, and deserialization behavior.

Changes

Cohort / File(s) Summary
CloudProvider Enum Extension
crates/basilica-common/src/types.rs
Added ComputeBroker variant to CloudProvider enum with serde rename attribute. Updated as_str() and FromStr trait implementations to recognize the new provider. Expanded test suite to validate parsing, serialization, and deserialization of ComputeBroker including GPU offering ID format.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A broker arrives on the cloud so grand,
With compute powers at its command,
The enum grew, the tests align,
New variants parse, serialize fine,
Another provider joins the clan! ☁️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(common): add ComputeBroker variant to CloudProvider enum' accurately and concisely describes the main change: adding a new variant to an existing enum in the common crate.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/compute-broker-cloud-provider

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 and usage tips.

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