Skip to content

feat(schema): the schema becomes a CUE package in a module - #295

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/cue-module
Nov 8, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/cue-module

Conversation

@aitrawog

@aitrawog aitrawog commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Head 1c63c453cfaff17c7d7b2bb87c6b909cfb22d06c — 78 files, +538 −75.

Summary

schema/ is now a real CUE package in a real module: cue.mod/module.cue declares
github.com/opencharly/spec, and all 64 schema/*.cue files carry one package schema clause.
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/schemaconcat and every consumer keep working unchanged:
ConcatSchema's exported API is the same and it still returns the package-less body every
consumer 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/main is the comment
corrections this PR makes.
charly core still compiles baseBody + "\n" + servedCUE, internal/schemagen still prepends
package spec + @go(spec), and charly's pinned spec tag is untouched. Removing the dual path —
charly importing github.com/opencharly/spec/schema through a module, and the text splice going
away — is the next change.

What the package form exposed

  • No duplicate definitions. All 719 top-level definitions across the 64 files have unique
    names across files; the one repeated name (#Distros) is two statements of ONE definition
    inside distro_vocab.cue (an open map arm plus the closed struct), which the concatenation
    already unified. No definition was renamed to dodge a conflict. Evidence below.
  • schema/_common.cue was 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 have
    been missing from the package. The file is now schema/00_common.cue; the 00_ keeps it FIRST
    in the concatenator's sort order, so the concatenated body order — and the generated Go — is
    unchanged.
  • The language version is a decision, not a bump. Under CUE v0.18.0 language semantics the
    schema's existing close() + embedded-definition idiom is rejected: #Step's arms
    ({#Op, run: ...}) fail with field not allowed, and #DescentDescriptor.transport likewise.
    A minimal repro measured the boundary: v0.16.1 and v0.17.0 accept it, v0.18.0 does not.
    cue.mod/module.cue therefore pins language: version: "v0.16.1" — the version spec's own
    cuetoolchain pins — so the package's value is identical to the concatenation's. Raising it is
    the §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.
  • Cross-file references resolve through the package. schema/*.cue carries no CUE import
    statements (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.
  • Two stale pipeline claims on this change's own surface, fixed here (R1): schema/README.md
    and the schemagen doc header documented -mode=concat, but the command takes -mode=params;
    and spec/version_gen.go no longer exists (the version machinery was deleted), so its mention
    is gone.

Files

Every file in the diff, tagged as git show --name-status reports it (R = rename, old first):

A cue.mod/module.cue
M internal/schemagen/main.go
M matchers/matchers.go
M matchers/matchers_test.go
M README.md
M schema/agent_control.cue
M schema/agent.cue
M schema/android.cue
M schema/arbiter.cue
M schema/box.cue
M schema/boxmetadata.cue
M schema/buildctx.cue
M schema/builder.cue
M schema/buildresolve.cue
M schema/buildwire.cue
M schema/cache.cue
M schema/candy.cue
M schema/candymodel.cue
M schema/checkresult.cue
M schema/clean.cue
M schema/cli_model.cue
R schema/_common.cue -> schema/00_common.cue
M schemaconcat/schemaconcat.go
A schemaconcat/schemaconcat_test.go
M schema/deploy_cpu_shape_test.go
M schema/deploy.cue
M schema/desktop.cue
M schema/distro.cue
M schema/distro_vocab.cue
M schema/docs.cue
M schema/doctor.cue
M schema/enc.cue
M schema/engine.cue
M schema/feature.cue
M schema/firecracker_client.cue
M schema/firecracker.cue
M schema/gpu.cue
M schema/hook.cue
M schema/init.cue
M schema/instrument.cue
M schema/k8sgen.cue
M schema/kindcluster.cue
M schema/kubernetes.cue
M schema/kubevirt_client.cue
M schema/kubevirt.cue
M schema/ledger.cue
M schema/llm.cue
M schema/loadedproject.cue
M schema/local.cue
M schema/marketplace.cue
M schema/node.cue
M schema/oci.cue
A schema/package_matches_concat_test.go
M schema/parsedproject.cue
M schema/pipeline.cue
M schema/pod.cue
M schema/README.md
M schema/refs.cue
M schema/resolvedbox.cue
M schema/resolvedproject.cue
M schema/resource.cue
M schema/seam.cue
M schema/sidecar.cue
M schema/skill.cue
M schema/status.cue
M schema/substrate_template.cue
M schema/system.cue
M schema/task.cue
M schema/testdata/workflow_run_list_arg.cue
M schema/tunnel.cue
M schema/validateproject.cue
M schema/vm_box_metadata.cue
M schema/vmclient.cue
M schema/vm.cue
M schema/workflow.cue
M spec/cue_types_gen.go
M spec/ref_parse.go
M spec/workflow_arg_list_wire_test.go

How tested

The pinned toolchain, per the brief:

$ /home/atrawog/.cache/charly/tool/cue/v0.18.0-rc.1/linux_amd64/cue version
cue version v0.18.0-rc.1

CUE language version v0.18.0
$ /home/atrawog/.cache/charly/tool/cue/v0.18.0-rc.1/linux_amd64/cue eval ./schema > /dev/null; echo "exit=$?"
exit=0
$ /home/atrawog/.cache/charly/tool/cue/v0.18.0-rc.1/linux_amd64/cue vet ./schema; echo "exit=$?"
exit=0
$ ./bin/cue eval ./schema > /dev/null; echo "exit=$?"
exit=0
$ git rev-parse HEAD
1c63c453cfaff17c7d7b2bb87c6b909cfb22d06c

The repo's own gate for a schema change, charly task cue-gen, and the module's CI gates, all on
the committed tree:

$ charly task cue-gen > /tmp/task.log 2>&1; echo "exit=$?"
exit=0
$ grep -E "^task|\[pass\]" /tmp/task.log
task bootstrap-cue: 1 step(s), 0 failed, 0 skipped
  [pass] run — download and checksum-verify the pinned cue CLI
task bootstrap-protoc: 1 step(s), 0 failed, 0 skipped
  [pass] run — download and pin protoc + the two Go codegen plugins
task wire-gen: 1 step(s), 0 failed, 0 skipped
  [pass] run — render the proto IDL from CUE and compile the Go stubs
task cue-gen: 2 step(s), 0 failed, 0 skipped
  [pass] run — gengotypes + schemagen the generated Go
  [pass] check — regen is reproducible — TestGenReproducible passes on the committed tree
$ GOWORK=off go build ./...; echo "build exit=$?"
build exit=0
$ GOWORK=off go vet ./...; echo "vet exit=$?"
vet exit=0
$ GOWORK=off go test ./... -count=1 > /tmp/gotest.log 2>&1; echo "test exit=$?"
test exit=0
$ grep -c "^ok" /tmp/gotest.log
27
$ gofmt -l .; echo "gofmt exit=$?"
gofmt exit=0
$ git status --porcelain proto/ | wc -l
0

The package carries the whole schema

cue eval ./schema is compared against the PRE-change concatenation — the 64 origin/main file
bodies 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:

$ python3 /tmp/prove_package_equals_concat.py
pre-change files: 64
declarations: concat 719 package 719
same names and values: True

The script reconstructs the pre-change body from origin/main with git show, compiles it in a
scratch module at the SAME language version, runs cue eval on both sides, and compares the
sorted, whitespace-normalized top-level blocks. The same equality is a committed test
(TestPackageCarriesTheWholeSchema), so it holds going forward rather than only in this run:

$ GOWORK=off go test ./schema/ -run TestPackageCarriesTheWholeSchema -count=1; echo "exit=$?"
ok  	github.com/opencharly/spec/schema	0.638s
exit=0

That test fails without the change — restore the _-prefixed name and the package loses the
shared definitions:

$ mv schema/00_common.cue schema/_common.cue && GOWORK=off go test ./schema/ -run TestPackageCarriesTheWholeSchema -count=1; echo "exit=$?"
--- FAIL: TestPackageCarriesTheWholeSchema (0.12s)
    package_matches_concat_test.go:69: the schema package does not compile: #Agent.timeout: reference "#Duration" not found (and 133 more errors)
FAIL
FAIL	github.com/opencharly/spec/schema	0.127s
FAIL
exit=1
$ mv schema/_common.cue schema/00_common.cue
$ git status --porcelain | wc -l
0

The concatenation every consumer compiles is unchanged

Per file, the body after the canonical package schema + blank line equals the origin/main body
with only the intended comment substitutions — no declaration is lost, none is reordered:

$ python3 /tmp/prove_concat_input_unchanged.py
checked: 64 unexpected: []

No schema file carries a CUE import, which is why the package form cannot make one file-local
and unused:

$ grep -rlE "^import" schema/*.cue | wc -l
0

And no live reference to the retired filename remains:

$ git grep -nP '(?<!00)_common\.cue' -- . ':!CHANGELOG'; echo "exit=$?"
exit=1

Duplicate-definition scan

$ grep -hoE "^#?[A-Za-z_][A-Za-z0-9_]*:" schema/*.cue | sort | uniq -d
#Distros:
$ grep -nE "^#?Distros:" schema/*.cue
schema/distro_vocab.cue:49:#Distros: [string]: #DistroTrait
schema/distro_vocab.cue:50:#Distros: { // @go(-) — see #DistroTrait
$ grep -hoE "^#?[A-Za-z_][A-Za-z0-9_]*:" schema/*.cue | wc -l
720

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

  • R0 — the dispatched skills were loaded before the first action: git-workflow, go,
    plugin, cutover-policy, strict-policy.
  • R1 — three anomalies, each root-caused before remediation. (1) cue eval ./schema would
    have 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 the
    close()-embedding idiom — mechanism: the 0.18 closedness change, measured with a minimal
    repro; 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.Subsume and failed
    on 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 go skill's source map) is filed — see Filed issues.
  • R2 — one clause per file, one normalization in schemaconcat (the single concatenation
    contract), one dual-path test. No second implementation of the schema or of the strip.
  • R3 — no sleep, retry, suppression or fallback. The language pin is a declared, measured
    constraint, not a workaround.
  • R4 — the product (the schema) is the source, and the prose was corrected to it
    (schema/README.md, README.md, the generator docs, and the stale claims above). No
    reader-facing command was added: the package form is described, and charly task cue-gen (which
    needs only the charly binary) stays the documented command. The cue invocations below are
    this PR's evidence, each with its exit code — not an instruction to a reader.
  • R5 — the one retired identifier is the filename _common.cue (now 00_common.cue), and the
    grep 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.
  • R6 — git status was clean before staging; the work is in a worktree branched off
    origin/main; no force-push, reset, hook bypass, or push to main.
  • R7 — the new tests fail without the change (mutation above), and the dual-path test reads the
    real artifacts — the loaded package and the embedded schema. The gate ran on the committed tree,
    and cue eval/cue vet ran live against the pinned binary.
  • R8 — N/A — no live-service boundary in this change.
  • R9 — N/A — spec ships no binary and deploys nothing; its maintenance surface is charly task, run here by the umbrella's charly 2026.306.0314.
  • R10 — spec declares no disposable: bed (charly.yml carries only tasks; the repo composes
    no box and ships no image), so this change class's gate is the repo's own cue-gen task plus its
    CI gates (go build, go vet, go test ./..., gofmt -l), all run on the committed tree and
    green above. The consumer's runtime is unchanged until charly bumps its spec pin in its own PR.
  • HC — this is one ordered unit of a tracked multi-unit cutover (schema: the schema becomes a CUE package in a module (the first unit of the concat→package cutover) #294), landed
    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 spec is 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 and
the 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 the
text 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 migrate entry 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 go skill's source map still calls spec/schema/*.cue
package-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)

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)
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 2f0ee09ecfc0abe316f5f11ce3169fd0f41fa965 (branch: feat/cue-module)

Change class: code/config (CUE schema packaged in a module, schemaconcat clause-strip normalization, new gating tests) with accompanying docs. The Go/CUE mechanism itself is sound: stripPackageClause is edge-correct (leading comments preserved, package: field untouched, missing blank separator handled), the new TestPackageCarriesTheWholeSchema and TestConcatSchemaStripsPackageClause would fail without the change (mutation is pasted and internally consistent), the dual path is gated and tracked by opencharly/spec#294, and the placement (schema files, leaf schemaconcat, tests) is correct for the spec module.

Blocks

  1. R4 — a reader-facing doc command needs more than the charly binary.
    schema/README.md, new "## The package form" section, tells the reader to run:
    ./bin/cue eval ./schema     # bootstrap-cue provisions the pinned CLI
    R4 requires every command a reader is told to run to work with nothing but the
    charly binary — explicitly "no task, no ./bin/charly, no repo-relative
    path
    , no cd into a checkout". ./bin/cue is a repo-relative path that needs
    the checkout plus the bootstrap-cue-provisioned CLI. The body's own R4 line
    ("runs with the repo's own provisioned CLI") confirms it needs more than
    charly, so the compliance claim does not hold. Fix: expose the eval through
    charly (the fix R4 says belongs in charly) and document that invocation, or
    remove the raw repo-relative command from the reader-facing docs.

Verdict: BLOCK


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

View action run

…-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)
@aitrawog

aitrawog commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Round 2 — RCA and fix

Finding (R4). schema/README.md's new "The package form" section instructed the reader to run
./bin/cue eval ./schema. That is 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.

Mechanism. The block was added as a convenience for a developer reading the schema README,
and I took "it runs in this checkout" as the bar. R4's bar is different: a command a reader is
told to run either works with only charly, or it is not documentation — it is evidence, and
evidence belongs in a PR body.

Missed control. My pre-push R4 pass checked that the command I pasted WORKS (it does, with the
repo's ./bin/cue); it never asked whether a doc block was allowed to exist at all. It audited
the execution, not the instruction — and the body's own R4 line named the dependency (runs with the repo's own provisioned CLI) that the rule forbids. A compliance line that names the
forbidden dependency is the finding, not the defence.

Root fix. The section now states what the package form IS — one CUE package in the module
github.com/opencharly/spec, which a consumer's own CUE module imports — and names
charly task cue-gen (the repo's supported command, which needs only charly) as the command.
The cue invocations stay in this PR's evidence, each with its exit code.

Blast radius. Documentation only. schema/README.md is not embedded, and no generated
artifact depends on it: charly task cue-gen produced no diff on the new tree.

Head 1c63c453cfaff17c7d7b2bb87c6b909cfb22d06c; the body is re-finalized for it and the gate
(charly task cue-gen, go build/vet/test ./..., gofmt -l, cue eval/vet ./schema) was
re-run green on the committed tree.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: 1c63c453cfaff17c7d7b2bb87c6b909cfb22d06c (branch: feat/cue-module)

Security screen: PASS — no secrets, no egress, no guardrail weakening, no supply-chain change (schemaconcat stays stdlib-only, adding bytes).
Checklist: All applicable rules PASS or NA.

Comments considered:

  • @github-actions[bot] (6727079254, BLOCK R4): stale-superseded — the offending ./bin/cue eval ./schema reader command is absent from the CURRENT schema/README.md diff; the section now only describes the package form and names charly task cue-gen.
  • @aitrawog (6727141631, Round 2 RCA): verified-non-blocking — the fix is present in commit 1c63c45, and the RCA names the missed control (audited command execution, not whether a doc instruction was permitted), satisfying R1 review-round evidence.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 8, 2026 21:10
@github-actions
github-actions Bot merged commit 2b39dfe into main Nov 8, 2026
4 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 8, 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.

1 participant