Skip to content

Commit bcc8b64

Browse files
refactor(engine): bundle apply_plan args into ApplyContext struct (#54)
apply_plan reached 9 positional parameters in M3 (5 adapters + plan + snapper config + 2 paths) and was carrying clippy::too_many_arguments allows on both itself and record_apply_failure. Per the M3 retrospective "Actions for M4" item 2, fold the system-side wiring into a borrow-only struct so future apply-time additions (e.g. ADR-0012 nix bootstrap preflight wiring) extend the struct rather than the call surface. - New `ApplyContext<'a>` struct in pearlite-engine::apply with eight borrowed fields (5 trait-object adapters, snapper_config, state_path, failures_dir). Re-exported from pearlite_engine. - `apply_plan(&self, plan, &ApplyContext)` — drops to 3 args. - `record_apply_failure` likewise takes the context, dropping from 9 to 6 args and removing its too_many_arguments allow. - CLI dispatch.rs constructs the context from its existing per-call values; no behavior change. - Test sites use a `make_ctx` helper for the standard mock set; the three injected-failure tests (FailingHm, FailingSnapper, FailingRestart) construct ApplyContext literals inline. Tests: 303 passing (no change). Clippy clean. fmt clean. audit clean. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8cd539c commit bcc8b64

3 files changed

Lines changed: 303 additions & 248 deletions

File tree

crates/pearlite-cli/src/dispatch.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,17 @@ fn dispatch_apply(
257257
),
258258
};
259259
}
260-
match ctx.engine.apply_plan(
261-
&plan,
262-
ctx.pacman.as_ref(),
263-
ctx.cargo.as_ref(),
264-
ctx.systemd.as_ref(),
265-
ctx.snapper.as_ref(),
266-
ctx.home_manager.as_ref(),
267-
opts.snapper_config,
268-
&ctx.state_path,
269-
&failures_dir,
270-
) {
260+
let apply_ctx = pearlite_engine::ApplyContext {
261+
pacman: ctx.pacman.as_ref(),
262+
cargo: ctx.cargo.as_ref(),
263+
systemd: ctx.systemd.as_ref(),
264+
snapper: ctx.snapper.as_ref(),
265+
home_manager: ctx.home_manager.as_ref(),
266+
snapper_config: opts.snapper_config,
267+
state_path: &ctx.state_path,
268+
failures_dir: &failures_dir,
269+
};
270+
match ctx.engine.apply_plan(&plan, &apply_ctx) {
271271
Ok(outcome) => Envelope::success(metadata_at(Some(host)), apply_outcome_view(&outcome)),
272272
Err(e) => Envelope::failure(
273273
metadata_at(Some(host)),

0 commit comments

Comments
 (0)