[PEOPLE-41271] Separate the validation plan from Go emission in protoc-gen-govalidator - #159
Draft
Dmitry Rotay (DmitryRotay) wants to merge 4 commits into
Draft
[PEOPLE-41271] Separate the validation plan from Go emission in protoc-gen-govalidator#159Dmitry Rotay (DmitryRotay) wants to merge 4 commits into
Dmitry Rotay (DmitryRotay) wants to merge 4 commits into
Conversation
Dmitry Rotay (DmitryRotay)
force-pushed
the
PEOPLE-41271-validator-emission-seam
branch
3 times, most recently
from
August 21, 2026 01:30
281e364 to
0d39bb4
Compare
This was referenced Aug 27, 2026
Dmitry Rotay (DmitryRotay)
force-pushed
the
PEOPLE-41271-validator-emission-seam
branch
from
August 28, 2026 05:43
0d39bb4 to
17d9229
Compare
…c-gen-govalidator Generated output is byte-identical: verified over the 1,760 files protoc-gen-govalidator produces for the full APISchema proto tree. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Review follow-ups: reset the pattern pool and regex names per run, hold the goldens equal to the checked-in output, and keep a replacement's table value verbatim rather than parsing it back to a rune.
Dmitry Rotay (DmitryRotay)
force-pushed
the
PEOPLE-41271-validator-emission-seam
branch
from
September 1, 2026 01:51
d098ea3 to
38f02bd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Splits protoc-gen-govalidator into a validation plan and a Go emitter, so a second output language can reuse the plan instead of re-deriving it from the field options.
PEOPLE-41271
Generated Go is byte-identical
Built the plugin at
masterand at this commit, ran both with the same protoc, diffed the output trees:valtest+example+playgroundplugin/testdata/*.goldenalso matches the checked-invaltest.validator.pb.goandgeo.validator.pb.goexactly, apart from theprotoc-gen-govalidatorversion line — those files were generated at v2.7.1 and the code reads v2.7.2, which predates this branch.Problem description
Which checks a field needs, and in what order they run, existed only as the sequence of Go statements the plugin printed. Nothing else could read it.
That matters most in
genStringValidator, which interleaves rewrites that permanently mutate the message field (NFC normalisation, URL breaking, trimming, the replacers, PUA stripping) with checks that read the mutated value. Order is data-changing, and the allow-list pattern is built as a side effect of walking those same rewrites. A C# emitter re-deriving that from the annotations would be free to diverge, silently.Moved
plugin/validation_definitions.go→validation/plan/definitions.go— pure rename, only the package clause changedget*ExtensionhelpersprepareRegex/mergeRegexcall, and the final pattern readpanics on an invalid option — same messages, same order, now during plan constructionplugin.godrops 1,236 → 716 lines and no longer imports the validator package.Added
validation/plan/plan.go— the vocabulary: 13Steptypes (one per validator option) and 13Optypes for the ordered operations inside a string fieldvalidation/plan/build.go— the builderplugin/golden_test.go+testdata/— there was no CI check that generated output stays put; now there is, viago test ./...Preserved deliberately
g.Psequences, same comments.Notes for review
go test ./protobuf/protoc-gen-govalidator/plugin/ -update. The request is assembled from the descriptors the generated Go packages register, so there is no checked-in descriptor set to keep in step.*protogen.Fieldon each node, so both emitters get naming from protogen. The seam is about rules, not names — the C# emitter derives its own casing from the descriptor.Checklist
Is this PR a reasonable size?
Large, but it is one mechanical split, and the diff is dominated by moved code and golden fixture.
List deployment sequence with all relevant PRs.
For breaking changes: I have confirmed that other repos are not affected, or I have planned a deployment sequence to address any impact.
No consumer-visible change — generated output is byte-identical.
Code Review Guidelines for Reviewers
blockers. Pair on a call for non-trivial feedback.
to make the PR perfect.
test coverage and complexity.
who is.