Skip to content

[Refactor]: Convert 5-6 parameter functions to use options objects #307

@sjnims

Description

@sjnims

Feature Type

Pipeline architecture

Problem or Need

19 functions across Stages 2, 3, and 4 have 5-6 parameters, which exceeds the recommended threshold of 4. While less critical than the 8-parameter functions tracked in #306, these would benefit from the same options object pattern for consistency and maintainability.

Stage 2 - Generation (4 functions):

File Function Params Line
src/stages/2-generation/cost-estimator.ts estimateGenerationCost 6 113
src/stages/2-generation/cost-estimator.ts countPromptTokens 5 76
src/stages/2-generation/diversity-manager.ts createBaseScenario 5 71
src/stages/2-generation/agent-scenario-generator.ts generateAllAgentScenarios 5 321
src/stages/2-generation/skill-scenario-generator.ts generateAllSkillScenarios 5 207

Stage 3 - Execution (3 functions):

File Function Params Line
src/stages/3-execution/index.ts runExecution 5 101
src/stages/3-execution/plugin-loader.ts buildPluginQueryInput 5 98

Stage 4 - Evaluation (12 functions):

File Function Params Line
src/stages/4-evaluation/multi-sampler.ts evaluateWithMultiSampling 6 173
src/stages/4-evaluation/aggregation/scenario-results.ts buildEvaluationResult 6 31
src/stages/4-evaluation/detection/capture-detection.ts createDetection 5 28
src/stages/4-evaluation/detection/orchestrator.ts detectAllComponentsWithHooks 5 110
src/stages/4-evaluation/index.ts runSynchronousEvaluation 5 258
src/stages/4-evaluation/index.ts calculateAndSaveMetrics 5 350
src/stages/4-evaluation/index.ts runEvaluation 5 408
src/stages/4-evaluation/llm-judge.ts evaluateWithLLMJudge 5 270
src/stages/4-evaluation/llm-judge.ts evaluateWithFallback 5 338
src/stages/4-evaluation/llm-judge.ts evaluateWithJsonFallback 5 397
src/stages/4-evaluation/multi-sampler.ts evaluateSingleSample 5 304
src/stages/4-evaluation/multi-sampler.ts runJudgment 5 340

Proposed Solution

Apply the same options object pattern as #306:

// Example for createDetection
interface CreateDetectionOptions {
  componentType: ComponentType;
  componentName: string;
  triggered: boolean;
  confidence: DetectionConfidence;
  reason: string;
}

function createDetection(options: CreateDetectionOptions): Detection

Recommended approach:

  1. Address Stage 4 functions first (most functions, highest impact)
  2. Then Stage 3 functions
  3. Finally Stage 2 functions

Pipeline Stage Affected

General / Multiple stages

Component Type (if applicable)

Not component-specific

Alternatives Considered

  • Higher threshold (6 params): Would only catch the worst offenders, but 5 params is already at the boundary of maintainability
  • Gradual adoption: Refactor as functions are modified for other reasons (lower priority approach)
  • Skip Stage 2: Generation functions are less frequently modified

How important is this feature to you?

Low - Just a suggestion

Additional Context

Acceptance Criteria:

  • All 19 functions converted to options object pattern
  • Interface types defined and exported as needed
  • All call sites updated
  • No functional changes (behavior must remain identical)
  • All tests pass

Depends on: #306 (address 8-parameter functions first for consistency)

Related: See anti-pattern-audit.md section 3.1.1 for full analysis


🤖 Created with Claude Code

Metadata

Metadata

Assignees

Labels

priority:lowNice to haverefactorCode restructuring without behavior changestage: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 Claude

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions