Skip to content

refactor: introduce runtime-neutral enclave runner lifecycle - #8686

Merged
lpcox merged 2 commits into
mainfrom
lpcox-runtime-neutral-enclave-runner
Sep 17, 2026
Merged

lpcox merged 2 commits into
mainfrom
lpcox-runtime-neutral-enclave-runner

Conversation

@lpcox

@lpcox lpcox commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add one closed lifecycle contract for Docker/gVisor script and agent enclave runners
  • make launch, deadline propagation, bounded result collection, cancellation, per-invocation cleanup, and run reconciliation explicit
  • preserve trusted runtime selection, network revalidation, shared admission/ledger timing, dynamic delegation, and fail-closed unsupported runtimes
  • keep Cloud Hypervisor execution and its broker protocol out of scope

Validation

  • npm test -- --runInBand src/enclave
  • npm run lint -- --quiet
  • npm run type-check
  • npm run build

Fixes #8679

Copilot AI balanced review requested due to automatic review settings September 17, 2026 04:09
@lpcox lpcox changed the title Introduce a runtime-neutral enclave runner lifecycle refactor: introduce runtime-neutral enclave runner lifecycle Sep 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 94.19% 94.21% 📈 +0.02%
Statements 92.87% 92.88% ➡️ +0.01%
Functions 93.48% 93.48% ➡️ +0.00%
Branches 86.72% 86.73% 📈 +0.01%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)

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

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.

Copilot review overview

🟡 Changes recommended

Cancellation races, duplicate cleanup, and the incorrect issue-closing reference remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 4 Medium severity · 1 Low severity

Open (5)
What changed in this PR

Introduces a shared runtime-neutral lifecycle for Docker/gVisor enclave runners.

Changes:

  • Adds launch, collection, cancellation, cleanup, and reconciliation lifecycle APIs.
  • Propagates absolute deadlines and cancellation signals.
  • Updates executor wiring and tests to use runInvocation.
File Description
src/​enclave/​runner-lifecycle.test.ts Tests lifecycle behavior.
src/​enclave/​mcp-server.test.ts Updates script-runner mocks.
src/​enclave/​dynamic-executor.test.ts Updates dynamic binding tests.
src/​enclave/​agent-runner-spec.test.ts Tests deadlines and network preflight.
src/​enclave/​agent-mcp-server.test.ts Updates agent-runner mocks.
containers/​enclave/​script-executor/​script-runner.js Wraps Docker/gVisor adapters.
containers/​enclave/​script-executor/​runner-lifecycle.js Implements the shared lifecycle.
containers/​enclave/​script-executor/​executor-handler.js Adds deadlines and shutdown cancellation.
containers/​enclave/​script-executor/​docker-script-runner.js Splits script launch and collection.
containers/​enclave/​script-executor/​docker-client.js Adds abort-signal support.
containers/​enclave/​mcp-server/​server.js Shares a monotonic clock.
containers/​enclave/​mcp-server/​agent-executor.js Removes the legacy runner wrapper.
containers/​enclave/​agent-executor/​enclave-runner.js Wraps agent runtime adapters.
containers/​enclave/​agent-executor/​docker-enclave-runner.js Splits agent launch and collection.
containers/​enclave/​agent-executor/​docker-client.js Adds abort-signal support.

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

Comment on lines +152 to +155
cancelInvocation(handle) {
handle.cancellation.abort();
return this.cleanupInvocation(handle);
}
Comment on lines +113 to 116
cancelInvocation(handle) {
handle.cancellation.abort();
return this.cleanupInvocation(handle);
}
Comment on lines +169 to +171
async runInvocation(request) {
const handle = await lifecycle.launchInvocation(request);
const signal = request.signal;
}
if (cancellationError) throw cancellationError;
if (operationError) throw operationError;
return boundedResult(result, signal?.aborted === true);
Comment on lines +63 to +66
/**
* Wraps one trusted runtime adapter in the lifecycle contract used by both
* enclave executor kinds. Runtime handles stay in a WeakMap and never enter an
* MCP request, response, audit record, or workspace.
@lpcox

lpcox commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Copilot AI commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in d4eb123:

  • cancelInvocation in both Docker adapters now only aborts the runtime signal, no longer also calling cleanup (fixes the double Docker list/remove pass).
  • runInvocation now short-circuits to the cancelled result before launching if the signal is already aborted, instead of launching first and cancelling after.
  • Replaced the post-listener-removal signal.aborted check with a cancelled flag set only when the abort handler actually ran, so a late abort during cleanup no longer mislabels a completed run as cancelled.
  • Left the Fixes #8679 reference as-is since that's PR metadata, not a file change — happy to update the linked issue if you'd like it repointed to a specific tracking issue.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

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

@lpcox
lpcox enabled auto-merge (squash) September 17, 2026 04:40
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Test Suite completed successfully!

Generated by Build Test Suite for #8686

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

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

Warning

Firewall blocked 8 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • msfeed25.pkgs.visualstudio.com
  • update.googleapis.com
  • www.google.com
  • www.gstatic.com

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "msfeed25.pkgs.visualstudio.com"
    - "update.googleapis.com"
    - "www.google.com"
    - "www.gstatic.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions

github-actions Bot commented Sep 17, 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 17, 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 17, 2026 •

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Sep 17, 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 17, 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 #8686

@github-actions

github-actions Bot commented Sep 17, 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 17, 2026 •

Copy link
Copy Markdown
Contributor

❌ Smoke Gemini reports failed. Facets need polishing...

💎 Faceted by Smoke Gemini

@github-actions

github-actions Bot commented Sep 17, 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 17, 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 17, 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 17, 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 17, 2026 •

Copy link
Copy Markdown
Contributor

❌ Security Guard failed. Please review the logs for details.

Generated by Security Guard for #8686

@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 #8686 · 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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot BYOK Smoke Test: PASS

Test Results:

  • ✅ GitHub MCP connectivity (2 merged PRs fetched)
  • ✅ GitHub.com HTTP 200
  • ✅ File write/read test passed
  • ✅ BYOK inference (direct BYOK mode via api-proxy → api.githubcopilot.com)

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) with api-proxy sidecar authentication.

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

@github-actions

Copy link
Copy Markdown
Contributor

📡 OTel Tracing Smoke Test Results

# Scenario Result
1 Module loading (otel.js) ✅ Loaded successfully — isEnabled: true; exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, ...
2 Test suite (otel*.test.js) ✅ 68/68 tests passed (3 suites: otel.test.js, plus serialization/exporters/fan-out)
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, and trace/span IDs present in api-proxy-env-config.ts
4 Token-tracker integration ✅ onUsage callback found in token-tracker-http.js (OTEL hook point)
5 OTEL diagnostics (span export) ⚪ No spans exported — /tmp/gh-aw/sandbox/firewall/logs/api-proxy/otel.jsonl not present, as expected since no LLM API calls were routed through the api-proxy sidecar during this run

Overall: ✅ All scenarios pass (scenario 5 is an expected no-op, not a failure — no proxied API traffic occurred in this run to generate spans).

📡 OTel tracing validated by Smoke OTel Tracing
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.21.0 v22.23.2 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: FAILED — Node.js version mismatch between host and chroot environment. smoke-chroot label not added.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Services Connectivity — PASS

  • ✅ Redis PING → PONG
  • ✅ pg_isready → accepting connections
  • ✅ psql 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: Use stable AWF sandbox for Auth Doctor Updater
Merged: Add Cloud Hypervisor enclave configuration model
PR: build: add attested enclave rootfs artifacts
PR: refactor: add Cloud Hypervisor workload profiles
GitHub checks: ✅
Playwright: ✅
File + cat: ✅
Build: ✅
Overall: PASS

Warning

Firewall blocked 8 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • msfeed25.pkgs.visualstudio.com
  • update.googleapis.com
  • www.google.com
  • www.gstatic.com

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "msfeed25.pkgs.visualstudio.com"
    - "update.googleapis.com"
    - "www.google.com"
    - "www.gstatic.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

🏗️ 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 OK) ✅ PASS
.NET json-parse ✅ N/A (ran OK) ✅ PASS
Go color ✅ ok ✅ PASS
Go env ✅ ok ✅ PASS
Go uuid ✅ ok ✅ PASS
Java gson ✅ 1/1 passed ✅ PASS
Java caffeine ✅ 1/1 passed ✅ PASS
Node.js clsx ✅ All passed ✅ PASS
Node.js execa ✅ All passed ✅ PASS
Node.js p-limit ✅ All passed ✅ PASS
Rust fd ✅ 1/1 passed ✅ PASS
Rust zoxide ✅ 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

All repositories cloned successfully. All builds/installs and tests succeeded across every ecosystem and project.

Note: Java builds required overriding Maven's local repository path (-Dmaven.repo.local=/tmp/...) because ~/.m2 was owned by root and not writable by the sandbox user; the provided settings.xml proxy configuration otherwise worked correctly through the firewall proxy.

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

@lpcox
lpcox merged commit b1c6781 into main Sep 17, 2026
172 of 178 checks passed
@lpcox
lpcox deleted the lpcox-runtime-neutral-enclave-runner branch September 17, 2026 04:53

This branch was previously deployed

1 inactive deployment
aoai-model — d4eb1230 Deployed Sep 17, 2026 by lpcox via conclusion #1682
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.

Build attested script and agent enclave rootfs artifacts

3 participants