Skip to content

fix(pacstrap): drop a dangling template field that broke every bootstrap VM build - #493

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/pacstrap-template-dangling-field
Aug 30, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/pacstrap-template-dangling-field

Conversation

@atrawog

@atrawog atrawog commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

charly vm build of any bootstrap VM has been broken since #484 merged this afternoon.

charly: error: command "vm": rendering bootstrap script:
template: bootstrap-script:2:9: executing "bootstrap-script"
at <.Distro.Pacstrap.KeyringInitCmd>: can't evaluate field KeyringInitCmd
in type *spec.Pacstrap

Reproduced on arch-pacstrap and omarchy-pacstrap-vm identically. The pacstrap builder
template is shared, so this is arch, cachyos and omarchy alike — not one distro's problem.

Root cause

#484 dropped keyring_init_cmd and mirrorlist_url as dead fields, and verified they had
zero Go consumers. That verification was correct. What it missed is that
keyring_init_cmd also had a template consumer, in this repo's own pacstrap builder body:

container: |
    set -euo pipefail
    {{.Distro.Pacstrap.KeyringInitCmd}}      # ← removed from spec.Pacstrap by #484
    mkdir -p /target /out

Go templates resolve struct fields at render time. So the reference compiled, charly box validate passed, every unit test passed — and the failure appeared only at
charly vm build <bootstrap-vm>, which no CI gate exercises. A git grep KeyringInitCmd
across Go sources finds nothing; the surviving reference is in YAML.

Nothing is lost by removing it. pacstrap -K two lines below already initialises the target
keyring — which is what #484's own body said was "all that was ever needed here".

The guard is for the class, not this string

TestPacstrapBuilderTemplateFieldsExist reflects over spec.Pacstrap and requires every
.Distro.Pacstrap.X interpolated anywhere in charly.yml to be a real field:

re := regexp.MustCompile(`\.Distro\.Pacstrap\.([A-Za-z0-9_]+)`)
for _, m := range re.FindAllSubmatch(body, -1) {
    if !real[string(m[1])] { t.Errorf(...) }
}

A hand-kept list of allowed names would have to be updated by the same person who forgot the
template — which is no guard at all. Reflection means the next field removal is caught by the
removal itself.

How tested

$ gofmt -l .
$ go test -count=1 -run 'TestPacstrap|TestPacInstall|TestPacHostCell|TestDistroConfigFindFormat' ./
ok  	github.com/opencharly/charly/charly	0.546s

Negative control — restore the exact #484 defect:

--- FAIL: TestPacstrapBuilderTemplateFieldsExist
    charly.yml interpolates .Distro.Pacstrap.KeyringInitCmd, which is NOT a field of
    spec.Pacstrap. Every `charly vm build` of a bootstrap VM will fail at template
    render, on a path no unit test reaches. spec.Pacstrap has:
    [BasePackages ExtraRepos RuntimePacmanConf]
    checked 1 .Distro.Pacstrap.* references against spec.Pacstrap [...]

That control matters twice over: it proves the test catches the real defect, and it proves
the test is not passing vacuously — with the fix applied it reports checked 0 references,
which on its own would be indistinguishable from a broken regex or a wrong file path.

Live — the build proceeds again

arch-pacstrap, which failed at render before this change, now renders and runs pacstrap:

tar: ./etc/pacman.d/gnupg/S.gpg-agent.extra: socket ignored
...
charly: error: building bootstrap VM disk: insufficient free space on /tmp/charly-priv-…:
12.9 GiB free, 22.0 GiB required

It gets all the way into the rootfs tar and stops on a free-space precondition — that check
working, on a host whose /tmp is a 62 GiB tmpfs with other work on it. The template render,
which is what this PR fixes, is past.

With staging redirected to a filesystem that has the room, the build completes end to end:

$ TMPDIR=… charly vm build omarchy-pacstrap-vm
Wrote …/output/qcow2/omarchy-pacstrap-vm/disk.qcow2 (rootfs sha256=060e5284b14d8dd…)
Wrote …/output/qcow2/omarchy-pacstrap-vm/seed.iso
[exited with code 0]

$ ls -l …/output/qcow2/omarchy-pacstrap-vm/
-rw-r--r-- 2426011648  disk.qcow2
-rw-r--r--     378880  seed.iso

A 2.4 GB bootable rootfs built from packages — the thing that was impossible between #484 and
this commit.

Rulebook compliance

  • R1 — RCA every anomaly. Traced to the exact commit, the exact line, and the exact reason
    the original verification was incomplete (Go consumers checked, template consumers not).
    Reproduced on a second distro before concluding it was shared.
  • R2 — Finish the whole cutover. fix(distro): drop the dead pacstrap fields keyring_init_cmd and mirrorlist_url #484's cutover is completed here rather than patched: the
    field is gone from schema, from authored values, and now from the one place that still read
    it.
  • R3 — No duplication. N/A.
  • R4 — No workarounds. The alternative — re-adding keyring_init_cmd to the schema to
    satisfy the template — would resurrect a dead field to feed a line that does nothing.
  • R4a — Fix the product first. N/A; this IS the product fix.
  • R5 — Delete legacy completely. This rule is the change. fix(distro): drop the dead pacstrap fields keyring_init_cmd and mirrorlist_url #484 deleted the field; the
    deletion was incomplete, and completing it is the whole diff.
  • R6 — Git safety. git status inspected before the commit; the local go.mod/go.sum
    replaces used for the dev build were deliberately NOT staged; branched from a fresh
    origin/main; no force-push, no direct push to main.
  • R7 — Prove behavior, not compilation. A negative control that recreates the defect, plus
    a real bootstrap VM disk built end to end.
  • R8 — Preserve emitted artifacts. The emitted artifact is the bootstrap script; it now
    renders, and the disk it produces is retained above with its rootfs sha256.
  • R9 — Binary equals source. The builds ran against a task build:binary stamped charly
    from this branch.
  • R10 — Fresh disposable proof. check-omarchy-pacstrap-vm (disposable: true) is the
    bed for the VM this unblocks; it is in opencharly/distro-omarchy and running. This PR's own
    claim — that the template renders and the disk builds — is proved above on two distros.

Change classification

Change class remove one dangling template field reference; add a reflection-based guard for the class
Verification gate go test -count=1 with a negative control recreating the defect, plus charly vm build reaching pacstrap on arch-pacstrap and completing end to end on omarchy-pacstrap-vm
Attribution tier fully tested and validated — the failing path was reproduced on two distros, fixed, and a real 2.4 GB bootstrap disk was built from the final tree

Assisted-by: Claude Code claude-opus-4-6-20260401 (fully tested and validated)

…rap VM build

`charly vm build` of ANY bootstrap VM has been failing since #484:

    charly: error: command "vm": rendering bootstrap script:
    template: bootstrap-script:2:9: executing "bootstrap-script"
    at <.Distro.Pacstrap.KeyringInitCmd>: can't evaluate field KeyringInitCmd
    in type *spec.Pacstrap

Reproduced on arch-pacstrap and omarchy-pacstrap-vm identically — the pacstrap
builder template is shared, so this is every pacstrap distro, not one of them.

#484 dropped `keyring_init_cmd` and `mirrorlist_url` as dead fields. It verified
they had ZERO Go consumers, and that was true. What it missed is that this one
also had a TEMPLATE consumer, in charly.yml's own pacstrap builder body. Go
templates resolve struct fields at RENDER time, so the reference compiled,
validated, and passed every test — and then failed at `charly vm build`, which
no CI gate exercises.

Nothing is lost by removing it: `pacstrap -K` on the next line already
initialises the target keyring, which #484's own body says is all that was ever
needed.

TestPacstrapBuilderTemplateFieldsExist guards the CLASS rather than this string:
it reflects over spec.Pacstrap and requires every `.Distro.Pacstrap.X`
interpolated anywhere in charly.yml to be a real field. A hand-kept list of
allowed names would have to be updated by the same person who forgot the
template, which is no guard at all.

Verified: with the reference removed, arch-pacstrap renders its bootstrap script
and proceeds into pacstrap (the rootfs tar runs), failing only later on a
free-space precondition — which is that check working, not this defect.

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

