Skip to content

refactor: share sbx ingress capability writer - #6961

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-fix-capability-writer
Aug 5, 2026
Merged

refactor: share sbx ingress capability writer#6961
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-fix-capability-writer

Conversation

Copilot AI commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Bounded-agent and bounded-query each implemented the same security-sensitive capability file write path (openSync with secure flags, write, chmod, close). This PR removes that duplication by centralizing the file creation/hardening flow in one shared helper while preserving behavior.

  • What changed

    • Added a shared bounded-runtime utility to write sbx ingress capability files with the existing atomic/safe semantics.
    • Updated:
      • src/bounded-agent/manager.ts
      • src/bounded-query/manager.ts
    • Both managers now delegate file creation + permission hardening to the shared helper; capability payload generation remains unchanged at call sites.
  • Security-sensitive behavior preserved

    • O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW
    • initial mode 0o600
    • explicit fchmodSync(fd, 0o600) before close
    • closeSync in finally
  • Result

    • Eliminates ~35 lines of duplicate code in a high-risk path.
    • Ensures bounded-agent and bounded-query stay aligned on inode/permission handling going forward.
// shared helper usage pattern
writeSbxIngressCapabilitiesFile(paths.capabilityPath, {
  version: 1,
  query: crypto.randomBytes(32).toString('hex'),
  probe: crypto.randomBytes(32).toString('hex'),
});

Copilot AI linked an issue Aug 5, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Refactor duplicated ingress capability file writer code Refactor duplicated sbx ingress capability writer into shared bounded-runtime utility Aug 5, 2026
Copilot AI requested a review from lpcox August 5, 2026 14:37
@lpcox
lpcox marked this pull request as ready for review August 5, 2026 14:56
Copilot AI balanced review requested due to automatic review settings August 5, 2026 14:56

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 wasn't able to review any files in this pull request.

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

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.87% 98.89% 📈 +0.02%
Statements 98.75% 98.78% 📈 +0.03%
Functions 99.10% 99.10% ➡️ +0.00%
Branches 94.97% 94.97% ➡️ +0.00%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/bounded-agent/manager.ts 98.7% → 98.6% (-0.03%) 98.7% → 98.7% (-0.02%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
✨ New Files (1 files)
  • src/bounded-execution/sbx-ingress-capabilities.ts: 100.0% lines

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

@github-actions

github-actions Bot commented Aug 5, 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 Aug 5, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

PR #6961 follows the contributing guidelines in the provided context: it adds tests for the new shared helper, keeps files under src/, and the PR description clearly explains the change and references Fixes #6952. No comment needed.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed...

@github-actions

github-actions Bot commented Aug 5, 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 Aug 5, 2026

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing reports failed. OTel tracing regression detected. ⚠️

OTel Tracing Smoke Test — all scenarios passed ✅

  1. Module Loading: ✅ otel.js loads successfully, isEnabled()=true, exports startRequestSpan/setTokenAttributes/setBudgetAttributes/endSpan/endSpanError/shutdown/isEnabled + internals.
  2. Test Suite: ✅ 68/68 tests passed across otel.test.js, otel-fanout.test.js, otel-workload-identity.test.js (3 suites, 0 failures).
  3. Env Var Forwarding: ✅ src/services/agent-environment/env-passthrough.ts forwards GITHUB_AW_OTEL_TRACE_ID and GITHUB_AW_OTEL_PARENT_SPAN_ID to the agent; src/services/api-proxy-env-config.ts forwards OTEL_EXPORTER_OTLP_ENDPOINT/HEADERS plus the same trace-context vars to api-proxy.
  4. Token Tracker Integration: ✅ onUsage callback present in token-tracker-http.js (used as the OTEL hook point, invoked after normalized usage extraction, feeding setTokenAttributes/budget attributes).
  5. OTEL Diagnostics: ✅ /tmp/gh-aw/otel.jsonl contains an exported resourceSpans record with service.name=gh-aw.smoke-otel-tracing and correct workflow/run metadata — spans were exported during this run.

No regressions detected. No issue filed; run triggered outside a PR comment context (issue/PR numbers not set), so reporting via noop per instructions.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode

Recent merged PRs (MCP connectivity ✅):

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) via api-proxy → api.githubcopilot.com

Overall: PASS

cc @lpcox

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

@github-actions

github-actions Bot commented Aug 5, 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 #6961 · haiku45 · 33.3 AIC · ⊞ 3.6K ·
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot Engine

Recent PRs: #6957 (Upgrade gh-aw to v0.85.0), #6951 (chore: model-to-API mapping)

Overall: PASS

cc @lpcox

📰 BREAKING: Report filed by Smoke Copilot
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 Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

EGRESS_RESULT allow=pass deny=pass

✅ Allowed domain (github.com) reachable: allowed=200
✅ Blocked domain (example.com) denied: CONNECT tunnel failed (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

@lpcox lpcox changed the title Refactor duplicated sbx ingress capability writer into shared bounded-runtime utility refactor: share sbx ingress capability writer Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 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 to resolve host.docker.internal ("Temporary failure in name resolution"). The AWF sandbox could not reach the host service containers.

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

@github-actions

github-actions Bot commented Aug 5, 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 (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 builds required overriding Maven's local repository path (-Dmaven.repo.local) since ~/.m2/ was pre-created as root-owned and read-only in this environment (unrelated to the firewall proxy config, which worked correctly via ~/.m2/settings.xml).

Generated by Build Test Suite for #6961 · auto · 38.2 AIC · ⊞ 11.7K ·
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Aug 5, 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.1 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

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

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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Gemini Engine Validation

PR titles:

Overall status: FAIL

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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
  • Upgrade gh-aw to v0.85.0 pre-release and recompile workflows
  • chore: update model-to-API mapping (2026-08-05)
  • PR history lookup: ✅
  • Playwright GitHub title check: ✅
  • File write/readback: ✅
  • Discussion comment: ❌
  • Build (npm ci && npm run build): ❌
  • 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 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Docker Sbx — PASS ✅

Overall: PASS

cc @lpcox

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

@lpcox
lpcox merged commit 176d98f into main Aug 5, 2026
138 of 143 checks passed
@lpcox
lpcox deleted the copilot/duplicate-code-fix-capability-writer branch August 5, 2026 16:17
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.

[Duplicate Code] Bounded ingress capability file writer is duplicated

3 participants