Codebase healthPhase 2 — File splits

Split runtime/launch.rs

Status: Partially implemented — the old monolithic runtime/launch.rs was split into a root module and child launch modules, but three large launch orchestration functions still carry the remaining reviewability risk. The next work is internal phase extraction inside those functions, not another top-level file move.

Current Shape

The launch area now uses Rust 2024 self-named module layout:

The split moved dedicated concerns such as DinD setup, slot claim, restore resolution, auth-error rendering, progress helpers, trust helpers, and launch-core execution out of the former root file. The remaining issue is that the largest orchestration functions still combine several behavioral phases behind broad context structs.

Remaining Split

Three production functions still need internal splitting:

Keep the current module layout. Do not split tests simply to reduce line counts; a growing tests.rs remains a signal that the production module may still own too much behavior, not an independent target.

Candidate Boundaries

launch_role_runtime:

  • launch-profile and cgroup/AppArmor validation;
  • sibling-auth prewarm;
  • Docker run-argument construction;
  • socket-directory preparation;
  • hardline handoff and session-finalization reporting.

load_role_with:

  • launch-input preparation;
  • workspace and role materialization;
  • trust and role-source checks;
  • image materialization and diagnostics;
  • environment/auth resolution;
  • run_launch_core invocation;
  • post-launch cleanup.

run_launch_core:

  • preflight state assembly;
  • Docker run execution;
  • wait-for-state handling;
  • teardown and error tagging.

Remaining Work

  1. Extract one cohesive phase at a time and keep existing launch behavior covered by the runtime launch tests.
  2. Avoid circular dependencies around trust confirmation and launch diagnostics.
  3. Move repeated Docker naming and launch-plan helpers behind shared runtime helpers only where duplication remains after phase extraction.
  4. Add or update links to Behavioral spec for runtime launch after each extracted phase has stable invariants.

On this page