Skip to content

refactor(engine): bundle apply_plan args into ApplyContext struct#54

Merged
UnbreakableMJ merged 1 commit into
mainfrom
refactor/apply-context-struct
Apr 28, 2026
Merged

refactor(engine): bundle apply_plan args into ApplyContext struct#54
UnbreakableMJ merged 1 commit into
mainfrom
refactor/apply-context-struct

Conversation

@UnbreakableMJ

Copy link
Copy Markdown
Contributor

Summary

  • New ApplyContext<'a> struct in pearlite-engine::apply bundling 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_failure drops from 9 to 6. Both clippy::too_many_arguments allows removed.
  • CLI dispatch.rs constructs the context from its existing values (zero behaviour change).
  • Test sites use a make_ctx helper for the standard mock set; three injected-failure tests (FailingHm, FailingSnapper, FailingRestart) use ApplyContext struct 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 — clean
  • cargo test --workspace --all-features — 303 passing (no regression)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • scripts/ci/check-spdx.sh — clean
  • pearlite-audit check . — 1 check, 0 violations
  • CI green on T1 / T2 / T3

🤖 Generated with Claude Code

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>
@UnbreakableMJ
UnbreakableMJ merged commit bcc8b64 into main Apr 28, 2026
3 checks passed
@UnbreakableMJ
UnbreakableMJ deleted the refactor/apply-context-struct branch April 28, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant