Skip to content

test(vm): vm-07 user-env apply + vm-08 user-env drift#51

Merged
UnbreakableMJ merged 1 commit into
mainfrom
feat/vm-user-env-scenarios
Apr 28, 2026
Merged

test(vm): vm-07 user-env apply + vm-08 user-env drift#51
UnbreakableMJ merged 1 commit into
mainfrom
feat/vm-user-env-scenarios

Conversation

@UnbreakableMJ

Copy link
Copy Markdown
Contributor

Summary

Plan §7.4 W2 — closes the M3 W2 VM-tier line items vm-07 user-env apply and 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 feat(diff,engine): UserEnvSwitch.config_hash + state.toml [[managed.user_env]] #50, not append).

Conventions

  • POSIX sh; shellcheck-clean.
  • Mutating; gated behind PEARLITE_VM_TEST=1 (the runner enforces this).
  • 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).
  • grep over the toml/json rather than jaq, matching 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.

Test plan

  • shellcheck clean.
  • Runner correctly skips both scripts when PEARLITE_VM_TEST is unset.
  • SPDX + audit clean.
  • T1/T2/T3 CI tiers green (no Rust changes).
  • T4 (vm.yml) gating unchanged. End-to-end verification needs the self-hosted CachyOS runner online.

🤖 Generated with Claude Code

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>
@UnbreakableMJ
UnbreakableMJ merged commit 2efaad3 into main Apr 28, 2026
3 checks passed
@UnbreakableMJ
UnbreakableMJ deleted the feat/vm-user-env-scenarios branch April 28, 2026 21:05
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>
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