Skip to content

feat(cuemodule): export the CUE module declaration to Go consumers - #296

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

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

Conversation

@aitrawog

@aitrawog aitrawog commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

schema.FS carries the schema package, but not the CUE module that owns it. cue.mod/module.cue sits at this module's root — outside schema/'s //go:embed *.cue tree — so a Go consumer that embeds the schema and composes it as a module instance cannot read the one fact it cannot derive: the pinned language.version that governs evaluation.

This adds package specmodule at this module's root (github.com/opencharly/spec): one embedded file, specmodule.FS, carrying cue.mod/module.cue at the path CUE's loader requires. A consumer overlays it at <root>/cue.mod/module.cue, overlays schema.FS at <root>/schema/, and loads ./schema from there.

Why this unit exists at all — the two alternatives, and why each is wrong:

  • Restate the declaration in the consumer (module path + v0.16.1): a second home for a declaration only this module may make.
  • Compose the files without the module: the loader then applies the consumer's toolchain default language version; the declared pin never governs, which is exactly the drift it exists to prevent.

cue_module_test.go gates the consumer-visible facts: exactly one file at the loader-required path, parseable as a module file, declaring this module path and language.version v0.16.1.

ConcatSchema is untouched and stays the gen pipeline's path. The two README claims that named it as the RUNTIME path now describe what does not move — the declaration's export, and the body the concatenator returns — because the consumer leg (charly) replaces that runtime path with this import. Neither sentence asserts that a consumer already composes the module: that leg lands after this merge, and the prose is scoped to what this head makes true.

Head e02bbf933f2cbef4c81d5a385a18a604c810ce4d — 4 files, +103 −16.

File What the diff does to it
cue_module.go NEW — package specmodule, specmodule.FS = //go:embed cue.mod/module.cue
cue_module_test.go NEW — the gate over that FS: one file, at the loader path, parseable, declaring module path and language.version
schema/README.md the consumer prose: item 1 names the two embedded trees and leaves the composition to the consumer; the blockquote now states the byte-identical body ConcatSchema returns rather than who compiles it; the package-form section names both trees a composing consumer needs
README.md the package table: the schema/ row names specmodule.FS; the schemaconcat/ row states its remaining role

How tested

The module's Go gates, on the committed tree:

$ GOWORK=off go build ./...
exit=0

$ GOWORK=off go vet ./...
exit=0

$ gofmt -l .
exit=0

$ GOWORK=off go test ./... -count=1 | grep -c '^ok'
28

The new package's own gate, and its proof that it can fail — the same test with the expected language version mutated to v0.16.2 goes RED on the file's real declaration, then GREEN again once restored:

$ GOWORK=off go test ./ -run TestFSDeclaresTheCueModule -v -count=1
=== RUN   TestFSDeclaresTheCueModule
--- PASS: TestFSDeclaresTheCueModule (0.00s)
PASS
ok  	github.com/opencharly/spec	0.011s

$ go test ./ -run TestFSDeclaresTheCueModule -count=1   # mutation: want := f.Language.Version, "v0.16.2"
--- FAIL: TestFSDeclaresTheCueModule (0.00s)
    cue_module_test.go:50: the module pins language version "v0.16.1", want "v0.16.2" — this is a SEMANTIC pin, not a toolchain bump: raising it is the §10.1 pattern rewrite (TODO 2.16), and a consumer composing this module would otherwise evaluate the schema under different semantics
FAIL
FAIL	github.com/opencharly/spec	0.008s

$ go test ./ -run TestFSDeclaresTheCueModule -count=1   # restored
ok  	github.com/opencharly/spec	0.013s

golangci-lint is CI-only in this repo and is not installed on the host this ran on, so the lint half of .github/workflows/ci.yml is left to CI; the host gate above is build, vet, test and gofmt.

The consumer leg is where the module instance is actually composed and where the parity proof lives (package value versus the retired concatenation, definition by definition) — opencharly/charly follows on the tag this merge mints.

