refactor: replace ProtoMeta AST inspection with prost::Name + prost-reflect - #538
Closed
vbarua wants to merge 8 commits into
Closed
refactor: replace ProtoMeta AST inspection with prost::Name + prost-reflect#538vbarua wants to merge 8 commits into
vbarua wants to merge 8 commits into
Conversation
Enable prost-build's type_names feature so all generated message types implement prost::Name. The ProtoMeta derive macro now calls prost::Name::full_name() instead of the brittle cook_path() heuristic which reconstructed proto type names from Rust module paths. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add prost-reflect as a dependency and configure prost-build to emit a file descriptor set at build time. Expose a global DESCRIPTOR_POOL in input::proto, loaded from the embedded descriptor bytes, for use by runtime proto introspection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the case-convention heuristics in ProtoMeta's enum derive with descriptor pool lookups. Enum type names now come from EnumDescriptor::full_name() and variant names from EnumValueDescriptor::name(), using Box::leak to satisfy the &'static str return type. The cook_path result is still used as the initial pool lookup key since prost-build does not generate Name impls for enums. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ssage The ProtoMeta derive macro no longer inspects struct field types at compile time to generate parse_unknown. Instead, each message now implements prost_reflect::ReflectMessage (via a generated descriptor() method), and parse_unknown enumerates unparsed fields at runtime using MessageDescriptor::fields(). DynamicMessage is used to check field presence before reporting unknowns. Removes the FieldType enum and is_repeated helper from the derive crate. Adds push_unknown_proto_field to traversal and field_descriptor_to_node to input::proto for constructing tree nodes from FieldDescriptor. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Oneof variant names and enum type names are always PascalCase identifiers, never Rust keywords, so the r# stripping in cook_ident is unnecessary. Replace cook_ident calls with plain ident.to_string() and remove the helper entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ssage Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…+ ReflectMessage - NodeType::ProtoMessage now holds String instead of &'static str, removing the need for Box::leak or Lazy caching at node-creation sites - parse_proto_message_unknown extracted from derive macro into traversal.rs as a standalone generic function; derive's InputNode::parse_unknown delegates to it - parse_proto and validate now require prost::Name + ReflectMessage instead of InputNode, so proto message types from substrait-prost can be passed to these entry points without needing InputNode derived on them Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <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.
Summary
Replaces the brittle compile-time AST inspection in the
ProtoMetaderive macro with proper runtime protobuf introspection viaprost::Nameandprost-reflect.prost::Name::full_name()(generated byprost_build::Config::enable_type_names()), replacing thecook_path(module_path!(), ...)heuristicfile_descriptor_set.binviaprost_reflect::DescriptorPool, replacing Rust AST reconstructionparse_unknown: now usesReflectMessage::descriptor()to enumerate fields andDynamicMessagefor presence detection, replacing direct struct field inspectionparse_proto,validate): now bound onprost::Name + ReflectMessageinstead ofInputNode, enabling future use of externally-generated proto types without requiringProtoMetaderived on themNodeType::ProtoMessagechanged from&'static strtoString, removing the need forBox::leakorLazycaching at node-creation sitesMotivation
This is groundwork toward consuming the
substrait-prostcrate (see #531) without needing to dynamically parse Rust code to reconstruct protobuf metadata. The previous approach reverse-engineered prost's naming conventions at compile time; this approach uses authoritative runtime reflection.🤖 Generated with Claude Code