Skip to content

schemaparams: a schema that imports the spec CUE module cannot be projected to Go — two independent failures, which block every per-consumer import conversion #298

Closed

Description

@aitrawog

What

Measured on the exact schema text of plugin-tunnel, the composition the campaign needed is now
real on both sides of the contract — and the Go projection in this repo cannot project that
same schema. Two independent failures, both measured, both below.

The composition works. A plugin's served schema may now carry
import "github.com/opencharly/spec/schema" and compose, with no cue.mod/module.cue at all,
because schemacompose's derived declaration already names the spec dependency and the pinned
language version (spec#297):

===== import (schema imports "github.com/opencharly/spec/schema", no cue.mod shipped)
ServedSchema: err=<nil>            # serve side, sdk.BuildCapabilities' gate
ServedText:   err=<nil>            # host side, charly's registerPluginUnitSchema
serve==host (#TunnelInput): true
serve top-level defs: [#TunnelInput]

The host half is the one that looked impossible — the wire carries schema_cue as text with no
module field — and it is not: ServedText composes the same package-less body under the same
derived declaration, so the import resolves on the host too. #TunnelInput composed from the twin
shape and from the import shape compare Equals, and eleven authored inputs (three accepted,
eight rejected for an empty method, a missing method, a string port, an unknown key at each
of the three levels, a string expect, a string public) give the identical verdict on both sides.

The projection fails (measured)

F1 — nothing resolves the import for the pinned cue. schemaparams writes its own scratch
module with no deps and shells out to the pinned CLI. CUE's CLI resolves modules only through an
OCI registry, and github.com/opencharly/spec is published to none:

$ cue mod tidy            # in a module declaring deps: {"github.com/opencharly/spec@v0": v: "v0.2026313.453"}
failed to resolve "github.com/opencharly/spec/schema": cannot fetch github.com/opencharly/[email protected]:
  module github.com/opencharly/[email protected]: module not found

# spec/schemaparams.GenerateWithCue(…, "cases/mod/schema", "params", cueV0.16.1):
github.com/opencharly/spec/schemaparams/codegen@v0: import failed: cannot find package
  "github.com/opencharly/spec/schema": cannot find module providing package
  "github.com/opencharly/spec/schema":
    ./params.cue:35:8

F2 — even resolved, the emitted Go names a type that does not exist. Placing spec/schema's
files inside the scratch module (module path github.com/opencharly/spec) DOES resolve the import,
and cue exp gengotypes then emits:

import (
	"github.com/opencharly/spec/schema"
)
…
	Config schema.TunnelConfig `json:"config,omitempty"`

github.com/opencharly/spec/schema is a real Go package, but it exports only FS:

$ go build ./f2        # var _ schema.TunnelConfig
f2/f2.go:6:14: undefined: schema.TunnelConfig

The shape's Go home is github.com/opencharly/spec/spec (the package's own doc says so), so the
CUE import path and the Go import path disagree, and DESIGN.md D-GEN-4's single permitted rewrite —
stripping a module path suffix — does not close that gap (and does not even arise here: an
intra-module import carries no @v0).

Mechanism

cue exp gengotypes runs in one module and types that module's definitions; the only module source
the CLI can fetch is an OCI registry (mod/modregistry.NewClient(registry ociregistry.Interface)),
while the offline resolution schemacompose relies on — a custom load.Config.Registry serving the
embedded spec module from a content-named directory — is reachable only from the CUE Go API.
So the serve side, the host side and the projection cannot share one resolution mechanism as long as
the projection shells out.

Missed control

opencharly/opencharly#950 records the sequence and states that "the same text feeds the Go
generation" as a fact of the same shape as the compile. After spec#294/sdk#490/sdk#491/
charly#1115 landed, nobody re-measured the projection. It is worth noting the per-PR backstop does
hold: opencharly/.github's candy-validate runs the projection recipe for every candy/*/schema,
so a consumer PR that adds the import is red at the required validate / validate check rather than
green and broken. Measured both directions with that step's exact shell: baseline schema rc=0,
import schema rc=1.

Blast radius

Every remaining per-consumer unit in #950: plugin-vision (6 names), plugin-pipeline (6),
plugin-egress (2), plugin-tunnel (2) — 26 census rows over 10 names. None can retire its
restatement until a plugin's Go params can be projected from a schema that imports this module.
None of the four repos ships a CUE module today (re-measured); plugin-tunnel has no parity test to
retire, the other three have one each and two for egress, as #950 says.

Root fix — a decision, not a patch

Two directions, each with a cost this issue does not choose:

  1. cue-gen: generate Go from the design grammar with charly's own CUE-API generator, retiring gengotypes and the hand mirrors #271 — charly's own CUE-API generator replaces cue exp gengotypes for these
    shapes. An in-process loader can serve this module exactly as schemacompose already does, and
    it can also name the Go type by the package that owns it.
  2. Align the CUE package path with the Go package that owns the shapes — a CUE schema package
    whose import path is github.com/opencharly/spec/spec, so the emitted
    schema.TunnelConfig becomes spec.TunnelConfig and the import compiles as-is.

Both change this repo, so the consumer units stay blocked until one lands. This issue carries the
measurement, not the choice.

Agent: schema-unit-1

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

Activity

  1. aitrawog commented on Nov 9, 2026

    @aitrawog
    ContributorAuthor

    STATUS

    Direction 1 landed in #299 (head 47738b7067571a475f304f9072a29d1470dc6c01). schemacompose exports ComposeText so the projection composes through the ONE offline registry; the generator runs in-process (a faithful port of cue exp gengotypes v0.16.1) and emits an imported definition through github.com/opencharly/spec/spec, the package that owns the shapes.

    Proved on the shape-B plugin-tunnel fixture (import, twins deleted): the generated params compile (go build ./params rc=0, go vet ./params rc=0). F1 is closed (the import resolves offline) and F2 is closed (the emitted Go names the owning package). A schema without an import regenerates byte-identically to the pinned CLI, and the committed spec/cue_types_gen.go is a no-op. This PR closes the issue on merge. Next update when the validator returns.

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

  2. added a commit that references this issue on Nov 9, 2026
    9428017
  3. aitrawog commented on Nov 9, 2026

    @aitrawog
    ContributorAuthor

    RESOLVED

    Merged as #299 — squash commit 9428017f5b182ccfd3f87efd92a3456b7158a797, tag v0.2026313.1428. schemaparams now generates params in-process over schemacompose's offline resolution, and an imported definition is emitted through github.com/opencharly/spec/spec; the plugin-tunnel shape-B params compile (go build rc=0). Closing as resolved.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions