Skip to content

Refactor Cloud Hypervisor runtime backend into focused modules - #8518

Merged
lpcox merged 6 commits into
mainfrom
copilot/refactor-split-runtime-backend
Sep 14, 2026
Merged

lpcox merged 6 commits into
mainfrom
copilot/refactor-split-runtime-backend

Conversation

Copilot AI commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

CloudHypervisorRuntimeBackend mixed boot orchestration, guest execution, readiness probing, and cleanup/diagnostics in one large file. This made the security-sensitive guest network readiness path harder to review independently.

  • Runtime facade

    • Moved the implementation to src/cloud-hypervisor/runtime-backend.ts.
    • Kept src/cloud-hypervisor-runtime-backend.ts as a compatibility re-export.
  • Boot lifecycle

    • Extracted boot retry orchestration, manager creation, filesystem write-policy planning, and readiness gating into runtime-boot-loop.ts.
  • Readiness probing

    • Extracted guest network readiness and service connectivity probes into runtime-readiness.ts.
    • Split long probe logic into smaller helpers for probe construction, execution, and failure formatting.
  • Cleanup and diagnostics

    • Extracted teardown, artifact snapshot cleanup, failed-boot diagnostics, and guest network diagnostic capture into runtime-cleanup.ts.
    • Preserved final-attempt diagnostics state across thrown startup failures.
  • Shared constants

    • Centralized shared runtime constants such as guest workspace, MCP gateway port, and probe timeout in backend-utils.ts.
// Existing callers continue to work:
export {
  createCloudHypervisorRuntimeBackend,
} from './cloud-hypervisor-runtime-backend';

// New focused implementation module:
export {
  createCloudHypervisorRuntimeBackend,
} from './cloud-hypervisor/runtime-backend';

Copilot AI changed the title [WIP] Refactor CloudHypervisorRuntimeBackend into focused modules Refactor Cloud Hypervisor runtime backend into focused modules Sep 14, 2026
Copilot AI requested a review from lpcox September 14, 2026 02:20
@lpcox
lpcox marked this pull request as ready for review September 14, 2026 02:29
Copilot AI balanced review requested due to automatic review settings September 14, 2026 02:29

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

Signal cleanup cannot reach the in-flight manager until boot fully completes, potentially orphaning microVM resources.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Refactors the Cloud Hypervisor runtime into focused lifecycle modules while preserving its compatibility entry point.

Changes:

  • Separates boot, readiness, cleanup, and runtime facade responsibilities.
  • Centralizes shared runtime constants.
  • Adds coverage for both import paths.
File summaries
File Description
src/cloud-hypervisor/runtime-readiness.ts Extracts network and connectivity probes.
src/cloud-hypervisor/runtime-cleanup.ts Extracts teardown and diagnostics.
src/cloud-hypervisor/runtime-boot-loop.ts Extracts boot orchestration and retries.
src/cloud-hypervisor/runtime-backend.ts Implements the focused runtime facade.
src/cloud-hypervisor/backend-utils.ts Centralizes shared constants.
src/cloud-hypervisor-runtime-backend.ts Preserves compatibility exports.
src/cloud-hypervisor-runtime-backend.test.ts Verifies both import paths.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.


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

failedBootDiagnostics: this.failedBootDiagnostics,
cleanedManagers: this.cleanedManagers,
});
this.manager = boot.manager;
@lpcox

lpcox commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

@copilot address the review feedback

Copilot AI commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address the review feedback

Addressed in 32e60a5 (plus follow-up 3e13d64):

  • The boot loop now publishes each newly created manager to the facade via publishManager() immediately after createManager() (and clears it when a failed attempt is torn down), so a stop() arriving mid-boot terminates the in-flight VMM/virtiofsd instead of only removing the artifact snapshot.
  • The loop checks isStopped() before starting another attempt, so no new microVM is booted after teardown began.
  • If a boot completes after a racing stop(), start() tears that microVM down (unless the teardown already stopped it) and rejects with an "aborted by shutdown" error rather than returning a "ready" backend.
  • Added a regression test: stops the in-flight microVM when cleanup races an unfinished boot.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 94.09% 94.09% ➡️ +0.00%
