Files
leleka/docs/architecture/size-split-deploy.md
T

6.1 KiB

Size split of leleka-deploy (STRA-338, batch deploy-1)

The owner order: no .rs file over 400 lines, no function over the limits of docs/architecture/limits-gate.md. This page records how the 15 oversize files of leleka-deploy (crates/deploy/) were split and how the test ids moved. Every module is named after what it holds, never _2/_3. The method is that of size-split-control-plane-desktop-core.md.

Test ids

A test id is <module path>::<test name>. A split changes the module path and nothing else:

  • 220 tests before and after (cargo test -p leleka-deploy --all-targets --features test-fakes, Linux): 0 missing, 0 new, 0 outcome changes; 122 ids differ only in the module path (the topic module is inserted).
  • Six tests fail on the Linux/WSL development host before and after, for host reasons: five in e2e (dry_run_* and reconfigure_flow::*, the preflight of the fake host is blocked) and recipe::the_pinned_archive_digest_of_the_stamps_is_the_one_the_engine_pins. Their outcome is part of the parity record; they were not touched.
  • tests/e2e.rs did not compile before the split (lifecycle matched KarSource without the None variant that the experimental GGUF-PLE profile added); the one-line fix is the first commit of the batch, so that the baseline exists.
  • Cargo test targets keep their names: tests/e2e.rs became tests/e2e/main.rs; the leleka-fake-runtime binary moved to src/bin/fake_runtime/main.rs (Cargo.toml names the path).
  • A shared module holds what several topics use: harness for the integration target, the parent tests.rs (fixtures and imports) for unit tests.

Unit tests (<module>/tests.rs or an inline mod tests becomes <module>/tests.rs + tests/)

Was Now (tests/ modules)
cli/tests.rs flags, reconfigure_args
expert_profile/tests.rs embedded_table, sources, report
preflight/tests.rs gpu_and_driver, host_resources, windows_host
reconfigure/tests.rs settings_ranges, planning, recording
plan.rs (inline) plan/tests.rs with install_steps, expert_profile_steps, mode_resolution
profile.rs (inline) profile/tests.rs with builtin_profiles, selection, budget_arguments, sparse_memfd
resources.rs (inline) resources/tests.rs with presets_and_workers, ram_fit, windows_presets
config.rs, supervisor.rs (inline) config/tests.rs, supervisor/tests.rs (unchanged ids)
app.rs (three inline modules) app/{version_tests,machine_tests,status_tests}.rs (unchanged ids)
sealed.rs linux module with its tests sealed/linux.rs, sealed/linux/tests.rs (unchanged ids)

Integration target

Target Modules next to main.rs
tests/e2e harness, supervisor_lifecycle, sealed_archive, engine_supervision, verify_commands, up_flow, expert_profile_install, dry_run_and_usage, reconfigure_flow (+ reconfigure_flow/service)

reconfigure_flow stays one module with its tests inside, so those ids are reconfigure_flow::<name> as before.

Sources

Was Now
supervisor.rs (1863 lines) supervisor/ logfile, cli_output, startup, signals, status, children, sparse, supervise, engine, api, live_reconfigure
app.rs (1490) app/ entry, preflight_report, install_flow, status_report, settings_change, verify_flow, stop_flow
plan.rs (1483) plan/ scope, gather_state, step_state, step_plan, host_steps, model_steps, service_steps, expert_table_step, render
profile.rs (1035) profile/ memory_budget, catalog, profile_limits
resources.rs (964) resources/sizing
config.rs (793) config/ engine_launch, service_documents
sealed.rs (592) sealed/ linux, unsupported_host, exec_arguments
facts.rs (430) facts/ linux, windows, parsers
preflight/evaluate_fn.rs (one 665-line function) preflight/ evaluation (the order of the checks) and one module per check family: platform, gpu, resource_preset, memory, kar_source, cuda_libraries, wsl_filesystem, disk, service_host, download_hints
bin/fake_runtime.rs (426) bin/fake_runtime/ main, engine_double, cli_double, gateway_double

plan_steps (369 lines) and evaluate (665 lines) were rewritten as one function per step or check; the texts, the order of the steps and checks and the commands they print are unchanged (the plan and preflight tests pin them).

Renamed mechanical modules

The earlier mechanical splits left names that said nothing (*_fn, impl_*). They are renamed after what they hold; the paths the parents re-export are unchanged: cli/{flag_parsing,dispatch,subcommands}, expert_profile/{provisioning,tier_report}, facts/parsers, logview/{collection,logs_command,report,entries}, reconfigure/{settings,plan_and_persist}, steps/{downloads,service_unit,model_assets,preparation,probes_and_tools,stamps_and_state}, winfront/{doctor_command,session,routing,commands}, wsl/{distros_and_paths,bridge}, preflight/report. The #[allow(unused_imports)] re-export lines of the parents became one use module::{names}; per module, and the lines nothing used were dropped.

Why the limits allowlist grew

The diff gate treats a function that moved to another file as added. The functions that moved verbatim and still miss a limit are in limits-allowlist.json (owner STRA-338, reason "moved verbatim"). Each entry can only fall; scripts/check-limits.py --update-baseline drops an entry when its function is brought within the limits.

Checks run

Compiled and checked on both targets, because winsys, winfront, winservice and facts::windows build only on Windows: cargo check -p leleka-deploy --all-targets --features test-fakes on Linux (WSL) and on the Windows host: no new warning (the one lab_holder_running dead-code warning of the Windows build exists before the batch). cargo clippy --no-deps -D warnings is clean on Linux; on Windows it reports the same three findings as before (lab_holder_running, layout.rs return, winsys.rs is_multiple_of).