Skip to content

fix: align reflected shapes with Serde behavior - #8

Merged
tisonkun merged 1 commit into
mainfrom
codex/fix-shape-correctness
Aug 29, 2026
Merged

fix: align reflected shapes with Serde behavior#8
tisonkun merged 1 commit into
mainfrom
codex/fix-shape-correctness

Conversation

@tisonkun

Copy link
Copy Markdown
Contributor

Summary

  • infer shape bounds on generic parameters and associated values so recursive generic derives do not create cyclic trait obligations
  • resolve the actual Cargo dependency name from derive expansions, including renamed serde-shape dependencies
  • identify graph definitions by the concrete builder type plus diagnostic Rust name instead of trusting type_name as a unique key
  • align byte-slice and network-address shapes with Serde calls, representing readable and compact network forms as unions
  • add built-in shapes for Result, Duration, and tuples through Serde's arity 16, with a documented support matrix

Design notes

std::net types use the existing ShapeRef::Union model rather than introducing a serializer-format context. Their string and compact enum/array/tuple forms are both visible to format-agnostic consumers.

Named definitions now use TypeId of the stable builder closure as their source identity, with the Rust type name retained as a specialization and diagnostic value. This prevents same-named types from different crate instances from being silently merged. The builder is consequently required to be 'static.

The derive compile fixture intentionally depends on serde-shape through a renamed Cargo dependency. Serde token tests record the readable and compact calls for byte slices and network types.

This PR does not add description/doc-comment metadata, a generic graph walker, or field-level shape override attributes; those are independent feature designs rather than correctness fixes. Unsupported foreign types remain addressable through documented local newtypes and manual shape implementations.

Validation

  • cargo x build --locked
  • cargo x test
  • cargo x lint

Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
tisonkun merged commit 1ad6c76 into main Aug 29, 2026
12 checks passed
@tisonkun
tisonkun deleted the codex/fix-shape-correctness branch August 29, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant