Skip to content

fix: isolate bounded-query private state from agent mounts - #6758

Merged
lpcox merged 4 commits into
mainfrom
lpcox-isolate-bounded-query-state
Jul 31, 2026
Merged

fix: isolate bounded-query private state from agent mounts#6758
lpcox merged 4 commits into
mainfrom
lpcox-isolate-bounded-query-state

Conversation

@lpcox

@lpcox lpcox commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • relocate bounded-query seeds, invocation workspaces, seed map, broker control state, and protected audits to a dedicated per-run private root under /var/tmp
  • expose only disjoint socket and generated-skill ingress mounts to Compose agents, retaining Docker-in-Docker path translation
  • add fail-closed realpath/symlink overlap preflight across the union of Docker, gVisor, and sbx agent-visible mounts
  • preserve staging order, audit copying, rootless cleanup repair, and --keep-containers diagnostics

This is layer 1 of the approved bounded-query multi-sandbox stack. It was developed on PR #6755's head; because #6755 merged and its branch was deleted before this PR was opened, this branch was rebased onto the merged parent and now targets main. It does not add sbx transport or sbx query execution.

Validation

  • node --check passed for bounded-query broker config/server/healthcheck
  • git diff --check passed
  • focused tests added for traversal, symlink aliases/races, broad and nested mounts, /tmp, workspace/session-state mounts, valid layouts, Compose ingress-only mounts, DinD translation, and lifecycle cleanup
  • local Jest/build/lint execution was blocked because this session cannot reach the configured npm feed or registry and had no installed dependencies; GitHub CI is the authoritative full-suite validation

Move broker-only bounded-query state outside agent-visible mounts and reject realpath or symlink overlaps before staging.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3ece9a45-56aa-4e6e-8e6b-079d0e114651
Copilot AI review requested due to automatic review settings July 31, 2026 00:18
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation build failed for this PR. View logs.

Built from commit 9af0d49

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

Moves bounded-query private state outside agent-visible mounts and adds isolation checks and cleanup support.

Changes:

  • Separates broker-private and agent-ingress roots under /var/tmp.
  • Adds realpath-aware overlap validation across sandbox mounts.
  • Updates broker control state, cleanup, diagnostics, tests, and documentation.
Show a summary per file
File Description
src/services/optional-services.ts Clarifies mandatory ingress mounts.
src/services/bounded-query-service.ts Mounts private control state and ingress-only agent paths.
src/services/bounded-query-service.test.ts Updates service mount expectations.
src/services/bounded-query-compose.test.ts Tests ingress-only Compose wiring.
src/docker-manager-diagnostics.test.ts Uses relocated audit path.
src/bounded-query/types.ts Updates seed-map documentation.
src/bounded-query/paths.ts Defines disjoint private and ingress roots.
src/bounded-query/paths.test.ts Tests the new layout.
src/bounded-query/mount-policy.ts Adds mount-overlap preflight.
src/bounded-query/mount-policy.test.ts Covers overlap and symlink cases.
src/bounded-query/manager.ts Integrates preflight, creation, and cleanup.
src/bounded-query/manager.test.ts Updates lifecycle tests.
src/artifact-preservation.ts Locates audits in the private root.
docs/bounded-queries.md Documents private audit isolation.
docs/awf-config-spec.md Specifies the new filesystem and mount policy.
containers/bounded-query/Dockerfile Creates the broker control mount point.
containers/bounded-query/broker/server.js Writes readiness state to the control mount.
containers/bounded-query/broker/config.js Defines the private control path.
CLAUDE.md Updates bounded-query architecture guidance.

Review details

Tip

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

Comments suppressed due to low confidence (1)

src/bounded-query/manager.test.ts:236

  • This --keep-containers test deliberately preserves both roots, but its finally block removes only the private root. The ingress socket/skill tree remains in /var/tmp after the test; clean up cleanupPaths.ingressRoot too.
      fs.rmSync(cleanupPaths.root, { recursive: true, force: true });
  • Files reviewed: 19/19 changed files
  • Comments generated: 3
  • Review effort level: Balanced

releaseSeedPermissions(resolveBoundedQueryPaths(workDir).seedsDir);
const paths = resolveBoundedQueryPaths(workDir);
releaseSeedPermissions(paths.seedsDir);
fs.rmSync(paths.root, { recursive: true, force: true });
// 2 masking mounts (hide the bounded-query root) + 2 socket mounts + 2 skill mounts = 6
expect(boundedQueryMounts).toHaveLength(6);
// Masking mounts are read-only; socket mounts are read-write; skill mounts are read-only
expect(boundedQueryMounts).toHaveLength(4);
Comment on lines +122 to +125
const root = path.join(privateBaseDir, `awf-bounded-query-private-${rootIdentity}`);
const ingressRoot = path.join(privateBaseDir, `awf-bounded-query-ingress-${rootIdentity}`);
const runDir = path.join(ingressRoot, 'run');
const agentDir = path.join(ingressRoot, 'skill');
@lpcox lpcox changed the title Isolate bounded-query private state from agent mounts fix: isolate bounded-query private state from agent mounts Jul 31, 2026
Update staging, skill, and compose expectations for the disjoint private and ingress roots.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3ece9a45-56aa-4e6e-8e6b-079d0e114651
@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.

