Skip to content

[Feature]: Remove export from 19 internal implementation details #373

@sjnims

Description

@sjnims

Feature Type

Pipeline architecture

Problem or Need

19 functions across the pipeline are exported solely so unit tests can import them directly. These are internal implementation details — not called from any other production module — and their export keyword falsely signals they're part of the module's public contract. This couples tests to implementation details, making refactors harder.

Proposed Solution

Remove the export keyword from 19 functions and refactor their tests to either:

  • (a) Test through the parent module's public function (preferred for tightly-coupled helpers), or
  • (b) Continue importing from the module file directly (TypeScript allows importing non-exported members for tests via path imports in some setups, or keep the export but gate behind @internal)

If (a) isn't practical for a given function, fall back to adding @internal instead of removing export.

Stage 1 — Analysis (2 exports):

Export File Line
analyzeHooks src/stages/1-analysis/hook-analyzer.ts 287
readRawManifest src/stages/1-analysis/plugin-parser.ts 89

Stage 2 — Generation (4 exports):

Export File Line
createBaseScenario src/stages/2-generation/diversity-manager.ts 83
baseToTestScenario src/stages/2-generation/diversity-manager.ts 106
createBatchConfig src/stages/2-generation/batch-calculator.ts 128
wouldExceedTokenLimit src/stages/2-generation/batch-calculator.ts 187

Stage 3 — Execution (9 exports):

Export File Line
filterTriggerCaptures src/stages/3-execution/hook-capture.ts 164
analyzeHookResponses src/stages/3-execution/hook-capture.ts 438
isFilesPersistedEvent src/stages/3-execution/sdk-client.ts 342
isTaskNotificationMessage src/stages/3-execution/sdk-client.ts 355
isAuthStatusMessage src/stages/3-execution/sdk-client.ts 368
extractSessionId src/stages/3-execution/transcript-builder.ts 255
countAssistantTurns src/stages/3-execution/transcript-builder.ts 292
isSuccessfulExecution src/stages/3-execution/transcript-builder.ts 271
parseCustomId src/stages/4-evaluation/batch-evaluator.ts 163

Stage 4 — Evaluation (1 export):

Export File Line
isLowVariance src/stages/4-evaluation/multi-sampler.ts 293

State (3 exports):

Export File Line
updateStateWithPartialExecutions src/state/updates.ts 146
updateStateWithError src/state/updates.ts 166
getIncompleteScenarios src/state/queries.ts 117

Steps:

  1. For each export, determine if the test can be refactored to test through the parent module's public interface
  2. If yes: remove export, refactor tests
  3. If no: add @internal JSDoc tag instead (knip already excludes @internal)
  4. Update barrel re-exports as needed
  5. Verify: npm run build && npm run typecheck && npm test && npm run knip

Pipeline Stage Affected

General / Multiple stages

Component Type (if applicable)

Not component-specific

Alternatives Considered

  • Keeping all exports as-is with documentation — rejected because it misleads about API surface
  • Moving functions to test utility files — rejected because they're genuinely called internally by production code; duplicating logic would be worse

How important is this feature to you?

Medium - Would be nice to have

Additional Context

Identified during comprehensive dead code analysis (2026-01-31). Related: #371 (dead types), #372 (stdlib wrappers). The 3 state exports (updateStateWithPartialExecutions, updateStateWithError, getIncompleteScenarios) are scaffolding for an unimplemented checkpointing/resume feature — consider whether to keep or delete entirely.


🤖 Created with Claude Code

Metadata

Metadata

Assignees

Labels

component:stateResume and checkpoint management (src/state/)effort:large> 4 hourspriority:mediumShould be addressedrefactorCode restructuring without behavior changestage:analysisStage 1: Plugin parsing and trigger extractionstage:evaluationStage 4: Programmatic detection and LLM judgestage:executionStage 3: Agent SDK execution with tool capturestage:generationStage 2: Test scenario generation (LLM + deterministic)status:analyzedIssue has been analyzed by Claudetest:unitUnit test changes (tests/unit/)

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions