Skip to content

refactor: split cloud-hypervisor cleanup registry into focused modules - #8519

Open
lpcox with Copilot wants to merge 2 commits into
mainfrom
copilot/refactor-cleanup-registry-module
Open

refactor: split cloud-hypervisor cleanup registry into focused modules#8519
lpcox with Copilot wants to merge 2 commits into
mainfrom
copilot/refactor-cleanup-registry-module

Conversation

Copilot AI commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

src/cloud-hypervisor/cleanup-registry.ts had grown to 870 lines, with a single DurableCloudHypervisorCleanupRegistry class owning network teardown, VMM identity/ACL cleanup, process lifecycle, and record persistence — including a 97-line deleteVmmIdentity method. This splits it along the boundaries the test suite already uses, with no behaviour change.

Module layout

  • cleanup-registry.ts (241 lines) — orchestration facade only: create, createPending, reapPending, reapRecord. Still exports DurableCloudHypervisorCleanupRegistry, CloudHypervisorCleanupHandle, CloudHypervisorCleanupRegistry, CloudHypervisorNetworkResource and re-exports CleanupRegistryDependencies, so none of the 16 callers change.
  • cleanup-dependencies.ts — dependency interfaces, resolveCleanupDependencies(), and the shared runCommand / runChecked / pathExists / formatError helpers.
  • cleanup-network.tsdeleteNetwork, validateRecordResources, file/interface identity validation.
  • cleanup-vmm-identity.tsdeleteVmmIdentity, decomposed into releaseVmmAcls, deleteVmmAccount, assertRuntimeIdentityUnchanged, deleteVmmGroup.
  • cleanup-record-store.ts — record read/write, registry directory checks, claim locking, virtiofsd unmounting, mount assertions, removeExactDirectory.
  • cleanup-process.ts — gains stopProcess, next to the existing process identity helpers.

Shape of the change

Private methods that only forwarded to this.dependencies became free functions taking the resolved dependency bag, matching the existing style in cleanup-process.ts/cleanup-identity.ts:

// before (method on the registry)
if (record.network) await this.deleteNetwork(record, ipPath);

// after (facade delegates to cleanup-network.ts)
if (record.network) await deleteNetwork(this.dependencies, record, ipPath);

Error messages, command invocations, and revalidation ordering are preserved verbatim; deleteVmmAccount returns the expected gid that the group check previously read from a mutable local. Duplicated private-file writing in writeRecord/claimRecord is consolidated into one writePrivateFile helper ('wx' and O_WRONLY|O_CREAT|O_EXCL are equivalent).

Copilot AI changed the title [WIP] Refactor cleanup registry into focused modules refactor: split cloud-hypervisor cleanup registry into focused modules Sep 14, 2026
Copilot AI requested a review from lpcox September 14, 2026 02:16
@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.

🔵 Needs a closer look

Security-critical crash-recovery cleanup behavior warrants final human and CI validation despite no concrete static-review defects.

Pull request overview

Splits the security-critical Cloud Hypervisor cleanup registry into focused modules while preserving its facade and behavior.

Changes:

  • Extracts dependency resolution, persistence, network, and VMM cleanup logic.
  • Moves process termination alongside existing process helpers.
  • Retains existing public registry interfaces and callers.
File summaries
File Description
cleanup-registry.ts Reduces registry to orchestration.
cleanup-dependencies.ts Centralizes dependencies and command helpers.
cleanup-network.ts Encapsulates network validation and teardown.
cleanup-vmm-identity.ts Encapsulates account, group, and ACL cleanup.
cleanup-record-store.ts Encapsulates persistence, claims, mounts, and directory cleanup.
cleanup-process.ts Adds process termination logic.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Balanced

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

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

@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 Copilot BYOK completed. Copilot BYOK mode operational. 🔓

🔑 BYOK report filed by Smoke Copilot BYOK

@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 #8519

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

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

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

Generated by Build Test Suite for #8519

@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

🔌 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

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

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

📰 BREAKING: Report filed by Smoke Copilot

@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

📰 DEVELOPING STORY: Smoke Docker Sbx reports failed. Our correspondents are investigating the incident...

📰 BREAKING: Report filed by Smoke Docker Sbx

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini reports failed. Facets need polishing...

💎 Faceted by Smoke Gemini

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Status
API ✅ PASS
gh CLI ✅ PASS
File ✅ 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 #8519 · claude · haiku45 · 55.2 AIC · ⊞ 4.5K ·
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

@lpcox
lpcox deployed to aoai-model September 14, 2026 03:51 — with GitHub Actions Active
@github-actions github-actions Bot added the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@lpcox
EGRESS_RESULT allow=pass deny=pass

✅ Allowed domain (github.com) reachable: allowed=200
✅ Non-allowed domain (example.com) blocked: proxy 403 (CONNECT tunnel failed)

Overall status: PASS

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

Smoke Test: Services Connectivity

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

Overall: PASS

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct Mode) ✅ PASS

  • ✅ GitHub MCP: Connected (2 recent merged PRs fetched)
  • ✅ GitHub.com: HTTP 200
  • ✅ File I/O: Write/read confirmed
  • ✅ BYOK Inference: Direct mode via api-proxy → api.githubcopilot.com

Running as @lpcox on gh-aw-firewall PR #8519 (COPILOT_PROVIDER_API_KEY).

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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 94.09% 94.14% 📈 +0.05%
Statements 92.76% 92.80% 📈 +0.04%
Functions 93.48% 93.53% 📈 +0.05%
Branches 86.63% 86.66% 📈 +0.03%
📁 Per-file Coverage Changes (3 files)
File Lines (Before → After) Statements (Before → After)
src/cloud-hypervisor/cleanup-process.ts 100.0% → 100.0% (+0.00%) 94.3% → 94.7% (+0.40%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
src/cloud-hypervisor/cleanup-registry.ts 94.1% → 100.0% (+5.89%) 91.0% → 100.0% (+9.02%)
✨ New Files (4 files)
  • src/cloud-hypervisor/cleanup-dependencies.ts: 95.5% lines
  • src/cloud-hypervisor/cleanup-network.ts: 100.0% lines
  • src/cloud-hypervisor/cleanup-record-store.ts: 97.9% lines
  • src/cloud-hypervisor/cleanup-vmm-identity.ts: 79.2% lines

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

@github-actions

Copy link
Copy Markdown
Contributor

📡 OTel Tracing Smoke Test Results

# Scenario Result
1 Module Loading (otel.js) ✅ Loaded successfully, isEnabled()=true, exports 15 functions incl. startRequestSpan, setTokenAttributes, endSpan, shutdown
2 Test Suite ✅ 68/68 tests passed (3 suites: otel.test.js, otel-fanout.test.js, split-module tests)
3 Env Var Forwarding GITHUB_AW_OTEL_TRACE_ID/GITHUB_AW_OTEL_PARENT_SPAN_ID present in env-passthrough.ts; GH_AW_OTLP_ENDPOINTS/OTEL_EXPORTER_OTLP_ENDPOINT/trace context present in api-proxy-env-config.ts
4 Token Tracker Integration onUsage callback present in token-tracker-http.js (OTEL hook point)
5 OTEL Diagnostics ⚠️ No api-proxy otel.jsonl span file found for this run (expected — this validation workflow doesn't drive live LLM traffic through the api-proxy sidecar, so no spans were generated)

All scenarios pass or show expected/benign results. No regressions detected in the OTEL tracing integration.

📡 OTel tracing validated by Smoke OTel Tracing
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 (ran, printed "Hello, World!") ✅ PASS
.NET json-parse N/A (ran, printed parsed JSON) ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx passed ✅ PASS
Node.js execa passed ✅ PASS
Node.js p-limit passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — PASS

Notes:

  • Java's Maven local repository defaulted to /home/runner/.m2/repository, which was not writable in this sandbox; ran with -Dmaven.repo.local=/tmp/gh-aw/agent/m2repo instead. Proxy settings from ~/.m2/settings.xml were still applied via JAVA_TOOL_OPTIONS.
  • All repositories cloned successfully; no CLONE_FAILED cases.

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

@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 environments. The smoke-chroot label was not added since not all tests passed.

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

@github-actions

Copy link
Copy Markdown
Contributor
  • chore(workflows): upgrade gh-aw to v0.89.10
  • [docs] auth: Cross-reference Copilot auto model prefix-stripping in authentication-architecture
  • GitHub PR reads ✅
  • Playwright title check ❌ (tool unavailable)
  • File write/readback ✅
  • Discussion lookup ✅ / discussion comment ❌ (permission disabled)
  • 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

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/cleanup-registry.ts into focused modules

3 participants