Repository navigation
fix(schemagen): emit a map for a pattern-keyed collection - #360
Conversation
`#CandyUse.Secret` is `{[#Name]: #SecretUse}` in CUE — a collection of `{src, dst,
optional}` — and it generated as `struct {}` in Go, so no caller could read which file to
deliver. #271.
## Root cause: the branch that collapses
`schemaparams/gotypes.go`, `emitStructKind`:
if elem := val.LookupPath(cue.MakePath(cue.AnyString)); elem.Err() == nil {
g.def.printf("map[string]")
…
}
…
g.def.printf("struct {\n")
`cue.AnyString` is the UNCONSTRAINED label `_`, so that lookup selects only the ellipsis
`[string]: T`. A universal pattern constraint — `[#Word]: T`, or `[("nvidia"|"amd"|"intel")]: T`
— does not resolve through it and fell through to `g.def.printf("struct {\n")`, which closed
immediately as `struct {}` because a pattern contributes no FIELD.
Measured on three fixtures (`schemacompose` + the API the branch uses):
#A: {[#Word]: {count: int}} AnyString lookup err = #A: field not found: [_] -> struct {}
#D: {[string]: int} AnyString lookup err = <nil> -> map[string]int64
#E: {[("x" | "y")]: {}} AnyString lookup err = #E: field not found: [_] -> struct {}
The information is not lost at that point; it is simply not asked for. `cue.Patterns` is the
API that exposes universal pattern constraints (`Selector.Pattern()` the constraint itself),
and it is now asked there: a struct whose ONLY constraint is a universal pattern emits
`map[string]<elem>`.
The Go key is `string`, and that is a property of what is available rather than a compromise:
`Selector.Pattern()` yields the CONSTRAINT (`=~"^[a-z][a-z0-9_]*$"`, or `"x" | "y"`), a
string-kind value, so the name of the definition whose regex it is does not survive to be
emitted; and Go has no sum type for a key at all. The set stays closed where it already lives
— the key type's `Valid()` (#Word, #EnvName, #Name), which every consumer of a vocabulary in
this module already calls. Typing the key here would mean recovering a definition name from a
constraint (a second authority over naming) and would buy a compile-time refusal only for a
constant key, which a value read from config never is. A struct that MIXES a pattern with named
fields keeps the struct branch, so nothing is silently dropped.
## Census of what moved — measured, before and after
94 depth-1 empty struct FIELDS before, 54 after
CandyNeed 21, CandyUse 21, Need 21, Use 21, Provide 9, DriverRow.Grant 1 (all 94 map-shaped)
`map[string]…` 194 -> 288: every one of those 94 fields became a real map
the remaining 54 are the map ELEMENT types (`map[string]struct{}` for an entry that carries
nothing, e.g. `env`), which is the correct shape and not a collapse
9 types that are themselves empty (`DeployNodeDelDispatchReply`, …) do not move
ZERO collateral: every converted field was pattern-keyed; no ellipsis site changed.
Large in line count, completely isolated in surface: six types, every one becomes a real map.
`spec.CandyUse.Secret` now reads:
Secret map[string]struct {
Src AbsPath
Dst AbsPath
Optional bool
}
## The oracle: not weakened, and it never had jurisdiction
`TestGenerateNoImportIsByteIdenticalToGengotypes` pins this generator to the pinned
`cue exp gengotypes`. Three measured facts:
1. The pinned CLI AGREES with the old behaviour — `cue v0.16.1 exp gengotypes` on the same
fixture emits `type Inline struct {}` for a pattern-keyed collection.
2. The branch that does it is upstream, at
`cuelang.org/[email protected]/internal/encoding/gotypes/generate.go:387`, under `internal/`: no
external module can import it, let alone patch it. That is why the divergence is ours.
3. The oracle's fixture (`schemaparams/testdata/twin/schema/`, one file) contains NO
pattern-keyed collection, so it makes no claim about this shape and stays byte-for-byte
true. The oracle does not need an exception; it needs a test of a case it never covered.
`TestThePinnedCLIStillCollapsesPatternMaps` measures the divergence against the pinned binary
(and skips visibly when it cannot be provisioned — live or skip, never fake), so if upstream
ever emits a map the test fails and the documented divergence is retired rather than drifting.
## R7: both halves, on the PAYLOAD
A test that greps for `map[` proves the container changed; the defect was the LOST payload, so
the assertion is that the element's own field is there with its value type.
PLANTED (pattern branch disabled — the pre-#271 behaviour):
--- FAIL: TestPatternKeyedCollectionIsAMapCarryingItsPayload
`#Inline: {[#Word]: {count: int}}` did not generate a map
(plus the definition-reference and disjunction-key subtests)
RESTORED:
--- PASS (all five subtests: payload, named reference, disjunction key, ellipsis
unchanged, mixed-struct guard)
## Cycle check (condition 2)
No cycle, and the reason is structural rather than lucky: the key's Go type is `string` for
every pattern shape, so the key side emits no reference at all and can never need `#Word`'s
emission. The VALUE side goes through the existing `emitType`, which already resolves
references depth-first and turns a still-`inProgress` definition into a nillable pointer, so
the reference case (`#Refd: {[#Word]: #Entry}` -> `map[string]Entry`) reuses that machinery
unchanged. That is why the fix is four pieces and not five.
Closes #271
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: code (generator) + test + regenerated Go, in the Blocks
Comment intakeNo comments in the thread — nothing to disposition. Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Second review round on the map branch (#360). Addresses all four findings. ## 1. The pinned-CLI test skipped, it did not fail (reviewer's fix, kept here) `TestThePinnedCLIStillCollapsesPatternMaps` called `t.Fatalf` when the pinned binary could not be provisioned, while its own doc comment said it skipped. The comment was a guarantee the code did not implement -- the `spec#353` `[^$]` defect in a third shape. The fix (from the review) is in this commit: `t.Skip` with the reason, the same way the oracle test skips. ## 2. The 16 `map[string]any /* TODO: IncompleteKind: _|_ */` sites The map branch turned every pattern-keyed collection into a map, which surfaced what the element type really is. For the four LEASABLE types (cpu, memory, storage, mount) it was BOTTOM: $ probe: patternMapElem(#CandyNeed) per field #CandyNeed.cpu?: patternMapElem=true elemKind=_|_ elemErr=exclusive: field not allowed #CandyNeed.memory?: patternMapElem=true elemKind=_|_ elemErr=exclusive: field not allowed #CandyNeed.storage?: patternMapElem=true elemKind=_|_ elemErr=exclusive: field not allowed #CandyNeed.mount?: patternMapElem=true elemKind=_|_ elemErr=exclusive: field not allowed Cause, isolated: #Closed: {count!: #Count} // a definition is CLOSED #C: #Closed & {exclusive: *false | bool} -> #C.exclusive: field not allowed (bottom) #Open: {count!: #Count, ...} // a trailing ellipsis opens it #B: #Open & {exclusive: *false | bool} -> count!: int&>0, exclusive: false (ok) `#Need`/`#Use` merge `#LeaseFields` into the need shape, and DESIGN makes that legal by writing the embedding with the postfix `...` (explicit open) -- refused by the pinned CUE v0.16.1 without @experiment(explicitopen). With a plain embedding the merge is a BOTTOM entry, which the generator can only spell `map[string]any`: the payload lost again, one level down, in a new spelling. It also means the shape can never carry what the design declares. Fix: the three LEASABLE shapes declare the lease field themselves -- `#CountNeed`/`#SizeNeed`/`#MountNeed` carry `exclusive: *false | bool`. That is the CUE-v0.16.1 spelling of DESIGN's net shape: `#Need`/`#Use` still add the field only for a `lease: true` row, and these four rows are exactly the leasable ones. Opening them with `...` instead would have made the element an ellipsis-keyed map -- filed as #362, because an OPEN struct is emitted as `map[string]any` too. TODO sites: 16 -> 0 CandyNeed.Cpu -> map[string]struct { Count Count; Exclusive bool } ## 3. Coverage for the shape this PR created `pattern_map_test.go` gains the required-field cases that produced the 16: an inline element with a required field (`#ReqInline: {[#Word]: {count!: int}}` -> `map[string]struct{ Count int64 }`) and a definition reference with one (`#ReqRef: {[#Word]: #Strict}` -> `map[string]Strict`), both asserted on the PAYLOAD, not on `map[`. `spec/leasable_need_payload_test.go` (new) asserts on the GENERATED types that every leasable need entry of `CandyNeed`/`CandyUse`/`Need`/`Use` carries its payload field (`Count`/`Size`/ `Host`) and `Exclusive` -- i.e. that a CPU need says how many, not merely that it is needed. ## 4. The census, corrected and grepped from the final tree Against `origin/main` (measured per generated field, not asserted): | outcome | count | what it means | |---|---|---| | `struct{}` -> `map[string]struct{…}` | 93 | the fix working, payload carried | | `struct{}` -> `map[string]string` | 1 | `DriverRow.Grant`, a string-word element: typed | | `struct{}` -> `map[string]any` | **0** | after this round's schema fix (16 before it) | | unchanged | 166 fields + 9 empty types | no move | plus 3 definitions gain `Exclusive bool` (`CountNeed`, `SizeNeed`, `MountNeed`). `spec/cue_types_gen.go`: 238 insertions, 109 deletions. `map[string]any` field occurrences are unchanged (32 before, 32 after; one more PROSE occurrence comes from the new schema comment). ## R7, both halves PLANTED (the lease field removed from the three leasable shapes): --- FAIL: TestLeasableNeedElementCarriesItsPayload the map's element is interface {}, not a struct — the payload is lost (map[string]any is the same defect as struct{}) --- FAIL: TestLeasableNeedElementCarriesTheLeaseField RESTORED: --- PASS both and the generator side, planted (the pattern branch disabled) then restored: --- FAIL: `#Inline: {[#Word]: {count: int}}` did not generate a map -> --- PASS Closes #271 Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: code (schemaparams generator) + schema + regenerated Go + tests, in the Blocks
Comment intake
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…eview round) The review read the payload table's "string" for .Size beside "spec.Count" for .Count as an inconsistency that would fail. It does not: #Size is declared @go(-) and emits `type Size = string`, an ALIAS, while #Count emits a real `type Count int64`. reflect.Type.String() on an alias field renders the underlying type, so "string" is correct. But the reviewer's CONFUSION is the defect -- a reader could not tell whether "string" was deliberate or a bug. Three things now make it a measurement rather than a claim: - a comment at the table saying exactly why, and warning that "fixing" it to "spec.Size" would fail; - TestSizeIsAnAliasAndCountIsNot, which asserts spec.Size renders as "string" AND spec.Count as "Count", so a future schema change that turns the alias into a defined type names itself; - the same test's failure message says which table entry to update. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: code ( Security screen: PASS — no scope mismatch, no secrets/egress, no weakened gate, no supply-chain change; the generator fix strengthens correctness rather than loosening a guardrail. Blocks
Comment intake
Non-blocking note (rulebook gap)
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…iew round)
The claim was 'every leasable entry carries its payload'; the table asserted it for CandyNeed and
CandyUse on all four fields but for Need and Use on Cpu ONLY -- ten of sixteen. Adding the six missing
rows, and proving the additions can fail: removing exclusive: from #SizeNeed makes TestLeasableNeed-
ElementCarriesItsPayload fail with 'the map's element is interface {}, not a struct -- the payload is
lost', and restoring it passes.
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: code ( Security screen: PASS — no scope mismatch, no secrets/egress, no weakened guardrail, no supply-chain change. Blocks
Comment intake
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
|
STATUS — the stale fragment is gone, and the root cause is my cleanup script, not the content RCA, since this is the second round on the same paragraph. Round 5 of this PR corrected the body with a Python script that cut from the
Missed control: I validated with The root fix is a check I should have run and did not: after any scripted body edit, grep the result for the string the edit was meant to REMOVE. Fixed now, and verified by that same grep: $ grep -c 'no other site moves\|payload assertion (fails today)' /tmp/goal/body-271.md
0The paragraph reads in full: "Six lines, three pairs, and no type gains or loses a definition — the pattern branch now resolves a key's referenced def before the consumer that used to come first, so emission order changes and those three declarations land earlier. The declarations are byte-identical on both sides; only their position moves." And the Files-changed table has exactly its five rows, once.
Agent: lead |
Review — PASSHead SHA: Security screen: PASS — no scope mismatch, no secrets/egress, no weakened guardrail, no supply-chain change; the generator fix strengthens correctness. Comment intake (all re-derived against the CURRENT diff/body):
Non-blocking note (rulebook gap): the doc comment above Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…ze (#551) * feat(deploykit): deliver a `use: secret:` entry as a FILE step at realize P07 unit 2b. DESIGN.md:2983 — "there is no `get`: a value reaches a consumer as a `secret:` need, never as text" — and D-SEC-1, DESIGN.md:2511 — "Secrets come only from the configured backend; they never enter the store, artifacts, labels, IR, state or output." The authored shape (`#SecretUse`: `src` a host path, `dst` a venue path, `optional`) is a FILE→FILE delivery, and the IR already has the step that performs one: `spec.FileStep{Source, Dest, Mode}` is realized by `kit.walkFile`, which reads `Source` on the OPERATOR host at realize and `DeployExecutor.PutFile`s the bytes into the venue. The step carries the two PATHS and a mode; the value never enters the plan, the ledger, a log line or an artifact, so D-SEC-1 holds by construction rather than by care. One emitter serves every substrate: `PutFile` is one method of the substrate-neutral `DeployExecutor`, and every deploy target is out-of-process over that same walk — no per-substrate code, no per-substrate shape. THIS IS THE FIRST PRODUCER OF A FileStep IN THE TREE. Until now the only non-test construction was the wire decoder (`spec/install_step_view.go:200`); `git -C sdk grep -c 'FileStep{' origin/main -- '*.go'` is 0, charly's hits are all `*_test.go`, and no checked-out plugin emits one. So `kit.walkFile` has had no compiled-plan caller before this change, which is why the wiring is proved end-to-end below rather than only at the compiler. ## The four decisions, implemented 1. `optional` is decided at COMPILE time, on the operator host where the source actually lives: an optional entry whose source is unreadable is skipped (DESIGN.md:735 — "the key is readable when the host had one"); a REQUIRED entry whose source is unreadable is an error naming the candy and the entry, so a typo cannot silently deliver nothing. THE RESIDUAL RACE IS NAMED IN THE CODE: the source is stat'ed at compile and read at realize, so an optional entry whose file disappears in between fails at realize instead of being skipped. Closing it needs an `optional` field on the File step, which is a wire-shape change and a separate unit. 2. Sorted by entry NAME, so a plan is reproducible compile to compile. 3. Mode `0o600` — a secret delivered world-readable is not delivered. 4. Position: slot 2.8 in `BuildDeployPlan`, AFTER `extract` and BEFORE the candy's own op steps, so a task that reads `dst` finds the file already in place. ## The accessor, and why it is not a reader-interface widening `deploykit.specCandyAdapter` is the ONE production implementation of `spec.CandyReader` (charly/layers.go wraps every candy through `deploykit.NewSpecCandyModel`), and it already holds the raw `spec.CandyModel`. So the authored `use:` block is reached by one method on that one type — `CandyUse()` — and a CandyModel that does not carry the authored model simply has no `use:` entries to compile. `spec.CandyReader` is unchanged. ## Pin `github.com/opencharly/spec` v0.2026320.2307 -> v0.2026321.1215 (the merge that made `spec.CandyUse.Secret` a real map, opencharly/spec#360). Producer first, consumer second. ## R7, both halves, twice PLANTED A (the CompileSecretSteps call removed from BuildDeployPlan): --- FAIL: TestBuildDeployPlan_CarriesTheSecretDeliveryStep the plan carries 0 file steps, want 1 — the secret delivery never reached the plan PLANTED B (the name sort reversed): --- FAIL: TestCompileSecretSteps_EmitsOneFileStepPerEntrySorted steps are not in entry-NAME order: "/run/lab/zzz" then "/run/lab/aaa" RESTORED: --- PASS all five (per-entry sorted steps with mode 0600; optional-and-missing skips; required-and-missing errors naming candy+entry; entry without `dst` errors; and the plan-level wiring plus its before-the-op-steps position) ## Not in this change, deliberately `deploykit.InjectSecretsIntoPlans` (the value-into-`OpStep.Op.Env` mechanism) is untouched: its only caller is the out-of-tree `plugin-pod` overlay, which switches to the steps compiled here in its own release. Deleting it in this diff would break that plugin at its next pin bump, and the cutover is producer-first. Gates on the final tree: go build ./... rc=0, go vet ./... rc=0, go test ./... rc=0 with 0 failures across 21 packages, the cross-compile matrix (linux/amd64, arm64, arm, 386) all rc=0, golangci-lint 0 issues, gofmt -l empty. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * feat(kit,deploykit): prove a compiled secret step lands the file, and only there Second review round on #551. The claim "one compiled step serves local, pod and vm" was written against a plan-level proof; this round makes it a realize proof, and closes the silent-skip hole in the accessor. ## The realize proof (the review's block 2) `walkFile` had never been driven by a compiled plan in this tree — this unit is the first producer of a `spec.FileStep`, and the only other construction anywhere is the wire decoder. So the claim was unproven at exactly the step that matters. `kit/secret_delivery_realize_test.go` (new, package kit_test) goes the whole way: a temp host file with known bytes, `deploykit.CompileSecretSteps`, `spec.StepsToView`, `kit.WalkPlans` against a recording `DeployExecutor`, and then TWO assertions: 1. the bytes arrive at `Dest` with mode `0600`, and nothing else was written; 2. **the bytes appear NOWHERE ELSE** — not in the plan, not in the serialized `InstallPlanView` that a ledger or a log would record. That is the D-SEC-1 assertion: the delivery is "a value reaches its consumer as a file, never as text", and (1) alone would pass on a plan that also carried the value in an env var. Both halves, planted and restored: PLANTED A (the step's Source corrupted — the walk cannot read it): --- FAIL: TestACompiledSecretStepLandsTheFileAndOnlyThere WalkPlans: walk step "File" (candy=lab-signing): read file source /nonexistent/planted: open /nonexistent/planted: no such file or directory PLANTED B (the value smuggled into an Op step's Env): --- FAIL: TestACompiledSecretStepLandsTheFileAndOnlyThere the secret VALUE is in the serialized plan — D-SEC-1: it never enters the IR, a label or a log RESTORED: --- PASS both `TestTheSecretStepRefusesAnUnreadableSource` pins the negative direction the race named in spec#363 creates: the source exists at compile (so the compile accepts a required entry) and is removed before the walk reads it — the walk must FAIL, not land nothing and report success. ## The accessor: a silent skip became a named error (the review's non-blocking note) `CompileSecretSteps` reached the authored `use:` block through a structural assertion on `secretUseCarrier`, and a CandyModel without it silently had no entries — the worst possible silent loss, because the deployment starts without the key it needs and reports success. Now: - `ErrUseBlockUnreachable` is returned, naming the offending Go type and pointing at `deploykit.NewSpecCandyModel`; the error wraps, so `errors.Is` classifies it. - `var _ secretUseCarrier = (*specCandyAdapter)(nil)` pins the one production implementation at compile time. - `TestCompileSecretSteps_UnreachableUseBlockIsAnError` pins the choice with a model that has every reader method and no accessor (`notACarrier{ Cmd CandyModel }` embeds the interface). - The doc records why a miss cannot happen on the production path (charly/layers.go is the scanner's only construction path, and the golden tool uses the same constructor) and what would break it (a caller that builds its own CandyModel). ## PR body corrections (for the next push) `## Filed issues` is `spec#363` (the `optional` gap THIS diff surfaced) and `sdk#552` (the `InjectSecretsIntoPlans` D-SEC-1 remainder, filed by the reviewer's finding). `spec#362` and `spec#348` are removed: both are real, but neither was surfaced by this diff, and listing them claims a provenance the section does not have. Gates on the final tree: go build ./... rc=0, go vet ./... rc=0, go test ./... -count=1 rc=0 with 0 failures across 21 packages, the cross-compile matrix (linux/amd64, arm64, arm, 386) all rc=0, golangci-lint 0 issues, gofmt -l empty. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated) --------- Co-authored-by: aitrawog <dsh-opencharly@local>
Summary
The generator asked the wrong question, and 94 fields paid for it.
#A: {[#Word]: {count: int}}generatedtype A struct {}— the payload gone. So did every regex-keyed and every literal-disjunction-keyed collection in the schema, which is whyspec#271exists. The branch is four lines in our ownschemaparams/gotypes.go:cue.AnyStringis the unconstrained label_, so only[string]: Tsatisfies the lookup. A regex key and a literal-disjunction key both fail it, fall through to the struct branch, and close immediately — because a pattern contributes no FIELD.The information is not lost at that point. It is simply not asked for.
The pattern IS reachable — through the resolved syntax, where
[#Word]arrives as[WORD.#x]inside alet WORD = {#x: =~"^[a-z][a-z0-9_]*$"}binding. So the fix is four pieces: a pattern detector overval.Syntax(), a key-type resolver, an emit path, and a policy for a disjunction key.The decision, and why
map[string]for a disjunction key:struct{}is strictly worse than either alternative because it loses the payload; Go has no sum type for a key, so a typed disjunction key would need a second authority enforcing the closed set at every call site; and the closure already lives in#Word'sValid(), which every vocabulary consumer already calls. Typing it buys nothing a runtimeValid()does not, because a key read from config is never a constant. One authority, per R2. For a regex key the same reasoning applies for a different reason:Selector.Pattern()yields the constraint value, not the definition's name, so the name does not survive to be emitted — and the comment at the emit site says so.What it moves, measured from the final tree — three outcomes, not one:
struct{}→map[string]struct{…}struct{}→map[string]stringDriverRow.Grant, a string-word element: typedstruct{}→map[string]anyThe 16 that were
map[string]anyare why this PR has a schema half. The first revision of the generator fix turned the four leasable entries —cpu,memory,storage,mount— intomap[string]any/* TODO: IncompleteKind: _|_ */, which is the same payload loss wearing a different spelling, one level down. The measured cause is not the branch:A definition is CLOSED, and
#Need/#Usemerge#LeaseFieldsinto it. DESIGN makes that legal with the postfix...at the EMBEDDING site — the@experiment(explicitopen)form the pinned CUE v0.16.1 refuses. With a plain embedding the element is bottom.So the three leasable shapes now declare the lease field themselves —
#CountNeed/#SizeNeed/#MountNeedcarryexclusive: *false | bool, which is the CUE-v0.16.1 spelling of DESIGN's net shape. The field is still added only for alease: truerow, and those four rows are exactly the leasable ones. The alternative — opening the defs with...— is whatspec#362records: an OPEN CUE struct is emitted asmap[string]any, losing every field, because theAnyStringlookup cannot tell an ellipsis-keyed map from an open struct. It is #271's sibling, not its remainder, and it is written down rather than worked around invisibly.Large in line count, completely isolated in surface: six types, every one becomes a real map carrying its payload, and no site moves to
any.And the payoff — the field that blocked a unit of work:
How tested
All six module gates, on the committed tree, run fresh:
The slowest-path watch, measured rather than assumed: the slowest package is
spec/schemaat 29.693s; the slowest single test isTestInjectedRowReachesTheDerivedListat 9.69s (the S3 mutation half, which recompiles the schema once per table). Nothing approaches Go's ten-minute package default, and no timeout was raised or hidden.The 16-site regression has its OWN coverage, on the payload — all sixteen
spec/leasable_need_payload_test.go(new) asserts on the GENERATED types that all four leasable fields (Cpu,Memory,Storage,Mount) carry their payload AND their lease field on all four types (CandyNeed,CandyUse,Need,Use) — sixteen rows, not the first four — a CPU need says how many, not merely that it is needed. It also carriesTestSizeIsAnAliasAndCountIsNot, which pins why.Sizerenders"string"while.Countrenders"spec.Count":#Sizeemitstype Size = string(an alias) and#Counta definedtype Count int64, so the bare"string"is deliberate and a reader must not "fix" it. The generator fixture gains the two required-field cases that produced the 16:#ReqInline: {[#Word]: {count!: int}}→map[string]struct{ Count int64 }and#ReqRef: {[#Word]: #Strict}→map[string]Strict.R7 — the assertion is the PAYLOAD, not the container
A test that greps for
map[proves the container changed. A map of nothing is the same defect wearing a different word. So the assertion isCount int64inside the emitted block:The oracle: untouched, and the divergence is now MEASURED
TestGenerateNoImportIsByteIdenticalToGengotypesis unchanged and still byte-for-byte true — its fixture (testdata/twin/schema/tunnel.cue) contains no pattern-keyed collection:It has been pinning byte-identity over a surface that excludes this shape. So it does not need weakening; it never had jurisdiction here.
The pinned CLI agrees with the defect, measured on the same fixture with the same binary the oracle provisions (
cue v0.16.1, matchingcuetoolchain/cuetoolchain.go:37):The branch is upstream too —
cuelang.org/[email protected]/internal/encoding/gotypes/generate.go:387, the identicalLookupPath(cue.MakePath(cue.AnyString))test, underinternal/and therefore unimportable and unpatchable from outside. That is precisely whyspec#271exists ("retiring gengotypes and the hand mirrors").TestThePinnedCLIStillCollapsesPatternMapsruns that CLI on the same fixture and asserts it still emitstype Inline struct {}, so the divergence cannot drift into an unstated one — the day upstream fixes it, that test fails and tells us to retire it. It skips visibly when the pinned binary cannot be provisioned. Live or skip, never fake.No cycle, structurally rather than luckily
The key's Go type is
stringfor every pattern shape, so the key side emits no reference at all and can never need#Word's emission. The value side reusesemitType's existing depth-first reference handling, which already turns a still-inProgressdef into a nillable pointer — so#Refd: {[#Word]: #Entry}→map[string]Entryworks through machinery that predates this change. Four pieces, not five.R10 honesty, premise and exit status pasted
opencharly/specis the contract module: nodisposable:target, no service, no binary. Its gate is the module suite plus lint, both pasted. Thegrepexits 1 — no match is not a success.Rulebook compliance
/charly-internals:go(SDD: Go is generated, never hand-transcribed — and a generator that loses data is an SDD defect).spec.CandyUse.Secretbeingstruct{}, which blocked a named unit of work. The RCA names the mechanism (cue.AnyStringis unconstrained), the missed control (no fixture ever carried a pattern-keyed collection, so every gate passed over the gap), the blast radius (94 fields across six types) and the root fix (the branch, not the callers).#Word'sValid(). Neither the key type nor the caller re-states it.[string]to dodge the generator.origin/main; the two other worktrees untouched.Change classification
Kind: a generator fix in
spec/schemaparamsplus the regeneratedspec/cue_types_gen.go.Breaking change + rollback: three CUE definitions gain a defaulted field (
exclusive: *false | bool), which is additive — an authoredcpu:need that says nothing about exclusivity still validates, defaulting tofalse. The Go API of six generated types changes —Need,Use,Provide,CandyNeed,CandyUseandDriverRowgain real maps where they carriedstruct{}, so any caller that read those fields as empty structs sees a different type. Nothing in the org reads them today (git -C <repo> grep 'SecretUse' origin/mainfinds three files inspeconly, andNeed.Env/.Gpu/.Cpuhad no entry payload to read), which is why this is additive in practice. Rollback reverts the branch ingotypes.goand regenerates; the 94 fields return tostruct{}and the payload is lost again.Filed issues
schemagen: an OPEN CUE struct ({a!: int, ...}) is emitted as map[string]any, losing every field. Measured; it is cue-gen: generate Go from the design grammar with charly's own CUE-API generator, retiring gengotypes and the hand mirrors #271's sibling, and it is why the leasable shapes declare the field rather than being opened with....auditkitis insdk, butaudit_appendis a host method and host core may not import sdk.Closes #271
Files changed
schema/capability.cue#CountNeed/#SizeNeed/#MountNeeddeclareexclusive: *false | bool— the CUE-v0.16.1 spelling of DESIGN's embed-site..., without which the leasable entries' elements are bottomspec/leasable_need_payload_test.goTestSizeIsAnAliasAndCountIsNotpinning the alias-vs-defined-type fact the table depends onschemaparams/gotypes.goemitStructKindpluspatternMapElem; the disjunction-key policy commentschemaparams/pattern_map_test.gospec/cue_types_gen.gomap[string]string, none becomesmap[string]any; three type declarations move position (below)Three type declarations move position in the generated file —
InitNeutral,CountandAbsPathare each removed from their old position and re-added earlier:Six lines, three pairs, and no type gains or loses a definition — the pattern branch now resolves a
key's referenced def before the consumer that used to come first, so emission order changes and those
three declarations land earlier. The declarations are byte-identical on both sides; only their
position moves.
gofmtand the generated-file reproducibility check both pass, so the order isstable rather than incidental. No site moves to
any, and nothing else in the file relocates.Agent: lead
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)