Skip to content

feat(distro): #DiskLayout — per-distro ESP mount point and btrfs subvolumes - #72

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/distro-disk-layout
Aug 30, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/distro-disk-layout

Conversation

@atrawog

@atrawog atrawog commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

A distro whose on-disk shape is part of its identity had no way to say so. #Distro
could describe its bootloader, its bootstrap and its packages, but the disk a bootstrap VM
is built on was fixed: a bare root filesystem with the ESP at /boot/efi.

Omarchy needs both halves changed, and neither is cosmetic:

  • Its ESP mounts at /boot, not /boot/efi — that is what limine-entry-tool and
    ESP_PATH assume. A loader written to the other path leaves an unbootable disk while
    the build reports success
    .
  • Its root is a @/@home/@log/@pkg subvolume set on every install, and its
    fstab and limine cmdline reference subvol=@. A VM built on a bare btrfs filesystem
    can never be snapshotted, and is not the distro it claims to be.

Both were read off a real ISO-installed Omarchy 4.0.1 guest, not from documentation.

Every file in the diff

File What changed
schema/distro.cue #DiskLayout + #Subvolume defs; disk_layout? on both #Distro and #ResolvedDistro
spec/cue_types_gen.go regenerated by task cue:gen — never hand-edited
schema/distro_disk_layout_test.go new — 3 corpus cases, 6 teeth, plus reachability and required-field guards

Why no #SchemaVersion bump

Every bump recorded in version.cue is an authored wire-key change or removal that
needs a migration. This is a purely additive optional field: no existing manifest
changes shape, and there is nothing to migrate. The same reasoning applied to the iso
#VmSource arm added in #71, which also did not bump it.

What is deliberately NOT in CUE

The rule "exactly one subvolume mounts at /" is left to OpValidate. "Exactly one
element of this list has field X = Y" is not expressible in a closed struct, and pretending
otherwise with a matchN would disable closedness — which is what catches the typo case
below. It is already enforced in plugin-vm's EmitDiskBuildScript, which refuses a
layout with zero or two roots.

How tested

$ go test -count=1 -v -run 'TestDiskLayout|TestSubvolume|TestDistro_WithDiskLayout' ./schema/...
=== RUN   TestDiskLayout_OmarchyCorpus
--- PASS: TestDiskLayout_OmarchyCorpus (0.01s)
=== RUN   TestDiskLayout_EmptyIsValid
--- PASS: TestDiskLayout_EmptyIsValid (0.01s)
=== RUN   TestDiskLayout_EspOnly
--- PASS: TestDiskLayout_EspOnly (0.01s)
=== RUN   TestDiskLayout_Teeth
=== RUN   TestDiskLayout_Teeth/a_relative_esp_mount_point_would_resolve_against_the_builder's_cwd
=== RUN   TestDiskLayout_Teeth/an_empty_subvolume_name_cannot_be_created
=== RUN   TestDiskLayout_Teeth/a_relative_subvolume_mount_point_would_mount_outside_the_guest_tree
=== RUN   TestDiskLayout_Teeth/a_subvolume_without_a_mount_point_has_nowhere_to_go
=== RUN   TestDiskLayout_Teeth/a_subvolume_without_a_name_cannot_be_created
=== RUN   TestDiskLayout_Teeth/an_unknown_field_is_a_typo,_not_an_extension_point
--- PASS: TestDiskLayout_Teeth (0.06s)
=== RUN   TestDiskLayout_ReachableFromDistro
--- PASS: TestDiskLayout_ReachableFromDistro (0.01s)
=== RUN   TestDistro_WithDiskLayout
--- PASS: TestDistro_WithDiskLayout (0.01s)
=== RUN   TestSubvolume_RequiredFields
--- PASS: TestSubvolume_RequiredFields (0.03s)
PASS
ok  	github.com/opencharly/spec/schema	0.148s

The corpus case is the exact Omarchy layout this def exists to express. The teeth
are the six ways to declare a layout that would build a disk nobody can boot:

Rejected shape Why it must be rejected
esp_mount_point: "boot" relative — would resolve against the builder's cwd
subvolume: [{name: "", …}] an unnamed subvolume cannot be created
mount_point: "home" relative — would mount outside the guest tree
a subvolume with no mount_point nowhere to mount it
a subvolume with no name nothing to create
esp_path: "/boot" a typo, caught only because the struct is closed

TestDiskLayout_ReachableFromDistro asserts the field exists on both #Distro and
#ResolvedDistro — a def that validates beautifully but is unreachable from the type the
resolver actually returns would be useless, and the Fields(cue.Optional(true)) iterator
is used because LookupPath does not return optional fields (the first version of that
test failed for exactly that reason).

