Skip to content

modules: split module extensions out of repos.bzl into extensions.bzl - #10016

Merged
TrapsterDK merged 4 commits into
mainfrom
fix-9870-extensions-split
Nov 10, 2026
Merged

TrapsterDK merged 4 commits into
mainfrom
fix-9870-extensions-split

Conversation

@TrapsterDK

Copy link
Copy Markdown
Collaborator

Closes #9870

What changed

  • Every module_extension moved from repos.bzl into a sibling extensions.bzl in the same package (18 dirs). Helper code stays in repos.bzl.
  • dart/pub.bzl and dotnet/rules_dotnet.bzl are new entry points. The extensions stay in dart/extensions.bzl and dotnet/extensions.bzl, so no extension loads a file from a repo it generates.
  • use_extension labels relabeled in root MODULE.bazel, family MODULE.bazel files, modules/families.json, MODULE.bazel.lock (regenerated with bazel mod deps --lockfile_mode=update), and the Rust code that parses those labels (libs/module_bazel, cli/adopt).
  • New tools/ci repos_bzl_test fails if any covered repos.bzl calls module_extension(.

Verification

  • repos_bzl_test: passes.
  • bazel build //:dx (with remote cache disabled): passes.
  • //modules:families_test: 3 failures. The relabeled labels match. The remaining reported items are gazelle, perl, php, and google_benchmark entries in families.json that my edits did not touch. Not yet verified against HEAD.
  • dx check generate phase: fails in proto_bindings, javascript/rules, and cpp_rust/apps. Those packages are unmodified. Not yet verified against HEAD.

Not run / not covered

  • Format, lint, and typecheck are not passing on this final state.
  • The repos.bzl check does not cover 4 nested-module repos.bzl files (families/msix and others). Bazel rejects them from the root package, so their extensions were moved but are not checked by the test.
  • 5 corpus targets are not visible from tools/ci, so their repos.bzl files are also uncovered.
  • dx check --apply was not used. It regenerates a duplicate pub_deps block in MODULE.bazel through cli/adopt/src/lock_hubs.rs (a literal extension_bindings label compare). That is pre-existing and not fixed here.
  • Nested Bazel and *_consumer_test targets were not run, per the task constraints.
  • docs/support-matrix.md was not regenerated; no diff was needed for this change as far as checked.

🤖 Generated with Claude Code

@TrapsterDK
TrapsterDK marked this pull request as draft November 9, 2026 15:15
@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Fixed: rebased onto current origin/main (one conflict in ruby/toolchain/repos.bzl: main's rubyinstaller_archive.patch carried into ruby/toolchain/extensions.bzl); MODULE.bazel.lock re-resolved with bazel mod deps --lockfile_mode=update, no drift from the committed lock.

Passes: //tools/ci:repos_bzl_test.

//modules:families_test still has 3 failures, none from lines this PR touches: stale families.json entries (gazelle/, swift_format_macos, ruby, cpan, composer), perl/php tests/bench missing from STARLARK_DOCS_PACKAGES, and families//third_party/rules_dx missing main's rules_dart.external_pkgsrcs.patch. The generate-check failures in proto_bindings, javascript/rules (framework_jest_config) and cpp_rust/apps (consumer_choice_test) are in packages this PR does not change. Not verified against a separate main build.

Nested-Bazel and consumer tests were not run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hwESun1HL2eSVd1d5B

@TrapsterDK
TrapsterDK force-pushed the fix-9870-extensions-split branch from dd90504 to 25c1e28 Compare November 9, 2026 15:28
@TrapsterDK
TrapsterDK marked this pull request as ready for review November 9, 2026 15:28
@TrapsterDK TrapsterDK added the needs-review Touches review paths; needs a second-session Review: comment label Nov 9, 2026
@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Review: changes requested

  1. Public load paths break with no shim. Consumer use_extension("@rules_dx//<pkg>:repos.bzl", ...) labels for every moved extension (msvc, gcc, erlang, php, fortran, ruby_tools, dotnet_tools, ...) now fail. Worse, two paths keep their name but change meaning:
    • @rules_dx//dart:extensions.bzl%pub (documented in dart/README.md) is now dart:pub.bzl. dart/extensions.bzl now holds dart_tools.
    • @rules_dx//dotnet:extensions.bzl%dotnet is now dotnet:rules_dotnet.bzl. dotnet/extensions.bzl now holds dotnet_tools.
      This is a breaking change for external consumers. Say so in the PR, or keep re-exports at the old paths. cli/adopt/src/lock_hubs.rs:71 and cli/adopt/src/status.rs:372 now generate or detect only the new labels, so already-adopted repos with the old labels are no longer recognised.
  2. Stale lockfiles. Family lockfiles still key the old extension ids and are not in the diff: families/dotnet/MODULE.bazel.lock:10539 (dotnet:extensions.bzl%dotnet), families/dart/MODULE.bazel.lock:10533 (dart:extensions.bzl%pub), and the cuda, fortran, php and beam locks. Only the root lock was regenerated. Under --lockfile_mode=error these fail.
  3. Docs missed: docs/cli/commands/README.md:634 still lists @rules_dx_cuda//toolchain:repos.bzl for CUDA license acceptance. cuda_license now lives in extensions.bzl.
  4. dart/repos.bzl:1 and dotnet/repos.bzl:1 are now docstring-only files with stale text. Delete them or give them real content.
  5. Verification gaps the PR admits: format, lint and typecheck do not pass, //modules:families_test has 3 failures not checked against HEAD, and dx check generate fails in 3 packages. The new repos_bzl_test (tools/ci/BUILD.bazel:1025) does not cover nested-module or corpus-invisible repos.bzl files. Resolve these before merge.

The behavior of the moved code looks unchanged. The moves are verbatim, and the pins and Label() references resolve in the same package.

AGENTS.md style: no new rationale comments.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hwESun1HL2eSVd1d5B

@TrapsterDK
TrapsterDK force-pushed the fix-9870-extensions-split branch from 25c1e28 to 5cd9500 Compare November 9, 2026 23:36
@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Fixed: (1) breaking public load paths are intended with no shims since nothing is released; (2) every family lock regenerated with bazel mod deps --lockfile_mode=update (android, apple, beam, cuda, dotnet, fortran, generation, haskell, js, julia, jvm, lua, msix, ocaml, perl, php, powershell, ruby, swift, zig, dart); no old extension ids remain; (3) docs/cli/commands/README.md CUDA reference now points at extensions.bzl; (4) dart/repos.bzl and dotnet/repos.bzl deleted; (5) restored the toolchain_type labels in d, erlang and fortran repos.bzl that the rebase had broken (dx failed to build). Rebased history onto b96490a (force-with-lease).

Not verified: dx format --affected ran 19 minutes and ended on unrelated analysis errors (python/tests/fixtures/hello missing package, cc/toolchains/msvc:unsupported fail), so format and lint did not complete. Nested-Bazel and consumer tests were not run. Mod deps reports 'ruby extension does not generate repository bundle' for family modules; not investigated.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hwESun1HL2eSVd1d5B

@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Review: approve

Checked at 5cd9500 against #9870:

  • No repos.bzl calls module_extension( at head, and no use_extension or lock entry names a moved repos.bzl% extension id.
  • No old dart:extensions.bzl%pub or dotnet:extensions.bzl%dotnet ids remain in any lock. dart/repos.bzl and dotnet/repos.bzl are gone.
  • The toolchain_type labels are right: @rules_d//d:toolchain_type in d/toolchain/repos.bzl:319, @rules_erlang//tools:toolchain_type in erlang/toolchain/repos.bzl:331 and @rules_fortran//fortran:toolchain_type in fortran/toolchain/repos.bzl:123.
  • Each package's BUILD.bazel lists extensions.bzl in its srcs.

No must-fix items. Optional follow-up: tools/testing/module_srcs_test.rs:8 and :21 still name erlang/toolchain/repos.bzl as the nested-consumer entry point, though consumers now load extensions.bzl. The load closure still covers repos.bzl.

Not verified here: I did not build or run any tests. The PR's reported families_test and generate-check failures are unconfirmed against main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hwESun1HL2eSVd1d5B

TrapsterDK and others added 4 commits November 10, 2026 01:17
…closes #9870)

Move every module_extension out of repos.bzl into a sibling extensions.bzl
in the same package and relabel the use_extension references in MODULE.bazel,
family MODULE.bazel files, modules/families.json, the lock, and the CLI and
libs that parse those labels.

dart and dotnet keep their extension entry points in pub.bzl and
rules_dotnet.bzl so the extension does not load a file from a repo it
generates.

Add tools/ci repos_bzl_test to fail if any repos.bzl calls module_extension(.

Co-Authored-By: Claude Haiku 5.5 <[email protected]>

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xut2hwESun1HL2eSVd1d5B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Touches review paths; needs a second-session Review: comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extensions: 13 module extensions live in repos.bzl, the rest in extensions.bzl

1 participant