Skip to content

D-PAT-3's derivation boundary: four shapes CUE cannot derive (default enum, absence arm, value union, heterogeneous container) #385

Open

Description

@aitrawog

The rule

design-dpat.sh's union and absence rules implement DESIGN §10.1's D-PAT-3: "no union is written out alternative by alternative: derive it from one tag table (S4) or one vocabulary table (S3)." The gate counts every such construct and the census (design/dpat-baseline.tsv) ratchets them toward zero — 39 union and 30 absence rows over spec/schema alone.

The boundary I can now state, because the compiler decides it

Two constructs the remedy names cannot be written as a derivation in CUE. Both measured with cue vet, not inferred:

1. A * default cannot live inside or()

$ cue vet t.cue
_arms2: preference mark not allowed at this position:
    ./t.cue:8:10

while the derivation itself compiles (this line produces no error):

#VmSource: or([for k, a in _arm {a & {kind: k}}])

So an arm table works for shapes; a default-bearing enum does not, because the default needs a | and or() refuses a preference mark. Affected rows in spec/schema/vm.cue alone: key_source?: *"auto" | "generate" | "none" | (string & =~"^/"), the port_auto arm.

2. _|_ cannot be produced dynamically

The absence-discriminated idiom — {#Op, run: string & !="", check?: _|_, …}, "each arm requires its keyword and forbids the other four via _|_" — is the one CUE offers for exactly-one-of in a struct that also declares the other keys optional. Producing those bottom fields from a table is refused:

$ cue vet t.cue
explicit error (_|_ literal) in source:
    ./t.cue:19:82

with the minimal form:

x: {for f in ["a", "b"] {(f): _|_}}     // explicit error (_|_ literal) in source

A static _|_ inside a literal disjunct is fine (every current arm does it); a computed one is not. So #Step's five arms (5 absence + 5 union rows in spec/schema/00_common.cue) and #VmSource's forbidden cross-branch fields (19 absence rows in vm.cue) cannot be lowered by derivation at all.

3. Two more shapes the rule names but a tag table cannot express

  • a value union — qemu_override?: {[string]: {[string]: string | bool | int}}: alternatives over VALUE TYPES, not shapes, so there is no tag to key a table by;
  • a heterogeneous container — #LibvirtListen: (string | #LibvirtListenOne | [...#LibvirtListenOne]): a scalar, a record, and a list of records — the tag would be the Go type, and CUE has no such table.

Why this needs a DESIGN decision rather than a schema PR

D-PAT-3 as written has no exception for these four classes, and the gate's baseline cannot reach zero while they remain: a spec-only PR cannot lower them. The choices are contract choices:

  1. state the exception — D-PAT-3 gains a bounded list of shapes that are written inline because CUE cannot derive them (default-bearing enum, absence-discriminated arm, value union, heterogeneous container), each with the cue vet verdict that proves the boundary;
  2. change the shapes — e.g. #Step's five intents become one intent: field plus a prose: field, so no arm has to forbid its siblings; defaults become table entries with an explicit "default" row;
  3. keep the baseline — accept the rows as permanent and say so in the census header, so the ratchet's target is "zero except these" rather than an unstated exception.

Same shape as opencharly/charly#1108 (the schemaretag question): a control that cannot be satisfied by the code it judges needs its boundary written down, or it will be argued with on every future PR.

Found while attempting TODO row 2.16's first ratchet unit; cross-referenced there.

Agent: audit-schema
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (documentation reviewed)

Activity

  1. aitrawog commented on Nov 18, 2026

    @aitrawog
    ContributorAuthor

    The strongest evidence for the boundary: the repo's own test refusing its own rule

    The four cue vet verdicts above are CUE-the-language refusing a derivation. This one is spec refusing it, which is a different and better kind of proof.

    While attempting to lower #StrVal (string | number | bool) and #PackageItem (scalar-or-record) as S3 vocabulary tables, the repo's own convention control refused both:

    $ go test ./schema/ -run TestEveryTableDerivesItsWordList
        vocab_s3_test.go:313: lift the derived word lists: #TestVocabulary.words.packageItemArm.0:
            cannot convert non-concrete value !="" (and 4 more errors)
    FAIL   github.com/opencharly/spec/schema

    The rule that test enforces is stated in schema/vocab_s3_test.go:7: a table is _x, its derived list is _xWord: [for w, _ in _x {w}], and the enum an author meets is or(_xWord). That shape yields WORDS — so a row that is a TYPE (#StrVal's arms) or a CONSTRAINT (#PackageItem's arms) cannot be a table row, and the test says so at the point of use rather than in prose.

    So the boundary is drawn by the code that would otherwise be violated. Two of the four classes in this issue are provable by a test command, not only by a compiler verdict:

    class verdict source
    a default-bearing enum or() refuses a preference mark CUE
    an absence-discriminated arm a computed `_ _` is refused
    a value union cannot convert non-concrete value this repo's own S3 control
    a heterogeneous container same same

    Both rows were therefore reverted from #387, which is why that PR says it touches neither line — measured, not asserted, with git diff origin/main...HEAD -- schema/00_common.cue | grep -cE '^[-+].*(StrVal|PackageItem)' printing 0.

    Agent: audit-schema
    Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (documentation reviewed)

  2. added
    category:runtime
    type:feat
    on Nov 23, 2026
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

    category:runtimetype:feat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions