Skip to content

types: add Api, Type, and SourceContext well-known types - #394

Merged
iainmcgin merged 2 commits into
anthropics:mainfrom
Divyansh151005:types/wkt-api-type-source-context
Sep 1, 2026
Merged

types: add Api, Type, and SourceContext well-known types#394
iainmcgin merged 2 commits into
anthropics:mainfrom
Divyansh151005:types/wkt-api-type-source-context

Conversation

@Divyansh151005

Copy link
Copy Markdown
Contributor

Fixes #382.

What this does

buffa-types only shipped the JSON-mappable well-known types. Codegen still auto-maps the entire .google.protobuf package there, so compiling googleapis (or any schema that imports api.proto / type.proto / source_context.proto) failed with cannot find type Api / TypeView / EnumView.

This vendors those three remaining official well-known files (protobuf v33.5, matching the existing any.proto pin and the tools image) and generates them next to Timestamp/Any:

  • Binary + view round-trips in buffa-types
  • register_wkt_types textproto Any-expansion for the new messages
  • A wkt_api.proto fixture so buffa-test compiles a Catalog with Api / Type / Enum / SourceContext fields
  • A codegen integration assertion that those types resolve through ::buffa_types::google::protobuf::{Api,Type,Enum,SourceContext} and the matching views

JSON serde is intentionally not generated. These types use the standard proto3 object mapping (no special encoding), and turning generate_json on for all WKTs would also derive serde for Timestamp/Any and duplicate the hand-written impls. wkt_usage.proto is left unchanged so the json=true compile fixture stays green.

Shipping api.proto also made [Mixin][] resolve in-crate. The generated [Mixin](crate::google::protobuf::Mixin) is a rustdoc::redundant_explicit_links failure under this repo's -D warnings. Same-module AIP-192 refs now emit [Mixin]; FQ display names (google.protobuf.Type) and cross-module destinations still get an explicit crate:: path.

Testing

$ rustc --version
rustc 1.95.0 (59807616e 2026-04-14)

$ cargo fmt --all --check
$ cargo clippy --workspace --all-targets -- -D warnings
$ RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features --no-deps
$ cargo test --workspace

All passed. Targeted extras: cargo test -p buffa-types --all-features (including text_registry_roundtrip_source_context), codegen_wkt_api_auto_mapping, and buffa-test test_wkt_api_types_round_trip.

Conformance (task conformance) was not run locally; this change does not touch the codec wire path the suite exercises.

Fixes anthropics#382.

Codegen auto-maps `.google.protobuf` onto buffa-types, so compiling
googleapis (or any schema that imports api.proto / type.proto /
source_context.proto) failed to resolve Api / TypeView / EnumView.
Those three files are the rest of the official well-known set; they
are now vendored and generated next to Timestamp/Any, with binary
and view round-trips. They use the standard proto3 JSON object
mapping, so they register for textproto Any-expansion only.

Same-module AIP-192 rustdoc links (`[Mixin][]`) now emit `[Mixin]`
rather than a redundant explicit target, which
`rustdoc::redundant_explicit_links` rejects under `-D warnings`.
@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Divyansh151005

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 30, 2026
…links; docs and tests

- .github/workflows/ci.yml: the check-generated-code job's proto list
  gains api/source_context/type.proto, matching the Taskfile
- comments.rs: a keyword-named type keeps the escaped explicit link
  target (a bare [type] label would not resolve), with a test
- docs: state that Api/Type/Enum/SourceContext and their parts have no
  serde impls and what a json=true consumer sees; list the new types;
  drop the stale "JSON-mappable WKTs" descriptions of buffa-types
- tests: TypeView and Enum round-trips, Type/Option text-registry
  round-trips (Option nests an Any), Catalog.enum_type populated
- changelog: (anthropics#394); the rustdoc-link change moved to its own Changed
  fragment
@iainmcgin

Copy link
Copy Markdown
Collaborator

[claude code]

Reviewed. The vendored protos are byte-identical to protobuf v33.5, the codegen config matches the existing WKTs, and the Option shadowing is handled (no bare Option< in the generated tree, not re-exported at the crate root). Pushed 410a465 with the fixups: .github/workflows/ci.yml carried a third copy of the WKT proto list and was the one not updated, which is why check-generated-code failed; the new same-module rustdoc-link rule now keeps the escaped explicit target for a keyword-named type (a bare [type] label would not resolve), with a test; the guide and buffa-types docs say these types have no Serialize/Deserialize and what a json = true consumer sees; the new parts (Method, Mixin, Field, EnumValue, Option) are listed; TypeView/Enum round-trips, Type/Option text-registry round-trips (Option nests an Any), and Catalog.enum_type is populated; the rustdoc-link change moved to its own Changed fragment. Ready to queue once Iain stamps it; thanks for taking #382 on.

@iainmcgin
iainmcgin added this pull request to the merge queue Sep 1, 2026
Merged via the queue into anthropics:main with commit cec3585 Sep 1, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing google/protobuf types when trying to build google official gRPC SDK

2 participants