Skip to content

Remove test-only container lifecycle helper from production API surface#4050

Merged
lpcox merged 3 commits into
mainfrom
copilot/remove-test-helper-export
May 30, 2026
Merged

Remove test-only container lifecycle helper from production API surface#4050
lpcox merged 3 commits into
mainfrom
copilot/remove-test-helper-export

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

src/container-lifecycle.ts was exporting containerLifecycleTestHelpers, a test-only state mutator bundle, from a security-critical production module. This change removes that dead/public export while preserving existing test access patterns.

  • API surface cleanup

    • Removed containerLifecycleTestHelpers export from src/container-lifecycle.ts.
    • Removed test-only helper functions from the production module.
  • Internal state extraction

    • Added src/container-lifecycle-state.ts to own the externally-killed lifecycle flag and related functions:
      • markAgentExternallyKilled
      • isAgentExternallyKilled
      • resetAgentExternallyKilled
    • Updated container-lifecycle.ts to consume this internal state module.
  • Test-only access path retained

    • Updated src/container-lifecycle.test-utils.ts to construct/export containerLifecycleTestHelpers from container-lifecycle-state.ts, so tests keep the same call shape without relying on production exports.
// src/container-lifecycle.test-utils.ts
import { isAgentExternallyKilled, resetAgentExternallyKilled } from './container-lifecycle-state';

export const containerLifecycleTestHelpers = {
  isAgentExternallyKilled,
  resetAgentExternallyKilled,
};

Copilot AI changed the title [WIP] Remove test helper from production module container-lifecycle.ts Remove test-only container lifecycle helper from production API surface May 30, 2026
Copilot finished work on behalf of lpcox May 30, 2026 13:34
Copilot AI requested a review from lpcox May 30, 2026 13:34
@lpcox lpcox marked this pull request as ready for review May 30, 2026 13:36
Copilot AI review requested due to automatic review settings May 30, 2026 13:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 30, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 96.46% 96.51% 📈 +0.05%
Statements 96.32% 96.37% 📈 +0.05%
Functions 98.26% 98.26% ➡️ +0.00%
Branches 90.61% 90.65% 📈 +0.04%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/container-lifecycle.ts 94.0% → 93.9% (-0.11%) 94.3% → 94.2% (-0.10%)
src/config-writer.ts 89.3% → 90.9% (+1.65%) 89.3% → 90.9% (+1.65%)
✨ New Files (1 files)
  • src/container-lifecycle-state.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.

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

This PR removes a test-only lifecycle state mutator bundle (containerLifecycleTestHelpers) from the production src/container-lifecycle.ts module by extracting the externally-killed flag into a dedicated internal state module, while preserving the existing test helper access pattern via src/container-lifecycle.test-utils.ts.

Changes:

  • Removed containerLifecycleTestHelpers (and its underlying test-only functions) from src/container-lifecycle.ts.
  • Added src/container-lifecycle-state.ts to own the externally-killed lifecycle flag and its accessors/mutators.
  • Updated src/container-lifecycle.test-utils.ts to build containerLifecycleTestHelpers from the new state module instead of re-exporting from production code.
Show a summary per file
File Description
src/container-lifecycle.ts Removes test-only export and switches externally-killed checks/updates to the new state module.
src/container-lifecycle.test-utils.ts Keeps tests’ helper import shape by constructing containerLifecycleTestHelpers from the extracted state module.
src/container-lifecycle-state.ts Introduces the extracted module-scoped externally-killed flag and helper functions used by runtime + tests.

Copilot's findings

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment on lines +10 to +13

export function resetAgentExternallyKilled(): void {
agentExternallyKilled = false;
}
@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.

@github-actions

This comment has been minimized.

@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented May 30, 2026

@copilot address review feedback

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 30, 2026

@copilot address review feedback

Addressed in 802c1d3 by adding an explicit internal/test-only note on resetAgentExternallyKilled() in src/container-lifecycle-state.ts to discourage production use.

Copilot finished work on behalf of lpcox May 30, 2026 14:04
@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine

Result: PASS

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

🔥 Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP (list merged PRs) ✅ PR #4051 "Remove copilotApiResolverTestHelpers..."
GitHub.com connectivity ⚠️ Pre-step data not expanded
File write/read ⚠️ Pre-step data not expanded
BYOK inference (agent → api-proxy → api.githubcopilot.com) ✅ Responding in BYOK offline mode

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

Author: @Copilot | Assignees: @lpcox, @Copilot

Overall: PARTIAL — BYOK inference and MCP confirmed ✅; pre-step outputs not injected (template vars unexpanded).

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smoke Test Results

Test Result
GitHub MCP connectivity ✅ PASS
GitHub.com HTTP connectivity ⚠️ N/A (template vars not expanded)
File write/read ⚠️ N/A (template vars not expanded)

Overall: PARTIAL — MCP connectivity confirmed; pre-step outputs were not injected into the workflow template.

PR: "Remove test-only container lifecycle helper from production API surface" — author @Copilot, assignees @lpcox @Copilot.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

🧪 Chroot Version Comparison Results

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

Result: ❌ Not all versions match — Python and Node.js differ between host and chroot environments.

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 passed ✅ PASS
Go env passed ✅ PASS
Go uuid passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx passed ✅ PASS
Node.js execa passed ✅ PASS
Node.js p-limit 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 #4050 · sonnet46 1.1M ·

@github-actions
Copy link
Copy Markdown
Contributor

Remove copilotApiResolverTestHelpers from the production API surface
Deduplicate server test HTTPS_PROXY/module-reset bootstrap across split api-proxy tests
GitHub MCP review: ✅
SafeInputs GH CLI: ❌
Playwright: ✅
File write: ✅
Bash readback: ✅
Discussion comment: ✅
Build: ❌
Overall: 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 Results

Check Result
Redis PING ❌ No response (timeout)
PostgreSQL pg_isready no response
PostgreSQL SELECT 1 ❌ Timeout

Overall: FAILhost.docker.internal is not reachable from this runner environment. Service containers may not be configured or running.

🔌 Service connectivity validated by Smoke Services

@github-actions
Copy link
Copy Markdown
Contributor

Smoke test complete.

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

@lpcox lpcox merged commit b1a31c5 into main May 30, 2026
62 of 64 checks passed
@lpcox lpcox deleted the copilot/remove-test-helper-export branch May 30, 2026 14:45
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.

[Export Audit] Test helper containerLifecycleTestHelpers exported from production module container-lifecycle.ts

3 participants