Statements 92.76% 92.77% ➡️ +0.01%
Functions 93.48% 93.38% 📉 -0.10%
Branches 86.63% 86.62% ➡️ -0.01%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/cloud-hypervisor-runtime-backend.ts 96.2% → 100.0% (+3.76%) 93.4% → 100.0% (+6.60%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
✨ New Files (4 files)
  • src/cloud-hypervisor/runtime-backend.ts: 96.3% lines
  • src/cloud-hypervisor/runtime-boot-loop.ts: 96.3% lines
  • src/cloud-hypervisor/runtime-cleanup.ts: 94.0% lines
  • src/cloud-hypervisor/runtime-readiness.ts: 92.7% lines

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed...

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

Tested by Smoke Chroot

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • api.anthropic.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.anthropic.com"

See Network Configuration for more information.

Generated by Smoke Claude for #8518

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed...

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Services Connectivity — PASS ✅

  • Redis PING: ✅ PONG
  • PostgreSQL pg_isready: ✅ accepting connections
  • PostgreSQL SELECT 1: ✅ 1

Overall: PASS

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Merged PR titles:

  • refactor: split cloud-hypervisor cleanup registry into focused modules
  • chore(workflows): upgrade gh-aw to v0.89.10
  • GitHub PR reads: ✅
  • Playwright title check: ❌ unavailable
  • File write + cat: ✅
  • Latest discussion lookup: ✅; comment skipped due workflow permission
  • Build (npm ci && npm run build): ✅
  • Overall: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • msfeed25.pkgs.visualstudio.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "msfeed25.pkgs.visualstudio.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot Engine@lpcox

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Result
API status ✅ PASS
gh check ✅ PASS
File status ✅ PASS

Overall result: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • api.anthropic.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.anthropic.com"

See Network Configuration for more information.

Generated by Smoke Claude for #8518 · claude · haiku45 · 55.8 AIC · ⊞ 4.5K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

EGRESS_RESULT allow=pass deny=pass

✅ Allowed domain (api.github.com) reachable: HTTP 200
✅ Non-allowed domain (example.com) blocked: CONNECT tunnel 403

Overall status: PASS

@lpcox

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • example.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot BYOK Smoke Test Results

  • GitHub MCP: Connected, verified PR data
  • GitHub.com Connectivity: HTTP 200
  • File Write/Read: Confirmed
  • BYOK Inference: Direct mode active (agent → api-proxy → api.githubcopilot.com)

Status: PASS
Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY via api-proxy sidecar)

cc: @lpcox

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OpenTelemetry Tracing — Results

Scenario Result
1. Module Loading (otel.js) ✅ Loaded successfully, exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, plus internals
2. Test Suite ✅ 3 suites / 68 tests passed (otel.test.js, otel-fanout.test.js, otel-workload-identity.test.js)
3. Env Var Forwarding env-passthrough.ts forwards GITHUB_AW_OTEL_TRACE_ID/GITHUB_AW_OTEL_PARENT_SPAN_ID to agent; api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, and trace context to api-proxy
4. Token Tracker Integration onUsage callback present in token-tracker-http.js as OTEL hook point
5. OTEL Diagnostics ✅ Spans exported — otel.jsonl contains 1 resourceSpans record (gh-aw.agent.setup span with trace/span IDs matching this run)

All scenarios passed. No issues found.

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@lpcox
lpcox deployed to aoai-model September 14, 2026 16:21 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 94.09% 94.09% ➡️ +0.00%
Statements 92.76% 92.77% ➡️ +0.01%
Functions 93.48% 93.38% 📉 -0.10%
Branches 86.63% 86.62% ➡️ -0.01%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/cloud-hypervisor-runtime-backend.ts 96.2% → 100.0% (+3.76%) 93.4% → 100.0% (+6.60%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
✨ New Files (4 files)
  • src/cloud-hypervisor/runtime-backend.ts: 96.3% lines
  • src/cloud-hypervisor/runtime-boot-loop.ts: 96.3% lines
  • src/cloud-hypervisor/runtime-cleanup.ts: 94.0% lines
  • src/cloud-hypervisor/runtime-readiness.ts: 92.7% lines

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.14 Python 3.12.14 ✅ YES
Node.js v24.20.0 v2.98.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: FAILED — Node.js version mismatch between host and chroot environment (v24.20.0 vs v2.98.0). The smoke-chroot label was not added since not all runtime versions matched.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color pass ✅ PASS
Go env pass ✅ PASS
Go uuid pass ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx pass ✅ PASS
Node.js execa pass ✅ PASS
Node.js p-limit pass ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — PASS

Notes:

  • Java: mvn could not write to ~/.m2/repository (owned by root, not the runner user), so -Dmaven.repo.local was pointed at a writable temp directory; proxy settings in ~/.m2/settings.xml (squid-proxy:3128) worked correctly for dependency resolution.
  • All other ecosystems used default toolchain configuration with no proxy issues.

Generated by Build Test Suite for #8518 · copilot · auto · 39.5 AIC · ⊞ 10.6K ·
Add label ready-for-aw to run again

@lpcox
lpcox merged commit d3b5fd6 into main Sep 14, 2026
210 of 237 checks passed
@lpcox
lpcox deleted the copilot/refactor-split-runtime-backend branch September 14, 2026 16:27

This branch was successfully deployed

1 active deployment
aoai-model dfe7cdc9 Deployed Sep 14, 2026 by lpcox via conclusion #1655
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.

[Refactoring] Split src/cloud-hypervisor-runtime-backend.ts into focused modules

3 participants