Skip to content

Skip serialized variants during type trace#91

Merged
ma2bd merged 1 commit into
zefchain:mainfrom
avvlas:skip-serialized-variants
May 26, 2026
Merged

Skip serialized variants during type trace#91
ma2bd merged 1 commit into
zefchain:mainfrom
avvlas:skip-serialized-variants

Conversation

@avvlas
Copy link
Copy Markdown
Contributor

@avvlas avvlas commented Mar 3, 2026

Summary

The tracer now records enum variants whose serialized VariantFormat is already complete, and deserialize_enum skips re-exploring those variants during type tracing. That avoids overwriting a complete serialized shape with a less precise deserialization-derived shape, while still allowing partially traced variants to be revisited and completed.

Motivation:

This change fixes the issue that can be reproduced with test: test_trace_type_skips_fully_serialized_bytes_variant

In mixed tracing flows, an enum variant may already be fully learned from trace_value before trace_type runs. For example, if tracing first sees Message::Send(Exact16([7; 16])), serialization can already determine that the variant payload is Bytes. During a later trace_type::<Message>(), re-exploring Send through deserialization is unnecessary and can be actively harmful, because the deserializer only has synthetic placeholder input and may fail or infer a weaker shape.

Test Plan

Tests added:

  • test_trace_type_revisits_partially_serialized_enum_variants
  • test_trace_type_skips_fully_serialized_bytes_variant

@avvlas avvlas requested a review from ma2bd as a code owner March 3, 2026 12:13
@avvlas
Copy link
Copy Markdown
Contributor Author

avvlas commented Mar 19, 2026

Hey, @ma2bd!
Please take a look when you have time :)

@ma2bd
Copy link
Copy Markdown
Contributor

ma2bd commented May 26, 2026

@avvlas This looks good. Thanks for the PR!

@ma2bd ma2bd merged commit 8bfb008 into zefchain:main May 26, 2026
14 checks passed
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.

2 participants