Skip to content

[Test Coverage] container-lifecycle.ts and compose-generator.ts - #6322

Merged
lpcox merged 4 commits into
mainfrom
test-coverage-lifecycle-compose-gaps-e20079d4b0c84bf8
Jul 17, 2026
Merged

[Test Coverage] container-lifecycle.ts and compose-generator.ts#6322
lpcox merged 4 commits into
mainfrom
test-coverage-lifecycle-compose-gaps-e20079d4b0c84bf8

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Adds Jest unit tests covering previously uncovered branches in two security-critical files.

src/container-lifecycle.ts (new: coverage-lifecycle-compose-gaps.test.ts)

  • onNetworkReady topology path (lines 58-72): tests the three-phase startup (squid-only → onNetworkReady callback → full bring-up), both with and without skipPull
  • handleRetryStartupFailure return path (line 175): verifies that when the retry succeeds after an api-proxy first-attempt failure, the function returns cleanly
  • runAgentCommand error rethrow (lines 313-314): verifies that an unexpected error from docker wait is caught, logged, and rethrown

src/compose-generator.ts (new: compose-generator-gaps.test.ts)

  • buildLocal containers-dir guard (lines 30-32): verifies the helpful error is thrown when --build-local is used without a full repo checkout
  • api-proxy port publishing + awf-ext attachment (lines 144-158): verifies that in microVM (sbx) mode, api-proxy ports are published and, when networkIsolation is set, the awf-ext network is attached

Tests added: 7 (all passing)

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Test Coverage Improver · 215.9 AIC · ⊞ 5.3K ·

- container-lifecycle.ts: cover onNetworkReady topology path (lines 58-72,
  skipPull in topology mode, handleRetryStartupFailure return at line 175,
  and runAgentCommand error rethrow path (lines 313-314)
- compose-generator.ts: cover buildLocal missing containers/ guard (lines
  30-32) and api-proxy port publishing + awf-ext network attachment for
  microVM/sbx runtime mode (lines 144-158)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox
lpcox marked this pull request as ready for review July 17, 2026 13:45
Copilot AI review requested due to automatic review settings July 17, 2026 13:45

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

Adds targeted Jest coverage for container lifecycle and Compose generation branches.

Changes:

  • Tests phased container startup, retries, and command errors.
  • Tests local-build validation and sbx API-proxy networking.
Show a summary per file
File Description
src/coverage-lifecycle-compose-gaps.test.ts Adds lifecycle branch tests.
src/compose-generator-gaps.test.ts Adds Compose-generation branch tests.

Review details

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 4
  • Review effort level: Medium

Comment on lines +40 to +43
describe('startContainers – onNetworkReady topology path', () => {
const { getDir } = useTempDir();

it('invokes onNetworkReady callback after squid-proxy starts (no skipPull)', async () => {
Comment on lines +91 to +107
it('returns after retry succeeds (handleRetryStartupFailure return path)', async () => {
const { didContainerFailStartup, logContainerLogsToStderr } =
jest.requireMock('./container-startup-diagnostics');

// First attempt: api-proxy fails
didContainerFailStartup
.mockResolvedValueOnce(true) // first call: api-proxy (handleStartupFailure)
.mockResolvedValueOnce(false) // squid check skipped
.mockResolvedValueOnce(false) // cli-proxy check skipped
.mockResolvedValueOnce(false); // retry: api-proxy check (handleRetryStartupFailure)

// docker rm
mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);
// docker compose up (first attempt — fails)
mockExecaFn.mockRejectedValueOnce(new Error('awf-api-proxy exited with code 1'));
// docker compose up (retry — succeeds)
mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);
Comment on lines +117 to +128
it('rethrows when docker wait throws an unexpected error', async () => {
const fatalError = new Error('docker daemon connection refused');

// docker logs -f (resolves immediately with reject:false)
mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);
// docker wait — throws
mockExecaFn.mockRejectedValueOnce(fatalError);

await expect(runAgentCommand(getDir(), ['github.com'])).rejects.toThrow(
'docker daemon connection refused'
);
});
Comment thread src/compose-generator-gaps.test.ts Outdated
Comment on lines +2 to +4
* Coverage tests for uncovered branches in compose-generator.ts:
* - buildLocal guard: throws when containers/ directory is missing (lines 30-32)
* - api-proxy port publishing + awf-ext network attachment for microVM mode (lines 144-158)
@lpcox

lpcox commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

- Remove duplicate topology tests (already in container-start.test.ts:390-461)
- Fix retry path: retry rejects, diagnostics return false, exercising line 175
- Add logger.error spy assertion to runAgentCommand test
- Delete compose-generator-gaps.test.ts (duplicates existing test files)

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed all four review threads in commit b2b5d7c:

  1. Topology block removed — the startContainers – onNetworkReady topology path describe block is gone; container-start.test.ts:390-461 already provides stronger coverage.

  2. Retry path fixed — the test now rejects the retry compose-up and sets all handleRetryStartupFailure diagnostics to return false, so handleHealthcheckError (mocked to resolve) is called and execution reaches the return at line 175.

  3. Logger spy addedjest.spyOn(logger, 'error') is now set up before the docker wait throws, and the test asserts expect(errorSpy).toHaveBeenCalledWith('Failed to run agent command:', fatalError).

  4. compose-generator-gaps.test.ts deleted — coverage already exists in compose-generator-buildlocal.test.ts and compose-generator.test.ts.

Copilot finished work on behalf of lpcox July 17, 2026 14:42
Copilot AI requested a review from lpcox July 17, 2026 14:42
@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Copilot review passed with no inline comments.

@github-actions[bot] Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

lpcox and others added 2 commits July 17, 2026 08:21
The doc-maintainer workflow was changed to weekly schedule with 30
max-turns in #6316 on main. Update the test assertions to match.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 99.01% 99.06% 📈 +0.05%
Statements 98.95% 99.00% 📈 +0.05%
Functions 99.35% 99.35% ➡️ +0.00%
Branches 95.15% 95.15% ➡️ +0.00%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/container-lifecycle.ts 99.1% → 100.0% (+0.91%) 99.1% → 100.0% (+0.87%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)

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

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed...

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

📰 VERDICT: Smoke Docker Sbx has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

Copy link
Copy Markdown
Contributor Author

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Contribution Check completed successfully!

PR #6322 follows the applicable CONTRIBUTING.md guidelines: it includes tests for the covered behavior, uses the expected test file locations, and provides a clear description. No documentation update is needed for test-only changes, and no related issue is identified to reference.

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed...

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: Claude Engine Validation

Check Result
API Status ✅ PASS
GH Check ✅ PASS
File Status ✅ PASS

Overall Result: PASS

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Smoke Claude for #6322 · 55.5 AIC · ⊞ 3.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test Results

Test Result
GitHub MCP Connectivity
GitHub.com HTTP ✅ 200
File Write/Read ⚠️ template vars unresolved

Overall: PASS (core connectivity verified)

Author: @lpcox

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: PAT Auth Validation

Test Result
GitHub MCP connectivity
GitHub.com HTTP ✅ 200
File write/read ⚠️ template vars unsubstituted

Overall: PASS (core connectivity OK; pre-step template substitution issue)

Author: @lpcox | Auth mode: PAT (COPILOT_GITHUB_TOKEN)

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🔑 PAT report filed by Smoke Copilot PAT
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: Copilot BYOK (Direct) Mode

Test Result
GitHub MCP connectivity
GitHub.com HTTP check ⚠️ template vars not expanded
File write/read ⚠️ template vars not expanded
BYOK inference (api-proxy → api.githubcopilot.com)

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) via api-proxy → api.githubcopilot.com.
PR author: @lpcox

Overall: PASS (BYOK inference confirmed ✅)

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test Results

Overall Status: FAIL

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
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: Services Connectivity

  • Redis PING: ❌ (host.docker.internal DNS resolution failed)
  • PostgreSQL pg_isready: ❌ (no response)
  • PostgreSQL SELECT 1: ❌ (DNS resolution failed)

Overall: FAILhost.docker.internal is not resolvable from this runner environment. Service containers appear unreachable.

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.18.0 v22.23.1
Go go1.22.12 go1.22.12

Go versions match, but Python and Node.js differ between host and chroot environment.

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

🔬 Smoke Test: Docker Sbx — Results

Test Status
GitHub MCP connectivity ✅ Connected (response received)
GitHub.com HTTP ⚠️ Pre-step data unavailable (template vars unresolved)
File write/read ⚠️ Pre-step data unavailable (template vars unresolved)

Overall: PARTIAL — MCP ✅, but pre-step outputs were not passed to the agent (unresolved ${{ }} variables).

cc @lpcox

📰 BREAKING: Report filed by Smoke Docker Sbx
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke test results:\n- chore: upgrade gh-aw extension to latest pre-release ✅\n- doc-maintainer: increase max-turns to 30, switch to weekly schedule ✅\n- GitHub title check ❌\n- file write/read ✅\n- discussion comment ✅\n- npm ci && npm run build ❌\nOverall status: FAIL

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • awmgmcpg
  • registry.npmjs.org

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

network:
  allowed:
    - defaults
    - "awmgmcpg"
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

🏗️ 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

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Build Test Suite for #6322 · 43.2 AIC · ⊞ 6.9K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Notes
1. Module Loading ✅ Pass otel.js loaded; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled + internal helpers
2. Test Suite ✅ Pass 59 tests passed, 0 failed across otel.test.js (47) and otel-fanout.test.js (12)
3. Env Var Forwarding ⚠️ Pending OTEL env vars not yet forwarded from api-proxy-service.ts — expected during development
4. Token Tracker Integration ✅ Pass onUsage callback present in token-tracker-http.js
5. OTEL Diagnostics ⏳ Pending Post-agent step; no spans exported yet (api-proxy OTEL not active in this run)

Overall: ✅ All completed validations pass. Pending items are expected during development.

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@lpcox
lpcox merged commit e764c1d into main Jul 17, 2026
134 of 137 checks passed
@lpcox
lpcox deleted the test-coverage-lifecycle-compose-gaps-e20079d4b0c84bf8 branch July 17, 2026 16:53
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.

3 participants