Skip to content

fix(schema): unwrap Type::Description and Type::Deprecated in Avro and Cap'n Proto helpers - #252

Open
clockblocker wants to merge 1 commit into
mainfrom
queue/fix-schema-unwrap-description-deprecated
Open

clockblocker wants to merge 1 commit into
mainfrom
queue/fix-schema-unwrap-description-deprecated

Conversation

@clockblocker

@clockblocker clockblocker commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

AI-authored below this line.

Problem

When a custom type wraps its ReflectionType in rfl::Description or rfl::Deprecated, schema definitions store the wrapper node directly.

Three Avro and Cap'n Proto helper predicates fail to unwrap those nodes, misclassifying named records and literal enums during schema generation.

struct DescribedRetries {
  using Inner = rfl::NamedTuple<rfl::Field<"retries", int>>;
  using ReflectionType = rfl::Description<"Nested retry settings", Inner>;
};
struct DescribedColor {
  using ReflectionType = rfl::Description<"Primary color", rfl::Literal<"red", "blue">>;
};

// Before: Avro emits anonymous "unnamed_0" records; Cap'n Proto emits invalid Map(Enum)
// After:  Avro emits named "DescribedRetries"; Cap'n Proto emits ScalarMap

Summary

  • Recursively unwraps Description and Deprecated nodes in the Avro and Cap'n Proto named-type and literal predicates to match the main schema converters.
  • Adds the missing <type_traits> include to include/rfl/capnproto/is_named_type.hpp for standalone builds.
For Agents

…d Cap'n Proto helpers

When a custom type exposes a `ReflectionType` (or `rfl::Reflector<T>::ReflType`)
wrapped in `rfl::Description` or `rfl::Deprecated`, `Parser_default::make_reference`
stores `Type::Description` or `Type::Deprecated` directly in `_definitions[name]`.

While `type_to_avro_schema_type` and `type_to_capnproto_schema_type` already
unwrapped both wrappers, three schema helper predicates did not:

- `rfl::avro::is_named_type` (`src/rfl/avro/to_schema.cpp`): failed to
  recognize wrapped records/enums as named types, emitting duplicated
  anonymous `unnamed_N` definitions instead of named references.
- `rfl::capnproto::is_named_type` (`include/rfl/capnproto/is_named_type.hpp`):
  failed to recognize wrapped structs/enums/unions/maps as named types (and
  was missing `#include <type_traits>` for standalone compilation).
- `rfl::capnproto::string_map_to_capnproto_schema_type`
  (`src/rfl/capnproto/to_schema.cpp`): failed to detect wrapped `Type::Literal`
  values via `is_literal_type`, emitting invalid generic `Map(Enum)` instead
  of `ScalarMap`.

Adds focused Avro and Cap'n Proto regression tests for `Description`- and
`Deprecated`-wrapped custom `ReflectionType` definitions.
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