refactor: split validate-options.ts into focused validator modules#3479
Conversation
Split the 450-line validateOptions function into four focused modules under src/commands/validators/: - log-and-limits.ts: log level, model multipliers, resource limits - network-options.ts: Docker host, domain resolution, network config - agent-options.ts: env vars, volume mounts, SSL Bump URL patterns - config-assembly.ts: config assembly + post-config validations validate-options.ts is now a thin ~33-line orchestrator that calls the sub-validators in sequence. Public API is unchanged. All 1991 existing tests continue to pass.
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
✨ New Files (4 files)
Coverage comparison generated by |
Smoke Test Results✅ GitHub API: 2 PR entries confirmed in recent-prs.json Result: PASS - All smoke tests passed successfully.
|
🔬 Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( PR author: Overall: PARTIAL (pre-step smoke data not injected; BYOK inference and MCP pass ✅)
|
🔬 Smoke Test Results
Overall: PASS 🎉 PR by
|
|
Smoke Codex: FAIL 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.
|
Chroot Smoke Test Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.
|
There was a problem hiding this comment.
Pull request overview
Refactors the CLI option validation pipeline by splitting the previously monolithic validateOptions implementation into focused validator modules, keeping the public API and call sites unchanged while isolating security-critical validation paths (domain/DNS resolution and SSL bump URL pattern checks).
Changes:
- Added focused validators for log/resource limits, network options, agent-runtime options, and post-assembly config guards under
src/commands/validators/. - Moved config assembly + post-validation guards (rate limits, feature-flag compatibility, port rules, API proxy warnings, docker host URI checks) into a dedicated assembly stage.
- Reduced
validate-options.tsto a thin orchestrator that composes the validators and returns the assembledWrapperConfig.
Show a summary per file
| File | Description |
|---|---|
| src/commands/validators/network-options.ts | Extracts Docker-host handling, domain allow/block resolution, and network config resolution into a typed validator result. |
| src/commands/validators/log-and-limits.ts | Extracts log level validation, Anthropic cache TTL validation, model multiplier parsing, memory limit parsing, and agent image validation. |
| src/commands/validators/config-assembly.ts | Centralizes buildConfig call and all post-assembly guards/warnings (docker host URI/path prefix, rate limits, ports, API proxy validations/warnings). |
| src/commands/validators/agent-options.ts | Extracts agent runtime validation (env/env-file, mounts) and SSL bump URL pattern validation (security-critical). |
| src/commands/validate-options.ts | Replaced monolithic implementation with a small orchestrator wiring the new validator modules together. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 0
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
Smoke test results: 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.
|
Smoke Test Results — FAIL
|
validateOptionswas a single 450-line function handling 11 distinct concerns, making security-critical sections (domain resolution, SSL Bump URL pattern validation) impossible to test or review in isolation.Structure
Extracts the monolith into four focused modules under
src/commands/validators/:log-and-limits.ts— log level,--anthropic-cache-tail-ttl, model multipliers (--max-effective-tokens,--max-model-multiplier,--max-runs), memory limit, agent imagenetwork-options.ts— Docker host detection,--docker-host-path-prefix, domain resolution (--allow-domains,--block-domains), upstream proxy, DNS (security-critical)agent-options.ts—--env/--env-file,--mount, SSL Bump--allow-urlsURL pattern validation (security-critical)config-assembly.ts—buildConfigcall + all post-assembly guards (docker host URI, rate limits, feature-flag compatibility, port rules, API proxy warnings)Orchestrator
validate-options.tsbecomes a 33-line thin orchestrator — public API unchanged, no caller modifications required:Each sub-validator exports a typed result interface (
LogAndLimitsResult,NetworkOptionsResult,AgentOptionsResult) so the assembly stage receives fully-typed, pre-validated inputs.