Skip to content

Refactor Squid config generation into focused modules#3637

Merged
lpcox merged 3 commits into
mainfrom
copilot/refactor-squid-config-modules
May 23, 2026
Merged

Refactor Squid config generation into focused modules#3637
lpcox merged 3 commits into
mainfrom
copilot/refactor-squid-config-modules

Conversation

Copilot AI commented May 23, 2026

Copy link
Copy Markdown
Contributor

src/squid-config.ts had grown into a single large generateSquidConfig() implementation spanning validation, ACL construction, access rules, and feature-specific config assembly. This change breaks that logic into focused modules while preserving the existing config surface and keeping src/squid-config.ts as a compatibility facade.

  • Module split

    • Added /src/squid/config-generator.ts as the main orchestrator for Squid config assembly
    • Extracted focused helpers into:
      • /src/squid/validation.ts
      • /src/squid/acl-generator.ts
      • /src/squid/access-rules.ts
      • /src/squid/config-sections.ts
  • Responsibility boundaries

    • validation.ts: api-proxy IP validation, host-access port validation/sanitization, api-proxy port validation
    • acl-generator.ts: allowed/blocked domain ACL generation
    • access-rules.ts: protocol-specific allow rules and default deny rule construction
    • config-sections.ts: DLP, SSL bump, port ACLs, DNS, and api-proxy config sections
  • Compatibility / caller updates

    • Kept src/squid-config.ts as a minimal facade exporting generateSquidConfig
    • Updated src/config-writer.ts to import generateSquidConfig from ./squid/config-generator
    • Left policy manifest generation in place under the existing facade path
  • Targeted coverage

    • Added focused tests for extracted validation behavior in src/squid/validation.test.ts
import { generateSquidConfig } from './squid/config-generator';
import { generatePolicyManifest } from './squid-config';

Copilot AI changed the title [WIP] Refactor squid-config.ts into focused configuration modules Refactor Squid config generation into focused modules May 23, 2026
Copilot finished work on behalf of lpcox May 23, 2026 17:04
Copilot AI requested a review from lpcox May 23, 2026 17:04
@lpcox lpcox marked this pull request as ready for review May 23, 2026 17:18
Copilot AI review requested due to automatic review settings May 23, 2026 17:18
@github-actions

github-actions Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 95.98% 96.09% 📈 +0.11%
Statements 95.81% 95.92% 📈 +0.11%
Functions 98.02% 97.92% 📉 -0.10%
Branches 89.44% 89.64% 📈 +0.20%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/services/agent-environment.ts 98.6% → 0.0% (-98.62%) 98.0% → 0.0% (-97.97%)
src/config-writer.ts 83.0% → 85.6% (+2.54%) 83.0% → 85.6% (+2.54%)
✨ New Files (15 files)
  • src/services/agent-environment/api-proxy-environment.ts: 100.0% lines
  • src/services/agent-environment/core-environment.ts: 100.0% lines
  • src/services/agent-environment/env-passthrough.ts: 96.8% lines
  • src/services/agent-environment/environment-builder.ts: 93.5% lines
  • src/services/agent-environment/excluded-vars.ts: 100.0% lines
  • src/services/agent-environment/github-actions-environment.ts: 100.0% lines
  • src/services/agent-environment/host-path-recovery.ts: 100.0% lines
  • src/services/agent-environment/observability-environment.ts: 100.0% lines
  • src/services/agent-environment/proxy-environment.ts: 100.0% lines
  • src/services/agent-environment/tool-specific-environment.ts: 100.0% lines
  • src/squid/access-rules.ts: 100.0% lines
  • src/squid/acl-generator.ts: 100.0% lines
  • src/squid/config-generator.ts: 100.0% lines
  • src/squid/config-sections.ts: 100.0% lines
  • src/squid/validation.ts: 100.0% lines

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

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors Squid configuration generation by splitting the previously large generateSquidConfig() implementation into focused modules under src/squid/, while keeping src/squid-config.ts as a compatibility facade for existing callers.

Changes:

  • Added a new orchestrator (src/squid/config-generator.ts) and extracted helpers for validation, ACL generation, access rules, and config sections.
  • Kept src/squid-config.ts as a re-exporting facade and adjusted src/config-writer.ts imports accordingly.
  • Added unit tests for the extracted validation helpers (src/squid/validation.test.ts).
Show a summary per file
File Description
src/squid/validation.ts New validation helpers for api-proxy IP/ports and host-access port sanitization/validation.
src/squid/validation.test.ts New focused tests for the extracted validation helpers.
src/squid/config-sections.ts New helpers to generate DLP/SSL/DNS/api-proxy/port ACL config sections.
src/squid/config-generator.ts New main generateSquidConfig() orchestrator assembling the final squid.conf output.
src/squid/acl-generator.ts New helpers to generate allowed/blocked domain ACLs and related deny rules.
src/squid/access-rules.ts New helpers to generate protocol-specific allow rules and the default deny rule.
src/squid-config.ts Reduced to a compatibility facade re-exporting generateSquidConfig and generatePolicyManifest.
src/config-writer.ts Updated to import Squid config generation from the new module structure.

