Skip to content

feat: add enclave MCP script executor - #6988

Merged
lpcox merged 3 commits into
mainfrom
lpcox-enclave-mcp-script
Aug 7, 2026
Merged

feat: add enclave MCP script executor#6988
lpcox merged 3 commits into
mainfrom
lpcox-enclave-mcp-script

Conversation

@lpcox

@lpcox lpcox commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • implement stack layer 2 of the enclave migration with an AWF-owned authenticated MCP server and static enclave_run_script tool
  • reuse the finite-disclosure schema, unified per-repository ledger, timing buckets, immutable staging, protected audit/telemetry, workspace, and hardened Docker/gVisor script runner
  • add private host lifecycle, Compose/image/release wiring, deterministic cleanup, documentation, and focused coverage while leaving legacy bounded queries/agents unchanged

This stacked PR targets lpcox-enclave-foundation and depends on #6986.

MCP contract

enclave_run_script accepts exactly:

  • privateRepo: configured bare owner/repo selector
  • schema: bounded finite-disclosure schema
  • script: bounded UTF-8 Python source

Trusted runtime, image, command, mount, network, credential, and resource controls are never caller-controlled. Executor outcomes use successful JSON-RPC tool responses with canonical structured content {status:"error"} or {status:"ok",result:<canonical finite value>} and never isError.

Validation

  • git diff --cached --check
  • Node syntax checks for all changed JavaScript
  • Node TypeScript syntax checks for changed source and tests
  • release workflow and action YAML parsing
  • focused runtime checks for MCP discovery/canonical errors, shared ledger debit, and hardened Docker/gVisor container arguments

Full Jest and TypeScript type-check could not run because the locked dependency install is blocked by the package feed returning 404 for typescript-eslint@8.66.0; dependency versions were not changed.

Copilot AI balanced review requested due to automatic review settings August 6, 2026 15:40

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.

Pull request overview

Adds the second unified-enclave migration layer: an authenticated, offline MCP script executor with hardened sandboxing and lifecycle integration.

Changes:

  • Adds enclave staging, Compose services, cleanup, and audit preservation.
  • Implements the MCP protocol, shared ledger, timing controls, and script runner.
  • Adds image/release wiring, documentation, and focused tests.
Show a summary per file
File Description
src/services/optional-services.ts Assembles enclave services.
src/services/enclave-mcp-service.ts Defines enclave Compose services.
src/services/enclave-mcp-service.test.ts Tests service isolation and configuration.
src/image-tag.ts Registers enclave image digests.
src/image-tag.test.ts Tests new digest keys.
src/enclave/workflow-integration.test.ts Tests staging order.
src/enclave/script-runner-spec.test.ts Tests sandbox controls.
src/enclave/preflight.ts Validates disclosure limits.
src/enclave/preflight.test.ts Tests limit validation.
src/enclave/paths.ts Defines private enclave paths.
src/enclave/paths.test.ts Tests path separation.
src/enclave/mcp-server.test.ts Tests protocol, authentication, ledger, and timing.
src/enclave/manager.ts Implements staging and teardown.
src/enclave/manager.test.ts Tests lifecycle behavior.
src/constants.ts Adds the server container name.
src/commands/main-action.ts Integrates lifecycle operations.
src/cli-workflow.ts Runs enclave staging before startup.
src/artifact-preservation.ts Preserves enclave audit artifacts.
docs/enclaves-architecture.md Documents migration layer 2.
docs/awf-config-spec.md Documents the script executor contract.
containers/bounded-query/enclave-mcp/server.js Implements authenticated HTTP transport.
containers/bounded-query/enclave-mcp/mcp-protocol.js Implements MCP JSON-RPC methods.
containers/bounded-query/enclave-mcp/healthcheck.js Checks server readiness.
containers/bounded-query/enclave-mcp/config.js Loads trusted runtime configuration.
containers/bounded-query/Dockerfile Builds the MCP server image.
containers/bounded-query/broker/workspace.js Enforces configured output bounds.
containers/bounded-query/broker/query-runner-spec.js Adds enclave labels and resource controls.
containers/bounded-query/broker/broker.js Adds shared-ledger and uniform-timing behavior.
containers/bounded-query/bounded-execution/sensitivity-policy.js Exposes unified enclave policy.
containers/bounded-query/bounded-execution/sensitivity-ledger.js Adds shared executor accounting.
action.yml Discovers enclave image digests.
.github/workflows/release.yml Builds, signs, and publishes enclave images.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 32/32 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread containers/bounded-query/broker/broker.js Outdated
Comment thread src/enclave/manager.ts
Comment thread src/artifact-preservation.ts
@github-actions

