Skip to content

refactor(types): split config.ts into focused modules and compose WrapperConfig by domain#2899

Merged
lpcox merged 3 commits into
mainfrom
copilot/refactor-split-config-ts
May 11, 2026
Merged

refactor(types): split config.ts into focused modules and compose WrapperConfig by domain#2899
lpcox merged 3 commits into
mainfrom
copilot/refactor-split-config-ts

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

✨ Enhancement

src/types/config.ts had grown into a 1,116-line mixed-responsibility module combining runtime port constants, a 61-field WrapperConfig, and unrelated auxiliary types. This refactor separates those concerns into focused modules while preserving existing import paths via compatibility re-exports.

What does this improve?

  • Better type discoverability and navigation by domain.
  • Clear separation of runtime constants from type-only modules.
  • Lower coupling in src/types/ as the codebase evolves.

Why is this valuable?

  • Reduces cognitive load around WrapperConfig maintenance.
  • Enables targeted imports and future incremental refactors.
  • Keeps callers stable through config.ts / index.ts re-export compatibility.

Implementation approach:

  • Runtime ports extracted
    • Moved API_PROXY_PORTS, API_PROXY_HEALTH_PORT, and CLI_PROXY_PORT to src/types/ports.ts.
  • Wrapper config decomposed
    • Added src/types/wrapper-config.ts with domain slices:
      • ContainerImageOptions
      • NetworkOptions
      • VolumeOptions
      • SecurityOptions
      • ApiProxyOptions
      • RateLimitOptions
      • RuntimeOptions
    • Composed WrapperConfig as an intersection of these domain types.
  • Auxiliary types isolated
    • Added src/types/upstream-proxy.ts (UpstreamProxyConfig)
    • Added src/types/log-level.ts (LogLevel)
    • Added src/types/rate-limit.ts (RateLimitConfig)
  • Backward compatibility retained
    • src/types/config.ts now re-exports from new modules.
    • src/types/index.ts updated to export the new module structure.
  • Docs and focused type-compat test
    • Updated architecture docs to reference new type file layout.
    • Added src/types/config.test.ts for re-export and composition coverage.
// src/types/wrapper-config.ts (shape)
export type WrapperConfig =
  ContainerImageOptions &
  NetworkOptions &
  VolumeOptions &
  SecurityOptions &
  ApiProxyOptions &
  RateLimitOptions &
  RuntimeOptions;

Copilot AI changed the title [WIP] Refactor config.ts by extracting port constants and decomposing WrapperConfig refactor(types): split config.ts into focused modules and compose WrapperConfig by domain May 11, 2026
Copilot AI requested a review from lpcox May 11, 2026 14:09
Copilot finished work on behalf of lpcox May 11, 2026 14:09
@lpcox lpcox marked this pull request as ready for review May 11, 2026 15:00
@lpcox lpcox requested a review from Mossaka as a code owner May 11, 2026 15:00
Copilot AI review requested due to automatic review settings May 11, 2026 15:00
@github-actions
Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation build failed for this PR. View logs.

Built from commit 626f450

@github-actions
Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 87.84% 87.93% 📈 +0.09%
Statements 87.77% 87.86% 📈 +0.09%
Functions 82.78% 82.90% 📈 +0.12%
Branches 79.72% 79.76% 📈 +0.04%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/container-lifecycle.ts 87.1% → 88.2% (+1.14%) 87.5% → 88.6% (+1.11%)
✨ New Files (1 files)
  • src/types/ports.ts: 100.0% lines

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Refactors src/types/config.ts by splitting the large mixed-responsibility module into focused type/constant modules, while keeping backward-compatible re-exports.

Changes:

  • Extracted runtime port constants into src/types/ports.ts.
  • Decomposed WrapperConfig into domain “slice” types and re-composed it in src/types/wrapper-config.ts.
  • Added focused type modules (log-level, rate-limit, upstream-proxy) and updated index.ts, docs, and a compatibility test.
Show a summary per file
File Description
src/types/wrapper-config.ts Introduces WrapperConfigBase, domain option slices, and an intersection-composed WrapperConfig.
src/types/upstream-proxy.ts New standalone UpstreamProxyConfig type module.
src/types/rate-limit.ts New standalone RateLimitConfig type module.
src/types/ports.ts New module for API/CLI proxy port constants.
src/types/log-level.ts New standalone LogLevel union type module.
src/types/index.ts Re-exports the new module structure (ports + wrapper-config slices + auxiliary types).
src/types/config.ts Reduces to backward-compatible re-exports from the new modules.
src/types/config.test.ts Adds tests to validate re-exports and WrapperConfig composition.
docs/architecture.md Updates docs to reflect the new type module layout.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 9/9 changed files
  • Comments generated: 4

Comment on lines +561 to +564
* - http://api-proxy:10000 - OpenAI API proxy (for Codex) {@link API_PROXY_PORTS.OPENAI}
* - http://api-proxy:10001 - Anthropic API proxy (for Claude) {@link API_PROXY_PORTS.ANTHROPIC}
* - http://api-proxy:10002 - GitHub Copilot API proxy {@link API_PROXY_PORTS.COPILOT}
* - http://api-proxy:10004 - OpenCode API proxy (defaults to Copilot/OpenAI routing) {@link API_PROXY_PORTS.OPENCODE}
Comment on lines +1023 to +1029
export type ContainerImageOptions = Pick<WrapperConfigBase,
| 'imageRegistry'
| 'imageTag'
| 'buildLocal'
| 'skipPull'
| 'agentImage'
>;
Comment on lines +1105 to +1112
export type WrapperConfig =
ContainerImageOptions
& NetworkOptions
& VolumeOptions
& SecurityOptions
& ApiProxyOptions
& RateLimitOptions
& RuntimeOptions;
Comment thread src/types/rate-limit.ts
Comment on lines +13 to +19
enabled: boolean;
/** Max requests per minute per provider (default: 600 when enabled) */
rpm: number;
/** Max requests per hour per provider (default: 1000) */
rph: number;
/** Max request bytes per minute per provider (default: 52428800 = 50 MB) */
bytesPm: number;
@github-actions
Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

Test Status
GitHub MCP connectivity ❌ (401 Bad credentials)
GitHub.com HTTP connectivity ❓ (template vars not expanded)
File write/read ❓ (template vars not expanded)

Overall: FAIL — Pre-computed template variables (${{ steps.smoke-data.outputs.* }}) were not substituted before agent execution. GitHub MCP returned 401 Bad credentials.

/cc @Copilot

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

🔥 Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP connectivity ❌ 401 (unauthenticated in sandbox)
GitHub.com HTTP connectivity ✅ 200
File write/read ⚠️ Pre-step vars not expanded
BYOK inference (this response)

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com

Overall: PARTIAL — BYOK inference path confirmed working; MCP/pre-step data unavailable due to sandbox constraints.

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

  • ❌ GitHub API test: gh CLI authentication error (HTTP 401)
  • ✅ Playwright: github.com page title verified
  • ✅ File write: Test file created successfully
  • ✅ Bash tool: File verified

Status: PARTIAL PASS (3/4) — GitHub CLI auth issue needs investigation

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

Overall status: FAIL
✅ Merged PR review: Add first-class ARC/DinD compatibility mode for AWF; Fix chroot bind mounts for ARC/DinD split runner-daemon filesystems
❌ safeinputs-gh PR query: tool missing
✅ Playwright: title contains GitHub
❌ Tavily search: no registered tools
✅ File writing: test file created
✅ Bash cat: file read back
❌ Discussion interaction: github-discussion-query missing
✅ Build: npm ci && npm run build

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

🏗️ 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 #2899 · ● 965.2K ·

@github-actions
Copy link
Copy Markdown
Contributor

Chroot Smoke Test Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.14.1 v20.20.2
Go go1.22.12 go1.22.12

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

Tested by Smoke Chroot

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results — FAIL

Check Result
Redis PING ❌ Timeout (no response)
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ Not attempted (pg unreachable)

host.docker.internal is not resolving/reachable from this runner. Service containers may not be configured or the host alias is unavailable in this environment.

🔌 Service connectivity validated by Smoke Services

@lpcox lpcox merged commit 61c4bef into main May 11, 2026
67 of 76 checks passed
@lpcox lpcox deleted the copilot/refactor-split-config-ts branch May 11, 2026 17:50
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.

[Refactoring] Split src/types/config.ts — extract port constants and decompose WrapperConfig

3 participants