Generated code cleanup + Optional field setters - #1
Merged
Conversation
Instead of defaulting to `index_n` for the `nth` field when there is no
specified name, we now try harder to generate field names using other
information like the type of the field so for example if we have:
`foo = [keyhash, scripthash, scripthash]`
we will generate something like:
```rust
struct Foo {
keyhash: Keyhash,
scripthash: Scripthash,
scripthash2: Scripthash,
}
```
which also applies to constructors/setters or anywhere else the fields
would be referred to.
Array support is handled too so `bar = [0, [input]]` would be:
```rust
struct Bar {
inputs: Inputs,
}
```
since the 0 isn't stored as we only need it for serialization
SebastienGllmt
added a commit
that referenced
this pull request
Jul 2, 2026
known-red #1 (passthrough alias to a named map typedef -> dangling `MapU64To…` wasm type, E0425) is not shallowly fixable. Records the investigation so it isn't re-attempted: The named map has a dual representation — a transparent `pub type Mp = BTreeMap` typedef AND a wasm wrapper struct. Inlining the map in the alias base_type is load-bearing for rust/newtype/struct-field serialization, but it drops the wrapper name the wasm side needs. Keeping a `Rust(Mp)` reference instead greens array-element + map-value but regresses collmap__newtype-inner (E0599 BTreeMap::serialize) and breaks struct-field/map-key — a single shared base_type can't serve both crates (arrays work only because they're transparent on both). The real fix is the wrapper-logic unification the handoff flags as out-of-scope, or a wasm-only alias-emission path resolving a Map base_type to its Table wrapper. Keeps the 5 passthrumap__* cells skip-listed with a pointer to the ROADMAP finding; no code change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: c797e9b0-113a-41f4-851d-8c35cd522549
SebastienGllmt
added a commit
that referenced
this pull request
Jul 2, 2026
…hook scope, extension guard, axis records A fresh-context finding-by-finding verification of audit run #1's remediation ledger against HEAD (88 findings: 78 VERIFIED with 12 gates executed green and 10 mutations red — including the run's CRITICAL verify.ts harness-failure guard and the canonical key-sort flip — 8 PARTIAL, 2 MISSING; full evidence in draft/test-setup-2/91) left a narrow tail, all closed here: - ArrayOptFields irregular-decode loop (tests/core/tests.rs) was assert-free (`let _ = ...unwrap()`): decode-accepts proved nothing. Now anchors every field per iteration to what the hand-built bytes encode (incl. c: nint -10 stored as magnitude 9; e compared by bytes — no PartialEq in the default profile). - The robustness catalogs' panic silencer was a process-global no-op hook: any UNRELATED test failing concurrently during the window lost its panic diagnostics. Replaced with a thread-id-filtered hook that delegates other threads' panics to the previously-installed hook (with_thread_silenced_panics, shared by both catalog tests). - The extensionless-input fix in api::cddl_paths (README/LICENSE/ dotfiles in a multifile input dir must be skipped, not parsed) had no guard: new unit test directory_input_skips_non_cddl_files, mutation-verified red against a removed extension filter. - The four never-dispositioned architecture axes are now in living docs (do-or-decline records, per the "decided, not overlooked" contract): MSRV/OS matrix for generated code and example/-plus-docs conformance in TESTING_ROADMAP's pending decisions; the decode-side reference-codec differential (ciborium/minicbor) folded into the decorrelated-conformance-parser bullet; cbor_event version-range testing recorded beside the ledgered DoS entry it will collide with. - The orphan-fixture-dir meta-test deprioritization moved from the gitignored draft into "Explicitly not worth it"; corpus_detect.ts's blanket approximate-by-design header now names its five audited known-approximate cases so they read as decided, not overlooked. Gates: fmt, clippy (0 warnings), core_no_wasm (anchored loop executes), robustness suite, the new api unit test, project_corpus.ts PASS. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SebastienGllmt
added a commit
that referenced
this pull request
Aug 2, 2026
…he family checks claims that arrive directly The loose `<Elem>List` collision family reached its collected plain needs only through a `[+ …]` shape — as a try_from source, or as a self-named rule — so a spec with no `[+ …]` anywhere never consulted them. The table-keys member of that gap was silent rather than loud: `create_and_register_array_type`'s last-wins registration replaced an authored rule of the structural ident outright, generation exited 0, and a field of the vanished type serialized as an array of the key element. The rest are loud, but reach only the generic duplicate-ident backstop, which reports the ident rather than the claim. Detector #1 gains a direct-claim leg over every plain use it already collects (a `*`-occurrence array, a map or table keys() wrapper, a rest row's keys(), a rest tail), rejecting an incompatible claim in this family's voice; the map side gains the symmetric leg for its plain map uses and table rules. Because the swallow deletes its own evidence — once the mint has run, the overwritten rule is indistinguishable from a rule that was never there — `create_and_register_array_type` records the incompatible claim at the instant it overwrites, and the leg reads that record. A rule that IS `[* elem]` of the same element stays shared: it is that builder, and the re-mint is byte-identical. That deliberate aliasing is now pinned by a test and stated in the wasm docs beside the sole-owner table rule it mirrors. Blast radius, measured by arming the leg before shipping it: zero committed fixtures flagged (snapshot corpus green), and zero of the 150 rule idents plus 51 `@name`/`@rust_name` overrides across the four CML specs spell a structural wrapper name. One in-tree re-attribution: the plain `[* bar]` claim moves from the backstop to the per-kind leg, the same asymmetry-closing move the default rest-row leg made for `MapKToV`. The backstop keeps a pin of its own on `@used_as_elem`, whose mint has no RustType for the IR scan to see. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SebastienGllmt
pushed a commit
that referenced
this pull request
Aug 18, 2026
Generated code cleanup + Optional field setters
SebastienGllmt
added a commit
that referenced
this pull request
Aug 18, 2026
known-red #1 (passthrough alias to a named map typedef -> dangling `MapU64To…` wasm type, E0425) is not shallowly fixable. Records the investigation so it isn't re-attempted: The named map has a dual representation — a transparent `pub type Mp = BTreeMap` typedef AND a wasm wrapper struct. Inlining the map in the alias base_type is load-bearing for rust/newtype/struct-field serialization, but it drops the wrapper name the wasm side needs. Keeping a `Rust(Mp)` reference instead greens array-element + map-value but regresses collmap__newtype-inner (E0599 BTreeMap::serialize) and breaks struct-field/map-key — a single shared base_type can't serve both crates (arrays work only because they're transparent on both). The real fix is the wrapper-logic unification the handoff flags as out-of-scope, or a wasm-only alias-emission path resolving a Map base_type to its Table wrapper. Keeps the 5 passthrumap__* cells skip-listed with a pointer to the ROADMAP finding; no code change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: c797e9b0-113a-41f4-851d-8c35cd522549
SebastienGllmt
added a commit
that referenced
this pull request
Aug 18, 2026
…hook scope, extension guard, axis records A fresh-context finding-by-finding verification of audit run #1's remediation ledger against HEAD (88 findings: 78 VERIFIED with 12 gates executed green and 10 mutations red — including the run's CRITICAL verify.ts harness-failure guard and the canonical key-sort flip — 8 PARTIAL, 2 MISSING; full evidence in draft/test-setup-2/91) left a narrow tail, all closed here: - ArrayOptFields irregular-decode loop (tests/core/tests.rs) was assert-free (`let _ = ...unwrap()`): decode-accepts proved nothing. Now anchors every field per iteration to what the hand-built bytes encode (incl. c: nint -10 stored as magnitude 9; e compared by bytes — no PartialEq in the default profile). - The robustness catalogs' panic silencer was a process-global no-op hook: any UNRELATED test failing concurrently during the window lost its panic diagnostics. Replaced with a thread-id-filtered hook that delegates other threads' panics to the previously-installed hook (with_thread_silenced_panics, shared by both catalog tests). - The extensionless-input fix in api::cddl_paths (README/LICENSE/ dotfiles in a multifile input dir must be skipped, not parsed) had no guard: new unit test directory_input_skips_non_cddl_files, mutation-verified red against a removed extension filter. - The four never-dispositioned architecture axes are now in living docs (do-or-decline records, per the "decided, not overlooked" contract): MSRV/OS matrix for generated code and example/-plus-docs conformance in TESTING_ROADMAP's pending decisions; the decode-side reference-codec differential (ciborium/minicbor) folded into the decorrelated-conformance-parser bullet; cbor_event version-range testing recorded beside the ledgered DoS entry it will collide with. - The orphan-fixture-dir meta-test deprioritization moved from the gitignored draft into "Explicitly not worth it"; corpus_detect.ts's blanket approximate-by-design header now names its five audited known-approximate cases so they read as decided, not overlooked. Gates: fmt, clippy (0 warnings), core_no_wasm (anchored loop executes), robustness suite, the new api unit test, project_corpus.ts PASS. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SebastienGllmt
added a commit
that referenced
this pull request
Aug 18, 2026
…he family checks claims that arrive directly The loose `<Elem>List` collision family reached its collected plain needs only through a `[+ …]` shape — as a try_from source, or as a self-named rule — so a spec with no `[+ …]` anywhere never consulted them. The table-keys member of that gap was silent rather than loud: `create_and_register_array_type`'s last-wins registration replaced an authored rule of the structural ident outright, generation exited 0, and a field of the vanished type serialized as an array of the key element. The rest are loud, but reach only the generic duplicate-ident backstop, which reports the ident rather than the claim. Detector #1 gains a direct-claim leg over every plain use it already collects (a `*`-occurrence array, a map or table keys() wrapper, a rest row's keys(), a rest tail), rejecting an incompatible claim in this family's voice; the map side gains the symmetric leg for its plain map uses and table rules. Because the swallow deletes its own evidence — once the mint has run, the overwritten rule is indistinguishable from a rule that was never there — `create_and_register_array_type` records the incompatible claim at the instant it overwrites, and the leg reads that record. A rule that IS `[* elem]` of the same element stays shared: it is that builder, and the re-mint is byte-identical. That deliberate aliasing is now pinned by a test and stated in the wasm docs beside the sole-owner table rule it mirrors. Blast radius, measured by arming the leg before shipping it: zero committed fixtures flagged (snapshot corpus green), and zero of the 150 rule idents plus 51 `@name`/`@rust_name` overrides across the four CML specs spell a structural wrapper name. One in-tree re-attribution: the plain `[* bar]` claim moves from the backstop to the per-kind leg, the same asymmetry-closing move the default rest-row leg made for `MapKToV`. The backstop keeps a pin of its own on `@used_as_elem`, whose mint has no RustType for the IR scan to see. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Codegen cleanup:
Generated code should be more readable now, as we try harder to generate useful field names.
We also no longer store field such as
to now be
and likewise for the binary data wrappers.
In the future we could remove the
groupsmodule and have everything as a part of the root structs. They were an abstraction that was thought would help earlier on, especially if plain groups were represented as both array/map. But now the code generation process is changed and the generation of the exposed wrapper + the inner group data is more coupled rather than being a separate process, so it makes less sense. This would make no difference for the wasm API, but for expanding upon the generated library from rust it would be you'd just doself.xinstead ofself.0.xorself.0.x.0, etc.The subset of
shelley.cddlwe support also was renamed to provide more field namesOptional field setters:
Before we only generated a way to set mandatory fields as part of the constructor, but now optional ones generate setters (the ctor defaults them to
None) to actually use them.