8000 refactor(compat): drop proto, field_mask, longrunning, health, metadata, uuid, flag, and google shims by VLukiantsev · Pull Request #1124 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

refactor(compat): drop proto, field_mask, longrunning, health, metadata, uuid, flag, and google shims - #1124

Merged
VLukiantsev merged 5 commits into
refactor/drop-compat-test-shims-spannerfrom
refactor/drop-compat-proto-aliases
Oct 8, 2026
Merged

VLukiantsev merged 5 commits into
refactor/drop-compat-test-shims-spannerfrom
refactor/drop-compat-proto-aliases

Conversation

@VLukiantsev
Copy link
Copy Markdown
Collaborator

Summary

Extracts proto.Modify into a dedicated testonly helper package internal/prototest (xmanager_cloud/internal/prototest) and eliminates 8 internal/compat shim packages (proto, field_mask, longrunning, health, metadata, uuid, flag, and google), migrating all callers directly to their canonical upstream open-source Go packages.

Motivation & Context

Part of the google3 compatibility layer elimination effort (#1066), stacked on refactor/drop-compat-test-shims-spanner. All functions in internal/compat/proto except the test helper Modify are natively provided by google.golang.org/protobuf/proto, and field_mask, longrunning, health, metadata, uuid, flag, and google were pass-through shims for legacy google3 import paths.

Key Changes

  • Extracted internal/prototest (xmanager_cloud/internal/prototest):
    • Created internal/prototest/prototest.go with prototest.Modify[T proto.Message](base T, fn func(T)) T, unit tests in internal/prototest/prototest_test.go (100.0% line coverage), and internal/prototest/BUILD.bazel (testonly = True).
    • Updated markdown documentation and engineering guidelines (.agents/AGENTS.md, .agents/rules/core_engineering.md, .agents/rules/languages/golang.md, .agents/skills/xmc_feature_development/SKILL.md, .agents/skills/xmc_review_pr/SKILL.md, docs/architecture/components.md, docs/developer.md) to reference prototest.Modify.
  • Removed 8 internal/compat Shim Packages:
    • internal/compat/proto (golang/protobuf/v2/proto/proto) -> google.golang.org/protobuf/proto (@org_golang_google_protobuf//proto) and xmanager_cloud/internal/prototest (//internal/prototest) for Modify.
    • internal/compat/field_mask (protobuf/field_mask_go_proto) -> google.golang.org/protobuf/types/known/fieldmaskpb (@org_golang_google_protobuf//types/known/fieldmaskpb).
    • internal/compat/longrunning (longrunning/operations_go_proto) -> cloud.google.com/go/longrunning/autogen/longrunningpb (@com_google_cloud_go_longrunning//autogen/longrunningpb).
    • internal/compat/health (grpc/health) -> google.golang.org/grpc/health (@org_golang_google_grpc//health).
    • internal/compat/metadata (golang/grpc/metadata/metadata) -> google.golang.org/grpc/metadata (@org_golang_google_grpc//metadata).
    • internal/compat/uuid (golang/uuid/uuid) -> github.com/google/uuid (@com_github_google_uuid//:uuid).
    • internal/compat/flag and internal/compat/google (go/google) -> deleted unused shims and removed remaining blank imports/deps.
  • Compat & Ratchet Cleanup:
    • Removed corresponding # gazelle:resolve lines from root BUILD.bazel, IMPORT_MAP entries from compat.bzl, and blank imports from internal/compat/imports.go.
    • Lowered tools/lint/legacy_imports_baseline.json: gazelle_resolve_directives (80 -> 75, -5) and go_legacy_root_imports (689 -> 515, -174).

Assumptions

  • Keeping prototest.Modify in a testonly = True package (internal/prototest) enforces at the Bazel build graph level that test-mutation helpers cannot be imported by production binaries.
  • Standard uuid.NewString() / uuid.New().String() from github.com/google/uuid is functionally identical to the removed internal/compat/uuid.New() wrapper.

Verification & Testing

  • Ran bazel build //... across all 1,082 targets (passed).
  • Ran bazel test --test_env=SPANNER_EMULATOR_HOST=localhost:9010 //... and bazel coverage //internal/prototest/... (100.0% line coverage: 5/5 lines).
  • Ran ./.githooks/pre-commit (passed).
  • Verified diff size via ./tools/analyze_diff_size.py --base-ref refactor/drop-compat-test-shims-spanner (prod_code_lines: 194/400, total_code_lines: 522/1000, doc_lines: 9/1000).

Related Issues / Bugs

TAG=agy
CONV=4d3b3bec-3d31-4d4a-a440-8e4bd19b2cf3

@VLukiantsev
VLukiantsev added this pull request to stack #1127 October 7, 2026 09:35
@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request removes legacy compatibility packages under internal/compat and replaces them with standard public packages (such as standard protobuf, UUID, and gRPC libraries) across the codebase. It also moves the Modify test helper to a new internal/prototest package. The review feedback recommends adding defensive nil checks to the Modify helper to prevent potential panics when handling nil inputs, as well as expanding unit tests to cover these edge cases.

Comment thread internal/prototest/prototest.go Resolved
Comment thread internal/prototest/prototest_test.go Resolved
@VLukiantsev
VLukiantsev marked this pull request as ready for review October 7, 2026 10:44
@github-actions
github-actions Bot requested a review from pachopepe October 7, 2026 10:44
pachopepe
pachopepe previously approved these changes Oct 7, 2026
@pachopepe pachopepe left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

197 files :O, At a glance LGTM. Some AI comments

Comment thread BUILD.bazel Resolved
Comment thread internal/prototest/prototest.go Resolved
pachopepe
pachopepe previously approved these changes Oct 8, 2026
…ta, uuid, flag, and google shims

Eliminates 8 internal/compat wrapper/alias packages (proto, field_mask, longrunning, health, metadata, uuid, flag, google) and extracts proto.Modify into a dedicated test-only package internal/prototest.

Refs #1066
TAG=agy
Add nil guards for typed-nil base proto messages (!base.ProtoReflect().IsValid())
and nil mutation functions in prototest.Modify, along with corresponding unit tests.

Comment link: #1124 (comment)
Comment link: #1124 (comment)
Part of #1066
TAG=agy
CONV=4d3b3bec-3d31-4d4a-a440-8e4bd19b2cf3
@VLukiantsev
VLukiantsev added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit 8312af9 Oct 8, 2026
18 of 23 checks passed
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

0