@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 99.13% 98.94% 📉 -0.19%
Statements 99.04% 98.86% 📉 -0.18%
Functions 99.28% 99.28% ➡️ +0.00%
Branches 95.87% 95.53% 📉 -0.34%
📁 Per-file Coverage Changes (3 files)
File Lines (Before → After) Statements (Before → After)
src/bounded-query/manager.ts 100.0% → 88.8% (-11.22%) 100.0% → 89.3% (-10.72%)
src/artifact-preservation.ts 96.2% → 96.2% (+0.04%) 96.2% → 96.2% (+0.03%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
✨ New Files (1 files)
  • src/bounded-query/mount-policy.ts: 91.5% lines

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

Exercise rootless repair, cleanup failures, and all mount-policy rejection paths while removing unreachable post-mkdir checks.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3ece9a45-56aa-4e6e-8e6b-079d0e114651
Comment thread src/bounded-query/manager.ts Fixed
Keep rootless cleanup available to teardown and focused tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3ece9a45-56aa-4e6e-8e6b-079d0e114651
@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 99.13% 99.17% 📈 +0.04%
Statements 99.04% 99.08% 📈 +0.04%
Functions 99.28% 99.29% 📈 +0.01%
Branches 95.87% 95.85% 📉 -0.02%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/artifact-preservation.ts 96.2% → 96.2% (+0.04%) 96.2% → 96.2% (+0.03%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
✨ New Files (1 files)
  • src/bounded-query/mount-policy.ts: 100.0% lines

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

@lpcox
lpcox enabled auto-merge (squash) July 31, 2026 00:45
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Security Guard completed successfully!

Security review complete for PR #6758. No security issues found. Changes strengthen security by isolating bounded-query broker-private state from agent mounts, implementing proper directory permissions (0o700), and preventing agent access to broker readiness markers.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

Contribution check complete: no guideline issues found in PR #6758. The PR includes focused tests, documentation updates, clear summary/validation, and files are placed in the expected directories.

@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

@lpcox Smoke test results:

  • GitHub MCP connectivity: ✅
  • GitHub.com HTTP connectivity: ✅
  • File write/read test: ✅
  • BYOK inference path: ✅

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 status: PASS

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

@github-actions github-actions Bot added the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Jul 31, 2026
@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 failed (403)

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

Smoke test summary for fix: isolate bounded-query private state from agent mounts

  • Fix bounded query smoke workflow run
  • docs: fix CLAUDE.md title and update API proxy provider description
  • GitHub page title contains GitHub
  • Smoke test file write/read
  • npm ci && npm run build
    Overall: PASS

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

Copy link
Copy Markdown
Contributor

Smoke Test Results: Copilot BYOK (Direct) Mode

GitHub MCP - MCP connectivity verified
github.com - HTTP 200 response
File I/O - Write/read test passed
BYOK Inference - Running in direct mode via api-proxy → api.githubcopilot.com

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

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke test: GitHub Actions services connectivity

  • Redis PING: ❌ (name resolution failure for host.docker.internal)
  • PostgreSQL pg_isready: ❌ (no response / DNS failure)
  • PostgreSQL SELECT 1: ❌ (DNS failure)

Overall: FAIL — host.docker.internal could not be resolved from the AWF sandbox.

🔌 Service connectivity validated by Smoke Services
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

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OpenTelemetry Tracing

  • Module Loading: otel.js loads successfully, exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, plus internal exporter helpers.
  • Test Suite: otel.test.js + otel-fanout.test.js — 59/59 tests passed.
  • Env Var Forwarding: OTEL env vars (OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID, OTEL_SERVICE_NAME) are forwarded to the api-proxy container via src/services/api-proxy-env-config.ts.
  • Token Tracker Integration: onUsage callback confirmed present in token-tracker-http.js as the OTEL hook point for token usage attributes.
  • i️ OTEL Diagnostics: No live run diagnostics available in this session context beyond static/unit validation; no errors observed in module load or tests, consistent with graceful degradation when OTEL is unconfigured.

Overall: all scenarios pass or are expected-pending; no issues found.

📡 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.13 Python 3.12.13 ✅ YES
Node.js v24.18.0 v22.23.1 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: FAILED — Node.js version mismatch between host and chroot environments (v24.18.0 vs v22.23.1). Since not all tests passed, the smoke-chroot label was not added.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

Overall status: FAIL

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

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox
✅ MCP connectivity
✅ GitHub.com connectivity
✅ File I/O
✅ BYOK inference
Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)
PASS

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)
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 (run OK) ✅ PASS
.NET json-parse N/A (run 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 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

Note: Java Maven builds required -Dmaven.repo.local override to a writable directory since ~/.m2/repository was not writable by the default runner user; used squid-proxy proxy settings per instructions.

Generated by Build Test Suite for #6758 · aut00 · 58.2 AIC · ⊞ 11.3K ·
Add label ready-for-aw to run again

@lpcox
lpcox merged commit 10885c9 into main Jul 31, 2026
138 of 141 checks passed
@lpcox
lpcox deleted the lpcox-isolate-bounded-query-state branch July 31, 2026 00:57
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