refactor: split docker-manager.ts into focused modules#2501
Conversation
Extract host-env utilities, compose generation, container lifecycle, and cleanup into separate modules. A facade docker-manager.ts re-exports everything for backwards compatibility. Closes #2473 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR refactors the AWF Docker management logic by splitting the former 3k+ line src/docker-manager.ts into focused modules (host env utilities, compose generation, container lifecycle, and cleanup) while keeping src/docker-manager.ts as a backwards-compatible facade via re-exports.
Changes:
- Added
src/host-env.ts,src/compose-generator.ts,src/container-lifecycle.ts, andsrc/container-cleanup.tsand moved logic into these modules by responsibility. - Replaced the original
src/docker-manager.tsimplementation with a thin re-export facade to preserve existing import paths. - Exposed shared constants/utilities needed across the new modules via
host-env.ts.
Show a summary per file
| File | Description |
|---|---|
| src/host-env.ts | New module containing host/env utilities and shared constants. |
| src/compose-generator.ts | New module containing generateDockerCompose() and compose redaction helper. |
| src/container-lifecycle.ts | New module containing writeConfigs(), startContainers(), and agent lifecycle helpers. |
| src/container-cleanup.ts | New module containing diagnostics, stop, audit preservation, and cleanup routines. |
| src/docker-manager.ts | Facade that re-exports symbols from the new modules for compatibility. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/5 changed files
- Comments generated: 3
| export * from './host-env'; | ||
| export * from './compose-generator'; | ||
| export * from './container-lifecycle'; | ||
| export * from './container-cleanup'; |
| import * as path from 'path'; | ||
| import * as yaml from 'js-yaml'; | ||
| import execa from 'execa'; | ||
| import { WrapperConfig, BlockedTarget, API_PROXY_HEALTH_PORT } from './types'; |
| // When bundled with esbuild, this global is replaced at build time with the | ||
| // JSON content of containers/agent/seccomp-profile.json. In normal (tsc) | ||
| // builds the identifier remains undeclared, so the typeof check below is safe. | ||
| declare const __AWF_SECCOMP_PROFILE__: string | undefined; | ||
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot merge main and address the review feedback |
…-manager-into-modules Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
- Remove unused API_PROXY_HEALTH_PORT import from container-lifecycle.ts - Remove unused __AWF_SECCOMP_PROFILE__ declaration from compose-generator.ts - Replace export * with explicit named re-exports in docker-manager.ts facade to avoid unintentionally widening the public API surface with internal-only constants (SQUID_PORT, *_CONTAINER_NAME, MAX_ENV_VALUE_SIZE, etc.) Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/b873ac30-3e8d-449e-a571-d9e45f65dc2c
Done in commit 5372b13:
|
|
Smoke Test Results:
Status: PASS
|
|
Smoke Test: Copilot BYOK (Offline Mode)
Running in BYOK offline mode ( PR by @lpcox · Reviewer:
|
This comment has been minimized.
This comment has been minimized.
Chroot Version Comparison Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
This comment has been minimized.
This comment has been minimized.
Smoke Test Results
Overall: FAIL —
|
🔬 Smoke Test Results
Author: @lpcox | Reviewer: Overall: PARTIAL — MCP test passed; HTTP & file tests could not be verified (pre-step outputs not passed to agent step).
|
|
Smoke test run 25331573365 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.
|
Summary
Split the 3,263-line
src/docker-manager.tsinto 4 focused modules. The original file becomes a thin facade re-exporting everything for backwards compatibility.src/host-env.tssrc/compose-generator.tsgenerateDockerCompose(~1,552 lines) and its helperssrc/container-lifecycle.tssrc/container-cleanup.tssrc/docker-manager.tsBackwards compatibility
All existing
import { ... } from './docker-manager'statements work unchanged via the facade re-export. No consumer files modified.Testing
Closes #2473