Skip to content

feat(plugin-distro)!: mirror spec's present_template + derive the schema-parity guard from spec (charly#771) - #9

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/present-template-771
Oct 3, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/present-template-771

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This plugin serves kind: distro, and it validates an authored distro: 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 #Distro must 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 #Format gained it (spec leg 1 of opencharly/charly#771, merged and tagged v0.2026276.1337), and this mirror did not, so an authored present_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 #Format has it (immediately after uninstall_template), plus the regenerated params/cue_types_gen.go through 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_template lives 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.installer was "rejected here for months", and disk_layout was 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 #DistroInput all 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.go asserts its closed set against spec.ProviderClasses and 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) and github.com/opencharly/spec/schemaconcat (ConcatSchema) are subpackages of a module this plugin already requires; schema holds 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 on spec.Format flows through once the pin moves. resolve.go, plugin.go and cmd/ 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 (branch feat/present-template-771, off origin/main = 5d31a3a5b4c1b3850bf24378998de7821bbea465) in .worktrees/readme-truth/plugin-distro, on a clean tree.

$ git rev-parse HEAD
762ba152b3f5b75a577b6fb4c721ca16685d7e4e
$ git log --oneline origin/main..HEAD
762ba15 feat(plugin-distro)!: mirror spec's present_template + derive the schema-parity guard from spec (charly#771)
$ git diff --stat origin/main
 candy/plugin-distro/go.mod                  | 15 +++--
 candy/plugin-distro/go.sum                  | 36 +++++------
 candy/plugin-distro/params/cue_types_gen.go |  2 +
 candy/plugin-distro/schema/distro.cue       |  1 +
 candy/plugin-distro/schema_parity_test.go  | 98 ++++++++++++++++++++++-------
 5 files changed, 108 insertions(+), 44 deletions(-)
$ git status --short
$

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 --short empty 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:

$ go test ./... -count=1 -run TestEveryMirroredDefMatchesSpec
--- FAIL: TestEveryMirroredDefMatchesSpec (0.01s)
    schema_parity_test.go:58: #DsFormat fields drifted from spec's #Format.
         got: [cache_mount local_pkg phase secondary section_field uninstall_template validate]
        want: [cache_mount local_pkg phase present_template secondary section_field uninstall_template validate]
        If spec added a field, mirror it here; if spec removed one, remove it here.
FAIL
FAIL	github.com/opencharly/plugin-distro/candy/plugin-distro	0.016s
?   	github.com/opencharly/plugin-distro/candy/plugin-distro/cmd/serve	[no test files]
?   	github.com/opencharly/plugin-distro/candy/plugin-distro/params	[no test files]
FAIL

2. On the committed head — build, vet, tests

$ go build ./...      # from candy/plugin-distro/ — no output, exit 0
$ go vet ./...        # exit 0
$ go test ./... -count=1
ok  	github.com/opencharly/plugin-distro/candy/plugin-distro	0.019s
?   	github.com/opencharly/plugin-distro/candy/plugin-distro/cmd/serve	[no test files]
?   	github.com/opencharly/plugin-distro/candy/plugin-distro/params	[no test files]
$ go test ./... -count=1 -run TestEveryMirroredDefMatchesSpec -v
=== RUN   TestEveryMirroredDefMatchesSpec
--- PASS: TestEveryMirroredDefMatchesSpec (0.01s)
PASS
ok  	github.com/opencharly/plugin-distro/candy/plugin-distro	0.010s

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

$ sed -n '57,66p' candy/plugin-distro/schema/distro.cue
#DsFormat: {
	cache_mount?: [...#DsCacheMount]
	section_field?: {[string]: "list" | "list_of_maps"}
	uninstall_template?: string
	present_template?: string
	phase?:              #DsPhaseSet
	validate?: [...#DsFormatRule]
	secondary?: bool
	local_pkg?: #DsLocalPkg
}

$ grep -n -A2 'Present_template' candy/plugin-distro/params/cue_types_gen.go
92:	Present_template string `yaml:"present_template,omitempty" json:"present_template,omitempty"`
93-
94:	Phase DsPhaseSet `yaml:"phase,omitempty" json:"phase,omitempty"`

params/cue_types_gen.go was 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: +2 lines (the field and a blank), nothing else.

The generated field is Present_template, not PresentTemplate — 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), so cue exp gengotypes camelises only the first letter, exactly like its siblings:

$ grep -n -E '^\s+(Uninstall_template|Section_field|Present_template|Local_pkg|Secondary) ' candy/plugin-distro/params/cue_types_gen.go
88:	Section_field map[string]string `yaml:"section_field,omitempty" json:"section_field,omitempty"`
90:	Uninstall_template string `yaml:"uninstall_template,omitempty" json:"uninstall_template,omitempty"`
92:	Present_template string `yaml:"present_template,omitempty" json:"present_template,omitempty"`
96:	Validate []DsFormatRule `yaml:"validate,omitempty" json:"validate,omitempty"`
98:	Secondary bool `yaml:"secondary,omitempty" json:"secondary,omitempty"`
100:	Local_pkg DsLocalPkg `yaml:"local_pkg,omitempty" json:"local_pkg,omitempty"`

4. The module pins moved together (mandatory, not cosmetic)

$ grep -n -e 'opencharly/sdk ' -e 'opencharly/spec ' candy/plugin-distro/go.mod
5:require github.com/opencharly/sdk v0.2026276.48
27:	github.com/opencharly/spec v0.2026276.1337

Bumping spec alone does not build: spec.FleetNode is the typed-ExtraCandyRef break from spec 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 tidy exits 0 and updates go.sum.

5. charly box validate

$ charly box validate          # from the repo root
charly box validate: OK — checked 1 candy, 7 distros, 7 builders; 0 warnings, 0 errors

Stated 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 declares present_template in its embedded defaults, while its compiled-in plugin-distro is still v0.2026272.29 — so that binary refuses to load any project with plugin_input fails #DistroInput: #DistroInput.format.pac.present_template: field not allowed. That is precisely the defect this PR fixes, observed from the other side. The 56c7efce binary is a committed tree, not a hand-edit, and it loads a project cleanly; it does not contain the consumer's present_template declaration, so it exercises this repo's schema check without the consumer's interference. charly box validate is 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

  • R0 (skills first): /charly-build:build, /charly-internals:plugin and /charly-internals:git-workflow were loaded before the first tool call.
  • R1 (root-cause every anomaly): RCA above — spec added a field to the inner #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.
  • R3 (one canonical implementation): the derived check replaces the literal one. The org precedent (plugin-box) is followed. No second copy of the invariant.
  • R4 (no workarounds): no allowlist, no || true, no retry, no sleep, no hand-edited generated Go, no charly migrate (which would have restored the retired config stamp).
  • R5 (delete legacy completely): the literal want list and the stale standalone-ness rationale are deleted, not left beside the new check.
  • R6 (git safety): no force-push, no hook bypass, no direct push to main.
  • R7 (prove the gate, not the plan): the guard's own FAIL→PASS is pasted above, on the same head, with the tree restored to clean afterwards.
  • R10 (fresh proof from the final committed tree): build, vet, tests and box validate all ran against committed head 762ba152, from a clean tree.
  • Umbrella rule 1 / rule 4: all change is in the owning repo, from a session worktree under .worktrees/readme-truth/; no submodule's tracked checkout was touched.
  • Umbrella rule 2: the worktree was created with git -C <absolute-path> worktree add.
  • Umbrella rule 5 (pin only merged refs): sdk v0.2026276.48 and spec v0.2026276.1337 are merged-and-tagged default-branch releases — spec's is the leg-1 tag of this very issue. No PR branch is pinned.
  • Umbrella rule 9 / rule 10: the org was searched first (gh pr list -R opencharly/plugin-distro --state open → empty; no PR existed on this branch); opencharly/charly#771 was 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

  • Change class: a plugin CUE-schema change (a decoded distro field) plus its generated params, and a test-only deepening of the parity guard. No runtime Go path changes.
  • Verification gate: go build / go vet / go test (with the load-bearing FAIL→PASS of the new guard pasted above) plus charly box validate on the final committed tree. The merge gate is the org-wide charly/pr-validator.
  • Attribution tier: 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 · session 2a317871-ba03-4713-89ba-8edbd4059c27
Assisted-by: Claude Code 2.1.288 deepseek-v4.1-flash:cloud (fully tested and validated)

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: 762ba152b3f5b75a577b6fb4c721ca16685d7e4e (branch: feat/present-template-771)

Security screen: PASS — no secrets/egress, no guardrail weakening (the change strengthens a parity guard), module bumps are org-internal (opencharly/sdk, opencharly/spec), no embedded directives.
Comments: thread is empty (0 comments) — nothing to disposition.
Checklist: All applicable rules PASS or NA. Diff↔body accounting matches (108 insertions(+), 44 deletions(-), 5 files); one atomic commit; derived guard replaces the literal (R3/R5); the pasted FAIL→PASS is internally consistent with the diff (the schema_parity_test.go:58 report is the t.Helper() caller line inside the mirrored-def loop, and the got/want lists match the pre/post-fix #DsFormat); the box validate binary-selection constraint is disclosed and root-caused, not used to dismiss a failure; placement is in the plugin (candy) — no capability moved into core.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 3, 2026 14:56
@github-actions
github-actions Bot merged commit 9108677 into main Oct 3, 2026
1 check passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 3, 2026
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.

2 participants