Copilot's findings

Tip

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

  • Files reviewed: 8/8 changed files
  • Comments generated: 2

Comment thread src/squid/validation.ts Outdated
Comment on lines +15 to +16
export function validateAndSanitizeHostAccessPort(port: string): string {
const parts = port.split('-');
Comment thread src/config-writer.ts Outdated
Comment on lines +6 to +7
import { generatePolicyManifest } from './squid-config';
import { generateSquidConfig } from './squid/config-generator';
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@lpcox

lpcox commented May 23, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Addressed in commit f983a5e.

  • Hardened validateAndSanitizeHostAccessPort to require trimmed input to match strict numeric/range format before parsing, preventing mixed-character bypass cases.
  • Switched config-writer.ts back to importing generateSquidConfig via ./squid-config so existing test mocks keep working.
  • Added validation tests for whitespace trimming and mixed-character rejection.

Validated with:

  • npm test -- --runInBand src/squid/validation.test.ts src/config-writer.test.ts
  • npm run build
  • npm run lint
  • CodeQL scan (0 alerts).

Copilot finished work on behalf of lpcox May 23, 2026 19:48
@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

GitHub API: 2 PR entries confirmed
GitHub check: playwright_check = ✅ PASS
File verify: smoke-test file exists

Result: PASS — All validation checks passed

💥 [THE END] — Illustrated by Smoke Claude

@github-actions

Copy link
Copy Markdown
Contributor

Service Connectivity Test Results

Redis: Connection timeout
PostgreSQL (pg_isready): No response
PostgreSQL (SELECT 1): Connection timeout

Overall: FAIL — All service connectivity checks failed. Services on host.docker.internal are unreachable from the AWF sandbox.

🔌 Service connectivity validated by Smoke Services

@github-actions

Copy link
Copy Markdown
Contributor

Merged PRs: Refactor agent environment assembly into focused modules | fix(claude-token-optimizer): resolve workflow file via .lock.yml when .md lacks name field
Listed PRs: Refactor agent volume assembly into focused mount modules | Refactor Squid config generation into focused modules
✅ GitHub PR review via gh fallback
❌ safeinputs-gh unavailable
✅ Playwright title contains GitHub
❌ Tavily search unavailable: server exposes no tools
✅ File write/read and build
❌ Discussion query wrapper unavailable; oracle comment posted via fallback
Overall status: FAIL

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

Smoke Test: Gemini Engine Validation

  1. GitHub MCP Testing: ✅
  2. GitHub.com Connectivity: ❌
    • HTTP Status: 000 (SSL Error 35: wrong version number) / 400 (Squid error)
  3. File Writing Testing: ✅
  4. Bash Tool Testing: ✅

Overall Status: FAIL (Network connectivity failed)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Runtime Version Test Results

Comparison of runtime versions between host and chroot environments:

Runtime Host Version Chroot Version Match?
Python 3.12.13 3.12.3 ❌ NO
Node.js v24.15.0 v22.22.3 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall Result: Some runtime versions do not match between host and chroot environments.

  • Python: Minor version mismatch (3.12.13 vs 3.12.3)
  • Node.js: Major version mismatch (v24 vs v22)
  • Go: Versions match ✅

The version mismatches indicate that the chroot environment is successfully isolating the agent from host binaries, using the Ubuntu 22.04 base image versions instead of GitHub Actions runner versions.

Tested by Smoke Chroot

@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 1/1 passed ✅ PASS
Node.js execa 1/1 passed ✅ PASS
Node.js p-limit 1/1 passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

All build and test operations completed successfully across all language ecosystems.

Generated by Build Test Suite for issue #3637 · ● 17.1M ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Offline) Mode — PASS ✅

  • ✅ GitHub MCP: Retrieved PR Refactor agent volume assembly into focused mount modules #3638 ("Refactor agent volume assembly into focused mount modules")
  • ✅ BYOK Inference: Running in COPILOT_OFFLINE mode via api-proxy → api.githubcopilot.com
  • ⚠️ File test: Unable to verify (template variable not expanded)
  • ⚠️ HTTP test: Unable to verify (template variable not expanded)

PR #3637: "Refactor Squid config generation into focused modules" — @Copilot, assignees: @lpcox, @Copilot

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

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

MCP Connectivity: ✅ (#3636: Refactor agent environment assembly into focused modules)
GitHub.com: ⚠️ (pre-step data not available)
File I/O: ⚠️ (pre-step data not available)

Status: INCOMPLETE (template vars not expanded)

cc @Copilot @lpcox

📰 BREAKING: Report filed by Smoke Copilot

@lpcox lpcox merged commit 78261f1 into main May 23, 2026
63 of 68 checks passed
@lpcox lpcox deleted the copilot/refactor-squid-config-modules branch May 23, 2026 20:27
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/squid-config.ts into focused configuration modules

3 participants