Split app/mod.rs
Status: Open — Phase 2, confirmation needed
Problem
Section titled “Problem”src/app/mod.rs is now 2767L total — more than double the 1243L at the original analysis (+123% growth). It is the second-largest file in the codebase after runtime/launch.rs. Nearly all production code is the run() dispatch function with a giant match on CLI commands, but the file has accumulated substantial new command handling, error recovery, and test coverage.
src/app/context.rs (1466L) has also grown and now contains significant instance management, workspace resolution, and Docker interaction logic.
Proposed split
Section titled “Proposed split”src/app/ mod.rs ← re-exports, pub fn run() dispatcher (~80L) dispatch.rs ← the giant match on cli::Command (~700L) workspace_cmd.rs ← workspace subcommand handlers (~150L) config_cmd.rs ← config subcommand handlers (~100L) load_cmd.rs ← load/hardline/eject command handlers (new — extracted from dispatch) instance_cmd.rs ← instance management commands (new — instance recovery/purge flows)Note: src/app/context.rs already implements the impl-extension pattern and stays as-is, though it may need its own split analysis if it continues growing.
Duplication found
Section titled “Duplication found”app/mod.rscontains its ownFakeOpWriter(stripped version) that duplicates the fuller one insrc/workspace/token_setup.rs. Should use a shared test utility.- 4 inline
format!("{name}-dind")/format!("{name}-net")derivations that should use a shared naming helper. fake_runner_with_runninghelper is near-identical to one inconsole/manager/input/save.rsbut with a subtle trailing-newline difference — potential copy-paste bug.
What needs confirmation
Section titled “What needs confirmation”- Whether
run()stays inmod.rsor also moves todispatch.rs - The exact boundary between
dispatch.rsandworkspace_cmd.rs(some workspace handling is interleaved in the dispatch match) - Whether
load_cmd.rsandinstance_cmd.rsare worth separate files or should stay indispatch.rs - Whether
context.rs(1466L) also needs splitting or is manageable at its current size
Auditability gain
Section titled “Auditability gain”To audit “does jackin workspace create correctly validate the workdir?”, a reviewer reads workspace_cmd.rs instead of scanning ~2700L of mixed-command dispatch.
Recommended priority
Section titled “Recommended priority”Split first among Phase 2 targets — it has the highest growth rate (+123%), pure dispatch structure (lowest risk), and its split will establish patterns for the remaining file splits.
Related files
Section titled “Related files”src/app/mod.rs— target file (2767L)src/app/context.rs— impl-extension module (1466L)src/cli/dispatch.rs— CLI argument types consumed by the dispatch match