spec/cue_types_gen.go is the output of task cue:gen, run after the schema edit, not a
hand transcription.

Rulebook compliance

  • R0 — skills first. /charly-internals:git-workflow; the existing #Bootloader /
    #Pacstrap shapes were read before a sibling def was added.
  • R1 — RCA every anomaly. Two surfaced, both root-caused. (a)
    TestDiskLayout_ReachableFromDistro failed on first run — CUE's LookupPath does not
    return optional fields; fixed with the Fields(cue.Optional(true)) iterator rather
    than by making the field required. (b) spec/proc and spec/container failed in the
    first full run. Neither is caused by this change and neither is waved away: spec/proc's
    own message says the checkout was under /tmp, so "this checkout cannot host the
    premise of the $TMPDIR tests … they would pass without discriminating"
    — verified
    identical on a stashed clean tree, then re-run from a checkout outside /tmp.
  • R2 — finish the whole cutover. Schema, both reachability points, generated Go and
    tests land together.
  • R3 — no duplication. One def, referenced from both distro shapes; no second
    description of a disk layout anywhere.
  • R4 — no workarounds. No defaults are encoded twice: the fields are optional and the
    consumer supplies the historical defaults, so the schema states shape and the emitter
    states behaviour.
  • R5 — delete legacy completely. N/A — purely additive; no field, key or code path is removed or replaced.
  • R6 — preserve user work and Git safety. Feature branch off current main, PR-only,
    no force-push, no direct push to main, no hook bypass.
  • R7 — prove behavior, not compilation. The tests unify against the shipped
    schema via schemaconcat.ConcatSchema(schema.FS, …) — the same bytes charly loads — and
    assert both acceptance and rejection. The behaviour this schema enables is proven end to
    end in opencharly/plugin-vm#6, where the emitted script was executed against real loop
    devices.
  • R8 — preserve emitted artifacts. The generated Go is committed as generated.
  • R9 — binary equals source. task cue:gen from this worktree; tests -count=1.
  • R10 — fresh disposable proof. N/A — a schema repo has no bed. Its gate is the corpus-and-teeth suite, run on the final tree.
  • ADE — spec-is-the-test. Every claim in the def's doc comments is asserted: the
    defaults, the reachability, the closedness, and each rejection.
  • RDD — prove high-risk assumptions before editing. The layout encoded here was
    measured on a real Omarchy guest, and the emitter that consumes it was proven live before
    this schema was written.
  • SDD — schema-driven design. This PR is the schema step: CUE first, task cue:gen
    second, no hand-written wire type.
  • Concurrency mandate. N/A — no roster.

Change classification

  • Change class: additive CUE schema + regenerated Go types. No behaviour change on its
    own.
  • Verification gate: go test -count=1 ./schema/... (corpus + teeth, all pass) and the
    full spec suite from a checkout outside /tmp.
  • Attribution tier: fully tested and validated — the new def is exercised against the
    shipped schema in both directions, and its consumer was proven live in plugin-vm#6.

Assisted-by: Claude Code claude-opus-5[1m] (fully tested and validated)

…olumes

A distro whose on-disk shape is part of its identity had no way to say so.
#Distro could describe its bootloader, its bootstrap and its packages, but
the disk a bootstrap VM is built on was fixed: a bare root filesystem with
the ESP at /boot/efi.

Omarchy needs both halves changed, and neither is cosmetic:

  - Its ESP mounts at /boot, not /boot/efi. That is what limine-entry-tool
    and ESP_PATH assume, and a loader written to the other path leaves an
    unbootable disk while the build reports success.

  - Its root is a @/@home/@log/@pkg subvolume set on every install, and its
    fstab and limine cmdline reference subvol=@. A VM built on a bare btrfs
    filesystem can never be snapshotted and is not the distro it claims.

Add #DiskLayout{esp_mount_point?, subvolume?} and #Subvolume{name,
mount_point, mount_options?}, reachable as disk_layout? on both #Distro and
#ResolvedDistro, and regenerate the Go types.

Both fields are optional and both default to charly's previous behaviour,
so every distro that omits the block builds exactly the disk it built
before. No #SchemaVersion bump: this is a purely additive optional field
with nothing to migrate, the same shape as the recent `iso` VmSource arm.

The "exactly one subvolume mounts at /" rule is left to OpValidate rather
than CUE -- "exactly one element of this list has field X = Y" is not
expressible in a closed struct -- and is already enforced by
EmitDiskBuildScript in plugin-vm.

Claude-Session: https://claude.ai/code/session_01YKF2VLqeHHbrBDz8XftaD3
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: bac5fe45daec (branch: feat/distro-disk-layout)

Security screen: PASS — no scope mismatch (diff matches description exactly: schema defs, regenerated Go, tests), no secrets/network/egress, no weakened guardrails, no new deps, no self-modifying security content.

Checklist: All applicable rules PASS or NA.

  • A1/A2/A3: Body accounts for every file; How-tested pastes real go test -count=1 output for the change's gate; rulebook section answers every rule; footer ends with the *Assisted-by:* line. Change class (additive CUE schema + regenerated Go) matches the evidence; "fully tested and validated" is justified — the new defs execute against the shipped schema in both acceptance and rejection directions, and the consumer was proven live in plugin-vm#6.
  • R1: Both surfaced anomalies have concrete RCA (CUE LookupPath omits optional fields → fixed with Fields(cue.Optional(true)); spec/proc+container failures root-caused to checkout-under-/tmp and re-run from outside /tmp) — not a flake/transient dismissal.
  • R2/R3/R4/R5: No parked issues; one def referenced from both distro shapes (no duplication); no ad-hoc workarounds; purely additive so R5 is N/A.
  • R6/R8/R9: Generated Go committed as generated; task cue:gen from worktree; tests -count=1.
  • R10: N/A — schema repo has no bed; its gate is the corpus-and-teeth suite, run on the final tree and pasted.
  • SDD: schema/distro.cue and spec/cue_types_gen.go change in the same commit; generated Go matches the CUE source (field names, optionality, @go tags — no banned @go(-)); no hand-written wire type.
  • Architecture gate: placement CORRECT — this is a wire SHAPE added CUE-first to spec, the right layer. No alias files, no new core imports of sdk kits.
  • B14/B15/B17: No roster (concurrency N/A); one atomic commit; no autonomous destroy/rebuild.

Verdict: PASS


ollama/deepseek-v4-flash — pi-review-action.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) August 30, 2026 07:53
@github-actions
github-actions Bot merged commit dadc1e8 into main Aug 30, 2026
1 check passed
charly-auto-merge Bot added a commit that referenced this pull request Aug 30, 2026
github-actions Bot pushed a commit that referenced this pull request Aug 30, 2026
…tro (#79)

ResolveInherits is a hand-written struct literal — twice, once per
branch — and it forgot DiskLayout, Installer, InheritPackages and Raw.
Any distro declaring `inherits:` arrived at its consumer with all four
nil, and the consumer took its default path. No error, anywhere.

What that broke, all of it already merged and green:

  - the BTRFS SUBVOLUME FEATURE did nothing for any distro with a
    parent — which is every derivative, the case it was built for.
    #DiskLayout/#Subvolume (#72), plugin-vm's EmitDiskBuildScript arm
    (#6, #7) and charly's omarchy layout (#476) are all inert without
    this.
  - source.kind: iso could not resolve an installer for a derived
    distro. `charly vm build` reports "declares no installer" against a
    distro that plainly declares one — how this was found.
  - inherit_packages, the switch the whole distro TAG CHAIN rests on,
    was dropped from the resolved value, so a consumer reading it after
    resolution saw false.
  - Raw, the authored body consumers fall back to for anything this
    projection does not model, became empty for any distro with a
    parent — turning "not modelled" into "not present".

DiskLayout and Installer INHERIT, like every other optional sub-block:
a derivative adding only an installer (an Arch spin reusing archinstall)
must not have to restate its parent's whole boot chain. A child's own
value still wins.

InheritPackages and Raw are taken from the CHILD, never the parent:
inherit_packages says "expand MY tag chain through my parent", which is
a statement about this node, and Raw is this node's authored body.

Four tests. The parity pair walks every exported field of
ResolvedDistro and fails on any that arrives zero, so a future spec
addition cannot be forgotten here silently. There is one per BRANCH
deliberately: ResolveInherits has two merged literals, selected by
whether the child declares its own bootstrap, and a fix applied to only
one of them passes the other test while breaking every child that omits
bootstrap. A negative control confirms exactly that.

Negative controls, both run:

  restore the drop in both literals:
    ResolveInherits dropped 4 field(s) the child declared:
    [DiskLayout InheritPackages Installer Raw]   (both branches)

  fix only the first literal:
    Note this is the SECOND merged literal — a fix applied only to the
    first one passes the other parity test and still breaks every child
    that omits bootstrap.

Claude-Session: https://claude.ai/code/session_01YKF2VLqeHHbrBDz8XftaD3

Co-authored-by: atrawog <[email protected]>
@aitrawog
aitrawog deleted the feat/distro-disk-layout branch September 25, 2026 19:09
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