Rulebook compliance

  • R0 — the dispatched skills were loaded before the first tool call: /charly-internals:go (the SDD pipeline), /charly-internals:plugin (the per-plugin CUE-schema contract this module's schema serves), /charly-internals:git-workflow.
  • R1 — one finding, and it is the reason this PR exists: a Go consumer cannot reach the CUE module declaration, so the composition the cutover needs is impossible from schema.FS alone. It is fixed here (the export) rather than routed around; nothing else surfaced, and nothing needed filing.
  • R2 — no duplication: specmodule.FS embeds the existing cue.mod/module.cue in place, so the module path and the language version still have exactly one home.
  • R3 — no workaround: no fallback, no default language version, no second declaration, no retry.
  • R4 — product before prose: the new capability is the change, and the two README claims it falsifies are corrected in the same diff, in the repo that owns the words.
  • R5 — nothing is deleted (no legacy path was removed here), so a claim-keyed grep has nothing to key on; the prose corrected above describes a mechanism that is being replaced, not deleted.
  • R6 — git status --short was read before staging; one commit, no amend, no force-push, no direct push to main.
  • R7 — the new test fails without the change (mutation above) and passes with it; the artifact under test is the shipped specmodule.FS, not a fixture.
  • R8 — N/A — no live-service boundary: the change reads one embedded file.
  • R9 — N/A — this repo ships no binary; the module's Go gates above are its R9-equivalent proof that source and artifact agree.
  • R10 — N/A — opencharly/spec declares no disposable: true target and no per-repo candy gate (its AGENTS.md: the merge gate is the org-wide charly/pr-validator), so there is no bed to run; the change class is a contract-library addition whose gate is the module's build/vet/test/gofmt, pasted above.

Change classification

  • Class: additive Go API — one new package (github.com/opencharly/spec, package specmodule) and two documentation corrections. No existing package, type, function or schema file changes, so every current consumer compiles unchanged.
  • Breaking change + rollback: none — nothing that exists today is removed or altered: a new root package is added and two README paragraphs are reworded, so no consumer of schema, spec, schemaconcat or the generated types sees a difference. Rollback is reverting the squash commit; the tag is the only artifact that would then dangle.

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

`schema.FS` carries the schema package but not the module that owns it:
`cue.mod/module.cue` sits at this module's root, outside `schema/`'s
`//go:embed *.cue` tree, so a Go consumer that embeds the schema and composes it
as a module instance cannot read the one fact it cannot derive — the pinned
`language.version` that governs evaluation.

Package `specmodule` (`github.com/opencharly/spec`) embeds that single file as
`specmodule.FS`. A consumer overlays it at `<root>/cue.mod/module.cue` and the
schema's files at `<root>/schema/`, then loads `./schema` from there: the module
instance, under the module's own language version, with no checkout, no module
cache entry and no restated declaration. The two alternatives are both wrong —
restating the module path and `v0.16.1` in the consumer makes a second home for
a declaration only this module may make, and composing the files without the
module silently evaluates them under the consumer's toolchain default, which is
the drift the pin exists to prevent.

`cue_module_test.go` gates the fact a consumer depends on: exactly one file at
the loader-required path, parseable as a module file, declaring this module path
and language version `v0.16.1` (a semantic pin — the schema's `close()` +
embedded-definition idiom is legal through v0.17 and rejected by v0.18).

Docs: two README claims named `schemaconcat.ConcatSchema` as the RUNTIME path,
which the consumer leg replaces with this import; they now describe what does not
move (the declaration's export and the consumer's duty) instead of a mechanism
that is being replaced. `ConcatSchema` remains the gen pipeline's path and the
package-less form the cutover's parity test judges against.

Refs #294 (the consumer leg's producer unit).

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

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review — BLOCK

Head SHA: ccf76b7f0da052d057a67cdd9e1570701fb4f2ba (branch: feat/export-cue-module)

Change class: Go library addition (specmodule.FS + test) plus documentation edits — not docs-only.

Blocks

  1. R1 — documentation describes a state that does not yet exist (divergence from reality / body↔diff contradiction).
    schema/README.md, the new "The package form" paragraph asserts, in the present tense, that the consumer-side module composition is already live:

    "A consumer that composes the module itself — charly core does, from the embedded trees rather than a checkout — needs BOTH halves …"

    The PR body says the opposite about timing: "The consumer leg … replaces that runtime path with this import … opencharly/charly follows on the tag this merge mints." So at this merge charly core still composes via ConcatSchema (package-less body), and does not yet compose the module instance from specmodule.FS + schema.FS. The README states as current a behavior the body itself places after the merge. (The same premature-tense issue underlies the blockquote edit "the runtime and the generator still compile …" → "the generator still compiles …", which implies the runtime no longer compiles the package-less body while charly still does.)

    Fix: make the prose match current reality — describe the contract / target ("a consumer such as charly, composing from the embedded trees rather than a checkout, needs both halves") rather than asserting charly core does, and scope the ConcatSchema blockquote to the generator without implying the runtime has already switched — or cite the merged charly change that makes the present-tense claim true. The body already concedes charly follows; the README must not assert it as done.

Notes (non-blocking)

  • Body evidence is internally consistent: the mutation proof's cue_module_test.go:50 matches the language-version t.Fatalf at line 50 of the 52-line test; go build/vet/test/gofmt and the "28 ok" count are plausible for this module. specmodule.FS embeds the existing cue.mod/module.cue in place (R2 satisfied); the test exercises the shipped FS and fails without it (R7 satisfied).
  • R10/disposable: true is legitimately N/A for opencharly/spec (contract library, no bed target); go build/vet/test is the applicable gate. No security screen findings (T1–T4 clean). No comments to disposition (0-comment thread).

Verdict: BLOCK


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

View action run

… consumer uses it yet

The previous paragraph asserted, in the present tense, that charly core composes the
module instance — while the consumer leg lands in opencharly/charly AFTER this merge, so
at this head charly still composes the package-less concatenation. The claim now describes
what the export enables and why a composing consumer needs both trees, and the
`ConcatSchema` blockquote describes the body it returns instead of naming who compiles it,
so neither sentence goes false between this merge and the consumer's.

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

aitrawog commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

STATUS — round 1 BLOCK addressed at head e02bbf933f2cbef4c81d5a385a18a604c810ce4d.

The finding, fixed. The new "package form" paragraph said "A consumer that composes the module itself — charly core does", in the present tense, while this PR body says the consumer leg follows on the tag. The blockquote edit carried the same premature tense by naming who compiles the package-less body. Both now describe the capability and the contract — the two trees a composing consumer needs, and the body ConcatSchema returns — and neither names a consumer's current behavior.

RCA — and the missed control. The mechanism claims in that prose were true; the TIMING claim was not, and the two live in different artefacts: the body knows the producer→consumer order ("charly follows on the tag"), the prose did not. My pre-push self-audit checked mechanism-vs-product and ran the repo's gate, but it never read the prose it was adding AGAINST the body's own ordering claim. A producer PR's prose has a second reader — the consumer's landing — and the audit only covered the first.

Root fix in the control. For a producer unit, prose states what THIS head makes true (the export, the contract, the path), and never what a consumer does with it; and when a body says "X follows on the tag", the diff is grepped for present-tense statements about X before the push.

No code changed in this round: cue_module.go and cue_module_test.go are identical to the previous head, the module's gates are re-run on this head above, and the body is re-keyed to it.

Agent: charly (DeepSeek Harness)

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review — BLOCK

Head SHA: e02bbf933f2cbef4c81d5a385a18a604c810ce4d (branch: feat/export-cue-module)

Change class: Go library addition (specmodule.FS + test) plus documentation edits — not docs-only.

Blocks

  1. A1 — the body misstates what the diff does to schema/README.md. The changed-files table says the blockquote's "the runtime and the generator" "becomes "the generator"". The actual diff replaces that clause with "the body it returns stays byte-identical to the pre-package one" — the string "the generator" does not appear in the new blockquote. The body's own Summary correctly says "the body the concatenator returns", so the table contradicts both the diff and the body's narrative (a stale description left over from the pre-fix wording). Fix: update the schema/README.md row to describe the actual resulting text (the body ConcatSchema returns), so the body's per-file account matches the current diff.

Comments considered

  • @github-actions[bot] BLOCK at ccf76b7 — its R1 finding (present-tense "charly core does" / "the runtime and the generator") is resolved in the current diff: the package-form paragraph is now conditional ("A consumer that composes the module itself … needs BOTH halves") and the blockquote no longer names the runtime. Not a surviving finding.
  • @aitrawog STATUS (round 1 fix) — RCA names the missed control (prose not checked against the body's producer→consumer ordering), code is unchanged from the prior head, and the prose fix is present in the diff. Verified; not itself a finding.

Verdict: BLOCK


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

View action run

@aitrawog

aitrawog commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

STATUS — round 2 BLOCK (A1, body-only) addressed at the SAME head e02bbf933f2cbef4c81d5a385a18a604c810ce4d.

The finding, fixed. The changed-files table's schema/README.md row still described the blockquote as the pre-fix wording ("the runtime and the generator" → "the generator"). The row now describes what the diff actually does: the blockquote states the byte-identical body ConcatSchema returns rather than who compiles it. No code changed; the body is re-keyed to the same head and the failed required run is re-run on it.

RCA — and the missed control. The Summary was swept when I fixed the tense; the TABLE row describing the same file was not. The body is a derived artefact re-keyed per round, and a fix that changes prose must be swept across EVERY description of that file in the body — Summary, table, and How tested — not just the paragraph I was looking at.

Root fix in the control. Before a push, every description of a changed file in the body is read against the diff it describes, and after any prose fix the sweep starts from the file list rather than from the paragraph that was fixed.

Agent: charly (DeepSeek Harness)

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: e02bbf933f2cbef4c81d5a385a18a604c810ce4d (branch: feat/export-cue-module)

Security screen: PASS (T1–T4: additive Go package embedding an in-repo file; no secrets, egress, guardrail weakening, or injected directives).
Checklist: All applicable rules PASS or NA. Change class = additive Go library + doc edits; R10/disposable bed legitimately N/A (no bed target in opencharly/spec), go build/vet/test/gofmt is the applicable gate. Body accounts for all 4 files; +103 −16 and the per-file table match the diff; test mutation proof is internally consistent (cue_module_test.go:50 = the language-version t.Fatalf; 52-line file). specmodule.FS embeds the existing cue.mod/module.cue in place (R2), the test fails without the change (R7), and the Assisted-by: trailer ends the body in the required AI form with a justified tier.

Comment dispositions:

  • @github-actions[bot] round-1 BLOCK (R1 present-tense "charly core does" / "runtime and generator") — stale-superseded: current schema/README.md package-form paragraph is conditional ("a consumer that composes the module itself — one that embeds … needs BOTH halves") and the blockquote no longer names who compiles.
  • @aitrawog round-1 STATUS — verified-non-blocking: fix present in diff, RCA names the missed control.
  • @github-actions[bot] round-2 BLOCK (A1 body-table mismatch on schema/README.md row) — stale-superseded: the row now correctly describes "the byte-identical body ConcatSchema returns rather than who compiles it", matching the diff.
  • @aitrawog round-2 STATUS — verified-non-blocking: table row fixed at same head, RCA present.

Non-blocking notes (rulebook-gap / precision): (1) The root README.md schemaconcat/ row drops the still-live "shared by runtime validation" role and uses present tense for a cutover that follows on the tag — recommend retaining the runtime role until the cutover lands (not a false claim, since the row's stated roles are true). (2) gofmt -l . with exit=0 is not proof of clean formatting (-l exits 0 even when it lists files); the diff is visibly gofmt-clean, so this is an evidence-format weakness only. (3) R6 "one commit" vs the two branch commits (initial + HC-permitted round-1 fix commit) is loose wording, not a git-safety defect.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 9, 2026 00:48
@github-actions
github-actions Bot merged commit d29dc52 into main Nov 9, 2026
6 of 7 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 9, 2026
github-actions Bot pushed a commit to opencharly/charly that referenced this pull request Nov 9, 2026
…CUE module (#1114)

* feat(schema): compose the base document schema by importing the spec CUE module

charly assembled the base document schema as TEXT: every `schema/*.cue` body
concatenated into one package-less blob (`schemaconcat.ConcatSchema`), and every
plugin's served schema compiled as `baseBody + "\n" + servedCUE`. `spec` is a real
CUE module now — `cue.mod/module.cue` declares `github.com/opencharly/spec` at
language version v0.16.1, and all 64 `schema/*.cue` files are one `package schema`
— so the base is composed the way that module says it should be: by IMPORT.

`sharedCueSchema` now loads `github.com/opencharly/spec/schema` as a CUE MODULE
INSTANCE: the package source (`schema.FS`) and the module that owns it
(`specmodule.FS`, the declaration spec exports) are overlaid at one virtual module
root and loaded with `load.Instances(["./schema"], …)`, so the module's own
`language.version` governs evaluation instead of the toolchain default. Nothing is
read from disk: the overlay is in memory, at a fixed path, so diagnostics stay
deterministic. It fails LOUD when the source does not arrive as a module, or when
the module declares no `language.version` — the two ways a package load silently
loses the pinned semantics.

The plugin half is unchanged on purpose: a plugin's served schema still arrives as
text and is still unified with the base. What changes is only HOW it merges —
`base & served` as VALUES, not `base ++ served` as text — and that is sound
because the load gate already requires a plugin schema to compile STANDALONE
(reference no base def), so it can only ever merge with the base's declarations.
Unify is exactly that merge. `ConcatSchema` loses its last runtime caller in
charly; it stays spec's generator path and the cutover's parity oracle.

The proof is value equality, not sampling: `TestBaseSchemaImportMatchesConcatenation`
composes the base both ways and compares every top-level field by name and rendered
value — 719 definitions, identical. `TestBaseSchemaParityDetectsAMissingFile` proves
that comparison can fail (one file dropped from the overlay => 8 differences
reported), because "the package loader silently dropped a file" is the failure this
cutover has already met once (`schema/_common.cue`, excluded for its leading `_`).

spec moves v0.2026309.1917 -> v0.2026313.48. That bump is the producer leg this
unit needed and did not have: the schema's source reached a Go consumer as
`schema.FS`, but the module that owns it did not, so the pinned language version
was unreachable (opencharly/spec#296, merged `d29dc52d2810dd1b4056024a8a5598e81e65c925`,
tag `v0.2026313.48`, exports it as package `specmodule`). Composing without it, or
restating it here, were the two wrong answers.

Prose that named the retired mechanism is corrected in the same change (the
`base ++ plugin` spelling in core's comments, and the two skill references that
described the runtime concatenation), and one separable finding is filed
(#1113 — six comments still point at the pre-2026.210 `sdk/schema`
paths).

Refs opencharly/spec#294 (unit 2, the consumer leg).

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

* chore(deps): align the tools modules with charly's spec pin

Bumping charly/go.mod to spec v0.2026313.48 left the three lockstep module trees on
v0.2026309.1917, and this repo's own gate (tools/gomod-canonical,
TestContractPinsMatchShared) is what noticed: every lockstep module must carry the
shared pins. The mods-tidy task adopts them: the three tools/*/go.mod files and their
lockfiles.

Found by CI's go job on the previous head, not by any run of mine. The local gate I ran
was go test ./... inside charly/, which never enters tools/*/ (each is its own module);
the repo's task surface was the missing control, and the gate that names it was right.

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

---------

Co-authored-by: aitrawog <[email protected]>
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