Skip to content

fix(protoc-gen-elixir): emit one file per service under one_file_per_module - #63

Merged
yordis merged 2 commits into
mainfrom
yordis/fix-ofpm-service-layout
Aug 2, 2026
Merged

fix(protoc-gen-elixir): emit one file per service under one_file_per_module#63
yordis merged 2 commits into
mainfrom
yordis/fix-ofpm-service-layout

Conversation

@yordis

@yordis yordis commented Aug 2, 2026

Copy link
Copy Markdown
Member
  • The escript emits a service's Service and Stub defmodules together in a single foo_service.pb.ex; the Go plugin split them into two files, which was the last known output divergence between the two implementations.
  • Matching the escript lets the parity suite in elixir-protobuf assert byte-identical output unconditionally, removing the known-mismatch gate that also hid the full all-flags combination from default CI runs.
  • Verified locally against the escript compare suite: all 21 cases byte-identical, including one_file_per_module+plugins=grpc and the full all-flags combination.

…module

The escript groups a service's Service and Stub defmodules into a single
foo_service.pb.ex; matching it removes the last known output divergence
so the escript parity suite can assert byte identity unconditionally.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@cursor

cursor Bot commented Aug 2, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Generator output layout change only for one_file_per_module + grpc; behavior is covered by updated tests and escript parity goals.

Overview
With one_file_per_module=true and plugins=grpc, each service now produces one output file (e.g. test/test_service.pb.ex) that contains both Service and Stub defmodules, keyed off the bare service module name—matching the escript instead of splitting into separate .Service / .Stub files.

renderService concatenates the rendered pair into a single renderedModule so modulePath no longer derives paths from .Service or .Stub suffixes. TestOneFilePerModuleWithGRPC was updated to assert a single merged file and the combined content, replacing expectations that assumed two files or a fragile \n\n split.

Reviewed by Cursor Bugbot for commit e62d5bc. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@yordis, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d95ed5b6-2732-4844-a873-a0068f03ae5a

📥 Commits

Reviewing files that changed from the base of the PR and between 3c3d5f2 and e62d5bc.

📒 Files selected for processing (1)
  • cmd/protoc-gen-elixir/one_file_per_module_test.go

Walkthrough

The generator now combines each gRPC service’s .Service and .Stub modules in one output module. The one-file-per-module test validates the combined file name and content.

Changes

gRPC service output

Layer / File(s) Summary
Combine service and stub rendering
cmd/protoc-gen-elixir/generator.go
renderService uses the bare service name as the output key and returns combined .Service and .Stub content.
Validate combined output
cmd/protoc-gen-elixir/one_file_per_module_test.go
The test expects both modules in test/test_service.pb.ex instead of separate files.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A rabbit watched the modules blend,
Service and Stub now share one den.
One file holds their ordered flow,
The test confirms the paths now show.
Hop, hop—clean output grows!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states that one file is emitted per service when one_file_per_module is enabled.
Description check ✅ Passed The description accurately explains the output change, parity goal, and local verification results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yordis/fix-ofpm-service-layout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/protoc-gen-elixir/one_file_per_module_test.go`:
- Around line 100-108: Extend the assertions in the test around
findGeneratedFile and the generated response to verify that no legacy separate
.Service or .Stub files are emitted. Assert the exact generated file set or
explicitly confirm the old service and stub paths are absent, while preserving
the existing content assertion for test/test_service.pb.ex.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 26a54eba-56bd-4b84-860a-2c9ef07e6036

📥 Commits

Reviewing files that changed from the base of the PR and between c9da2db and 3c3d5f2.

📒 Files selected for processing (2)
  • cmd/protoc-gen-elixir/generator.go
  • cmd/protoc-gen-elixir/one_file_per_module_test.go

Comment thread cmd/protoc-gen-elixir/one_file_per_module_test.go
Content-only assertions would still pass if the legacy split
.Service/.Stub files were emitted alongside the merged file.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis
yordis merged commit 6efd221 into main Aug 2, 2026
4 checks passed
@yordis
yordis deleted the yordis/fix-ofpm-service-layout branch August 2, 2026 09:11
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