Skip to content

fix: classify enclave gateway readiness failures - #9488

Merged
lpcox merged 2 commits into
mainfrom
lpcox-gateway-connectivity-diagnostics
Oct 6, 2026
Merged

lpcox merged 2 commits into
mainfrom
lpcox-gateway-connectivity-diagnostics

Conversation

@lpcox

@lpcox lpcox commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add bounded, structured diagnostics from AWF's actual host startup and MCP readiness requests, rather than expanding guesses from fatal error text. This follows #9482 and provides missing evidence for the still-unclassified pre-broker exit in run 37406537897, using immutable v0.28.36.

  • Track bootstrap/configuration, runtime/host/storage/artifact preflight, seed staging, recovery, host service, host network, compose/container startup, gateway attachment, optional GitHub readiness, gateway contract, actual initialize/initialized/tools-list requests, delegation, and primary-agent stages.
  • Explicitly distinguish not-attempted, attempted, and ready, with perspective awf-host. Missing/invalid observations remain unknown.
  • Allowlisted codes distinguish DNS not-found/temporary failures, refused/timed-out/unreachable/reset connections, other transport failures, whole-request timeout, HTTP auth/status, retryable backend-unavailable, framing/JSON/protocol/RPC errors, identity/tools mismatch, and readiness deadline. Export only bounded HTTP error status and initialization attempt count (saturated at 1200), never endpoints, headers, payloads, credentials, or raw errors.
  • Preserve existing retries: only documented retryable HTTP 503 backend_unavailable responses retry. Permanent failures remain failures; no fallback, widened schema, topology, or permission boundary.
  • Reuse the existing startup-error record for fixed-message progress and fatal snapshots. Validate descriptor ownership/single-link regular-file metadata before truncation, preserve no-follow access and descriptor-bounded reads, and bound serialized fatal messages.
  • Retain legacy schema-1 diagnostics. Schema 2 adds only the validated snapshot; complete diagnostic lines are <=640 bytes, record reads <=16 KiB, and stderr fallback <=64 KiB. Raw logs/records are removed, never uploaded.
  • Both initial and recovery acceptance launches require AWF's own completed handshake and emit AWF_HOST_GATEWAY_READINESS before separate harness requests. Broker health or harness success is not substituted for AWF proof.
  • Update architecture/coverage documentation and deterministic CI selectors; no registry finding is invented for an unknown cause.

Docs audit CI follow-up

Audit job 112093257576 failed on newly reported transitive source-map-js, not gateway behavior. Commit 7c33b82dced67bc79ced783507fd6ec90e662a09 changes only the docs lockfile's version, tarball, and integrity entry 1.2.1 → 1.2.2. GHSA-68fv-2mgg-jv7q affects >=1.0.0 <1.2.2; 1.2.2 is the published first patched release and satisfies every existing magicast/css-tree/PostCSS range. No direct dependency, override, suppression, threshold, registry configuration, or service behavior changed. The single GHSA-ch52-4w7c-c8xp acceptance and 2027-01-03 expiry remain unchanged.

Remote confirmation: dependency audit run 37409692540 passed both Docs and Main audit jobs on 7c33b82d.

The exact CI package-lock-only audit flags and unchanged enforcement script pass against npmjs: source-map-js is absent, no new unique advisories appeared, and only the previously accepted http-cache-semantics high finding remains. The local Microsoft mirror returned a 404 for the patched tarball and a stale/differing transitive audit graph; local install/audit validation used public npm explicitly without changing repository configuration or bypassing enforcement.

Validation

  • Exact deterministic enclave workflow: 33 suites / 818 tests passed on macOS with privileged storage/network probes disabled.
  • Additional startup/container lifecycle, artifact preservation, and log discovery/aggregation regressions: 20 suites passed.
  • Build, type-check, full-source lint, changed-document markdownlint, harness syntax, diagnostic registry validation/check-sync, and diff checks passed.
  • Deterministic coverage includes actual request errno/status/phases, retries/permanent failures, wrong identity/tools, success/deadline, pre-readiness failures, AWF-vs-harness perspective, maximum output bounds, secrets/hostnames/IPs/paths/newlines/sentinels, unsafe/changing reads, and symlink/hardlink/path-replacement publication safety.
  • Docs follow-up: clean npmjs install, Astro check (zero errors/warnings/hints), static build (9 pages), all installed source-map-js users at 1.2.2, and unchanged audit enforcement suite (8 tests) passed. Existing chunk/content build warnings are unrelated.

Limits and non-goals

The original v0.28.36 startup cause remains unknown. Readiness is host-to-loopback Docker gateway traffic (Docker primary runtime, CH enclave roles), not guest DNS/data-plane evidence. macOS cannot establish eligible live KVM acceptance; an authorized future release and eligible run remain necessary. No merge, release, secret-bearing live dispatch, or change to the independent privileged network-hook/recovery-directory failures is included.

Track bounded host startup stages and actual gateway request failure codes without exposing private transport details. Preserve readiness retries and distinguish AWF handshake proof from harness requests.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 03:27
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-9488 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit 1bcc24b

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

JSON-RPC correlation, RPC-error handling, and snapshot validation can currently produce false readiness evidence.

Review effort: Balanced
Findings: 3 Medium severity

Open (3)
What changed in this PR

Adds bounded host-side diagnostics for enclave gateway readiness and integrates them into Cloud Hypervisor acceptance workflows.

Changes:

  • Tracks startup stages, readiness attempts, and allowlisted failure classifications.
  • Publishes sanitized startup snapshots and consumes them in the live harness.
  • Expands deterministic tests, workflow coverage, and architecture documentation.
File Description
src/​enclave/​workflow-integration.test.ts Tests pre-readiness failures.
src/​enclave/​startup-progress.ts Defines startup progress state.
src/​enclave/​manager.ts Records enclave preparation stages.
src/​enclave/​gateway.ts Classifies gateway readiness requests.
src/​enclave/​gateway.test.ts Tests readiness classifications.
src/​enclave/​cloud-hypervisor-lifecycle.ts Tracks lifecycle stages.
src/​enclave/​cloud-hypervisor-lifecycle.test.ts Tests lifecycle diagnostics.
src/​enclave/​cloud-hypervisor-host-service.ts Reports host-service startup.
src/​enclave/​cloud-hypervisor-host-service.test.ts Tests host-service reporting.
src/​commands/​main-action.ts Persists bounded progress snapshots.
src/​commands/​main-action.test.ts Tests diagnostic publication safety.
src/​commands/​main-action-startup-diagnostics.test.ts Adds filesystem-level publication tests.
src/​commands/​main-action-fs-mock.test-utils.ts Extends filesystem mocks.
src/​cloud-hypervisor/​host-enclave-executor.ts Reports executor preflight stages.
src/​cloud-hypervisor/​host-enclave-executor.test.ts Tests preflight stage reporting.
src/​cloud-hypervisor/​enclave-executor-types.ts Adds the stage callback type.
src/​cli-workflow.ts Tracks workflow startup stages.
scripts/​ci/​test-cloud-hypervisor-enclave-workflow.test.ts Updates deterministic suite assertions.
scripts/​ci/​cloud-hypervisor-enclave-live-smoke.test.ts Tests live diagnostic handling.
scripts/​ci/​cloud-hypervisor-enclave-live-smoke.js Exports validated readiness evidence.
docs/​INTEGRATION-TESTS.md Documents diagnostic schemas and coverage.
docs/​enclaves-architecture.md Documents readiness diagnostics.
docs/​cloud-hypervisor-foundation.md Documents acceptance limitations.
.github/​workflows/​test-cloud-hypervisor-enclaves.yml Expands workflow triggers and tests.

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

Comment on lines +265 to +269
|| (value.readiness === 'not-attempted'
&& (value.attempts !== 0 || !['none', 'unknown', 'readiness-deadline'].includes(value.code)))
|| (value.readiness !== 'not-attempted' && value.attempts === 0)
|| (value.readiness === 'ready'
&& (value.code !== 'ready' || !['tools-list', 'delegation', 'primary-agent'].includes(value.stage)))) {
Comment thread src/enclave/gateway.ts
? events[events.length - 1]
: raw;
const parsed = !jsonText ? {} : JSON.parse(jsonText) as JsonRpcResponse;
if (body.id !== undefined && (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))) {
Comment thread src/enclave/gateway.ts
Comment on lines 528 to +533
const tools = (listed.response.result as { tools?: unknown })?.tools;
if (canonicalToolSet(tools) !== canonicalToolSet(expectedRoutedTools(contract.expectedTools))) {
throw new Error('Gateway enclave tool contract did not exactly match the enabled executors');
throw new GatewayReadinessError(
'Gateway enclave tool contract did not exactly match the enabled executors', false,
listed.response.error ? 'rpc-error' : 'tools-mismatch',
);
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 92.80% 92.83% 📈 +0.03%
Statements 91.23% 91.27% 📈 +0.04%
Functions 89.67% 89.71% 📈 +0.04%
Branches 84.86% 84.89% 📈 +0.03%
📁 Per-file Coverage Changes (8 files)
File Lines (Before → After) Statements (Before → After)
src/enclave/manager.ts 86.8% → 86.7% (-0.11%) 85.6% → 85.6% (-0.07%)
src/enclave/gateway.ts 100.0% → 100.0% (+0.00%) 99.5% → 99.5% (+0.05%)
src/cloud-hypervisor/host-enclave-executor.ts 95.6% → 95.7% (+0.07%) 91.0% → 91.1% (+0.13%)
src/commands/main-action.ts 96.0% → 96.1% (+0.13%) 96.0% → 96.2% (+0.13%)
src/enclave/cloud-hypervisor-lifecycle.ts 94.7% → 95.0% (+0.26%) 92.3% → 92.6% (+0.34%)
src/commands/main-action-fs-mock.test-utils.ts 94.4% → 94.7% (+0.29%) 95.2% → 95.5% (+0.22%)
src/cli-workflow.ts 96.0% → 96.3% (+0.38%) 96.0% → 96.4% (+0.36%)
src/log-directory-setup.ts 96.8% → 100.0% (+3.18%) 96.9% → 100.0% (+3.13%)
✨ New Files (1 files)
  • src/enclave/startup-progress.ts: 100.0% lines

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

Update the compatible transitive source-map-js lock entry from 1.2.1 to 1.2.2 for GHSA-68fv-2mgg-jv7q. Preserve the existing docs audit acceptance and high/critical enforcement.

Co-authored-by: Copilot App <[email protected]>
@github-actions

github-actions Bot commented Oct 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.

@lpcox
lpcox merged commit f1c3282 into main Oct 6, 2026
36 checks passed
@lpcox
lpcox deleted the lpcox-gateway-connectivity-diagnostics branch October 6, 2026 03:52
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.

2 participants