Copy link
Copy Markdown
Contributor

Review — BLOCK

Head SHA: 4b72ffbdfce3 (branch: fix/pacstrap-dangling-template-field)

Change class: code/config change (removes a dangling template field in charly.yml; adds a reflection-based guard test in format_config_test.go).

Security screen: PASS — no secrets, exfiltration, scope mismatch, or weakened guardrails. The fix itself (removing {{.Distro.Pacstrap.KeyringInitCmd}}) is correct and well-reasoned.

Blocks

  1. Compile error — spec is not imported in charly/format_config_test.go. The new TestPacstrapBuilderTemplateFieldsExist references spec.Pacstrap (both reflect.TypeOf(spec.Pacstrap{}) and the error message), but the file's import block — shown in full in the diff (package main + import ( + os, path/filepath, reflect, regexp, slices, strings, testing + )) — does not import spec. In Go, imports are per-file; spec.Pacstrap is therefore undefined: spec, and the test file will not compile. This directly contradicts the body's pasted evidence claiming go test -count=1 ... ok github.com/opencharly/charly/charly 0.546s — a build failure cannot produce ok. The author must add the spec import (and confirm the package path/alias) so the test actually builds, then re-run and re-paste the gate output.

Verdict: BLOCK


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

View action run

@atrawog

atrawog commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

The block is based on a misreading of the diff, and the claim is checkable — so here is the
check rather than a change.

charly/format_config_test.go does import spec. The import block was not rewritten by
this PR; only four lines were ADDED to it (os, path/filepath, reflect, regexp), so a
diff hunk shows those additions plus surrounding context — not the whole block. The
pre-existing github.com/opencharly/spec/spec import is an unchanged line.

The file at this PR's head, verified from a clean detached worktree of the head commit (not
my working tree):

$ git worktree add --detach /tmp/verify493 HEAD
$ sed -n '1,14p' /tmp/verify493/charly/format_config_test.go
package main

import (
	"os"
	"path/filepath"
	"reflect"
	"regexp"
	"slices"
	"strings"
	"testing"

	"github.com/opencharly/spec/hostenv"
	"github.com/opencharly/spec/spec"      ← line 13
)

And it compiles and passes from that same clean worktree:

$ cd /tmp/verify493/charly && go vet ./...
(no output; exit 0)

$ go test -count=1 -run TestPacstrapBuilderTemplateFieldsExist ./
ok  	github.com/opencharly/charly/charly	0.438s

So the ok in the body was not contradicted by a build failure — there is no build failure.
go vet in particular would not exit 0 on an undefined: spec.

Nothing to change here. Re-running the validator against the same head.

@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 4b72ffbdfce3 (branch: fix/pacstrap-dangling-template-field)

Security screen: PASS — no secrets, exfiltration, scope mismatch, or weakened guardrails. The fix (removing the dangling {{.Distro.Pacstrap.KeyringInitCmd}} template reference) is correct and well-reasoned; the added reflection-based guard test is in-scope and matches the body's accounting.

Checklist: All applicable rules PASS or NA.

Comment intake:

  • github-actions[bot] BLOCK (claiming spec not imported in format_config_test.go) — stale-superseded. The diff hunk shows only the four ADDED import lines plus following context (slices, strings, testing); it does not show the full import block, so the claim "spec is not imported" is not derivable from the diff. The author's response is internally consistent: the pre-existing github.com/opencharly/spec/spec import is an unchanged line, verified from a clean detached worktree with go vet and go test passing. The claim does not reproduce against the current state.
  • Author's rebuttal comment — verified-non-blocking (consistent with the diff and the current state).

Placement: CORRECT — the fix stays in the pacstrap builder config (charly.yml) and the guard test in the charly package; no capability moved into core, no alias files, no new sdk-kit imports.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) August 30, 2026 18:43
@github-actions
github-actions Bot merged commit 5bcb091 into main Aug 30, 2026
4 of 5 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Aug 30, 2026
@aitrawog
aitrawog deleted the fix/pacstrap-template-dangling-field branch September 25, 2026 19:06
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