Skip to content

refactor: split agent-service.test.ts by concern into three focused files#5573

Merged
lpcox merged 2 commits into
mainfrom
copilot/refactor-split-agent-service-test
Jun 26, 2026
Merged

refactor: split agent-service.test.ts by concern into three focused files#5573
lpcox merged 2 commits into
mainfrom
copilot/refactor-split-agent-service-test

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

src/services/agent-service.test.ts (644 lines) mixed three independent test suites under one file, making the security-critical buildAgentSecurityConfig tests buried 500+ lines deep.

Split

New file Tests
agent-service-build.test.ts buildAgentService — volumes, env, host-ports, GITHUB_PATH, toolchain vars (~35 tests)
agent-service-image.test.ts resolveAgentImageConfig — preset/custom image resolution (~6 tests)
agent-security-config.test.ts buildAgentSecurityConfig — seccomp, capabilities, memory limits (~9 tests)

No logic changes. Each file carries its own jest.mock('execa', ...) declaration per the existing per-file hoisting requirement. Shared test utilities (service-test-setup.test-utils, agent-service.test-utils) are imported as-is.

Copilot AI changed the title [WIP] Refactor agent service test file by splitting concerns refactor: split agent-service.test.ts by concern into three focused files Jun 26, 2026
Copilot finished work on behalf of lpcox June 26, 2026 15:54
Copilot AI requested a review from lpcox June 26, 2026 15:54
@lpcox lpcox marked this pull request as ready for review June 26, 2026 16:36
Copilot AI review requested due to automatic review settings June 26, 2026 16:36

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

This PR refactors the agent service unit tests by splitting previously co-located suites into smaller, concern-focused test files, making security-critical coverage (e.g., buildAgentSecurityConfig) easier to find and maintain.

Changes:

  • Extract resolveAgentImageConfig tests into agent-service-image.test.ts.
  • Extract buildAgentSecurityConfig tests into agent-security-config.test.ts.
  • Remove the extracted suites from agent-service-build.test.ts, leaving it focused on compose/service build behaviors.
Show a summary per file
File Description
src/services/agent-service-build.test.ts Removes the image-resolution and security-config suites, keeping the file focused on docker-compose/service build expectations.
src/services/agent-service-image.test.ts New focused suite for resolveAgentImageConfig (preset vs custom image behavior, GHCR vs local build).
src/services/agent-security-config.test.ts New focused suite for buildAgentSecurityConfig (capabilities, seccomp/security_opt, tmpfs overlays, resource limits).

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/services/agent-service-build.test.ts:1

  • PR description references splitting src/services/agent-service.test.ts, but this PR's changes are to agent-service-build.test.ts and new files agent-service-image.test.ts / agent-security-config.test.ts. If agent-service.test.ts was already renamed/removed earlier, consider updating the PR description to match the actual source file being split to avoid confusion for reviewers.
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Low

@github-actions

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 Jun 26, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jun 26, 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 Jun 26, 2026

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

Contribution check complete for PR #5573: the changes are a test-only refactor, include/retain relevant tests, are organized under src/services, and the PR description is clear. No guideline issues requiring a PR comment were found.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jun 26, 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 Jun 26, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.24% 98.28% 📈 +0.04%
Statements 98.17% 98.21% 📈 +0.04%
Functions 99.53% 99.53% ➡️ +0.00%
Branches 94.00% 94.00% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 92.7% → 94.5% (+1.82%) 92.7% → 94.5% (+1.82%)

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode ✅

Test Result
GitHub MCP ✅ 2 closed PRs listed
github.com (HTTP) ✅ 200 OK
File I/O ✅ Write/read working
BYOK inference ✅ api-proxy → api.githubcopilot.com

Running in direct BYOK mode via COPILOT_PROVIDER_API_KEY
@Copilot @lpcox Overall: PASS

🔑 BYOK report filed by Smoke Copilot BYOK

@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 issue #5573 · 61.6 AIC · ⊞ 3.3K ·

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smoke Test Results

PR: refactor: split agent-service.test.ts by concern into three focused files
Author: @Copilot | Assignees: @lpcox @Copilot

Test Result
GitHub MCP connectivity
github.com HTTP (200)
File write/read ❌ (pre-step vars not expanded)

Overall: FAIL — pre-step template variables (${{ steps.smoke-data.outputs.* }}) were not expanded; file test could not be verified.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results — Auth mode: PAT (COPILOT_GITHUB_TOKEN)

Test Result
GitHub MCP connectivity ✅ PASS
GitHub.com HTTP ❓ (pre-step outputs not resolved)
File write/read ❓ (pre-step outputs not resolved)

Overall: PASS — PAT auth confirmed via MCP.

PR: "refactor: split agent-service.test.ts by concern into three focused files" — author @Copilot, assignees @lpcox @Copilot

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

  • GitHub MCP Testing: ❌ (Could not retrieve PR titles)
  • GitHub.com Connectivity: ❌ (HTTP 000)
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

Overall status: FAIL

Warning

Firewall blocked 1 domain

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

  • localhost

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

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions github-actions Bot mentioned this pull request Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@lpcox

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

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

Status: PASS

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Notes
1. Module Loading ✅ Pass otel.js loads; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled
2. Test Suite ✅ Pass 59 tests across otel.test.js + otel-fanout.test.js — all pass
3. Env Var Forwarding ✅ Pass api-proxy-env-config.ts:116–123 forwards GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID, OTEL_SERVICE_NAME
4. Token Tracker Integration ✅ Pass onUsage callback present at token-tracker-http.js:324
5. OTEL Diagnostics i️ N/A No api-proxy container running (Docker-in-Docker not supported in this environment); no span export expected

All scenarios pass. OTEL tracing integration is in place and functional.

📡 OTel tracing validated by Smoke OTel Tracing

@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.3 ❌ No
Node.js v24.17.0 v22.23.0 ❌ No
Go go1.22.12 go1.22.12 ✅ Yes

Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environment.

Tested by Smoke Chroot

@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 ✅ PASS
.NET json-parse N/A ✅ 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

Generated by Build Test Suite for issue #5573 · 38.9 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

Check Result
Redis PING ❌ Timeout
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ Blocked

Overall: FAIL

host.docker.internal resolves to 172.17.0.1, but ports 6379 (Redis) and 5432 (PostgreSQL) are explicitly blocked by AWF iptables rules in containers/agent/setup-iptables.sh — these are listed under "dangerous ports" (databases, Redis). The sandbox cannot reach GitHub Actions service containers on those ports by design.

🔌 Service connectivity validated by Smoke Services

@github-actions

Copy link
Copy Markdown
Contributor

"refactor: split agent-service.test.ts by concern into three focused files"

  • GitHub MCP Testing: ✅
  • 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)

Overall: PASS

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@lpcox lpcox merged commit b5ba5bd into main Jun 26, 2026
91 checks passed
@lpcox lpcox deleted the copilot/refactor-split-agent-service-test branch June 26, 2026 19:35
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