refactor(engine): bundle apply_plan args into ApplyContext struct#54
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ApplyContext<'a>struct inpearlite-engine::applybundling the 5 trait-object adapters + snapper config name + state path + failures dir into a single borrow.Engine::apply_plan(&self, plan, &ApplyContext)drops from 9 args to 3;record_apply_failuredrops from 9 to 6. Bothclippy::too_many_argumentsallows removed.dispatch.rsconstructs the context from its existing values (zero behaviour change).make_ctxhelper for the standard mock set; three injected-failure tests (FailingHm,FailingSnapper,FailingRestart) useApplyContextstruct literals.Resolves M3 retrospective Actions-for-M4 item 2 (
docs/retrospectives/M3.md§"Actions for M4"). Sets up the next chunks (ADR-0012 nix bootstrap preflight wiring) to extend the context rather than the call surface.Test plan
cargo build --workspace --all-features— cleancargo test --workspace --all-features— 303 passing (no regression)cargo clippy --workspace --all-targets --all-features -- -D warnings— cleancargo fmt --all -- --check— cleanscripts/ci/check-spdx.sh— cleanpearlite-audit check .— 1 check, 0 violations🤖 Generated with Claude Code