Skip to content

fix(a2a-pb): generate the gRPC code into OUT_DIR - #409

Merged
muscariello merged 2 commits into
a2aproject:mainfrom
gulldan:fix/pb-build-in-out-dir
Oct 31, 2026
Merged

muscariello merged 2 commits into
a2aproject:mainfrom
gulldan:fix/pb-build-in-out-dir

Conversation

@gulldan

@gulldan gulldan commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #402.

Problem

a2a-pb/build.rs wrote the prost/tonic output with .out_dir("src/gen"), into the crate's own sources, so every dependent's build wrote into its copy of a2a-pb. From a read-only source — cargo vendor output, the Nix store, a sandboxed build — the build script failed with PermissionDenied. And because a dependent resolves the current tonic-prost-build (0.14.9, which adds #[allow(clippy::all)]) while this repository locks 0.14.6, a dependent's build also rewrote the shipped src/gen it was about to compile.

Fix

The gRPC pass now writes to OUT_DIR/grpc, and proto includes it from there, as protojson already includes the second pass from OUT_DIR. The checked-in src/gen (lf.a2a.v1.rs, and google.api.rs, which nothing included) is removed. The public modules and types are unchanged.

Tests

  • New a2a-pb/tests/read_only_source.rs: asserts the build leaves no src/gen in the crate. On main it fails (…/a2a-pb/src/gen exists); it also fails if a later change writes there again, since the build would recreate the directory.
  • cargo package -p a2a-pb from this branch, unpacked into a read-only directory and used as a path dependency: builds, and a2a_pb::proto::a2a_service_server::A2aServiceServer and a2a_pb::protojson::Task resolve. The same build from the published 0.3.2 fails as shown in [Bug]: a2a-pb: build script writes generated code into its own src/gen, so a read-only source fails to build #402.
  • CI steps on Linux, stable 1.99.1: cargo metadata --locked, cargo hack check --all-targets --each-feature, cargo fmt --check, cargo hack clippy --all-targets --each-feature -- -D warnings, cargo test --workspace --exclude itk-rust-current-agent, copyright headers — all green.

Notes

🤖 Generated with Claude Code

The build script wrote the prost/tonic output into the crate's own
src/gen, so every dependent's build wrote into its copy of a2a-pb:
from a read-only source (cargo vendor, the Nix store, a sandbox) the
build script failed with PermissionDenied, and with the current
tonic-prost-build the dependent's build rewrote the shipped sources.

The code is now generated into OUT_DIR/grpc and included from there,
like the protojson pass already is, and the checked-in copy is gone.
A test asserts the build leaves no src/gen behind.

Fixes: a2aproject#402

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: gulldan <[email protected]>
@gulldan
gulldan requested a review from a team as a code owner October 31, 2026 10:54
@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@muscariello muscariello left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@muscariello
muscariello added this pull request to the merge queue Oct 31, 2026
Merged via the queue into a2aproject:main with commit 6791b61 Oct 31, 2026
22 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 31, 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.

[Bug]: a2a-pb: build script writes generated code into its own src/gen, so a read-only source fails to build

2 participants