Skip to content

feat: add proto descriptor set and message name to introspect response#909

Open
AnthonyWadham wants to merge 1 commit into
mainfrom
Anthony/code-gen-introspect-fix
Open

feat: add proto descriptor set and message name to introspect response#909
AnthonyWadham wants to merge 1 commit into
mainfrom
Anthony/code-gen-introspect-fix

Conversation

@AnthonyWadham

@AnthonyWadham AnthonyWadham commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

TL;DR

Adds proto descriptor metadata to command introspection so clients can encode commands as protobuf without a separately distributed .proto file.

What changed?

Commands now use a dedicated commandReflector that falls back to Go field names (instead of msgpack tags) when generating their JSON schema, since proto field names align with Go names rather than msgpack tags.

During command registration, the proto descriptor is resolved from the return type of each command's ToProto() method via reflection — the method is never invoked, only its return type is inspected. The resolved protoreflect.MessageDescriptor is stored in a new commandProtoTypes map keyed by command name.

When Introspect is called, collectDescriptorSet walks all resolved descriptors, pulls in transitive file imports (deduplicated by path), and serializes the result as a google.protobuf.FileDescriptorSet into IntrospectResponse.proto_descriptor_set. Each command's TypeSchema also gains a proto_message_name field carrying the fully-qualified proto message name, so clients can look up the right message in the descriptor set. File ordering is deterministic (sorted by command name before walking) to produce byte-identical output across calls.

The proto definitions for IntrospectResponse and TypeSchema are updated accordingly, with generated code regenerated for Go, C#, and TypeScript.

The existing msgpack-based schema path for components and events is unchanged.

Why make this change?

Clients receiving command schemas from introspection need enough information to encode commands as protobuf on the wire without access to a compiled .proto descriptor at build time. Shipping the FileDescriptorSet alongside the fully-qualified message name in the introspection response allows clients to construct valid protobuf payloads — for example via protobufjs's Root.fromDescriptor — using only what the server advertises at runtime.

Copy link
Copy Markdown
Contributor Author

How to use the Graphite Merge Queue

Add the label graphite/merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@AnthonyWadham AnthonyWadham changed the title fix: introspect feat: advertise proto wire field numbers/kinds in command JSON schema via x-proto-wire Jul 14, 2026
@AnthonyWadham AnthonyWadham changed the title feat: advertise proto wire field numbers/kinds in command JSON schema via x-proto-wire feat(introspect): advertise proto wire field numbers/kinds in command JSON schema via x-proto-wire Jul 14, 2026
@AnthonyWadham
AnthonyWadham force-pushed the Anthony/code-gen-introspect-fix branch 2 times, most recently from 7d165d3 to 54350a9 Compare July 14, 2026 16:25
@AnthonyWadham
AnthonyWadham marked this pull request as ready for review July 14, 2026 16:49
@AnthonyWadham
AnthonyWadham force-pushed the Anthony/code-gen-introspect-fix branch from 54350a9 to a396d2a Compare July 15, 2026 13:39
@AnthonyWadham AnthonyWadham changed the title feat(introspect): advertise proto wire field numbers/kinds in command JSON schema via x-proto-wire feat: add proto descriptor set and message name to introspect response Jul 15, 2026
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