Repository navigation
feat(schema): the schema becomes a CUE package in a module - #295
Conversation
schema/*.cue is now ONE CUE package, `package schema`, inside a real module (cue.mod/module.cue, github.com/opencharly/spec, language v0.16.1). This is the first unit of the concat -> package cutover (TODO 2.5/2.16/3.1, D-SCH-2/3); the dual path is deliberate and its removal is the next change. * cue.mod/module.cue added. The language version is v0.16.1 - the version spec's own cuetoolchain pins: CUE v0.18's semantics reject the schema's close() + embedded-definition idiom with "field not allowed" (measured on #Step's arms), so raising it is the 10.1 pattern rewrite (2.16), not a bump. * All 64 schema/*.cue files carry exactly one `package schema` clause. * schema/_common.cue -> schema/00_common.cue: CUE excludes a file whose name starts with `_` from a package load, so the shared definitions were invisible to `cue eval ./schema`. `00_` sorts first, keeping the concatenation's body order - and therefore the generated Go - unchanged. * ConcatSchema strips a file's leading clause (and the single blank separator line that conventionally follows it), so every consumer compiles the SAME package-less body as before. schemaparams/schemagen/README docs updated for the new form. * New tests: schemaconcat pins the normalization in both directions (strip when present; leave package-less plugin schemas alone), and schema/package_matches_concat_test.go compares all 719 top-level definitions of the loaded package against the concatenation's. It fails if the package loader excludes a file - proven by renaming 00_common.cue back to `_common.cue`: `reference "#Duration" not found`. * Swept the claims this change falsifies: `Package-less` -> `package schema` in the schema comments, `_common.cue` -> `00_common.cue` everywhere live, and the schema/README + README pipeline prose. Corrected two stale pipeline claims found on the way: `-mode=concat` is `-mode=params`, and spec/version_gen.go no longer exists. * Regenerated spec/cue_types_gen.go (comment-only diff) and re-ran the whole cue-gen task: no other generated change, and wire-gen is a no-op. Proof: `cue eval ./schema` (CUE v0.18.0-rc.1) and `./bin/cue eval ./schema` (v0.16.1) both exit 0; the package's 719 definitions are identical to the pre-change concatenation's (names and values); `charly task cue-gen`, `go build`, `go vet`, `go test ./...` and `gofmt -l` are clean. Refs #294. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: code/config (CUE schema packaged in a module, Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…-relative command R4: schema/README.md's "The package form" section told the reader to run `./bin/cue eval ./schema` - a repo-relative path that needs the checkout plus the `bootstrap-cue`-provisioned CLI, while R4 requires every documented command to work with nothing but the `charly` binary. The section now states what the package form IS (one CUE package in the module; a consumer module imports `github.com/opencharly/spec/schema`) and names `charly task cue-gen`, which needs only `charly`, as the supported command. No behavior change. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (documentation reviewed)
Round 2 — RCA and fixFinding (R4). Mechanism. The block was added as a convenience for a developer reading the schema README, Missed control. My pre-push R4 pass checked that the command I pasted WORKS (it does, with the Root fix. The section now states what the package form IS — one CUE package in the module Blast radius. Documentation only. Head Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) |
Review — PASSHead SHA: Security screen: PASS — no secrets, no egress, no guardrail weakening, no supply-chain change ( Comments considered:
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Head
1c63c453cfaff17c7d7b2bb87c6b909cfb22d06c— 78 files, +538 −75.Summary
schema/is now a real CUE package in a real module:cue.mod/module.cuedeclaresgithub.com/opencharly/spec, and all 64schema/*.cuefiles carry onepackage schemaclause.The package form evaluates to the same value the text concatenation compiles — so a consumer's own
CUE module can import the schema instead of holding a copy — and that equality is proved below. This is unit 1 of the concat → package cutover (TODO.md 2.5, 2.16, 3.1; DESIGN
D-SCH-2/D-SCH-3). It is deliberately not the cutover itself.
The dual path is deliberate.
spec/schemaconcatand every consumer keep working unchanged:ConcatSchema's exported API is the same and it still returns the package-less body everyconsumer compiles — it now strips each file's leading package clause (and the single blank line
that conventionally follows it), so the only difference from
origin/mainis the commentcorrections this PR makes.
charly core still compiles
baseBody + "\n" + servedCUE,internal/schemagenstill prependspackage spec+@go(spec), and charly's pinned spec tag is untouched. Removing the dual path —charly importing
github.com/opencharly/spec/schemathrough a module, and the text splice goingaway — is the next change.
What the package form exposed
names across files; the one repeated name (
#Distros) is two statements of ONE definitioninside
distro_vocab.cue(an open map arm plus the closed struct), which the concatenationalready unified. No definition was renamed to dodge a conflict. Evidence below.
schema/_common.cuewas invisible to CUE. CUE excludes a file whose name starts with_from a package load, so the shared defs (
#Context,#Step,#Op, and the rest) would havebeen missing from the package. The file is now
schema/00_common.cue; the00_keeps it FIRSTin the concatenator's sort order, so the concatenated body order — and the generated Go — is
unchanged.
schema's existing
close()+ embedded-definition idiom is rejected:#Step's arms(
{#Op, run: ...}) fail withfield not allowed, and#DescentDescriptor.transportlikewise.A minimal repro measured the boundary: v0.16.1 and v0.17.0 accept it, v0.18.0 does not.
cue.mod/module.cuetherefore pinslanguage: version: "v0.16.1"— the version spec's owncuetoolchainpins — so the package's value is identical to the concatenation's. Raising it isthe §10.1 pattern rewrite (TODO 2.16), not this change; the pinned v0.18.0-rc.1 binary reads the
module and evaluates it with these semantics.
schema/*.cuecarries no CUEimportstatements (sweep below), so no import can become file-local and unused, and the dual-path test
compares every
definition's rendered value, so a def that resolved differently through the package would fail it.
schema/README.mdand the
schemagendoc header documented-mode=concat, but the command takes-mode=params;and
spec/version_gen.gono longer exists (the version machinery was deleted), so its mentionis gone.
Files
Every file in the diff, tagged as
git show --name-statusreports it (R= rename, old first):How tested
The pinned toolchain, per the brief:
The repo's own gate for a schema change,
charly task cue-gen, and the module's CI gates, all onthe committed tree:
The package carries the whole schema
cue eval ./schemais compared against the PRE-change concatenation — the 64origin/mainfilebodies joined in the same sorted order — declaration by declaration, after whitespace
normalization (the printer aligns values across neighbouring fields, and the alignment groups
differ between one file and a package). Run from the worktree root:
The script reconstructs the pre-change body from
origin/mainwithgit show, compiles it in ascratch module at the SAME language version, runs
cue evalon both sides, and compares thesorted, whitespace-normalized top-level blocks. The same equality is a committed test
(
TestPackageCarriesTheWholeSchema), so it holds going forward rather than only in this run:That test fails without the change — restore the
_-prefixed name and the package loses theshared definitions:
The concatenation every consumer compiles is unchanged
Per file, the body after the canonical
package schema+ blank line equals theorigin/mainbodywith only the intended comment substitutions — no declaration is lost, none is reordered:
No schema file carries a CUE
import, which is why the package form cannot make one file-localand unused:
And no live reference to the retired filename remains:
Duplicate-definition scan
720 declarations, 719 distinct names: the only repeat is the one file's two statements of
#Distros. There is no cross-file duplicate definition to resolve.Rulebook compliance
git-workflow,go,plugin,cutover-policy,strict-policy.cue eval ./schemawouldhave excluded the underscore-named shared-definitions file — mechanism: CUE's loader file
filter, not the package form; root fix: the
00_rename. (2) Language v0.18.0 rejects theclose()-embedding idiom — mechanism: the 0.18 closedness change, measured with a minimalrepro; root fix: pin the language version the schema is written for, and leave the pattern
rewrite to TODO 2.16. (3) The first dual-path test compared with
cue.Value.Subsumeand failedon closed definitions — mechanism: subsumption of a closed struct is not symmetric even for
equal values; root fix: compare the rendered value, which is the equality meant here. Zero
warnings. The two doc divergences on this change's own surface are fixed here; the one
finding in ANOTHER repo (the
goskill's source map) is filed — see Filed issues.schemaconcat(the single concatenationcontract), one dual-path test. No second implementation of the schema or of the strip.
constraint, not a workaround.
(
schema/README.md,README.md, the generator docs, and the stale claims above). Noreader-facing command was added: the package form is described, and
charly task cue-gen(whichneeds only the
charlybinary) stays the documented command. Thecueinvocations below arethis PR's evidence, each with its exit code — not an instruction to a reader.
_common.cue(now00_common.cue), and thegrep above shows no live reference to it. The dual path is not legacy left behind: it is the
runtime half of a decomposed cutover, named as the next unit.
git statuswas clean before staging; the work is in a worktree branched offorigin/main; no force-push, reset, hook bypass, or push tomain.real artifacts — the loaded package and the embedded schema. The gate ran on the committed tree,
and
cue eval/cue vetran live against the pinned binary.charly task, run here by the umbrella'scharly2026.306.0314.disposable:bed (charly.ymlcarries only tasks; the repo composesno box and ships no image), so this change class's gate is the repo's own
cue-gentask plus itsCI gates (
go build,go vet,go test ./...,gofmt -l), all run on the committed tree andgreen above. The consumer's runtime is unchanged until charly bumps its spec pin in its own PR.
as forward motion; the tracking issue stays open until the dual path is deleted. No deferred work
inside this unit's scope.
Change classification
No
!. This PR adds the package form and keeps the text form; nothing a consumer uses changes.The Go API of
specis untouched,schemaconcat.ConcatSchema's signature and output are unchanged,and charly keeps compiling the spec tag it already pins. The package form is additive.
Dual path, deliberate. Two forms of one schema coexist on purpose — the CUE package
(
cue eval ./schema, what a module imports) and the package-less concatenation (the runtime andthe generator) — and a test gates them against each other. Removing the dual path is the next PR:
charly composes the schema through a module import, and
schemaconcat's normalization (and thetext splice) go away.
Breaking change + rollback: none for this repo's consumers — the package form is new, the
concatenated body still carries every definition (only comment lines differ), and no authored key
moved, so no
charly migrateentry is owed.Rollback is a revert of this commit: it restores the package-less files and the old
ConcatSchema,and no consumer ever observed the package form.
Filed issues
#294 — the tracking issue for the concat → package cutover; filed and claimed
before branching, and it stays open for the unit that deletes the dual path.
opencharly/charly#1112 — the
goskill's source map still callsspec/schema/*.cuepackage-less; the package form makes that input description false. Documentation only, in the
repo that authors the skill (its rendered marketplace copy follows the source on regeneration),
so it is filed rather than fixed here.
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)