Repository navigation
fix(vm)!: make #ResolvedVm.backend and .autostart optional, unbreaking every vm create - #342
Conversation
…g every vm create
`charly vm create` fails for every VM in the org:
charly: error: command "vm": applying vm defaults for "<entity>":
applyCueDefaults vm: decode: autostart: cannot convert non-concrete value bool
MECHANISM, traced end to end rather than inferred. The SDK's kind table maps the vm
kind to THIS def (sdk/loaderkit/cue_schema.go: cueKindDefs["vm"] = "#ResolvedVm"), and
plugin-vm (candy/plugin-vm/vm_host_seams.go) routes every vm create through
loaderkit.ApplyCueDefaults("vm", vm), which:
1. marshals the RESOLVED struct - whose Backend is `string` and Autostart is `bool`,
both with `omitempty`, so an unset value is omitted from the marshaled YAML;
2. unifies that YAML with #ResolvedVm;
3. DECODES back, with no `.Default()` call anywhere.
With `autostart!: bool` / `backend!: string`, step 2 leaves those fields non-concrete
whenever the struct omitted their zero values, and step 3 fails on them. That is the
whole org-wide breakage: `false` is a zero value, so an entity that does NOT autostart
could never be encoded.
WHY NOT A DEFAULT - measured, and it corrects my own earlier report. The obvious fix,
`autostart!: *false | true`, does not work:
#ResolvedVm.autostart: cannot convert non-concrete value *false | true
Decode never resolves a default disjunction, so a required-with-default spelling fails
identically. I asserted the opposite on #341 and am correcting it there.
Optional (`?:`) is both the fix and the shape this envelope already documents - its own
comment says the resolved envelope carries "PLAIN post-default scalars", set by the
producer when they are set.
WHAT THIS DOES NOT CHANGE: an authored `backend:`/`autostart:` still validates against
the same closed vocabulary; the second test below pins that every provider word is still
accepted, so this trades no validation for the fix.
R7 - the new test fails on the pre-fix schema with the PRODUCTION error:
$ git stash push schema/vm.cue && go test ./schema/ -run TestResolvedVmBackendAndAutostart
vm_defaults_test.go:52: decode #ResolvedVm without backend/autostart:
#ResolvedVm.autostart: cannot convert non-concrete value bool
FAIL
and passes with it. Reproducibility, build and the whole suite are green:
$ charly task cue-gen #[pass] run -- generate ... / [pass] check -- reproducible
$ GOWORK=off go build ./... # ok
$ GOWORK=off go test ./... # ok github.com/opencharly/spec/{schema,spec,schemaconcat,...}
$ gofmt -l schema/ spec/ # empty
CONSUMER NOTE: this lands the CONTRACT fix. The runtime proof - a real `charly vm create`
succeeding - needs the spec tag, then the sdk/charly require bump, then a rebuilt binary;
it follows producer-first and is not claimed here.
Refs #341.
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: schema (CUE) change + regenerated Go + one new test — code/config, not docs-only. Blocks
Everything else — security screen (no secrets/egress/guardrail weakening/injection), SDD (CUE source and Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
`if out.Autostart != false` is S1002; it is `if out.Autostart`. Caught by review, since golangci-lint is not installed on this host - go vet and the test stay green. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS — schema/test change only; no secrets, egress, guardrail weakening, supply-chain edit, or injected directives. Comment disposition — 6929459267 (@github-actions[bot], head Non-blocking notes (do not affect verdict): Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…fields optional (#88) Mechanical pin bump, and the first link of a two-repo chain. spec v0.2026320.2116 carries opencharly/spec#342, which makes `#ResolvedVm.backend` and `#ResolvedVm.autostart` optional - the fix for the org-wide failure of `charly vm create`: applyCueDefaults vm: decode: autostart: cannot convert non-concrete value bool NO SOURCE CHANGE IS NEEDED HERE, and that is verified rather than assumed: with only the pin moved, `go build ./...`, `go vet ./...` and `go test ./...` all pass. This module's code already compiles against the new spec API; it was simply pinned behind it. WHY THIS REPO AND NOT `charly` DIRECTLY. Bumping `charly` to the new spec without re-releasing this repo fails at compile time: [email protected]/inspect_list.go:228:29: a.Name undefined This module pinned by `charly` was built against the OLD spec, so the chain is spec -> plugin-box -> charly. Measured: this is the ONLY plugin in charly's build graph that fails, so the wave is two PRs, not an org-wide sweep. R9: the binary under test was built from this worktree, not a shared install. R10: this change class is a dependency pin in a plugin repo whose gate is its own module suite; there is no `disposable: true` target in this repo, and the live proof (a real `charly vm create`) belongs to the consumer commit that follows. Refs opencharly/spec#341, opencharly/spec#342. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) Co-authored-by: aitrawog <[email protected]>
…ate org-wide (#1180) * chore(deps): bump spec/sdk/plugin-box to the releases that fix vm create org-wide Consumes opencharly/spec#342, which makes `#ResolvedVm.backend` and `.autostart` optional, and therefore fixes the failure that has blocked every `charly vm create`: charly: error: command "vm": applying vm defaults for "<entity>": applyCueDefaults vm: decode: autostart: cannot convert non-concrete value bool MEASURED AFTER THE BUMP, on this tree's own binary (`2026.320.0227`, built by scripts/bootstrap-charly.sh - R9): $ charly -C <distro-ubuntu> vm create ubuntu-debootstrap Generated SSH keypair in ~/.local/share/charly/vm/charly-ubuntu-debootstrap Created VM charly-ubuntu-debootstrap (libvirt session) The probe VM was destroyed afterwards and `vm list` verified empty. THE CHAIN, producer-first, with each link's evidence recorded on the way: spec v0.2026319.1619 -> v0.2026320.2116 (PR #342, merged + tagged) plugin-box v0.2026317.2259 -> v0.2026320.2124 (PR #88, merged + tagged) sdk v0.2026319.1356 -> v0.2026320.1345 plugin-box had to go between them rather than being skipped: bumping straight to the new spec failed to compile at the OLD plugin-box pin (`inspect_list.go:228: a.Name undefined`), and enumerating charly's build graph showed it was the ONLY module that needed the intermediate release - so this is a two-link chain, not an org-wide sweep. The four lockstep `tools/*` modules are bumped to the same pins (the canonical-go.mod gate asserts one shared pin) and each still builds. `charly/testdata/…/go.mod` is deliberately NOT touched: it is a fixture that pins its own older version on purpose. Gates on this tree: $ scripts/bootstrap-charly.sh # built ./bin/charly (2026.320.0227) $ cd charly && go build ./... # ok $ tools/{generate-packages,golden-cloudinit,golden-compile,gomod-canonical}: go build ./... # ok $ vm create ubuntu-debootstrap # Created VM charly-ubuntu-debootstrap (libvirt session) THE VM BED, run against this binary (distro-ubuntu's check-ubuntu-debootstrap-vm, run 2026.320.2130) - it now gets through the VM lifecycle the decoder used to block: [vm-build] PASS [vm-create] PASS (1.9s) [wait-ready] PASS [deploy-add] PASS (2m12) [bring-up-members] PASS [check-live] FAIL [cleanup] PASS [cleanup-members] PASS The single FAILURE is not this bump's: `tailscale-repo-suite-ubuntu-resolute` greps the guest's /etc/apt/sources.list.d/tailscale.list for the `resolute` SUITE, and this binary still embeds the `noble` vocabulary because the vocabulary change is #1177, not this commit. That is the producer-first order made visible by the artifact: the sweep asserts the new suite, the vocabulary that writes it has not landed, so the assertion fails while `tailscale-package-installed` PASSES (the package came from the old suite). So the ordering this commit enables is exactly: this bump -> #1177 rebases onto it and its bed passes -> distro-ubuntu#65's bed passes I am not claiming a green VM bed here: I am claiming the decoder is fixed, which the first five steps show by getting through `vm-create` at all. Refs opencharly/spec#341 (closed by #342). Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) * test(spec): decode the RawBody view sub-shapes the spec's authored-def extraction left opaque The pin bump alone does not compile the test suite, and the reviewer's CI found it before I did: candy_test_helpers_test.go:147: have Alias() []spec.CandyAlias want Alias() []spec.ResolvedCandyAlias MEASURED, and the mechanism is a deliberate upstream design rather than a rename: - spec v0.2026320.2116 moved the AUTHORED candy sub-shapes (#CandyAlias, #CandyVolume, ...) out of spec and into the plugin that owns the candy body, keeping only the WIRE (resolved) twins. The spec's own candy_reader.go states the split: "A reader decodes a body that has already been validated, so the resolved form is what it needs - the same split the vm unit landed (VmSpec = ResolvedVm)". - so `CandyView`/`CandyModel`'s sub-shape fields are now `spec.RawBody` (= json.RawMessage), and a reader must DECODE them into the resolved types it returns. Only the TEST helper implements spec.CandyReader in this repo (production builds untouched - `go build ./...` passed before this commit), so the adaptation is confined to candy_test_helpers_test.go: two small generic helpers plus the accessors the compiler names. This is exactly the sibling of the defect this PR's pin fixes: the vm unit made the same authored/resolved split, and that split is what opencharly/spec#341 was about. Gates on this tree: $ go vet ./... # clean $ go test ./... # rc=0, zero failures (the CI failure was here) A first attempt at this used a regex over the accessors and touched fields that were never RawBody (Plan/PlanSteps among them) - reverted in full and redone one accessor per compiler error, which is why the diff is now only the six the type-checker named. Refs opencharly/spec#341, #1177. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) * fix(test): count DECODED elements in the Has* predicates, not raw-JSON bytes The RawBody migration left four predicates measuring byte length instead of element count, so a body encoding an EMPTY list (the two-byte empty JSON array) reported as present: HasExtract() { return len(a.m.Extract) > 0 } // a.m.Extract is now spec.RawBody HasData() { return len(a.m.Data) > 0 } HasAliases() { return len(a.v.Aliases) > 0 } HasVolumes() { return len(a.v.Volumes) > 0 } Measured from the spec's own structs, which are the authority on which fields moved: CandyModel's RawBody fields are Service, Extract, Data, Volumes, Aliases, Hook, Artifact, and CandyView's are Volumes and Aliases - so these four are exactly the predicates over a RawBody field. The other ten Has* predicates read typed slices and are unchanged. They now count the decoded slice: return len(decodeRawSlice[spec.CandyExtract](a.m.Extract)) > 0 This is a semantic bug, not a compile error: len(bytes) > 0 is true for the empty JSON array, so a fixture with no aliases would have reported HasAliases() true and silently widened what a downstream test believed. Caught by review, not by the compiler - the compiler cannot see it, which is exactly why the four predicates needed reading rather than patching. gates: go vet ./... clean; go test ./... rc=0, zero failures. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
Summary
Makes
#ResolvedVm.backendand#ResolvedVm.autostartoptional instead of!-required, whichunbreaks
charly vm createfor every VM in the org (#341).Head
6d0b176, 3 files, 122 insertions(+), 4 deletions(−).Mechanism — traced, not inferred
The SDK's kind table maps the vm kind to this def (
sdk/loaderkit/cue_schema.go:cueKindDefs["vm"] = "#ResolvedVm") andcandy/plugin-vm/vm_host_seams.goroutes every VMoperation through
loaderkit.ApplyCueDefaults("vm", vm), which:Backend stringandAutostart bool, both withomitempty, so anunset value is omitted from the marshaled YAML;
#ResolvedVm;.Default()call anywhere in the function.With
autostart!: bool/backend!: string, step 2 leaves those fields non-concrete whenever the structomitted their zero values, and step 3 fails.
falseis a zero value, so an entity that does notautostart could never be encoded at all.
Why not a default — measured, and it corrects my own earlier report
The obvious fix,
autostart!: *false | true, does not work:Decodenever resolves a default disjunction, so a required-with-default spelling fails identically.I asserted the opposite on #341 earlier in this campaign; this PR and a comment on that
issue correct it.
Optional is both the fix and the shape this envelope already documents for itself — its own comment
says the resolved envelope carries "PLAIN post-default scalars", set by the producer when they are set:
What this does not change: an authored
backend:/autostart:still validates against the same closedvocabulary, and the second test pins that every provider word is still accepted — no validation is traded
for the fix.
How tested
R7 — the new test fails on the pre-fix schema with the PRODUCTION error, and passes on the fixed one:
The fixture is
compileShipped, the package's existing helper whose comment states it is "the SAMEcontract the runtime's sharedCueSchema uses" — so the test exercises the shipped concatenation, not a
hand-built approximation of it. The entity is filled through the shipped value's own context, because
a
cue.Valueonly interoperates with values from the context that built it.The module's own gates, on this tree:
The generated diff is NOT comment-only, and my first revision of this body wrongly said it was. The
retag transform follows the constraint, so the JSON tags change too:
The Go types are unchanged (
string,bool), so nothing recompiles differently — but the JSON wireshape does: a consumer decoding JSON now sees the key ABSENT where it previously saw
""/false. Thatis the correct counterpart to the optionality (YAML already carried
omitempty) and it is called out inthe breaking-change answer below rather than left for a consumer to discover.
Coverage limit, stated rather than glossed: this lands the CONTRACT fix. The end-to-end proof — a real
charly vm createsucceeding — needs this tag, then thesdk/charlyrequire bump, then a rebuilt binary.That is the producer-first sequence and it is not claimed here.
Rulebook compliance
/charly-internals:go(withreferences/schema-change-recipe.md),/charly-internals:vm-spec, plus this repo's ownAGENTS.md. The recipe's step 1 ("edit CUE only, thenregenerate — never hand-transcribe") and step 3 (
charly task cue-gen, reproducibility-gated) arefollowed exactly.
a specific function and line before anything was changed, and the two candidate fixes were measured
rather than argued: required-with-default was implemented first, observed to fail with a different
non-concrete error, and discarded.
string/booland the vocabulary stays in#VmBackend;nothing is duplicated and no second spelling of the word list is introduced.
#Vmdefault machinery was already gone, which is how thesefields lost their defaults, and this restores a workable contract without reviving it.
origin/main(e433c4b); the submodule itself was neveredited in place.
disposable: truetarget in thisrepo (its
AGENTS.md: "this repo carries no per-repo candy gate; the merge gate is the org-widecharly/pr-validator"). The gate that owns it ischarly task cue-gen+ the module suite, both green onthis tree. The live VM target is exercised in the consumer bump that follows.
Filed issues
remaining proof.
RESOLVEDagainst this.ADDof debootstrap's device nodes). Not blocked by this PR.Change classification
Schema (CUE) change plus one generated-file refresh and one new test.
Breaking change + rollback: it is
!-marked because it relaxes a required field, and the effect reachesthe wire in two directions. In CUE, an envelope whose producer omitted the values now DECODES instead of
failing — that is the fix. In JSON, those keys are now omitted instead of emitted as
""/false, becausethe retag transform put
omitemptyon the JSON tags to match; a JSON consumer that assumed the keys arealways present must treat absence as the zero value. Nothing else moves: both fields keep their names,
their types, their validation (the provider-word test above pins it), and their YAML spelling, so no Go
consumer recompiles differently. Rollback is a revert of this commit; the
two fields return to required and every
charly vm createbreaks again, which is the state this PR existsto leave.
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)