test(vm): vm-07 user-env apply + vm-08 user-env drift#51
Merged
Conversation
Plan §7.4 W2 — closes the M3 W2 VM-tier line items "vm-07 user-env apply, vm-08 user-env drift". vm-07 declares one HM-enabled user with an inline home.nix fixture, applies, and verifies: - apply exit 0, actions_executed >= 1 - state.toml grew a [[managed.user_env]] entry for $PEARLITE_VM_USER with a non-empty 64-hex config_hash vm-08 exercises the drift loop end-to-end: 1. Apply with home.nix v1 → state.toml records hash_v1. 2. Re-plan (no edits) → no user_env_switch action emitted (idempotency). 3. Mutate home.nix to v2 → re-plan emits a user_env_switch action. 4. Apply v2 → state.toml's config_hash flips to hash_v2 AND managed.user_env still contains exactly one row for the user (upsert per PR #50, not append). Both scripts: - POSIX sh; shellcheck-clean. - Mutating, gated behind PEARLITE_VM_TEST=1 (the runner enforces). - Honour $PEARLITE_VM_USER (default `pearlite-vm`) for the test account; fail fast with a clear error if that user doesn't exist rather than calling useradd from inside the script (cleaner: the VM image owns user provisioning). - Use grep over the toml/json output rather than jaq so they run on minimal CachyOS images, matching the convention from vm-02..06. vm-09 (Nix bootstrap via DeterminateNixInstaller) defers — the LiveNixInstaller adapter exists but no caller wires it yet; the bootstrap-via-curl-pipe behaviour belongs in M3 follow-up. README updated with the new rows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
UnbreakableMJ
added a commit
that referenced
this pull request
Apr 28, 2026
Closes M3 — User Environment (Plan §7.4). 8 PRs since m2-exit (#44 – #51), 303 workspace tests passing (up from M2's 267). Phase 7 is wired end-to-end: pearlite-userenv adapter (HM + Nix installer) → diff classifier emits UserEnvSwitch when HM-enabled users drift → engine dispatches the switch via HomeManagerBackend → state.toml's [[managed.user_env]] upserts the (user, generation, config_hash) triple. The next plan re-reads, sees no drift, emits no action — the loop closes. Three M3 carry-overs roll into M4: 1. Wire LiveNixInstaller as apply-time / bootstrap caller; ADR for where the installer script + SHA come from. 2. apply_plan ApplyOpts struct (9-arg signature past comfort). 3. Per-user nix.conf ADR. Other TODOs remain: forgotten_count field, envelope-shape freeze, fork-based fs crash tests, state.toml parse benchmark, KernelInfo population, ADR-001..007 backfill. 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
Plan §7.4 W2 — closes the M3 W2 VM-tier line items
vm-07 user-env applyandvm-08 user-env drift.vm-07
Declares one HM-enabled user with an inline
home.nixfixture, applies, and verifies:actions_executed >= 1state.tomlgrew a[[managed.user_env]]entry for$PEARLITE_VM_USERwith a non-empty 64-hexconfig_hashvm-08
Exercises the drift loop end-to-end:
home.nixv1 →state.tomlrecordshash_v1.user_env_switchaction emitted (idempotency).home.nixto v2 → re-plan emits auser_env_switchaction.state.toml'sconfig_hashflips tohash_v2andmanaged.user_envstill contains exactly one row for the user (upsert per PR feat(diff,engine): UserEnvSwitch.config_hash + state.toml [[managed.user_env]] #50, not append).Conventions
shellcheck-clean.PEARLITE_VM_TEST=1(the runner enforces this).$PEARLITE_VM_USER(defaultpearlite-vm) for the test account; fail fast with a clear error if that user doesn't exist rather than callinguseraddfrom inside the script (cleaner: the VM image owns user provisioning).grepover the toml/json rather thanjaq, matching vm-02..06.vm-09(Nix bootstrap viaDeterminateNixInstaller) defers — theLiveNixInstalleradapter exists but no caller wires it yet; the bootstrap-via-curl-pipe behaviour belongs in M3 follow-up.Test plan
shellcheckclean.PEARLITE_VM_TESTis unset.vm.yml) gating unchanged. End-to-end verification needs the self-hosted CachyOS runner online.🤖 Generated with Claude Code