Skip to content

Split executor.rs god module (1,918 lines, 5+ responsibilities) #25

@codesoda

Description

@codesoda

Summary

executor.rs is 1,918 lines with at least 5 distinct responsibilities: step execution loop, RESULT-marker protocol parsing, bootstrap message construction, terminal UI output, and 1,060 lines of tests. It is the highest-coupling module in the codebase.

Severity: S2 (Medium) | Confidence: 0.95 | Blast radius: Low (structural, no runtime risk)

Technical Details

Responsibilities currently mixed in executor.rs:

Responsibility Lines Why it should be separate
Step execution loop execute_steps() ~200 lines Core orchestration — the only thing that should stay
Protocol parsing parse_result_marker() line 183, parse_log_events() Stateless, highly unit-testable
Bootstrap message construction build_bootstrap_content() lines 250-319 Prompt assembly — belongs in provider layer
Terminal UI output print_step_result() line 733, print_run_summary() line 758, 25+ println! calls Couples I/O to execution engine
Tests Lines 858-1918 (1,060 lines, 32 tests) Duplicated setup boilerplate inflates file

Key problem: The UI functions and inline println! calls mean the execution engine cannot be used without side-effecting stdout. This prevents:

  • Using the executor in a library context
  • Testing execution logic without stdout capture
  • Replacing the UI (e.g., for a TUI or JSON progress mode)

Proposed Fix

Split into a module directory:

src/executor/
  mod.rs          — public API, execute_steps() orchestration
  markers.rs      — parse_result_marker(), parse_log_events()
  bootstrap.rs    — build_bootstrap_content()
  display.rs      — ProgressReporter trait + default terminal impl

Steps:

  1. Extract parse_result_marker + parse_log_events into executor/markers.rs
  2. Define a ProgressReporter trait in executor/display.rs with methods like step_started(), step_completed(), run_summary()
  3. Replace all println! calls in the execution loop with reporter.method(...) calls
  4. Move build_bootstrap_content into executor/bootstrap.rs or provider.rs
  5. Apply the same ProgressReporter pattern to the 14 println! calls in command.rs (see F6)

Estimated effort: 1-2 days

Related

  • Related to F6: UI logic in command.rs (same ProgressReporter pattern)
  • Related to F9: test duplication concentrated here
  • Part of refactor Bundle 6: Split executor.rs

🔍 Found by vibe-code-audit — automated codebase audit skill for Claude Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditFound via automated code auditrefactorCode structure and architecture improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions