refactor(agent-service): extract resolveAgentImageConfig from buildAgentService#5129
Conversation
Extract image-selection logic from buildAgentService into a standalone resolveAgentImageConfig function (Sub-concern C, ~46 lines). - Isolates the three-way branch (GHCR preset / local build / passthrough) making image-provenance logic straightforward to audit - Reduces buildAgentService from 167 to ~120 lines - Exports resolveAgentImageConfig and testHelpers shim for direct unit testing without constructing a full service object - Adds 6 focused unit tests covering all three branches Closes #5118
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
Refactors the agent Docker Compose service builder by extracting the agent image/build selection logic into a dedicated helper, making the selection branches clearer and directly unit-testable.
Changes:
- Extracted image/build resolution into
resolveAgentImageConfig(config, imageConfig)and simplifiedbuildAgentServiceviaObject.assign(...). - Added unit tests covering GHCR preset selection,
--build-localbuild config, custom base image builds, and passthrough behavior.
Show a summary per file
| File | Description |
|---|---|
| src/services/agent-service.ts | Extracts agent image/build selection into resolveAgentImageConfig and wires it into buildAgentService. |
| src/services/agent-service.test.ts | Adds a focused test suite for resolveAgentImageConfig branch coverage. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
✅ Copilot review passed with no inline comments. @copilot Add the |
|
@copilot fix this failing ci check https://github.com/github/gh-aw-firewall/actions/runs/27648235992/job/81765494555?pr=5129 |
Fixed in |
|
✅ Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓 |
|
✅ Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓 |
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
❌ Contribution Check failed. Please review the logs for details. |
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded. |
|
✅ Smoke Gemini completed. All facets verified. 💎 Smoke test completed with FAIL status. Comment added to PR #5129. |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
✅ Build Test Suite completed successfully! |
|
❌ Smoke Claude failed |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
🔌 Smoke Services — All services reachable! ✅ |
|
🚀 Security Guard has started processing this pull request |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
chore(deps): Bump
|
Smoke Test Results — Auth mode: PAT (COPILOT_GITHUB_TOKEN)
Overall: FAIL — pre-step outputs ( cc
|
|
Smoke Test: Copilot BYOK (Direct) Mode — PASS ✅
Running in direct BYOK mode (
|
🔬 Smoke Test Results
Overall: FAIL — pre-step template variables ( PR: refactor(agent-service): extract resolveAgentImageConfig from buildAgentService
|
Smoke Test: Gemini Engine Validation
Overall status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Chroot Version Comparison Results
Overall: ❌ Not all versions match Python and Node.js versions differ between host and chroot. Go matches correctly.
|
|
✅ fix: add bare API proxy targets as https:// only to prevent over-broad allowlisting Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
📡 Smoke Test: API Proxy OpenTelemetry Tracing
All scenarios pass or are expected-pending. No regressions detected.
|
|
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
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results
Overall: FAIL — service containers are not reachable from this runner environment.
|
buildAgentService(167 lines) mixed three concerns; the image-selection branch (~46 lines) was particularly opaque — a three-way conditional that constructs differentbuild:vsimage:objects depending on GHCR availability, preset type, and--build-local.Changes
src/services/agent-service.ts— extractedresolveAgentImageConfig(config, imageConfig)as a standalone exported function:{ image }, local/custom build →{ build: { context, dockerfile, args } }, passthrough →{ image: agentImage }buildAgentServicedelegates viaObject.assign, reducing it from 167 → ~120 linestestHelpersexport pattern (@internal) so the function can be unit-tested directlysrc/services/agent-service.test.ts— 6 new unit tests forresolveAgentImageConfigcovering all branches (default GHCR, act GHCR, default--build-local, act--build-local, custom image build, and passthrough)