Skip to content

feat(sdl): auto-match confidential compute deployments to capable providers - #3387

Closed
baktun14 wants to merge 1 commit into
mainfrom
feat/deployment-tee-provider-auto-match
Closed

feat(sdl): auto-match confidential compute deployments to capable providers#3387
baktun14 wants to merge 1 commit into
mainfrom
feat/deployment-tee-provider-auto-match

Conversation

@baktun14

@baktun14 baktun14 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Why

Part of CON-543.

When a tenant enables Confidential Compute (TEE) on a deployment, it must only ever be offered to providers that can actually run it. Today the per-service params.tee choice only lands in the provider manifest (TEEParams) — it never becomes an on-chain group placement requirement, so any provider can bid on a confidential workload and a won bid can't be honored as confidential.

@akashnetwork/chain-sdk's generateManifest builds group_spec.requirements.attributes exclusively from profiles.placement.<name>.attributes; it does not derive anything from params.tee. So the builder must inject the matching requirement itself.

What

Auto-manage a tee/type provider-matching requirement derived from the tenant's TEE choice, fully round-tripped and hidden from the manual attribute editor.

  • Export (sdlGenerator.ts): derive each placement's TEE type from its services' params.tee (CON-449 guarantees one shared type per placement) and merge tee/type: cpu | cpu-gpu into the placement attributes — mirroring the existing location-region handling.
  • Import (sdlImport.ts): drop tee/type in hydratePlacement (same lift as location-region) so it never populates the hand-editable attribute list and can't duplicate on re-export. The value is re-derived from params.tee (which already round-trips) on every export.

Single injection point covers both consumers: once tee/type is on the group spec, on-chain bidding and the marketplace bid-screening request (buildPlacementScreeningRequest) both pick it up automatically. Non-TEE deployments are unchanged.

Acceptance criteria

  • Enabling Confidential Compute auto-restricts the deployment to capable providers, no manual action.
  • CPU and CPU+GPU deployments round-trip (import → edit → re-export) losslessly, ending with exactly one requirement, no duplicates.
  • Re-importing an SDL that already carries the requirement does not add a second/conflicting one.
  • The requirement is not exposed in the manual attribute editor and cannot be hand-edited.
  • Consistent in managed Console and Console Air — this repo covers managed Console; Console Air is a separate repo (akash-network/console-air) with its own copy of these utils, so the same pattern must be mirrored there as a follow-up.

Verification

  • New unit tests in sdlGenerator.spec.ts / sdlImport.spec.ts cover injection (cpu/cpu-gpu), no-injection when off, merge with region + other attributes, single attribute for multi-service placements, import-drop, and no-duplication on re-import. Full affected SDL suite: 75 passing.
  • Confirmed end-to-end against the real generateManifest: a generated TEE SDL yields group requirements.attributes: [{"key":"tee/type","value":"cpu-gpu"}].

Note (to confirm with provider/AEP-83): matching key is tee/type with value cpu/cpu-gpu — the contract the console read side (confidentialCompute.ts) already uses. Only the constant changes if the provider expects a different key.

Summary by CodeRabbit

  • New Features

    • SDL generation now automatically adds the required confidential compute placement attribute when a service requests a TEE type.
    • Import and export flows now preserve this placement requirement without exposing it as a manually editable field.
  • Bug Fixes

    • Prevented duplicate TEE placement requirements when multiple services share the same placement.
    • Improved round-tripping so existing placement attributes remain intact while derived TEE requirements are handled consistently.

…viders

Derive the placement's TEE type from services' params.tee and inject a
tee/type provider-matching requirement into the generated SDL's placement
attributes, so only TEE-capable providers can bid/match. Strip it back out on
import (mirroring location-region) so it stays out of the manual attribute
editor and cannot duplicate across an import/export round-trip; the value is
re-derived from params.tee on every export.

Once present on the group spec, both on-chain bidding and the marketplace
bid-screening request pick it up automatically.
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds automatic derivation of a placement-level tee/type attribute from each service's params.tee during SDL generation, and excludes that auto-managed attribute from editable placement attributes during SDL import/hydration, with accompanying test coverage.

Changes

TEE type placement attribute

Layer / File(s) Summary
Derive and inject tee/type during generation
apps/deploy-web/src/utils/sdl/sdlGenerator.ts, apps/deploy-web/src/utils/sdl/sdlGenerator.spec.ts
generateSdl builds a teeTypeByPlacementId map from services' params.tee and merges a TEE_TYPE_ATTRIBUTE_KEY attribute into each placement's attributes; tests verify injection, omission, merging with other attributes, and deduplication.
Exclude tee/type from import hydration
apps/deploy-web/src/utils/sdl/sdlImport.ts, apps/deploy-web/src/utils/sdl/sdlImport.spec.ts
hydratePlacement skips attributes keyed by TEE_TYPE_ATTRIBUTE_KEY so they don't surface as editable fields; tests verify exclusion on import and no duplication on regenerate roundtrip.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

Suggested reviewers: stalniy

✨ 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/deployment-tee-provider-auto-match

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

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.43%. Comparing base (03f99fb) to head (e25c637).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3387      +/-   ##
==========================================
- Coverage   69.79%   68.43%   -1.37%     
==========================================
  Files        1100     1010      -90     
  Lines       26910    24577    -2333     
  Branches     6448     5990     -458     
==========================================
- Hits        18783    16819    -1964     
+ Misses       7133     6796     -337     
+ Partials      994      962      -32     
Flag Coverage Δ *Carryforward flag
api 85.13% <ø> (ø) Carriedforward from 03f99fb
deploy-web 54.98% <ø> (ø) Carriedforward from 03f99fb
log-collector ?
notifications 91.44% <ø> (ø) Carriedforward from 03f99fb
provider-console 81.38% <ø> (ø) Carriedforward from 03f99fb
provider-inventory ?
provider-proxy 86.26% <ø> (ø) Carriedforward from 03f99fb
tx-signer ?

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
apps/deploy-web/src/utils/sdl/sdlGenerator.ts 56.43% <ø> (ø)
apps/deploy-web/src/utils/sdl/sdlImport.ts 84.68% <ø> (ø)

... and 90 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
apps/deploy-web/src/utils/sdl/sdlGenerator.spec.ts (1)

67-105: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Good coverage, but missing a conflicting-TEE-in-shared-placement test.

The dedup test (line 95-105) only exercises two services with the same params.tee value. There's no test locking down behavior when two services share a placement but declare different TEE types — which is exactly the scenario the sdlGenerator.ts map-building logic (line 36-38) silently resolves via last-write-wins. Adding a test here would pin down intended behavior once/if that logic is hardened.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/deploy-web/src/utils/sdl/sdlGenerator.spec.ts` around lines 67 - 105,
Add a regression test in sdlGenerator.spec.ts for two services sharing the same
placement but declaring different params.tee values, since generateSdl currently
builds the placement attributes in a way that can be overwritten by
last-write-wins behavior. Use buildFormValues, buildLogCollectorService, and
generateSdl to assert the intended outcome for conflicting tee/type inputs in
the shared dcloud placement, so the behavior is explicitly pinned down alongside
the existing tee/type merge and dedup tests.
apps/deploy-web/src/utils/sdl/sdlGenerator.ts (1)

32-39: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Unvalidated cross-service TEE consistency invariant.

This map silently uses last-write-wins if two services sharing a placementId set different params.tee values, relying entirely on the comment's claim that "CON-449 guarantees" consistency. Unlike the unknown-placementId check a few lines down (line 82-84) that throws, there's no equivalent guard here — if the invariant is ever violated (e.g., a future UI change, a bug in the placement-assignment flow, or a manually-crafted form state), the mismatch is silently discarded rather than surfaced.

Consider adding a lightweight validation (e.g., detect a differing existing value in the map and throw/log) to fail loudly instead of silently picking one TEE type.

🛡️ Proposed defensive check
   const teeTypeByPlacementId = new Map<string, TeeType>();
   formValues.services.forEach(service => {
-    if (service.params?.tee) teeTypeByPlacementId.set(service.placementId, service.params.tee);
+    if (service.params?.tee) {
+      const existing = teeTypeByPlacementId.get(service.placementId);
+      if (existing && existing !== service.params.tee) {
+        throw new Error(`Placement "${service.placementId}" has services with conflicting TEE types: "${existing}" and "${service.params.tee}"`);
+      }
+      teeTypeByPlacementId.set(service.placementId, service.params.tee);
+    }
   });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/deploy-web/src/utils/sdl/sdlGenerator.ts` around lines 32 - 39, The
teeTypeByPlacementId map in sdlGenerator.ts currently does last-write-wins when
multiple services with the same placementId have different params.tee values, so
add a defensive consistency check in the service iteration to detect an existing
tee type mismatch and fail loudly instead of silently overwriting it. Update the
logic around teeTypeByPlacementId population to compare each service's
params.tee against any already stored value for that placementId and throw or
log an explicit validation error if they differ, using the sdlGenerator flow and
placement-based grouping as the reference point.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/deploy-web/src/utils/sdl/sdlGenerator.spec.ts`:
- Around line 67-105: Add a regression test in sdlGenerator.spec.ts for two
services sharing the same placement but declaring different params.tee values,
since generateSdl currently builds the placement attributes in a way that can be
overwritten by last-write-wins behavior. Use buildFormValues,
buildLogCollectorService, and generateSdl to assert the intended outcome for
conflicting tee/type inputs in the shared dcloud placement, so the behavior is
explicitly pinned down alongside the existing tee/type merge and dedup tests.

In `@apps/deploy-web/src/utils/sdl/sdlGenerator.ts`:
- Around line 32-39: The teeTypeByPlacementId map in sdlGenerator.ts currently
does last-write-wins when multiple services with the same placementId have
different params.tee values, so add a defensive consistency check in the service
iteration to detect an existing tee type mismatch and fail loudly instead of
silently overwriting it. Update the logic around teeTypeByPlacementId population
to compare each service's params.tee against any already stored value for that
placementId and throw or log an explicit validation error if they differ, using
the sdlGenerator flow and placement-based grouping as the reference point.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 63c39702-54c1-4ebe-b782-1eaec9b90885

📥 Commits

Reviewing files that changed from the base of the PR and between 03f99fb and e25c637.

📒 Files selected for processing (4)
  • apps/deploy-web/src/utils/sdl/sdlGenerator.spec.ts
  • apps/deploy-web/src/utils/sdl/sdlGenerator.ts
  • apps/deploy-web/src/utils/sdl/sdlImport.spec.ts
  • apps/deploy-web/src/utils/sdl/sdlImport.ts

@baktun14

baktun14 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Closing as redundant. chain-sdk 1.0.0-alpha.38 (already pinned in this repo) auto-injects the tee/type provider-matching requirement into group requirements from service.params.tee in generateManifest (lines 89-92), which both on-chain bidding and bid-screening already consume. This PR was written against a stale local node_modules (alpha.36) that predates that derivation. Worse, alpha.38's guard doesn't dedupe against profiles.placement.*.attributes, so this change would produce a duplicate tee/type requirement. CON-543 is effectively delivered by the dependency.

@baktun14 baktun14 closed this Jul 5, 2026
@baktun14
baktun14 deleted the feat/deployment-tee-provider-auto-match branch July 5, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant