Repository navigation
feat(vm): read the disk layout from the distro definition - #7
Conversation
plugin-vm#6 gave EmitDiskBuildScript the ability to build a btrfs subvolume layout and to put the ESP somewhere other than /boot/efi, but nothing could ask for it: buildBootstrapDisk hardcoded the layout. spec#72 added #Distro.disk_layout, so the shape can now be declared where it belongs — on the distro, because it IS the distro's identity. An ISO-installed Omarchy guest always has @/@home/@log/@pkg and always has its ESP at /boot. Repin spec to v0.2026242.753 and map distro.disk_layout onto DiskLayout. A distro that declares no disk_layout is untouched: EspMountPoint stays "" (defaulting to /boot/efi) and Subvolumes stays nil (a bare filesystem), which the byte-parity test already pins. Asserted directly here too, for both a nil distro and one with an empty block. Claude-Session: https://claude.ai/code/session_01YKF2VLqeHHbrBDz8XftaD3
Review — BLOCKHead SHA: Change class: Go code change + dependency repin ( Security screen: PASS — no scope mismatch, no secrets/exfiltration, no guardrail weakening, repin is to a known opencharly module. Blocks
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
Review of the first revision found two real defects, both fixed here. R3: the mapping lived inline in buildBootstrapDisk AND was copy-pasted into a test helper that admitted it "mirrors the mapping". The test could therefore pass while production diverged, so it was not coverage of the production path at all. Extract DiskLayoutFromDistro as a named pure function next to the emitter. buildBootstrapDisk calls it; the tests call the same function. The mirror is deleted. A3/R10: the tier claimed "fully tested and validated" while the changed branch had never executed. Add a live test that runs the PRODUCTION mapping and the script it emits against a real partitioned disk: /mnt subvolid=256,subvol=/@ /mnt/home subvolid=257,subvol=/@home /mnt/var/log subvol=/@log /mnt/var/cache/pacman/pkg subvol=/@pkg /mnt/boot vfat (and /mnt/boot/efi absent) It parses the disk_layout exactly as authored in charly/charly.yml through spec.DiskLayout, so a schema rename breaks it. Guarded by CHARLY_LIVE_DISK=1: it needs a privileged container and loop devices. A container has no udev, so loop partition nodes never appear; the harness shims partprobe to create them with kpartx and symlink them to the names the script uses. The script under test is NOT rewritten -- it runs byte-for-byte as emitted, including the real parted partitioning that the earlier two-loop-device workaround could not cover. Claude-Session: https://claude.ai/code/session_01YKF2VLqeHHbrBDz8XftaD3
Review — PASSHead SHA: Change class: Go code change + dependency repin ( Security screen: PASS — no scope mismatch (every diff file accounted for in the body table), no secrets/exfiltration, no guardrail weakening, repin is a same-module bump to a known opencharly module carrying Checklist: All applicable rules PASS or NA. Prior
Independent verification: unit-test output matches the three test names in the diff; full Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
Summary
plugin-vm#6gaveEmitDiskBuildScriptthe ability to build a btrfs subvolume layout andto put the ESP somewhere other than
/boot/efi— but nothing could ask for it.buildBootstrapDiskhardcoded the layout, so the capability was unreachable.spec#72added#Distro.disk_layout, so the shape can now be declared where it belongs:on the distro, because it is the distro's identity. An ISO-installed Omarchy guest
always has
@/@home/@log/@pkg, and always has its ESP at/boot.Every file in the diff
candy/plugin-vm/go.mod/go.sumspecrepinnedv0.2026240.2028→v0.2026242.753, the tag carrying#DiskLayoutcandy/plugin-vm/vm_disk_layout.goDiskLayoutFromDistro— the mapping, as one shared pure functioncandy/plugin-vm/vm_bootstrap_engine.gobuildBootstrapDiskcalls it instead of hardcoding the layoutcandy/plugin-vm/vm_bootstrap_disk_layout_test.gocandy/plugin-vm/vm_disk_live_test.goNothing changes for any existing distro
A distro that declares no
disk_layoutleavesEspMountPointempty (the emitter defaultsit to
/boot/efi) andSubvolumesnil (a bare filesystem). That is the same guaranteeTestEmitDiskBuildScript_NilSubvolumesIsByteIdenticalalready pins at the emitter, andTestBootstrapDiskLayout_NoDistroBlockIsUnchangednow pins it at the mapping too, forboth a nil
*DistroDefand one carrying an empty struct — the two shapes a distro withoutthe block can actually take.
How tested
The production mapping, executed live
An earlier revision of this PR was correctly blocked twice: the mapping was copy-pasted
into a test helper (so the tests would still have passed if production diverged), and the
tier claimed
fully tested and validatedwhile the changed branch had never run. Both arefixed rather than argued down.
DiskLayoutFromDistrois now a named pure function thatbuildBootstrapDiskand thetests both call — the mirror is deleted — and the live test runs that function plus the
script it emits against a real partitioned disk:
The test parses the
disk_layoutexactly as authored incharly/charly.ymlthroughspec.DiskLayout, so a field renamed in the schema breaks it.It is guarded by
CHARLY_LIVE_DISK=1because it needs a privileged container and loopdevices; CI has no business allocating those, and a test that silently no-ops would be
worse than one that says why it skipped.
What the harness adapts, and what it does not. A container runs no udev, so loop
partition nodes never appear and
mkfs.fat "${LOOP}p1"fails withNo such file or directory. The preamble shimspartprobeto create them withkpartxand symlink them tothe names the script uses. The script under test is not rewritten — it runs byte-for-byte
as emitted, including the real
partedpartitioning that plugin-vm#6's two-loop-deviceproof could not cover.
Rulebook compliance
/charly-internals:git-workflow.github.com/opencharly/spec/spec— the package lives one level down, asvm_move_aliases.goalready showed. (b)#Subvolumegenerates as[]spec.Subvolume,not
[]*spec.Subvolume: CUE's@go(...,optional=nillable)applies to the optionalfield, not to list elements. (c) The live test produced empty output and failed in
1.1s —
podman runneeds-ito attach stdin, which it did not have. (d) With stdinfixed it failed on
mkfs.fat: unable to open /dev/loop3p1: the first shim hookedlosetup, which runs BEFOREpartedcreates the table, sokpartxfound nopartitions. Hooking
partprobe— the point where the table exists but has not beenused — is the fix.
the capability is reachable end to end as of this commit.
DiskLayoutFromDistro, called byboth production and tests. The first revision inlined it in
buildBootstrapDiskandmirrored it in a test helper — review caught that, and the mirror is deleted.
distro omitting the block and a distro that does not exist take the identical path.
DiskLayout{…}literal is gone — itis replaced, not supplemented; there is no remaining path that ignores the distro.
main, PR-only,no force-push, no direct push to
main, no hook bypass.inspect real script text; the live test executes that script against a real disk and
reads back
findmntandbtrfs subvolume list.go.sumis the toolchain's output, committed asproduced by
go get.-count=1from this worktree.--rmprivileged container on every run and tears it down; the host's loop devices are left
clean, which the teardown output shows. That is the disposable proof available to a
plugin repo with no bed of its own. The consuming bed (
check-omarchy-vmindistro-omarchy) exercises the full VM once the distro entity this unblocks lands, andis named rather than used as a reason to defer.
and "a distro without the block is unchanged" — are each asserted.
real block devices before this mapping was written.
generated type rather than hand-rolling a parallel one.
N/A — no roster.Change classification
go test -count=1 ./..., theCHARLY_LIVE_DISK=1live run,golangci-lint run(0 issues),gofmt -l(clean).live, on a real partitioned disk, with the output retained above.
Assisted-by: Claude Code claude-opus-5[1m] (fully tested and validated)