Repository navigation
feat(cuemodule): export the CUE module declaration to Go consumers - #296
Conversation
`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)
Review — BLOCKHead SHA: Change class: Go library addition ( Blocks
Notes (non-blocking)
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
… 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)
|
STATUS — round 1 BLOCK addressed at head 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 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: Agent: charly (DeepSeek Harness) Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) |
Review — BLOCKHead SHA: Change class: Go library addition ( Blocks
Comments considered
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
|
STATUS — round 2 BLOCK (A1, body-only) addressed at the SAME head The finding, fixed. The changed-files table's 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) |
Review — PASSHead SHA: Security screen: PASS (T1–T4: additive Go package embedding an in-repo file; no secrets, egress, guardrail weakening, or injected directives). Comment dispositions:
Non-blocking notes (rulebook-gap / precision): (1) The root Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…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]>
Summary
schema.FScarries the schema package, but not the CUE module that owns it.cue.mod/module.cuesits at this module's root — outsideschema/'s//go:embed *.cuetree — so a Go consumer that embeds the schema and composes it as a module instance cannot read the one fact it cannot derive: the pinnedlanguage.versionthat governs evaluation.This adds
package specmoduleat this module's root (github.com/opencharly/spec): one embedded file,specmodule.FS, carryingcue.mod/module.cueat the path CUE's loader requires. A consumer overlays it at<root>/cue.mod/module.cue, overlaysschema.FSat<root>/schema/, and loads./schemafrom there.Why this unit exists at all — the two alternatives, and why each is wrong:
v0.16.1): a second home for a declaration only this module may make.cue_module_test.gogates the consumer-visible facts: exactly one file at the loader-required path, parseable as a module file, declaring this module path andlanguage.versionv0.16.1.ConcatSchemais 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.cue_module.gospecmodule,specmodule.FS=//go:embed cue.mod/module.cuecue_module_test.golanguage.versionschema/README.mdConcatSchemareturns rather than who compiles it; the package-form section names both trees a composing consumer needsREADME.mdschema/row namesspecmodule.FS; theschemaconcat/row states its remaining roleHow tested
The module's Go gates, on the committed tree:
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.2goes RED on the file's real declaration, then GREEN again once restored:golangci-lintis CI-only in this repo and is not installed on the host this ran on, so the lint half of.github/workflows/ci.ymlis 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
/charly-internals:go(the SDD pipeline),/charly-internals:plugin(the per-plugin CUE-schema contract this module's schema serves),/charly-internals:git-workflow.schema.FSalone. It is fixed here (the export) rather than routed around; nothing else surfaced, and nothing needed filing.specmodule.FSembeds the existingcue.mod/module.cuein place, so the module path and the language version still have exactly one home.git status --shortwas read before staging; one commit, no amend, no force-push, no direct push tomain.specmodule.FS, not a fixture.opencharly/specdeclares nodisposable: truetarget and no per-repo candy gate (its AGENTS.md: the merge gate is the org-widecharly/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
github.com/opencharly/spec, packagespecmodule) and two documentation corrections. No existing package, type, function or schema file changes, so every current consumer compiles unchanged.schema,spec,schemaconcator 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)