Skip to content

build(proto): make make proto fully hermetic#199

Closed
albertywu wants to merge 1 commit into
mainfrom
hermetic-proto-toolchain
Closed

build(proto): make make proto fully hermetic#199
albertywu wants to merge 1 commit into
mainfrom
hermetic-proto-toolchain

Conversation

@albertywu
Copy link
Copy Markdown
Contributor

@albertywu albertywu commented Jun 4, 2026

Pin the entire codegen toolchain so a single make proto produces byte-identical output on any host, with every version in version control.

Previously, make proto was dependent on host-installed versions of protoc + plugins which led to different output when run on different machine.

Validation

make fmt && make proto && make build && make test && make e2e-test
✅ Confirmed that after running make proto none of the already committed proto source code was changed
✅ Confirmed that I can make a .proto change and make proto updates the generated source code as expected

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 4, 2026 22:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes protobuf generation reproducible across hosts by pinning protoc and all Go codegen plugins, wiring the hermetic flow into make proto, and enforcing freshness in CI.

Changes:

  • Add hermetic wrappers: ./tool/protoc (pinned via .protocversion + SHA256) and ./tool/protoc-gen-* (run pinned Go tools via go tool).
  • Update make proto to use the wrappers and run a pinned goimports pass; add make check-proto.
  • Wire check-proto into CI and update module/docs to reflect the pinned toolchain.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tool/protoc-gen-yarpc-go Adds a go tool wrapper to run the pinned YARPC plugin hermetically.
tool/protoc-gen-go-grpc Adds a go tool wrapper to run the pinned gRPC plugin hermetically.
tool/protoc-gen-go Adds a go tool wrapper to run the pinned protobuf Go plugin hermetically.
tool/protoc Adds a Bazelisk-style protoc downloader/verifier driven by .protocversion.
tool/BUILD.bazel Exposes the new tool wrappers as exported files for Bazel usage.
MODULE.bazel Adds the Bazel repo for protoc-gen-go-grpc.
Makefile Switches proto generation to the hermetic wrappers; adds check-proto; runs pinned goimports.
go.sum Records sums for the newly added protoc-gen-go-grpc module.
go.mod Adds tool directives to pin plugin versions and pulls in protoc-gen-go-grpc.
doc/howto/DEVELOPMENT.md Updates proto generation instructions to reflect hermetic behavior.
.protocversion Pins the protoc version used by ./tool/protoc.
.github/workflows/ci.yml Adds make check-proto to the tidy job to prevent stale generated protos.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tool/protoc Outdated
Comment thread tool/protoc Outdated
Comment thread doc/howto/DEVELOPMENT.md Outdated
`make proto` previously used the host's protoc and plugins (Homebrew protoc,
`go install ...@latest` for protoc-gen-go / protoc-gen-go-grpc /
protoc-gen-yarpc-go), so generated stubs could drift between machines. Pin
the whole toolchain so one command produces identical output anywhere.

- Pin protoc via ./tool/protoc, a Bazelisk-style wrapper that downloads and
  SHA-256-verifies the version in .protocversion (29.3) and caches it.
- Pin all three plugins via `tool` directives in go.mod at the versions that
  reproduce the committed output (protoc-gen-go v1.36.10, protoc-gen-go-grpc
  v1.5.1, protoc-gen-yarpc-go from yarpc v1.81.0); protoc-gen-go-grpc is a
  separate module, now added to the graph.
- Add tool/protoc-gen-{go,go-grpc,yarpc-go} wrappers that run the pinned
  plugins via `go tool`, and pass them to protoc with explicit --plugin=
  flags so $PATH is never consulted.
- Run a pinned goimports pass so `make proto` emits the committed (formatted)
  form in a single command.
- Add a `check-proto` target wired into the CI `tidy` job so stale generated
  files fail the required-checks gate.
- Drop the host protoc/plugin install steps from DEVELOPMENT.md.

No change to the generated stubs: the committed yarpc output stays on the
existing gogo codec. Switching to the protobuf v2 codec will be a separate PR.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@albertywu albertywu force-pushed the hermetic-proto-toolchain branch from e632592 to 0fec623 Compare June 4, 2026 22:59
@albertywu albertywu closed this Jun 5, 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.

2 participants