github-actions Bot commented Aug 6, 2026

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.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation build failed for this PR. View logs.

Built from commit 383a7ca

@lpcox
lpcox force-pushed the lpcox-enclave-mcp-script branch from 0d7f247 to 4c98ad9 Compare August 7, 2026 01:42
Base automatically changed from lpcox-enclave-foundation to main August 7, 2026 13:59
@lpcox

lpcox commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot resolve merge conflicts and fix failing ci checks

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve merge conflicts and fix failing ci checks

Resolved merge conflicts in c45a3b87 and fixed the failing lint/type/test checks in a459975b. The remaining pr-title check requires the PR title to be changed to a conventional-commit title, e.g. feat: add enclave MCP script executor.

@github-actions

github-actions Bot commented Aug 7, 2026

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 98.92% 98.58% 📉 -0.34%
Statements 98.78% 98.45% 📉 -0.33%
Functions 98.67% 98.52% 📉 -0.15%
Branches 95.04% 94.52% 📉 -0.52%
📁 Per-file Coverage Changes (4 files)
File Lines (Before → After) Statements (Before → After)
src/artifact-preservation.ts 93.2% → 87.6% (-5.60%) 93.2% → 87.7% (-5.56%)
src/services/optional-services.ts 100.0% → 100.0% (+0.00%) 98.4% → 98.5% (+0.10%)
src/commands/main-action.ts 97.4% → 97.4% (+0.02%) 97.0% → 97.0% (+0.03%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
✨ New Files (3 files)
  • src/enclave/manager.ts: 82.4% lines
  • src/enclave/paths.ts: 100.0% lines
  • src/services/enclave-mcp-service.ts: 85.3% lines

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

@lpcox

lpcox commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed all review findings in 1ce585d: queued invocation-cap rejections now begin timing after the queue drains; enclave runtime failures name enclaves.executors.script.runtime; and audit preservation covers enclave audit/telemetry copies plus an absent-root case.

@lpcox lpcox changed the title Add enclave MCP script executor feat: add enclave MCP script executor Aug 7, 2026
lpcox and others added 3 commits August 7, 2026 08:03
Implement stack layer 2 with an AWF-owned authenticated MCP server, unified script ledger, hardened enclave runner, lifecycle wiring, release images, and tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lpcox
lpcox force-pushed the lpcox-enclave-mcp-script branch from 1ce585d to 2aa7982 Compare August 7, 2026 15:05
@github-actions

github-actions Bot commented Aug 7, 2026

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 98.92% 98.66% 📉 -0.26%
Statements 98.78% 98.52% 📉 -0.26%
Functions 98.67% 98.52% 📉 -0.15%
Branches 95.04% 94.54% 📉 -0.50%
📁 Per-file Coverage Changes (4 files)
File Lines (Before → After) Statements (Before → After)
src/artifact-preservation.ts 93.2% → 92.4% (-0.77%) 93.2% → 92.5% (-0.77%)
src/services/optional-services.ts 100.0% → 100.0% (+0.00%) 98.4% → 98.5% (+0.10%)
src/commands/main-action.ts 97.4% → 97.4% (+0.02%) 97.0% → 97.0% (+0.03%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
✨ New Files (3 files)
  • src/enclave/manager.ts: 82.4% lines
  • src/enclave/paths.ts: 100.0% lines
  • src/services/enclave-mcp-service.ts: 85.3% lines

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

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation reports failed to deliver outputs while checking network isolation. Investigate the egress model.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Security Guard failed. Please review the logs for details.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Build Test Failed Build Test Suite - See logs for details

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Contribution Check failed. Please review the logs for details.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot Engine — PASS ✅

Overall: PASS

cc @lpcox

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

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

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

Overall result: PASS

Generated by Smoke Claude for #6988 · haiku45 · 60.6 AIC · ⊞ 3.6K ·
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

EGRESS_RESULT allow=pass deny=pass

✅ Allowed domain (api.github.com): reachable, HTTP 200
✅ Blocked domain (example.com): denied (CONNECT tunnel 403)

Overall: PASS

cc @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

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode ✅

Test Results:

  • ✅ GitHub connectivity (HTTP 200)
  • ✅ File I/O
  • ✅ Direct BYOK inference (agent → api-proxy → api.githubcopilot.com)

Status: PASS — Direct BYOK mode operational via COPILOT_PROVIDER_API_KEY

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

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: GitHub Actions Services Connectivity

  • Redis PING: ❌ (DNS resolution failure)
  • PostgreSQL pg_isready: ❌ (no response)
  • PostgreSQL SELECT 1: ❌ (DNS resolution failure)

Overall: FAIL

All checks failed with Temporary failure in name resolution for host.docker.internal.

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

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.13 ✅ YES
Node.js v24.18.0 v22.23.2 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: FAILED — Node.js version differs between host and chroot environment.

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

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test Results (Gemini)

  • GitHub MCP Testing: ✅
  • GitHub.com Connectivity: ✅
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

PRs Reviewed:

  1. chore: upgrade gh-aw to v0.86.0 pre-release and recompile workflows (chore: upgrade gh-aw to v0.86.0 pre-release and recompile workflows #7027)
  2. chore(deps): bump the npm_and_yarn group across 2 directories with 2 updates (chore(deps): bump the npm_and_yarn group across 2 directories with 2 updates #7016)

Overall Status: PASS

💎 Faceted by Smoke Gemini
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Merged PR titles:

  • chore: upgrade gh-aw to v0.86.0 pre-release and recompile workflows
  • fix(api-proxy): stop alias fallback picking arbitrary models
  • GitHub merged PR review: ✅
  • SafeInputs PR query: ❌ (safeinputs-gh unavailable; gh fallback worked)
  • Playwright GitHub title: ✅
  • File write + cat readback: ✅
  • Discussion interaction: ❌ (discussion write disabled)
  • Build AWF: ✅
    Overall: FAIL

Warning

Firewall blocked 1 domain

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

  • registry.npmjs.org

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

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

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

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor
  • chore: upgrade gh-aw to v0.86.0 pre-release and recompile workflows: ✅
  • fix(api-proxy): stop alias fallback picking arbitrary models: ✅
  • MCP: ✅
  • HTTP: ✅
  • File I/O: ✅
  • BYOK: ✅

Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra
Overall: PASS

cc @lpcox

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

📡 OTel Tracing Smoke Test Results

Scenario Result
1. Module Loading otel.js loaded, isEnabled()=true, exports 15 functions (startRequestSpan, setTokenAttributes, endSpan, shutdown, etc.)
2. Test Suite ✅ 68/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/PARENT_SPAN_ID; api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, and trace context
4. Token Tracker Integration onUsage callback present in token-tracker-http.js (4 refs) as OTEL hook point
5. OTEL Diagnostics /tmp/gh-aw/otel.jsonl populated with a workflow-level span (gh-aw.agent.setup); no api-proxy LLM-call spans expected since the smoke steps don't invoke the LLM

All scenarios passed. No regression detected in OTEL tracing integration.

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

@github-actions

github-actions Bot commented Aug 7, 2026

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 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

Notes:

  • Maven required -Dmaven.repo.local pointing to a writable path since ~/.m2/repository was not creatable due to pre-existing root ownership of ~/.m2 (unrelated to firewall config); ~/.m2/settings.xml proxy config was applied as specified.
  • All repositories cloned successfully; all builds/installs/tests completed without errors through the AWF-proxied network.

Generated by Build Test Suite for #6988 · auto · 65 AIC · ⊞ 11.6K ·
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Docker Sbx Validation

Overall: PASS

cc @lpcox

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

@lpcox
lpcox merged commit b4087a9 into main Aug 7, 2026
131 of 141 checks passed
@lpcox
lpcox deleted the lpcox-enclave-mcp-script branch August 7, 2026 15:52
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.

3 participants