Repository navigation
feat(plugin-distro)!: mirror spec's present_template + derive the schema-parity guard from spec (charly#771) - #9
Conversation
…ema-parity guard from spec (charly#771)
Review — PASSHead SHA: Security screen: PASS — no secrets/egress, no guardrail weakening (the change strengthens a parity guard), module bumps are org-internal ( Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
This plugin serves
kind: distro, and it validates an authoreddistro:body against its own, self-contained#DistroInput(with inner#Ds*defs) before dispatching. That duplication is sanctioned — the plugin schema must compile standalone while spec's#Distromust generate Go — but the two can drift, and when they do the failure is confusing: charly core accepts a field and this plugin rejects it with#DistroInput.<field>: field not allowed, which reads like the field does not exist at all.That is what happened to
present_template. spec's#Formatgained it (spec leg 1 ofopencharly/charly#771, merged and taggedv0.2026276.1337), and this mirror did not, so an authoredpresent_template— the command whose stdout lists the already-present packages, which leg 1/leg 2 use to subtract the venue's pre-existing packages from teardown — was rejected here, at the kind provider.Two things are fixed, and the second is the one that matters:
1. The mirror is completed. One line in the inner
#DsFormat, placed exactly where spec's#Formathas it (immediately afteruninstall_template), plus the regeneratedparams/cue_types_gen.gothrough this repo's own pipeline.2. The parity guard is replaced with a derived, inner-deep one. The old guard compared top-level fields only — by explicit design — against a hand-maintained literal.
present_templatelives on the inner#DsFormat, one level below that guard, so it drifted silently. The file's own comments already recorded the identical class twice:#Distro.installerwas "rejected here for months", anddisk_layoutwas next. So the guard now reads spec's own CUE source — the embed in the spec module this plugin already requires — and descends into every mirrored def.Measured on this head: 19 mirrored
#Ds*defs plus#DistroInputall compare equal to spec.Why derived rather than a better literal. A hand-maintained list has two drift surfaces — the schema, and the list — and re-checks only what someone remembered to write. The org's own precedent for a parity test is derived:
plugin-box/candy/plugin-box/validate_parity_test.goasserts its closed set againstspec.ProviderClassesand says so — "DERIVED from spec.ProviderClasses (the ONE CUE-owned vocabulary)". Following that precedent is R3; keeping both would be two implementations of one invariant. The old test's rationale — "Kept as a literal rather than read from the spec module because the plugin's schema is deliberately standalone — importing spec here to check standalone-ness would defeat the point" — reasons about the schema's standalone-ness, which a test reading a dependency's CUE does not touch. It is deleted (R5).No new module dependency.
github.com/opencharly/spec/schema(var FS embed.FS) andgithub.com/opencharly/spec/schemaconcat(ConcatSchema) are subpackages of a module this plugin already requires;schemaholds exactly one non-test Go file (the embed).No production Go changes. The projection carries the whole format map by reference (
resolve.go:32—Format: d.Format), so a new field onspec.Formatflows through once the pin moves.resolve.go,plugin.goandcmd/are untouched.Refs opencharly/charly#771 — this is the schema-mirror leg; the issue closes with the charly leg, not here.
How tested
Run on the final committed head
762ba152b3f5b75a577b6fb4c721ca16685d7e4e(branchfeat/present-template-771, offorigin/main=5d31a3a5b4c1b3850bf24378998de7821bbea465) in.worktrees/readme-truth/plugin-distro, on a clean tree.1. The new guard is load-bearing — it FAILS on the pre-fix drift, and names it
The decisive run (R7): the mirrored line was temporarily removed and the guard re-run on the same head, then the tree restored (
git status --shortempty afterwards, above). This is the proof that the deepened guard catches exactly what the old top-level-only guard missed — the drift is on the inner#DsFormat:2. On the committed head — build, vet, tests
The guard cannot pass vacuously: it fails loudly if either schema parses to zero fields, or if zero
#Ds*defs are found.3. The mirror field and its generated param
params/cue_types_gen.gowas produced by this repo's own generation pipeline (concat →cue exp gengotypes→ adopt → retag →gofmt), never hand-edited. The pipeline was first run against the unmodified schema and produced a 0-line diff, so the diff below is exactly this change:+2lines (the field and a blank), nothing else.The generated field is
Present_template, notPresentTemplate— verified as this file's real convention, not a mistake. This mirror deliberately carries no@go()annotations (its schema header records that annotations are dropped for a builtin), socue exp gengotypescamelises only the first letter, exactly like its siblings:4. The module pins moved together (mandatory, not cosmetic)
Bumping spec alone does not build:
spec.FleetNodeis the typed-ExtraCandyRefbreak fromspec v0.2026273.203(spec#188), so the sdk must move with spec; with only the spec bump the compiler reports[email protected]/vmshared/spec_aliases.go:29:36: undefined: spec.FleetNode.go mod tidyexits0and updatesgo.sum.5.
charly box validateStated plainly, because it is a real environmental fact about how this run was produced (R1, not hidden): this validation was run with a charly binary built from the committed pre-#771-charly-leg-3 tree (
56c7efce), not from the branch head of the in-flight session's charly worktree. The reason is a genuine chicken-and-egg created by the consumer leg, not by this change: the in-flight charly worktree already declarespresent_templatein its embedded defaults, while its compiled-in plugin-distro is stillv0.2026272.29— so that binary refuses to load any project withplugin_input fails #DistroInput: #DistroInput.format.pac.present_template: field not allowed. That is precisely the defect this PR fixes, observed from the other side. The56c7efcebinary is a committed tree, not a hand-edit, and it loads a project cleanly; it does not contain the consumer'spresent_templatedeclaration, so it exercises this repo's schema check without the consumer's interference.charly box validateis a structural check of this repo's candy entity and CUE schema, and it passes.This repo has no per-repo candy bed; the merge gate is the org-wide
charly/pr-validator.Rulebook compliance
/charly-build:build,/charly-internals:pluginand/charly-internals:git-workflowwere loaded before the first tool call.#Format; the guard's top-level scope plus a hand-maintained literal made the drift invisible. Both root causes are fixed, not the symptom. The generated-name convention and the binary-selection constraint are each root-caused above rather than worked around. No "pre-existing / out of scope / follow-up" classification.plugin-box) is followed. No second copy of the invariant.|| true, no retry, no sleep, no hand-edited generated Go, nocharly migrate(which would have restored the retired config stamp).wantlist and the stale standalone-ness rationale are deleted, not left beside the new check.main.box validateall ran against committed head762ba152, from a clean tree..worktrees/readme-truth/; no submodule's tracked checkout was touched.git -C <absolute-path> worktree add.sdk v0.2026276.48andspec v0.2026276.1337are merged-and-tagged default-branch releases — spec's is the leg-1 tag of this very issue. No PR branch is pinned.gh pr list -R opencharly/plugin-distro --state open→ empty; no PR existed on this branch);opencharly/charly#771was already CLAIMED by this slug (readme-truth, 2026-10-03T13:28:49Z) rather than duplicated, and this PR references it. No peer session holds this repo.Change classification
go build/go vet/go test(with the load-bearing FAIL→PASS of the new guard pasted above) pluscharly box validateon the final committed tree. The merge gate is the org-widecharly/pr-validator.fully tested and validated— the changed paths were compiled and executed live on the final committed head, and the new guard was proven to fail on the exact drift it exists to catch.Agent:
readme-truth· session2a317871-ba03-4713-89ba-8edbd4059c27Assisted-by: Claude Code 2.1.288 deepseek-v4.1-flash:cloud (fully tested and validated)