Refactoring Opportunity
Summary
- File:
src/services/agent-volumes-mounts.test.ts
- Current size: 862 lines
- Responsibilities identified: 6 distinct volume-mount feature areas in one flat
describe block
Evidence
The file has one top-level describe('agent service', ...) block (line 43) with 35+ flat it() test cases and zero sub-describe grouping. Six distinct functional areas are intermixed across 820 lines:
- Basic mounts (lines 44–155): default required volumes, custom volume mounts, path normalization, trailing-slash handling.
- ARC/DinD staging (lines 159–303): ARC runner binary staging, PATH candidate selection, path escaping guard,
etc/passwd/etc/group non-prefixing.
- Docker socket / DinD exposure (lines 330–503): api-proxy health-check mount,
enableDind flag, DOCKER_HOST env forwarding, invalid-socket fallback.
- Toolchain mounts (lines 504–624): Rust/cargo, npm, Gemini API key dir,
container.runnerToolCachePath, RUNNER_TOOL_CACHE, symlink exclusion.
- Chroot host-access mounts (lines 625–760):
enableHostAccess, custom chroot-hosts file, host.docker.internal injection, sessionStateDir.
- DNS pre-resolution in mounts (lines 761–862): domain-to-IP pre-resolution, failed-resolution skip, duplicate deduplication.
There are no describe() sub-groups at all. Finding the test for a specific feature (e.g., "does the Gemini dir get mounted?") requires scanning the entire 862-line file.
Proposed Split
Split into focused test files, each importing shared fixtures from service-test-setup.test-utils:
agent-volumes-basic.test.ts — default and custom mounts, path prefixing (~155 lines)
agent-volumes-arc-dind-staging.test.ts — ARC staging, binary path resolution (~150 lines)
agent-volumes-dind-socket.test.ts — Docker socket exposure, enableDind, DOCKER_HOST (~175 lines)
agent-volumes-toolchain.test.ts — toolchain dirs, tool-cache paths, symlink exclusion (~130 lines)
agent-volumes-chroot-hosts.test.ts — chroot host-access, custom hosts injection (~140 lines)
agent-volumes-dns-preresolution.test.ts — DNS pre-resolution in bind mounts (~110 lines)
This matches the splitting pattern used for docker-manager-lifecycle.test.ts, docker-manager-cleanup.test.ts, and docker-manager-utils.test.ts.
Effort Estimate
Low
Benefits
- Test failures immediately name the affected feature area (DinD, toolchain, DNS, etc.)
- 150-line files are scannable in seconds vs. an 862-line monolith
- Individual feature-area tests run faster in isolation during development
- Consistent with existing split-test conventions in this codebase
Detected by Refactoring Scanner workflow. Run date: 2026-06-24
Generated by Refactoring Opportunity Scanner · 140.6 AIC · ⊞ 6.9K · ◷
Refactoring Opportunity
Summary
src/services/agent-volumes-mounts.test.tsdescribeblockEvidence
The file has one top-level
describe('agent service', ...)block (line 43) with 35+ flatit()test cases and zero sub-describegrouping. Six distinct functional areas are intermixed across 820 lines:etc/passwd/etc/groupnon-prefixing.enableDindflag,DOCKER_HOSTenv forwarding, invalid-socket fallback.container.runnerToolCachePath,RUNNER_TOOL_CACHE, symlink exclusion.enableHostAccess, customchroot-hostsfile,host.docker.internalinjection,sessionStateDir.There are no
describe()sub-groups at all. Finding the test for a specific feature (e.g., "does the Gemini dir get mounted?") requires scanning the entire 862-line file.Proposed Split
Split into focused test files, each importing shared fixtures from
service-test-setup.test-utils:agent-volumes-basic.test.ts— default and custom mounts, path prefixing (~155 lines)agent-volumes-arc-dind-staging.test.ts— ARC staging, binary path resolution (~150 lines)agent-volumes-dind-socket.test.ts— Docker socket exposure,enableDind,DOCKER_HOST(~175 lines)agent-volumes-toolchain.test.ts— toolchain dirs, tool-cache paths, symlink exclusion (~130 lines)agent-volumes-chroot-hosts.test.ts— chroot host-access, custom hosts injection (~140 lines)agent-volumes-dns-preresolution.test.ts— DNS pre-resolution in bind mounts (~110 lines)This matches the splitting pattern used for
docker-manager-lifecycle.test.ts,docker-manager-cleanup.test.ts, anddocker-manager-utils.test.ts.Effort Estimate
Low
Benefits
Detected by Refactoring Scanner workflow. Run date: 2026-06-24