Commit 41b39a7
feat(engine,cli): apply preflight halts with NIX_NOT_INSTALLED when needed (#58)
Implements ADR-0012 decision 3: when a plan would dispatch a
UserEnvSwitch but `nix --version` fails, apply halts at preflight
(class 1, exit 2) before any snapshot or db sync. The CLI's hint is
the literal `pearlite bootstrap` invocation.
- pearlite-userenv::NixInstaller gains a `nix_installed()` probe
method. LiveNixInstaller hoists the previously-private
`nix_already_installed` body to satisfy it; `install_if_missing`
now calls the public method instead. MockNixInstaller returns its
`already` flag, so existing test fixtures are unchanged in
behavior.
- pearlite-engine::ApplyContext gains a `nix_installer` field. The
apply_plan body checks `needs_nix(plan)` (any UserEnvSwitch action)
and probes via the adapter before pre-snapshot. New
ApplyError::NixNotInstalled (preflight) and ApplyError::NixProbe
(#[from] InstallerError) variants surface the failure modes.
- CLI dispatch's apply_error_payload maps the two variants to typed
codes NIX_NOT_INSTALLED and APPLY_NIX_PROBE_FAILED with class
"preflight" / exit 2, overriding the recorded-failure-class
default since these errors halt before any FailureRef is written.
The hint for NIX_NOT_INSTALLED is `pearlite bootstrap
--installer-script <path>`.
- 20 engine test sites updated via make_ctx to thread the new field;
the 3 injected-failure tests update their ApplyContext literals.
- Two new engine tests cover the preflight branch (halts before
snapshot, no FailureRef) and the no-UserEnvSwitch path (nix probe
is skipped entirely).
Tests: 316 passing (+2). Clippy clean. fmt clean. audit clean.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2f83813 commit 41b39a7
5 files changed
Lines changed: 223 additions & 23 deletions
File tree
- crates
- pearlite-cli/src
- pearlite-engine/src
- pearlite-userenv/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| 282 | + | |
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
| |||
928 | 929 | | |
929 | 930 | | |
930 | 931 | | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
931 | 940 | | |
932 | 941 | | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
938 | 957 | | |
939 | 958 | | |
940 | 959 | | |
941 | 960 | | |
942 | 961 | | |
943 | | - | |
| 962 | + | |
944 | 963 | | |
945 | 964 | | |
946 | 965 | | |
947 | 966 | | |
948 | | - | |
| 967 | + | |
949 | 968 | | |
950 | 969 | | |
951 | 970 | | |
| |||
0 commit comments