Repository navigation
compilers/protobuf: revive the Protocol Buffers compiler from #21 against the current contract #469
Description
What exists
A complete Protocol Buffers / gRPC compiler was drafted in #21 (branch feat/protobuf-compiler, head 2345b07, +10,170 lines across 67 files). It lowers proto2, proto3 and the 2023 edition through github.com/bufbuild/protocompile: messages and enums into the ID-keyed registry, field numbers onto Property.WireID, oneof as a WireTagged union behind a Flatten wrapper, repeated/map as hoisted containers, the well-known types, extensions and reserved ranges — with a conformance corpus under testdata/conformance/protobuf and goldens under testdata/golden/protobuf. The PR body is the design record; read it before starting over.
It was opened 2026-07-21, last pushed 2026-07-23, and has not been reviewed. README milestone 5 places the Protobuf compiler after AsyncAPI and GraphQL, so this is the tracking issue for that row, not a request to land the draft now.
Why the draft cannot land as it stands
Measured against main at e1e92a0 (166 commits ahead of the draft's base):
- Contract.
compilers.Compilernow requiresFormats,DetectandCompile(compilers/compilers.go, added by feat(engine)!: let compilers own format detection and options #341). The draft implementsFormatsandCompileonly, so it does not build. - IR version. Every golden the draft ships writes
"irVersion": "0.1.0";mainis at0.4.0after three breaking revisions (feat(ir)!: add Payload.Required and Parameter.Provenance #437–feat(ir)!: bump IRVersion to 0.4.0 for the stack's shape changes #442, feat(ir)!: land the IR 0.4.0 stack #464). The lowering targets struct shapes that no longer exist —ErrorCaseis a response, exclusive bounds are carried separately,Payload.RequiredandParameter.Provenanceexist, and so on. - Package layout. The draft predates the micro-compiler restructure (
docs/micro-compiler-design.md) and is one flat package.internal/archtest'srulesmap, the 20-method cap on compiler types, and the per-package allowlists all postdate it; thearch_test.goconflict is that map having been rewritten underneath it. - Shared grammar.
canonicalWordsand the identifier grammar were extracted intocompilers/compileby compilers/compile: own the identifier grammar shared by every compiler #162/compilers/compile: own the canonical naming grammar #163/refactor: move the naming and ID grammars into the framework #183 specifically because the draft's copy had diverged (compilers: canonical naming grammar diverges across the three compilers #161). The draft still carries its own. go.sumconflicts, and CI was green only against the Julymain.
What reviving it needs
- Rebase is not the shape of the work — start a fresh branch from
mainand port the lowering, using the draft as the reference for the proto→IR mapping decisions. - Implement
Detect(a.protosource is recognisable fromsyntax =/edition =at the top; bounded sniff, same discipline ascompilers/openapi/detect.go). - Lay it out as
compilers/protobuf+compilers/protobuf/internal/*, each internal package with its ownarchtestrules entry; usecompilers/compilefor naming and IDs rather than a local grammar. - Regenerate the goldens at the current
IRVersionand re-derive the conformance matrix witnesses (docs/ir-spec-matrix.mdrow keys) for the rows Protobuf can express. - Run the full oracle sweep:
go run ./cmd/morphic-harness testdata/conformance/protobuf.
Decision needed
Whether #21 stays open as a draft or is closed with this issue as its pointer. Either way the branch should not be deleted — the design work in it is the asset.
Refs #21.
Activity
OmarAlJarrah commentedon Oct 19, 2026
What reviving the draft costs at
c387e25c, measured by copyingcompilers/protobuffromorigin/feat/protobuf-compilerintomainand building it:ir.Extensions, replaced byUnmodeledentries that carry a reason and provenance;Provenance.Pointer, now ajsontext.Pointer;MapT.Key, now a pointer.A mechanical rename then surfaces 2 more, at
UnmodeledEntryconstruction sites, each needing a reason decided per key.FormatsandCompileonly.compilers.Compilernow also requiresDetect,DecodeOptionsandSourceTable.encoding/jsonv1, which archtest bans.maineither: an input-only union, and a non-finite default (spike: evaluate first-class IR representation for input-only unions and non-finite numeric values #25).The issue text names only
Detect. The harness and the conformance matrix also take only the OpenAPI compiler today (#968).