Skip to content

Support Cloud Hypervisor primaries with static script enclaves - #67772

Merged
lpcox merged 5 commits into
mainfrom
copilot/support-compiling-cloud-hypervisor-enclave
Oct 11, 2026
Merged

lpcox merged 5 commits into
mainfrom
copilot/support-compiling-cloud-hypervisor-enclave

Conversation

Copilot AI commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

The compiler rejected Cloud Hypervisor primary agents combined with enclaves, blocking compiler-owned workflows targeting AWF’s unified workload backend. This change enables the same-backend combination for static script enclaves while keeping it experimental; compilation is not evidence of Linux/KVM acceptance or production readiness.

  • Compiler: Permit matching Cloud Hypervisor primary and enclave runtimes; reject backend mismatches and agent enclaves with a Cloud Hypervisor primary.
  • Runtime setup: Preserve attested primary and enclave artifacts from the same AWF release, plus mcpg attachment and isolated handoffs.
  • Documentation: Specify AWF v0.28.47+, experimental status, and the acceptance boundary.
sandbox:
  agent:
    runtime: cloud-hypervisor
    version: v0.28.47
enclaves:
  - script:
    runtime: cloud-hypervisor
    repos:
      - repo: octo-org/private-service
        sensitivity: confidential

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Support compiling a unified Cloud Hypervisor primary and static script enclave Support Cloud Hypervisor primaries with static script enclaves Oct 11, 2026
Copilot AI requested a review from lpcox October 11, 2026 19:51
@lpcox
lpcox marked this pull request as ready for review October 11, 2026 19:53
Copilot AI balanced review requested due to automatic review settings October 11, 2026 19:53
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Lean already. Ship.

Generated by Ponytail Reviewer for #67772

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

Copilot AI 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.

🟡 Changes recommended

The version gate targets unsupported AWF releases, and some conflicting runtime overrides bypass validation.

2 open findings
What changed in this PR

Enables experimental Cloud Hypervisor primaries with static Cloud Hypervisor script enclaves while preserving artifact and MCP gateway wiring.

Changes:

  • Allows matching Cloud Hypervisor primary/enclave runtimes.
  • Adds mismatch validation and compilation coverage.
  • Documents requirements and acceptance boundaries.
File Description
pkg/​workflow/​sandbox_validation.go Removes the blanket enclave rejection.
pkg/​workflow/​enclaves_runtime.go Adds combination-specific validation.
pkg/​workflow/​enclaves_runtime_test.go Tests runtime compatibility rules.
pkg/​workflow/​enclave_cloud_hypervisor_test.go Verifies generated setup and gateway wiring.
pkg/​workflow/​cloud_hypervisor_test.go Updates sandbox validation expectations.
docs/​src/​content/​docs/​experimental/​enclaves.md Documents the experimental combination.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

case AgentRuntimeDockerSudoIptables:
return errors.New("enclaves cloud-hypervisor runtime is incompatible with sandbox.agent.runtime: docker-sudo-iptables; use sandbox.agent.runtime: docker")
case "sbx", AgentRuntimeCloudHypervisor, "nvx":
case "sbx", "nvx":

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 695f9a9: the combined Cloud Hypervisor primary/script-enclave path now requires AWF v0.28.51+, separately from the v0.28.47 standalone enclave minimum. The default AWF version and sample/tests were updated.

Comment thread pkg/workflow/enclaves_runtime.go Outdated
Comment on lines +106 to +113
switch runtime {
case "sbx", "nvx":
return fmt.Errorf("enclaves cloud-hypervisor runtime is incompatible with --container-runtime %s; use a Docker primary agent runtime", runtime)
case "docker", "cloud-hypervisor":
if runtime != primaryRuntime {
return fmt.Errorf("enclaves cloud-hypervisor runtime requires --container-runtime %s to match sandbox.agent.runtime", primaryRuntime)
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 695f9a9: --container-runtime is now rejected unless its value exactly matches the primary runtime, including unknown, gvisor, and missing values. Regression tests cover both argument forms and duplicate overrides.

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (113 new lines in pkg/, above the 100-line threshold) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/67772-allow-cloud-hypervisor-primary-with-script-enclaves.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

🔍 Decision inferred from the diff
  • Decision: Permit a Cloud Hypervisor primary agent together with Cloud Hypervisor static script enclaves, enforcing backend parity instead of banning the combination (sandbox_validation.go blanket rejection removed; enclaves_runtime.go now matches --container-runtime against the resolved primary runtime and rejects agent enclaves under a VM primary).
  • Driver: Compiler-owned workflows targeting AWF's unified workload backend need one microVM backend for both primary and enclaves; the previous rule forced a Docker primary.
  • Alternatives visible in the diff: keep the blanket rejection (Docker primary only); allow all enclave kinds including agent enclaves.
  • Consequences: same-release artifact coordination and more actionable mismatch errors, versus a weaker compile-time signal for an unvalidated Linux/KVM configuration and a more complex runtime-compatibility matrix.
📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and list real alternatives you considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-67772: Allow a Cloud Hypervisor Primary Agent with Static Script Enclaves

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · opus50 · 48.8 AIC · ⌖ 51.1 AIC · ⊞ 1.8K · ◷
Comment /review to run again

@lpcox

lpcox commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

@github-actions github-actions 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.

Request changes

This relaxes the Cloud Hypervisor validation too far: a Cloud Hypervisor primary can now slip through with default/Docker enclaves that never selected the supported runtime.

Blocking themeThe new implementation only runs the Cloud Hypervisor enclave checks when at least one enclave already declares `runtime: cloud-hypervisor`. Because this PR also removes the previous hard rejection for Cloud Hypervisor primaries with enclaves, unsupported primary+default-runtime enclave combinations now validate successfully instead of failing closed.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 55.9 AIC · ⌖ 5.64 AIC · ⊞ 21.1K
Comment /review to run again

Comment thread pkg/workflow/enclaves_runtime.go
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

Copilot AI commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Addressed in 695f9a9: the unified primary/script-enclave path now requires AWF v0.28.51+, while standalone VM enclaves retain v0.28.47 support. All mismatched or missing runtime overrides are rejected, as are Docker/default enclaves under a Cloud Hypervisor primary. Updated regression tests, sample, and ADR. Build, focused tests, lint, impacted-test gate, workflow drift checks, secret scan, and fallback code review passed. Automated review was unavailable; CodeQL skipped analysis due to database size.

@github-actions github-actions 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.

Skills-Based Review 🧠

Applied /tdd on the validation path for Cloud Hypervisor primary + enclave compatibility. Requesting changes: one real validation gap that lets a declared-incompatible configuration compile successfully.

📋 Key Themes & Highlights

Key Themes

  • Validation gap: validateCloudHypervisorEnclaves checks the primary/enclave runtime match only through --container-runtime AWF args (validateCloudHypervisorEnclaveAWFArgs), but never validates that enclave.Runtime itself equals cloud-hypervisor when the primary is cloud-hypervisor. A Docker-runtime (or default/omitted-runtime) enclave combined with a Cloud Hypervisor primary compiles without error, contradicting both the PR description and the new docs text ("A Cloud Hypervisor primary may be combined with static script enclaves when both explicitly select cloud-hypervisor").
  • Test coverage masks the gap: every new/updated test case uses the cloudHypervisorEnclaveWorkflowData helper, which unconditionally forces every enclave's Runtime to cloud-hypervisor before the mutation under test runs. No test exercises a CH primary paired with a Docker/default-runtime enclave, so TDD's red-green loop never surfaced this.
  • Reproduced directly: compiling a markdown workflow with sandbox.agent.runtime: cloud-hypervisor and an enclave omitting runtime: produces a lock file containing both the CH primary's --container-runtime cloud-hypervisor and a Docker-shaped enclave config side-by-side.

Positive Highlights

  • ✅ Clean extraction of validateCloudHypervisorEnclaveAWFArgs to share the AWF-arg parsing between the pre-existing Docker-only path and the new dual-runtime path.
  • ✅ Good coverage of the already-handled failure modes (agent enclave + CH primary, conflicting --container-runtime args in both directions).
  • ✅ Documentation clearly states the experimental scope and acceptance boundary.

Flagged the gap inline with a suggested fix and regression test. Everything else in the diff looks solid.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 360.7 AIC · ⌖ 13.7 AIC · ⊞ 10.3K
Comment /matt to run again

return err
}
for i, enclave := range workflowData.Enclaves {
if enclave.Runtime != string(AgentRuntimeCloudHypervisor) {

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.

[/tdd] With a Cloud Hypervisor primary, validateCloudHypervisorEnclaves never checks that each enclave's runtime is actually cloud-hypervisor; it only rejects a non-cloud-hypervisor enclave when the enclave list already contains at least one cloud-hypervisor entry (gated by hasCloudHypervisorEnclaves at line 42). A workflow with sandbox.agent.runtime: cloud-hypervisor and an enclave that omits runtime (or sets runtime: docker) compiles successfully today, emitting a lock file that still stages the CH bundle/enclave-artifact steps and --container-runtime cloud-hypervisor for the primary while the enclave config silently requests Docker — exactly the Docker/VM mismatch this PR's validation is meant to prevent.

💡 Reproduction and suggested fix

Verified by compiling (with the private cloudHypervisorEnclaveWorkflowData test helper) a sandbox.agent.runtime: cloud-hypervisor workflow whose single enclave had Runtime: "" and Runtime: "docker": both pass validateEnclavesConfig with err == nil, and compiling an equivalent markdown workflow produces a lock file containing both --container-runtime cloud-hypervisor for the primary and the Docker-shaped enclave entry.

Add an explicit check once a CH primary is detected, e.g. in validateCloudHypervisorEnclaves:

if isCloudHypervisorRuntime(workflowData) {
    for i, enclave := range workflowData.Enclaves {
        if enclave.Runtime != string(AgentRuntimeCloudHypervisor) {
            return fmt.Errorf("enclaves[%d].runtime must be cloud-hypervisor when sandbox.agent.runtime is cloud-hypervisor; Docker and default enclave runtimes are not supported with a Cloud Hypervisor primary", i)
        }
    }
}

Add a regression test (e.g. in enclaves_runtime_test.go) asserting this combination is rejected, matching the existing cloudHypervisorEnclaveWorkflowData helper pattern.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Already addressed in 695f9a9: the enclave validation explicitly rejects each non-Cloud-Hypervisor runtime, including omitted and Docker values, with regression tests for both cases.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/workflow/enclaves_runtime.go:34): This permits the unified primary/enclave path while it is still gated only by AWFEnclaveCloudHypervisorMinVersion (v0.28.47), and the default is v0.28.50. Both releases predate upstream backend resolution/lifecycle PRs Remove invalid GITHUB_TOKEN fallback for project operations #9771 and [agentics] Dev Hawk failed #9776; the first release whose history contains those changes is v0.28.51. A workflow pinned to the documented v0.28.47 therefore compiles against an AWF release that cannot provide this same-backend lifecycle. Gate this specific combination on v0.28.51 (separately from standalone VM enclaves) and update the sample/tests/default-version handling accordingly... - Support Cloud Hypervisor primaries with static script enclaves #67772 (comment)
  3. Review (pkg/workflow/enclaves_runtime.go:113): This switch lets other runtime values bypass the backend-match check. AWF recognizes gvisor and passes arbitrary values through as Docker runtime names, while custom arguments are emitted after the compiler-owned Cloud Hypervisor flag; for example, --container-runtime gvisor is accepted here despite contradicting the primary runtime. Reject every value other than primaryRuntime (including a missing value), rather than allowlisting only four mismatches. - Support Cloud Hypervisor primaries with static script enclaves #67772 (comment)
  4. Review (pkg/workflow/enclaves_runtime.go:60): This now lets a cloud-hypervisor primary compile with enclaves that never opted into runtime: cloud-hypervisor, so the compiler accepts a primary+Docker/default enclave combination that the new docs explicitly call unsupported. - Support Cloud Hypervisor primaries with static script enclaves #67772 (comment)
  5. Review (pkg/workflow/enclaves_runtime.go:60): [/tdd] With a Cloud Hypervisor primary, validateCloudHypervisorEnclaves never checks that each enclave's runtime is actually cloud-hypervisor; it only rejects a non-cloud-hypervisor enclave when the enclave list already contains at least one cloud-hypervisor entry (gated by hasCloudHypervisorEnclaves at line 42). A workflow with sandbox.agent.runtime: cloud-hypervisor and an enclave that omits runtime (or sets runtime: docker) compiles successfully today, emitting a lock file that still stages the CH bundle/enclave-artifact steps and --container-runtime cloud-hypervisor... - Support Cloud Hypervisor primaries with static script enclaves #67772 (comment)

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 695f9a9
Sous-chef work: 64d1f5ca4b42335b288cc0ef87aa1c539e9dcc7f73756232e0fe16b863919ac5 7c47cf1bd26354fe345e454de6e8fe579719e79d2974f4a7fdd901485c95be26 87e951270d52a9be2734f50e68dbb8631527f2f80b85fb8c9310bd64536b6285 be94ed66c7a70425582465a5ec8c9f63802a2696b570573c77a818b00aaf84ac
Sous-chef state: 16f9c2741d3f8ef629c8898dd86eb3ff49802d91057c098a72c165e1988a2ddc

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · 4.42 AIC · ⌖ 8.86 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

…ling-cloud-hypervisor-enclave

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for this contribution, Copilot! 👋 This PR looks ready for review — it includes tests for the Cloud Hypervisor + enclave feature, updated docs, and a clear description. The focused 292-line diff is easy to review. Great work!

Generated by ✅ Contribution Check · copilot · auto · 40.8 AIC · ⌖ 0.61 AIC · ⊞ 9.2K · ◷

Copilot AI requested a review from gh-aw-bot October 11, 2026 21:05
@lpcox
lpcox merged commit c16656e into main Oct 11, 2026
37 checks passed
@lpcox
lpcox deleted the copilot/support-compiling-cloud-hypervisor-enclave branch October 11, 2026 21:38
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.91.8

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.

Support compiling a unified Cloud Hypervisor primary + static script enclave

4 participants