feat: add AWF JSON/YAML config ingestion with schema validation and CLI precedence#2018
feat: add AWF JSON/YAML config ingestion with schema validation and CLI precedence#2018
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class AWF config-file support (JSON/YAML, including stdin) with early shape validation, a deterministic precedence model (CLI overrides config), and a formal config contract for tooling.
Changes:
- Introduces
--config <path|->to load JSON/YAML config files (or stdin via-) and merge into Commander options with CLI precedence. - Adds runtime config parsing + validation + CLI option mapping (
src/config-file.ts) and corresponding Jest coverage. - Publishes a JSON Schema + normative spec documenting the config model and CLI mapping, and links them from the README.
Show a summary per file
| File | Description |
|---|---|
| src/config-file.ts | Implements config parsing (JSON/YAML/stdin), validation, mapping to existing CLI option names, and CLI-precedence merge. |
| src/config-file.test.ts | Adds unit tests for validation, parsing (file/stdin), mapping, and precedence behavior. |
| src/cli.ts | Wires --config into the CLI and applies config-derived options before existing option validation/processing. |
| docs/awf-config.schema.json | Defines the machine-readable schema for config files (closed-world / additionalProperties: false). |
| docs/awf-config-spec.md | Documents the normative processing model, precedence rules, and CLI mapping contract for tooling. |
| README.md | Links the new schema and spec for discoverability. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 0
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 85.35% | 84.41% | 📉 -0.94% |
| Statements | 85.24% | 83.64% | 📉 -1.60% |
| Functions | 87.96% | 87.39% | 📉 -0.57% |
| Branches | 77.95% | 74.82% | 📉 -3.13% |
📁 Per-file Coverage Changes (2 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/cli.ts |
59.5% → 58.9% (-0.61%) | 60.0% → 59.4% (-0.61%) |
src/docker-manager.ts |
86.8% → 87.1% (+0.30%) | 86.4% → 86.7% (+0.29%) |
✨ New Files (1 files)
src/config-file.ts: 65.6% lines
Coverage comparison generated by scripts/ci/compare-coverage.ts
…o local variable' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 85.35% | 84.41% | 📉 -0.94% |
| Statements | 85.24% | 83.64% | 📉 -1.60% |
| Functions | 87.96% | 87.39% | 📉 -0.57% |
| Branches | 77.95% | 74.82% | 📉 -3.13% |
📁 Per-file Coverage Changes (2 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/cli.ts |
59.5% → 58.9% (-0.61%) | 60.0% → 59.4% (-0.61%) |
src/docker-manager.ts |
86.8% → 87.1% (+0.30%) | 86.4% → 86.7% (+0.29%) |
✨ New Files (1 files)
src/config-file.ts: 65.3% lines
Coverage comparison generated by scripts/ci/compare-coverage.ts
The initial apt-get update can fail with hash mismatches when Ubuntu mirrors are mid-sync. The existing retry logic only covered apt-get install failures, not apt-get update failures. This adds a retry with cache clear for the initial apt-get update in both agent and squid Dockerfiles. Fixes: squid-proxy build failure (exit code 100) in --build-local CI Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 85.35% | 84.41% | 📉 -0.94% |
| Statements | 85.24% | 83.64% | 📉 -1.60% |
| Functions | 87.96% | 87.39% | 📉 -0.57% |
| Branches | 77.95% | 74.82% | 📉 -3.13% |
📁 Per-file Coverage Changes (2 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/cli.ts |
59.5% → 58.9% (-0.61%) | 60.0% → 59.4% (-0.61%) |
src/docker-manager.ts |
86.8% → 87.1% (+0.30%) | 86.4% → 86.7% (+0.29%) |
✨ New Files (1 files)
src/config-file.ts: 65.3% lines
Coverage comparison generated by scripts/ci/compare-coverage.ts
The byok-copilot feature flag generates an empty COPILOT_MODEL fallback, but BYOK providers require an explicit model. This patches the lock file with claude-sonnet-4.5 as the default. Workaround for: github/gh-aw#26565 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 85.35% | 84.41% | 📉 -0.94% |
| Statements | 85.24% | 83.64% | 📉 -1.60% |
| Functions | 87.96% | 87.39% | 📉 -0.57% |
| Branches | 77.95% | 74.82% | 📉 -3.13% |
📁 Per-file Coverage Changes (2 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/cli.ts |
59.5% → 58.9% (-0.61%) | 60.0% → 59.4% (-0.61%) |
src/docker-manager.ts |
86.8% → 87.1% (+0.30%) | 86.4% → 86.7% (+0.29%) |
✨ New Files (1 files)
src/config-file.ts: 65.3% lines
Coverage comparison generated by scripts/ci/compare-coverage.ts
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Replace single-retry apt-get update with a 3-attempt retry loop using exponential backoff (10s, 20s, 30s). The single retry was insufficient when Ubuntu mirrors are in prolonged sync states (observed in CI where mirror hash mismatches persisted across multiple minutes). The apt_update_retry function clears the apt cache before each attempt, ensuring a clean state. Applied to all apt-get update calls in both agent and squid Dockerfiles, including the install-retry fallback paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 85.35% | 84.41% | 📉 -0.94% |
| Statements | 85.24% | 83.64% | 📉 -1.60% |
| Functions | 87.96% | 87.39% | 📉 -0.57% |
| Branches | 77.95% | 74.82% | 📉 -3.13% |
📁 Per-file Coverage Changes (2 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/cli.ts |
59.5% → 58.9% (-0.61%) | 60.0% → 59.4% (-0.61%) |
src/docker-manager.ts |
86.8% → 87.1% (+0.30%) | 86.4% → 86.7% (+0.29%) |
✨ New Files (1 files)
src/config-file.ts: 65.3% lines
Coverage comparison generated by scripts/ci/compare-coverage.ts
GitHub Actions runners are Azure-hosted, so azure.archive.ubuntu.com is geographically closer and more reliable than archive.ubuntu.com. This reduces Hash Sum mismatch failures during Ubuntu mirror syncs. Handles both traditional sources.list (jammy/22.04) and DEB822 format (noble/24.04+) used by ubuntu/squid:latest. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 85.35% | 84.41% | 📉 -0.94% |
| Statements | 85.24% | 83.64% | 📉 -1.60% |
| Functions | 87.96% | 87.39% | 📉 -0.57% |
| Branches | 77.95% | 74.82% | 📉 -3.13% |
📁 Per-file Coverage Changes (2 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/cli.ts |
59.5% → 58.9% (-0.61%) | 60.0% → 59.4% (-0.61%) |
src/docker-manager.ts |
86.8% → 87.1% (+0.30%) | 86.4% → 86.7% (+0.29%) |
✨ New Files (1 files)
src/config-file.ts: 65.3% lines
Coverage comparison generated by scripts/ci/compare-coverage.ts
Smoke Test Results✅ GitHub MCP: chore: recompile workflows for gh-aw v0.68.5 / chore: upgrade gh-aw to v0.68.4 and recompile workflows Overall: PASS
|
Copilot Smoke Test Results ✅GitHub MCP: ✅ Listed PR #2006 by Status: PASS cc
|
Smoke Test: GitHub Actions Services Connectivity
All checks passed.
|
🤖 OpenCode Smoke Test Results
Overall: PASS
|
Smoke Test Status
|
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
|
AWF’s growing flag surface made non-trivial invocations hard to maintain and share. This change introduces JSON/YAML config-file support (including stdin), validates config shape early, and formalizes a tooling-oriented configuration contract that
gh-awcan consume.CLI config ingestion + precedence
--config <path|->to load config from JSON/YAML files or stdin (--config -).Structured config parsing/validation
src/config-file.tsfor:--no-rate-limit).Schema + W3C-style spec for compiler/tooling
docs/awf-config.schema.json(machine-readable schema for IDE/completion/validation).docs/awf-config-spec.md(normative processing model, conformance, precedence, and CLI mapping) to serve as the contract forgh-awcompiler integration.Coverage and docs updates
src/config-file.test.tsfor parsing, validation, stdin mode, mapping, and precedence behavior.Example config usage:
Example schema-backed config shape:
{ "$schema": "https://raw.githubusercontent.com/github/gh-aw-firewall/main/docs/awf-config.schema.json", "network": { "allowDomains": ["github.com", "api.github.com"], "dnsServers": ["1.1.1.1", "1.0.0.1"] }, "apiProxy": { "enabled": true, "targets": { "openai": { "host": "api.openai.com", "basePath": "/v1" } } }, "logging": { "logLevel": "debug" } }