Skip to content

Code review fixes: encryption/merge correctness, install-stage safety, runner cleanup - #10

Merged
AdamJHall merged 9 commits into
mainfrom
integration/review-fixes
Jun 22, 2026
Merged

Code review fixes: encryption/merge correctness, install-stage safety, runner cleanup#10
AdamJHall merged 9 commits into
mainfrom
integration/review-fixes

Conversation

@AdamJHall

Copy link
Copy Markdown
Owner

Addresses eight findings from a full-codebase review (correctness, maintainability, code smells). Built across four parallel worktree agents, then integrated centrally (zero merge conflicts). gofmt clean; go build/vet/test ./... all pass; archinstall golden renders are byte-identical (no -update).

Fixes

# Fix
1 luks_on_lvm was silently rendered as lvm_on_luks (opposite topology, untested). Removed from the validator enum + both buildEncryption/encryptionErrors switches → now rejected with a clear must be one of: luks lvm_on_luks.
2 rootDevice returned the pre-LUKS plaintext device, so postInstall mounted the still-encrypted partition behind silent Try mounts. Encrypted installs now short-circuit with explicit warnings (LUKS remount is unimplemented / VM-validation-pending); the unencrypted path uses checked mounts so a failure aborts instead of chrooting into nothing.
3 kernel.default pointing at a base kernel (with empty packages) was silently ignored. Gate widened to len(Packages) > 0 || Default != "", with an empty-pacman guard.
4 Layered-config list merge silently flipped from merge-by-name to wholesale-replace when any element lacked a name. Hook.Name is now required; the sharp edge is documented in merge.go.
6 Two privilege mechanisms coexisted (inline sudo in shell strings vs the Runner.Root/Sudo abstraction). Added Runner.RootShell/TryRoot; converted snapper/grubtheme/helpers; updated affected plan-assertion tests.
8 Removed dead code from the reverted TUI (Capture, Out, outWriter). Added internal/run/run_test.go (package previously had no tests).
9 Deduped the ~90%-identical plainBuilder/btrfsBuilder (new singleDiskRoot + rootSpec) and the duplicated partDev (now exported once as archinstall.PartDev).
11 probeGeometry silently faked geometry for absent devices under dry-run; now warns, naming the device.

Notes

New tests: encryption_luksonlvm_test.go, hook_name_required_test.go, postinstall_gating_test.go, run_test.go.

🤖 Generated with Claude Code

AdamJHall and others added 9 commits June 22, 2026 19:36
…uilders

plainBuilder.build and btrfsBuilder.build were ~90% duplicated: probe
disk1 geometry, build the ESP partition, optionally append a linux-swap
partition, compute the remaining root bytes, and append the root
partition. Only the root partition's fs_type, mount options and btrfs
subvolume list differed.

Extract singleDiskRoot(esp, swap, espBytes, geom, rootSpec) which builds
the ESP + optional swap prefix and the root partition, taking the three
varying fields via a small rootSpec struct. The newObjID() call order
(ESP, swap, root) is preserved, so golden renders stay byte-identical
and the archinstall golden tests pass without -update.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…RootShell/TryRoot

Issue #8: delete Capture (zero callers), the Out field + outWriter helper
(fed only the reverted TUI viewport), wiring Cmd/Shell straight to
os.Stdout/os.Stderr. Drop now-unused bytes/io imports. Add run_test.go
covering the dry-run recording seam for Cmd/Shell/Root(Sudo on+off)/Try.

Issue #6: add Runner.RootShell (run a shell pipeline as root: sudo bash -c
in Phase B, bash -c in Phase A) and Runner.TryRoot (best-effort Root). Convert
the snapper, grub-theme, and kernel-cmdline shell snippets that hardcoded inner
sudo to RootShell with the inner sudo removed, and snapper set-config to TryRoot.
The vinceliuice install.sh keeps inner sudo (cloneBuild runs as the user).
Equivalent root behaviour in Phase B; updated the affected plan assertions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Issue #1: luks_on_lvm was silently rendered as lvm_on_luks (encrypting the
PVs, the wrong topology) because buildEncryption collapsed both into one
branch. The luks-on-lvm topology is unimplemented, so remove it from the
encryption oneof set and its renderer branch — Validate() now surfaces a
clear "must be one of" error instead of doing the wrong thing silently.

Issue #4: configsrc merge-by-name downgrades to wholesale-replace when any
slice element lacks a name, so a single nameless hook in an overriding layer
silently dropped the base layer's hooks. Make Hook.Name required so a
nameless hook fails validation, and document the sharp edge in merge.go.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… dry-run geometry warning

Phase-A postInstall fixes:

- Issue #2: encrypted layouts no longer remount the still-encrypted
  plaintext device (rootDevice returns the pre-LUKS path). Until the LUKS
  remount is implemented + VM-validated, encrypted installs skip the
  remount, all chroot post-install steps, and Phase B staging, emitting
  loud warnings (incl. that staging must be done manually). Unencrypted
  post-install remounts are now CHECKED (Root, aborts on failure) instead
  of best-effort Try; umounts stay best-effort.

- Issue #3: installKernels now runs when kernel.default is set even with
  no extra packages, so a default pointing at a base kernel is actually
  pinned in the bootloader. installKernels skips the empty pacman -S.

- Issue #11: probeGeometry warns when it falls back to the 512 GiB
  placeholder for an absent device under dry-run, instead of silently
  masking a typo'd device path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The identical partDev was defined in both internal/archinstall and
internal/stages. Export it once from archinstall (stages already imports
that package) and drop the stages copy.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@AdamJHall
AdamJHall merged commit c8d06ab into main Jun 22, 2026
7 checks passed
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