Skip to content

[Export Audit] Test-only export resetAgentExternallyKilled in container-lifecycle-state.ts #4183

@github-actions

Description

@github-actions

API Surface Issue

Category

Unused export (production-side dead code)

Summary

  • File: src/container-lifecycle-state.ts
  • Symbol: resetAgentExternallyKilled (line 15)
  • Issue: resetAgentExternallyKilled is exported but never imported by any production module. The only external consumer is src/container-lifecycle.test-utils.ts, which re-exports it for use in lifecycle test suites. The sibling state-mutation functions (markAgentExternallyKilled, isAgentExternallyKilled) are consumed by production code (src/container-cleanup.ts, etc.); resetAgentExternallyKilled is the odd one out — its sole purpose is to reset module-level state between Jest test cases.

Evidence

$ grep -rw "resetAgentExternallyKilled" src/ --include="*.ts"
src/container-lifecycle-state.ts:15:  export function resetAgentExternallyKilled(): void {
src/container-lifecycle.test-utils.ts:5:  import { isAgentExternallyKilled, resetAgentExternallyKilled } from './container-lifecycle-state';
src/container-lifecycle.test-utils.ts:9:    resetAgentExternallyKilled,

The .test-utils.ts suffix on the only consumer is the project's convention for test scaffolding (parallel to copilot-api-resolver.test-utils.ts, host-env.test-utils.ts, etc.), confirming the symbol exists solely to support test isolation.

This matches the pattern of #3828, #4173, #4174 — module-private helpers exported solely so the test layer can drive them.

Recommended Fix

This case is borderline. Unlike parseResolvConf or validateApiTargetInAllowedDomains, there is no "public entrypoint" the test could call instead: resetting module-level state between tests legitimately requires a reset function, and the alternatives (e.g., jest.resetModules() + dynamic re-import) are clunkier than a one-line helper.

Options:

  1. Keep the export, document it. Add a // test-only JSDoc tag and accept the slightly wider surface in exchange for clean test isolation.
  2. Move the state into a small object/class so each test can instantiate a fresh state holder rather than reset a module-level flag — eliminating the need for the reset function entirely.

The maintainer should pick based on how much refactor budget exists for the lifecycle-state module.

Impact

  • Dead code risk: Low (sole consumer is the test scaffolding)
  • Maintenance burden: Low (single one-line function on a small file, unlikely to drift)

Detected by Export Audit workflow. Triggered by push to main on 2026-06-02

Generated by API Surface & Export Audit · opus47 5.5M ·

  • expires on Jul 2, 2026, 12:58 AM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions