Skip to content

Say when a rules_jvm_external hub builds a Maven artifact that a patch does not reach - #2157

Merged
Mikola Lysenko (mikolalysenko) merged 19 commits into
mainfrom
bazel-maven/01-hub-notice
Nov 19, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 19 commits into
mainfrom
bazel-maven/01-hub-notice

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

In a Bazel workspace, get, scan, vendor and apply now warn when a rules_jvm_external hub builds a Maven artifact from its own lock, so that a patch they report does not reach the Bazel build (maven_bazel_hub_unpatched, maven_bazel_unreadable).

Stacked. This pull request is stacked on the pull request of the reader of Bazel workspace files ("Read the calls of a Bazel workspace's files", branch bazel-vex/02-reader). That branch (#2148) is its base, so the diff shows this pull request's four commits only: the tests, the change, what a code review of it changed, and a fix of a test's environment. It moves onto main when the reader has landed. The reader's branch also holds the .bazelignore change ("Keep Go module copies under .socket out of Bazel packages"), whose bazel_root and docs section this one uses.

What the code does today

A rules_jvm_external hub (maven.install(..., lock_file = "//:maven_install.json") in MODULE.bazel) builds each jar that its own lock names, at the sha256 the lock holds. It reads no pom.xml and no Gradle file. A lock with m2local takes a jar that none of its repositories lists from the Maven local repository, at the lock's sha256 too. So nothing socket-patch does for a Maven artifact reaches a Bazel build, and until now nothing said so. The first commit holds that on a real Bazel, with two flows that assert what the product code does before the second commit. They pass on Bazel 9.3.2 with that code:

  • A checkout that Maven builds too (maven::a_pom_patch_beside_a_pinned_hub). socket-patch get <purl> --mode hosted --yes pins the artifact in pom.xml (three files), reports it applied and gives no warning. bazel run //:consumer prints the upstream marker before and after, and Bazel never asks for the patched jar.
  • A tree that only Bazel builds (maven::a_tree_only_bazel_builds). The same command writes nothing, reports the patch skipped (redirect_unconfirmed) and explains it with redirect_maven_no_pom: "no pom.xml present; maven redirect skipped".

What changes

socket-patch still does not patch a hub. It now says when one builds an artifact it has a patch for.

When the project is in a Bazel workspace, a command that pins or applies Maven patches reads the root MODULE.bazel and the files it includes for the tags of the maven extension of rules_jvm_external (under whatever name the file gives the ruleset and the extension). A hub is the install, artifact and from_toml tags of one name, and override replaces an artifact of one. Then it reads the lock each hub names with the lock_file of its install (format 2 or 3, up to 16 MiB; every other file up to 1 MiB). Nothing is evaluated, no Bazel is run and nothing is written. For each Maven patch of the run:

  • maven_bazel_hub_unpatched when a pinned hub fetches the jar of that artifact, without a classifier, at the patch's version, and nothing below makes that uncertain. The hub fetches a jar that its lock has a sha256 for and does not skip, and that a repository of the lock lists or, in a lock with m2local, that none lists. For a hub with the default name:

    pkg:maven/<group>/<artifact>@<version>: Bazel takes this artifact from maven_install.json (hub "maven", maven.install at MODULE.bazel:4), which pins the upstream jar. socket-patch does not patch a rules_jvm_external hub yet, so the Bazel build stays unpatched whatever this command did for another build of the checkout

  • maven_bazel_unreadable when socket-patch could not tell whether a hub builds the jar:

    • When no hub that was read holds the jar, and one may:
      • a hub without lock_file, which is also a hub that only maven.artifact or maven.from_toml tags make: Bazel resolves what such a hub builds when it builds;
      • a maven.artifact or maven.from_toml tag that cannot be read (a name that is not a plain string, a tag that is not a statement of its own);
      • install tags of one hub that name different locks;
      • a lock that is missing, empty, not format 2 or 3, larger than 16 MiB or no JSON;
      • the WORKSPACE file Bazel would take (WORKSPACE.bzlmod, else WORKSPACE.bazel, else WORKSPACE) when it calls maven_install, under that name or the one a load of the file gives it, or when it cannot be read. This one is passed over when the Bazel root names Bazel 9 or later, which reads no such file. A directory of one of those names is not such a file, for Bazel and here.
    • Whether or not a hub's lock holds the jar. The ruleset takes a hub's lock from the last install tag of the hub in the root module, so an install tag that was not read may change the lock of any hub, and no lock is named beside one:
      • a maven.install whose name or lock_file is not a plain string, whose name Bazel would not take for a repository, or that is not a statement of its own;
      • anything the reader could not read with certainty in MODULE.bazel and the files it includes: a construct that needs running, a load, an if, for or def statement, a file past the reader's bounds, the extension handed to override_repo.
    • When a hub's lock holds the jar: a maven.override of the artifact, which makes the hub hand out a target of the checkout in the jar's place, or a maven.override whose coordinates are not a string. An override is matched as the ruleset matches it, by the name of the artifact's target (com_google_guava_guava), and for every hub, as rules_jvm_external 6.5 applies it.

    pkg:maven/<group>/<artifact>@<version>: socket-patch could not tell whether Bazel takes this artifact from a rules_jvm_external hub: MODULE.bazel:4: hub "maven" has no lock_file``

The Bazel release is the one that .bazeliskrc (USE_BAZEL_VERSION) or else .bazelversion at the Bazel root names, read as bazelisk reads them: the last USE_BAZEL_VERSION line counts, without the blanks around the name and the value, and an empty value leaves it to the first line of .bazelversion, taken as it is written. Only one release of three numbers (9.3.2) names a release. With latest, 9.x, a release candidate, a fork's release or a file that cannot be read, the WORKSPACE file counts as one Bazel may read. USE_BAZEL_VERSION in the environment and in the .bazeliskrc of the home directory is not read: socket-patch does not run in the environment of the build.

Both warnings are run-level warnings[] under --json and a Warning: ... line on stderr otherwise. They come from the three places every such command passes through, each of which calls one helper: the hosted flow (get and scan with --mode hosted), the vendoring step (vendor, and get and scan with --mode vendored) and the apply run (apply, and the agent-mode get and scan that end in one). A human vendor prints the line above its closing summary and "Next steps:".

What does not change:

  • No event, no exit code and no written file. A pom.xml or Gradle build of the checkout is patched exactly as before.
  • No other warning. The new warning is added to a run and none is removed or replaced for it. A hosted run of a tree without pom.xml gives redirect_maven_no_pom as before and, after it, the new warning.
  • Nothing for a project outside a Bazel workspace. No Bazel file is looked for unless the run has a Maven patch and the project is in a workspace: a MODULE.bazel, REPO.bazel, WORKSPACE or WORKSPACE.bazel in the project's directory or above it, up to the root of its git checkout (bazel_root).
  • Nothing for a Maven project that no hub builds: every hub was read and none holds the artifact as a plain jar at that version. Also nothing under --global, nothing from apply for a patch whose package it does not find, and nothing from a vendor whose --ecosystems leaves Maven out.

Contents

The reader this sits on is bazel/starlark.rs and bazel/workspace.rs (3,903 lines with its tests, 940 of them code). It lists the calls of MODULE.bazel and of the files it includes without evaluating anything, answers "which calls of this tag of this module extension does the workspace make" together with what it could not read with certainty, and reports the WORKSPACE file Bazel would take apart from that. Everything here reads Bazel files through it and treats each of its doubts as "cannot tell".

Commit What Size
Test a hosted Maven patch beside a rules_jvm_external hub on real Bazel tests only: the Maven module of the real-Bazel tests, its fixture (three eras), bazel-maven.yml, Cell::bazel_env 12 files, +732
Say when a rules_jvm_external hub builds a Maven artifact that a patch does not reach the reads, the warning, its three call sites, docs, tests; the flows' expectations changed to the warning 15 files, +1,835 −60
Correct what the Maven hub notice reads and where a run reports it the eight corrections of the code review below, with their tests and docs 13 files, +563 −205

The three commits together, against the reader's branch: 25 files, +2,886 −21.

  • Implementation: 534 added lines and 9 removed; 350 more code lines as scripts/loc-budget.py counts them (325 in the bazel group, 25 in the CLI).
    • bazel/maven.rs 413 lines (287 code): hubs, the lock reader, overrides, the answer per artifact, the warning. The WORKSPACE part is 20 code lines; maven.override is 22, 5 of them the ruleset's own rule for the name of an artifact's target.
    • bazel/rc.rs 58 (32): the Bazel release a launcher is told.
    • bazel/workspace.rs +16 −9 (4 more code lines): disk_up_to, the reader's view of the checkout with a size bound of the caller's, because a lock can be larger than the 1 MiB of a Starlark file. disk is that view at 1 MiB and reads as before; a write the run still holds and the read of one byte past the bound apply to every bound.
    • CLI: 45 added lines and none removed (25 more code lines) in commands/mod.rs (the helper), scan/hosted.rs, vendor.rs and apply.rs.
  • The third commit alone: 132 added implementation lines and 94 removed, 7 more code lines. The core grows by 18 code lines (maven.rs 7, rc.rs 11) and the CLI shrinks by 11 (scan/hosted.rs −11, vendored_backend/mod.rs −8 and back to the reader's version, commands/mod.rs +5, vendor.rs +3).
  • Tests: 2,033 lines. Unit tests 958; the real-Bazel module 497, plus 10 in the harness; tests/e2e_bazel_maven_beside.rs 440; vendor_jvm_cli.rs 128 (one test, and its helper split so that a run can be read as a person reads it).
  • Fixture: 100 lines in 8 files. Workflow: 147 lines. Docs: 71 lines (docs/ecosystems.md "Bazel workspaces: Maven", two rows in CLI_CONTRACT.md).
  • scripts/loc-budget.json: the bazel group goes from 1134 to 1459.

Three tests of the reader change with disk_up_to, and no expectation of the reader changes: a_file_that_grows_past_the_bound_is_not_cut_there passes the bound to the function that now takes it, and the_checkout_on_disk_is_read_through_the_same_code and a_write_the_run_still_holds_is_what_is_read gain lines for a bound other than 1 MiB.

The bound of a lock. A lock of exactly 16 MiB made of 274,181 small artifacts took 0.54 s and 299 MB of memory to read (debug build, macOS arm64; 30 MB without a workspace). One byte more is refused in 0.01 s with maven_bazel_unreadable. This was measured on the head before the third commit, which does not change how a lock is read, and not again.

Code review

A review of the second commit found eight things. The third commit corrects them. Each one was first shown by a unit test or a test through the binary that failed, and then corrected.

  • A vendor limited to other ecosystems warned about Maven. socket-patch vendor --ecosystems npm, in a workspace whose hub builds a Maven patch of the manifest, gave the warning although the run vendored no Maven patch: the vendoring step asked about every patch of the manifest. It now asks about the patches the run vendors, which is the selection --ecosystems makes.
  • A hub made by maven.artifact or maven.from_toml was not seen. The ruleset makes a hub of a name from those tags as it does from install (private/extensions/maven.bzl: artifact at 6.5, 6.9 and 7.2, from_toml at 6.9 and 7.2; override and amend_artifact make none). A hub that only those tags make has no lock, and Bazel resolves it when it builds. A patch for one of its artifacts got no warning, while the same hub written as maven.install() got maven_bazel_unreadable. Now both get it, with the file and line of the tag. Such a tag that cannot be read is said as a doubt; it cannot name a lock, so the hubs that were read stay as they are. A pinned hub with such tags stays pinned: its lock holds their artifacts.
  • The hub's warning was counted as one of the lock rewriters'. In a human hosted run, a package that got no lock entry is pointed at the warnings that explain it ("see the warning below"), and the count behind that pointer is the lock rewriters' own list. The hub's warning was put into that list, so a package of any ecosystem without a lock entry was pointed at a warning about a Maven hub. It now joins the run's merged list of warnings, after the rewriters' ones, and is not counted. scan/hosted.rs is 13 lines smaller for this and the next point (19 removed, 6 added; 11 code lines fewer).
  • redirect_maven_no_pom was taken away after the fact. The CLI removed that warning of the core by its text and by comparing two counts, so a rename in the core would have ended it silently, and a user who ran in the wrong directory lost the one line that says there is no pom.xml. That code is deleted. The new warning is added and no other warning is removed or replaced: a tree that only Bazel builds now gets both lines, which are both true.
  • A lock with m2local. The lock reader took a jar that no repository of the lock lists as one the hub does not fetch. Under m2local the ruleset fetches such a jar from the Maven local repository, at the lock's sha256 (private/extensions/download_pinned_deps.bzl and the lock readers of formats 2 and 3, at 6.5, 6.9 and 7.2). Such a jar now counts as one the hub builds, and gets maven_bazel_hub_unpatched, whose text names the lock and no repository. The module's documentation and docs/ecosystems.md no longer say that a hub reads no Maven local repository.
  • .bazeliskrc and .bazelversion were not read as bazelisk reads them. The reader took the first line that began with USE_BAZEL_VERSION= and cut the blanks off the line of .bazelversion. bazelisk (v1.30.0: config/config.go lines 62 to 73, core/core.go lines 406 to 433, versions/versions.go lines 20 to 27) drops the blanks around the key and the value, lets the last line of a key win, passes over an empty value, and takes the first line of .bazelversion as it is written. So the old reader could name Bazel 9 where bazelisk runs Bazel 7 (two USE_BAZEL_VERSION lines, or USE_BAZEL_VERSION = 7.7.2 beside a .bazelversion of 9), and then pass over a WORKSPACE file that Bazel does read. The files are now read as bazelisk reads them, and every form that is not one release of three numbers names none, which keeps the careful answer. The variable of the environment is not read, and the documentation says so.
  • One view of 16 MiB for every file. The view made for locks also served MODULE.bazel, the files it includes, the WORKSPACE file and the two release files, so the reader's bound of 1 MiB per file was no longer applied when a file was read: a MODULE.bazel of 15 MiB was read whole before it was refused, and the reason it gave was another one. Those files are read through the reader's own view again, and only a hub's lock through the larger one.
  • Three ways to report one warning. apply added the warning to the warnings of its run, the hosted flow converted it three times, and the vendoring step printed it with a loop of its own, after the run's closing summary and "Next steps:". Now one helper returns the warnings and, for a caller that asks, tells a human run itself (not under --json, not under --silent), as the helper of the .bazelignore change does. The vendoring step calls it before its closing lines. What is left as it was: apply and the hosted flow print the warnings of their run themselves, apply in the loop that prints its other warnings and the hosted flow after its summary in its own format, so they take the warnings and do not ask the helper to print. One consequence: a vendor that is refused before it vendors anything (a ledger that cannot be read, or one that git ignores) no longer gets the warning, like a vendored get that fails early.

Expectations of existing tests that changed with it:

  • tests/e2e_bazel_maven_beside.rs, a_hub_only_tree_names_the_lock_that_builds_it, now a_hub_only_tree_names_the_lock_beside_the_missing_pom: a tree without pom.xml beside a hub that builds the artifact expected the one warning maven_bazel_hub_unpatched and no "no pom.xml" line; it now expects redirect_maven_no_pom and then maven_bazel_hub_unpatched, and for a person the pointer "(see the warning below)", the line "No pom.xml present; maven redirect skipped" and the hub's line, in that order. The same order is expected beside a hub without a lock, where the pointer read "(see the warnings below)" before.
  • tests/e2e_bazel_build/maven.rs, maven::a_tree_only_bazel_builds: the warnings of the command were exactly the hub's; they are now redirect_maven_no_pom and then the hub's.
  • bazel::maven, a_hub_is_an_install_tag_of_the_rulesets_maven_extension, now a_hub_is_a_tag_of_the_rulesets_maven_extension: the artifact tag of its fixture, which gives no name, now makes a second hub, maven, without a lock.
  • bazel::rc, a_release_is_three_numbers_or_nothing: a .bazelversion whose first line has blanks around 9.3.2 named 9.3.2 and now names no release.

A fourth commit keeps the coverage profile out of the hermetic tests' project directory: under the coverage job the instrumented binary wrote a default_*.profraw there, which the tests counted as a file the run wrote, and all four failed on the first run of this pull request. The tests now hand LLVM_PROFILE_FILE to the child; the product is untouched.

What it proves, and where

On real Bazel, on this head (macOS arm64). Each release ran from an empty repository cache, an empty Bazel output base and an empty Coursier cache, as the reusable workflow's run step runs the tests; the two flows of a release run side by side.

Bazel rules_jvm_external lock a_pom_patch_beside_a_pinned_hub a_tree_only_bazel_builds downloaded connections to public Maven hosts
9.3.2 7.2 format 3 22.2 s 22.0 s 397 MB 0 of 91
8.8.2 6.9 format 2 20.9 s 21.1 s 345 MB 0 of 63
7.7.2 6.5 format 2 24.3 s 24.1 s 327 MB 0 of 76

On every release the build printed the upstream marker before and after the command, the patched jar was never asked for, the warning about the hub had the text above with the fixture's hub and the line of its maven.install (hub "fixture_maven", MODULE.bazel:15), and the lock that release wrote was read by the product's own lock reader (format, version, sha256 of the run's jar). In the checkout with a pom.xml it was the command's one warning; in the tree without one it came after redirect_maven_no_pom. rollback --yes restored every file.

  • With the binary of the second commit in the place of this head's, a_tree_only_bazel_builds fails on Bazel 9.3.2, at the warnings: that binary gives the hub's warning alone.
  • On the head before the third commit, the first commit's two flows passed on Bazel 9.3.2 with the product code before the second commit, from an empty repository cache, and with the binary of that product code both flows of the second commit failed at the warning. The first commit has not changed; those two runs were not repeated.

The flows ask no public Maven repository. An earlier form of the fixture had a hub with the default name, maven. A hub of that name also takes the artifacts that other Bazel modules of the build add to a hub named maven, and protobuf, which is in the module graph of every era, adds gson, guava and what they depend on. A pin resolves all of them from the repositories the root gives the hub, so the fixture had to list Maven Central, and every pin of every run asked it, with the empty Coursier cache a test gives its pin. Repeated runs of that form can get an address refused by Maven Central (HTTP 429), and a hosted runner, which shares its address with others, can be refused the same way. Now:

  • The hub is the fixture's own. It is named fixture_maven, nothing but the fixture adds to it, and its one repository is the test's loopback server. The lock a pin writes holds the fixture's two artifacts and that one repository, in the format of the era.
  • The hub that protobuf still declares is never fetched. The ruleset's extension keeps one entry per hub name, the root's and the other modules' apart (private/extensions/maven.bzl at 7.2, lines 375-376 and 409-475, merged by name at 563-604; at 6.9, lines 429-499 and 570-614; at 6.5 one map, lines 275-345). For each name it only declares repositories: the unpinned one that runs Coursier (7.2: 668-698; 6.9: 679; 6.5: 408) and, for a hub with a lock, one per jar of the lock and the pinned hub (7.2: 713 and 740; 6.9: 722 and 746; 6.5: 450 and 474). It reads files and downloads and runs nothing. Coursier runs in _coursier_fetch_impl (private/rules/coursier.bzl: 7.2 line 1247, 6.9 line 1036, 6.5 line 972), the rule of an unpinned hub, which Bazel runs when a label of that repository is asked for. @fixture_maven//:pin and //:consumer ask for none of the other hub. On Bazel 9 protobuf 33.4 gives its hub a lock of its own, which the extension reads; on Bazel 8 and 7 protobuf 29.0 and 21.7 give it none.
  • Measured. The runs of the table had every child of the tests (Bazel, its downloader, the Coursier that pins) behind a loopback proxy that logs each connection and refuses the hosts of public Maven repositories: any host with maven, sonatype, jcenter, bintray, jitpack, clojars, gradle.org, repo.spring.io, repository.apache.org, aliyun, huaweicloud, tencent, jfrog, artifactory or nexus in its name, which covers Maven Central, its well-known mirrors and Google's Maven repository. The harness needed no change for it: it keeps the proxy settings of the caller for Bazel's children, and the ruleset hands them to Coursier. No connection was refused on any release. What was asked: bcr.bazel.build (65, 44 and 47 connections on 9.3.2, 8.8.2 and 7.7.2), github.com (11, 8, 12), release-assets.githubusercontent.com (7, 5, 11), cdn.azul.com (2 each, the JDK), mirror.bazel.build (3, 4, 4), and on 9.3.2 codeload.github.com (1) and go.dev (2, a module of the graph asks for the list of Go releases).
  • What Bazel fetched. Of the repositories of the ruleset's extension, each release fetched four: the fixture's hub, its unpinned twin and the two jars. No repository of the hub named maven and none of its jars were fetched (92, 67 and 100 repositories in all on the three releases).
  • The proxy sees a pin that leaves the loopback server. As a control, on the head before the third commit, one flow per release was run with a second repository on a host of the refused kind that exists nowhere (https://maven-control.invalid/maven2) and an artifact the loopback server lacks. Coursier asked that host through the proxy, was refused (three logged connections per release), and the flow failed at the pin. The fixture was put back afterwards. The fixture and the harness have not changed since, and the control was not repeated.
  • Bazel's own mirror. mirror.bazel.build is the first URL that rules_java gives its two java_tools archives; what is asked inside a TLS connection is not visible to the proxy. So, on that earlier head, the first commit's flows were run once more on 9.3.2 from an empty cache with that host refused as well: they passed, with no connection to a public Maven host.

Two tests keep it so. A flow asserts that the lock its pin wrote names the fixture's two artifacts and the loopback repository and nothing else. maven::the_fixture_has_one_repository_to_replace_per_era, which runs without Bazel in the required job, asserts that each era's MODULE.bazel has the hub's name and no other URL, and that the build file names that hub; it fails for the earlier form of either file.

What the real-Bazel flows no longer show: a hub of the default name whose lock also holds the artifacts of another Bazel module, under two repositories. Without a Bazel, tests/e2e_bazel_maven_beside.rs writes exactly that for every checkout it makes: a hub whose tag has no name, and a format 3 lock with the fixture's artifacts and one that protobuf adds, each listed under two repositories, as a pin of such a hub wrote it. a_hub_that_pins_the_artifact_adds_one_warning_and_nothing_else and a_hub_only_tree_names_the_lock_beside_the_missing_pom expect the warning with hub "maven" from it. The unit tests a_hub_is_a_tag_of_the_rulesets_maven_extension and a_notice_names_the_lock_and_the_hub_or_what_was_not_read read a hub without a name. No test reads such a lock from a real pin any more.

On Linux, on GitHub's runners, the three Maven legs of this pull request pass at its head on Bazel 9.3.2, 8.8.2 and 7.7.2 (101 to 104 seconds per leg), with the other 63 checks. The runner had a Java for the era that Bazel 7.7.2 builds.

Nothing changes where no hub builds the artifact. The binary of this head was compared with the binary of the second commit, run by run, on exit code, stdout, stderr and the files written:

  • 242 runs in 21 checkouts, none of which has a hub that builds the artifact: no Bazel file at all, with and without a pom.xml; a workspace file alone (WORKSPACE, REPO.bazel, a MODULE.bazel without the ruleset); another ruleset's hub beside a lock that holds the artifact; a pinned hub that holds the artifact at another version, only with a classifier or another packaging, skipped, or not at all; a WORKSPACE file with maven_install below a declared Bazel 9; a project below the Bazel root; a directory named WORKSPACE. Twelve commands in twenty of them, and two in the last: get --mode hosted as JSON, as a person reads it and as a dry run; apply as JSON, as a person reads it, as a dry run and with --check; scan --mode hosted both ways; vendor both ways and a vendored get (these three run with --offline and are refused, since the fixture has no patch server for them). Every run is byte for byte the same, 227,265 bytes in all.
  • 24 runs of vendor that vendors two Maven patches from the tests' patch server, in 4 checkouts (no Bazel file, a hub that holds another artifact, one that holds another version, a WORKSPACE file alone), as JSON and as a person reads it, wet and dry, with --silent and with --ecosystems npm. Exit code, stderr and every written file are the same; stdout is the same but for the port of the test's own server in two lines of the JSON runs, which differs from run to run.

The two drivers were temporary and are not committed.

Without a Bazel (tests/e2e_bazel_maven_beside.rs, in the required test job):

  • A hosted get and an agent apply, as JSON, as a person reads them and as a dry run, print the same bytes and write the same files in three checkouts: without a Bazel file; with a workspace that has only another ruleset's hub, beside a lock that holds the artifact; with a pinned hub that holds the artifact at another version.
  • A hub that builds the artifact adds exactly one warnings[] entry, or one stderr line, and nothing else, in a dry run too.
  • A tree only Bazel builds gets redirect_maven_no_pom and then the hub's warning, maven_bazel_hub_unpatched beside a pinned hub and maven_bazel_unreadable beside one without a lock. A person is pointed at one warning, the one about the missing pom.xml, and reads the hub's below it.
  • A --global run says nothing.
  • vendor_jvm_cli.rs has the same twin for vendor: the warning as JSON; the one Warning: line a person reads, above the closing summary and "Next steps:"; none under --silent, and none on stderr under --json; and no warning from a run whose --ecosystems leaves Maven out, which reaches the end of the vendoring with an npm patch of the manifest.

Unit tests (bazel/maven.rs, bazel/rc.rs) hold the rules one by one, among them: a later install that cannot be read, a doubt of the reader and an override of the artifact each turn "a hub builds it" into "could not tell"; an override of another artifact does not, and none says anything for a jar no hub fetches; a hub that only an artifact or a from_toml tag makes is "could not tell", a pinned hub with such a tag stays pinned, and such a tag that cannot be read leaves the hubs as they are; under m2local, in both lock formats, a jar that no repository lists is one the hub fetches; of the three WORKSPACE names only the one Bazel takes is read; a lock over 1 MiB is read and one over 16 MiB is not, while a MODULE.bazel or a .bazelversion over 1 MiB is not read; and two tables for the release, one for .bazelversion and one for .bazeliskrc, each row under the lines of bazelisk's source it rests on.

Through the binary, by hand, on the head before the third commit and not repeated on this one: a maven.override of the artifact, a second maven.install with a computed lock_file or name, the extension handed to override_repo and a hub name with a line break each gave maven_bazel_unreadable; an override of another artifact left maven_bazel_hub_unpatched. The unit tests that hold each of these pass on this head.

That the tests can fail.

  • On this head, 26 single changes to the product code each fail a named test:

    • in bazel/maven.rs: artifact tags ignored; from_toml tags ignored; a tag of those two that cannot be read removing every hub; such a tag giving no doubt; an artifact tag counted as naming another lock; m2local ignored; every file read through the 16 MiB view; every file read through the 1 MiB view; a lock read through the reader's view; the release files read through the locks' view;
    • in bazel/rc.rs: the key not trimmed; the value not trimmed; the first line of a key winning; an empty value not passed over; a .bazeliskrc that cannot be read passed over; the line of .bazelversion trimmed; its carriage return kept;
    • in the CLI: the vendoring step asking about every patch of the manifest; the hub's warning in the lock rewriters' list; redirect_maven_no_pom removed beside it; the vendoring step's warning printed after the closing lines; printed under --json; printed under --silent; never printed; printed twice by the hosted flow; printed twice by apply.

    Several ran in one build where they fail different tests or different rows of a table.

  • On this head, a_tree_only_bazel_builds fails on real Bazel with the binary of the second commit (above), and the test of the fixture fails for the earlier hub name, for a second URL and for the earlier label in the build file (shown on the earlier head; the fixture and that test are unchanged).

  • On an earlier head, fourteen single changes to the product code of the second commit each failed a named test: an override ignored; an override matched by its text instead of the target's name; an override said for a jar no hub fetches; an override that cannot be read passed over; an install that cannot be read ignored; a doubt of the reader ignored; any string taken for a hub's name; the lock's bound doubled; the lock read through the 1 MiB view; the Warning: line of vendor removed; no warning on a hosted dry run; no warning from apply for a package it did not rewrite; and two about dropping redirect_maven_no_pom, which no longer apply because nothing drops it. The others were not repeated on this head, except the one about the view a lock is read through and the one about the Warning: line, which are in the list above.

  • One change still passes every test: reading the Bazel files in a run without a Maven patch, which changes no output.

What starts on main

  • .github/workflows/bazel-maven.yml, a caller of bazel-compatibility.yml like the npm one. Legs: Bazel 9.3.2, 8.8.2 and 7.7.2 on Linux, each with its own era of the fixture, and 9.3.2 on macOS nightly and on demand. Not required for merge.
  • When it runs. On a pull request that touches the Maven flows, their fixture, the harness, the two workflows, the Bazel installer and its pins, formats/maven/**, patch/redirect/maven_index.rs, crawlers/maven_selection.rs, maven_scope.rs and maven_crawler.rs, vex/discover/maven.rs, patch/redirect/upstream/maven.rs, or bazel/**. On a push to main, those and the shared engine and test helpers, as the other callers have them. Nightly at 05:27 UTC, a minute no other caller uses.
  • Downloads. A cold leg downloaded 397 MB on Bazel 9.3.2, 345 MB on 8.8.2 and 327 MB on 7.7.2. On 9.3.2 that is one JDK (215 MB), java_tools (50 MB), the archive of rules_kotlin, a Bazel module the ruleset depends on (46 MB), Coursier (41 MB), a Python toolchain that a module of the graph asks for (18 MB), and the archives of the other modules. Each era's .bazelrc names one JDK for every Java role; with only the run-time JDK named a leg downloaded three JDKs and 777 MB.
  • Cache. One repository cache per era and platform, saved from main, of the sizes above. The artifact under test cannot come from it or from anywhere else: the test makes it, with an id of the run in the jar, under the group dev.socket.fixture, which only the owner of socket.dev can publish to Maven Central, and the hub's one repository is the test's loopback server.
  • No public Maven repository. A leg asks none, for a pin or for a build (above), so no leg depends on Maven Central or loads it. What a leg does ask on a cold cache is the Bazel registry, GitHub, the JDK's host, Bazel's mirror and, on Bazel 9, go.dev.
  • One new test target in the required job: e2e_bazel_maven_beside (four tests, about two seconds).

Not covered

  • Any patching of a hub. The Bazel build stays unpatched; the warning says so.
  • vex does not look at the hub yet: a patch that a pom.xml pin or a patched jar attests is still attested, although the Bazel build does not have it.
  • A vendored or agent get that fails before it patches anything says what it said before. In a tree only Bazel builds those are vendor_jvm_shape_unsupported and package_not_installed. So does a vendor that is refused before it vendors anything.
  • A lock with m2local beside agent mode. Such a hub takes a jar from the Maven local repository at the lock's sha256, and agent mode patches jars in that repository. What Bazel then does with a jar whose sha256 no longer matches the lock is not measured here. By the ruleset's source the jar is fetched as a file with that sha256, so a fetch that Bazel's own cache does not answer should fail. The warning says that the Bazel build stays unpatched and does not say this.
  • Not seen: a hub or a maven.override that another Bazel module declares, a maven_install inside a function of a .bzl file, a maven_install under a second name of the file's own (install = pin after a load that names it pin), a jar that reaches Bazel without a hub, what the target of a maven.override builds, what a flag or an rc file tells Bazel, and a USE_BAZEL_VERSION of the environment or of the .bazeliskrc in the home directory. Only the release files at the Bazel root are read: bazelisk takes the nearest ones from the directory it is started in. With WORKSPACE.bzlmod present only that file is read, as Bazel does with Bzlmod on; a Bazel 7 started with --noenable_bzlmod reads WORKSPACE instead.
  • Said more often than needed: rules_jvm_external 6.9 and 7.2 apply a maven.override to the hub its name gives. Here an override counts for every hub, as 6.5 applies it, so an override for another hub turns the warning into "could not tell". And any maven.install that cannot be read does so for every hub, also when it belongs to another one.
  • Not run:
    • Real Bazel on Windows: those tests are Unix-only. The tests without Bazel pass on Windows (the four of e2e_bazel_maven_beside, the one in vendor_jvm_cli and the unit tests of bazel::maven and bazel::rc), in a run of the workspace tests started by dispatch on this branch (run 44493211121, at the third commit). That run is red for one other test, scan_project_discovery_e2e::agent_scan_names_a_python_project_below_with_its_own_venv, in a file this pull request does not touch: it builds a virtualenv with the Unix layout.
    • The 6.5 era with a runner's Java: it starts Coursier with JAVA_HOME or the java on PATH.
    • The first commit's flows on 8.8.2 and 7.7.2. They pass on 9.3.2.
    • A hub of the default name on a real Bazel on this head: the flows had one until the fixture's hub was renamed, and passed with it on an earlier head on all three releases.
    • The run with Bazel's mirror refused, and the control of the proxy, on this head.
    • A maven.override, a hub that only maven.artifact or maven.from_toml tags make, and a lock with m2local on a real Bazel. One build on Bazel 9.3.2 (rules_jvm_external 7.2) of an earlier head printed the overriding target's marker. That the last install of a hub gives its lock, that the two other tags make a hub, and what m2local does are read from the ruleset's source at 6.5, 6.9 and 7.2, not built.
    • bazelisk itself: how it reads the two files is read from its source at v1.30.0, not run.
    • go::hosted_go_deps on this head. It passed on 9.3.2 on an earlier one.
    • scan --mode hosted beside a hub that builds the artifact has no committed test; it was run by hand through the binary of an earlier head, and the warning was there. scan, an eject and the agent get share the three call sites that get --mode hosted, vendor and apply are tested through.
    • Two patches in one hosted run beside a hub: the tests' stand-in API selects one. So the case the pointer was wrong for, a package of another ecosystem without a lock entry in a run that also has the hub's warning, has no test of its own. The committed test holds that the pointer does not count the hub's warning, in a run with one package.
    • A vendor that is refused before it vendors, beside a hub: that it gives no warning now is read from the code, not tested.
  • That no Bazel file is opened for a run without a Maven patch holds by an early return and is not asserted by a test.

What follows

Next, a Maven patch for a pinned hub: one managed block appended to MODULE.bazel that puts the patched jar in the place of the hub's own repository for that artifact (override_repo), for hosted get and rollback. That step writes to MODULE.bazel, a new kind of write, which the maintainer has agreed to.
Then scan for what a pinned hub builds, VEX, vendored mode and agent mode, each as a pull request of its own.

Decisions for the maintainer

  1. A patch that a hub builds unpatched still counts as applied when a pom.xml or Gradle build took it, with the warning. The stricter choice is to report it skipped, which changes a contract for projects that pass today.
  2. maven_bazel_unreadable is one warning per Maven patch of the run. A workspace with a hub that has no lock, or with a WORKSPACE file that cannot be read below Bazel 9, gets as many as the run has Maven patches. One warning per run that lists them is possible.
  3. Test size. 2,033 lines of tests for 534 of implementation. The unit tests carry cut-down copies of the ruleset's own locks (about 70 lines); those and the second half of the twin file are what could go first.

🤖 Generated with Claude Code

`scan --mode vendored` and agent mode (`scan --mode agent`, `apply`)
patch a Go module by keeping a patched copy of it in the checkout, under
`.socket/vendor/golang` or `.socket/go-patches`, and pointing `go.mod`
at it with a directory `replace`. Only the hosted flow had a test on a
real Bazel. This adds the two other modes for the same gazelle `go_deps`
workspace, on Bazel 9.3.2, 8.8.2 and 7.7.2, and records what the code
does there today.

The next build is patched in both modes, and the undo is clean
(`vendor --revert`) or leaves only the emptied `.socket/manifest.json`
(`rollback`). The user's next step breaks the build:

- `bazel run //:gazelle` writes a BUILD.bazel into the copy. gazelle's
  `go_deps` copies the directory with that file, and every target that
  uses the module fails to load:
  `No repository visible as '@rules_go'`.
- When the module ships a BUILD file of its own, `bazel build //...`
  fails right after the command: the copy is a package of the checkout
  whose load of `@io_bazel_rules_go` nothing maps.

Each test asserts that break by its error, so that the commit that
fixes it has to change the expectation.

The fixture gains a `gazelle` target, and its BUILD file is now the one
gazelle writes, so a gazelle run on the unpatched checkout changes
nothing and what a later run writes comes from the patch. Agent mode
copies the module from the user's module cache; the test lays that
directory out itself, so the runner needs no Go toolchain beyond the one
rules_go downloads. gazelle is built from Go modules of its own: a flow
that runs it has proxy.golang.org last in its GOPROXY list, after the
stand-in that serves the module under test.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Vendored and agent mode patch a Go module by keeping a copy of it under
the project's `.socket` directory and pointing `go.mod` at it with a
directory `replace`. In a Bazel workspace that copy is a directory
Bazel and gazelle walk like any other. The next build is patched, and
then the user's ordinary steps break it, on Bazel 9.3.2, 8.8.2 and
7.7.2 with gazelle's `go_deps`:

- `bazel run //:gazelle` writes a BUILD.bazel into the copy, `go_deps`
  copies the directory with it, and every target that uses the module
  fails to load (`No repository visible as '@rules_go'`);
- when the module ships a BUILD file of its own, `bazel build //...`
  fails right after the command.

One line in the `.bazelignore` at the root of the workspace prevents
both, and socket-patch now writes it. This is the first Bazel file
socket-patch writes.

Where it applies

A project is in a Bazel workspace when its directory, or one above it
up to the root of its git checkout, holds a regular file `MODULE.bazel`,
`REPO.bazel`, `WORKSPACE` or `WORKSPACE.bazel`. Those are the names
Bazel's client looks for from the working directory up
(`WorkspaceLayout::InWorkspace`, src/main/cpp/workspace_layout.cc line
36 at the tags 7.7.2, 8.8.2 and 9.3.2). The nearest such directory is
the Bazel root; a directory of that name does not count. Without such a
file nothing is read or written, and the run writes the same files as
before, byte for byte.

The checkout is the one `repo_root::find_git_repo` finds, and it
counts only when its `.git` belongs to a trusted owner
(`GitRepo::trusted`: the user, root, or the user sudo ran for; a root
process trusts any), which is the rule the `socket.yml` lookup has for
the repository root. Without it, another user's `/tmp/.git` and
`/tmp/MODULE.bazel` on a shared machine would make a command in
`/tmp/job/proj` create `/tmp/.bazelignore`. A project in no such
checkout (a Docker build context, an unpacked source archive, a
checkout of another user) is looked for in its own directory only:
nothing above it is read, so a workspace file there gives no line and
no warning. Neither does a Bazel root above the root of the checkout (a
git submodule, several checkouts below one workspace): this repository
reads no project file outside the checkout, so a look there could see
the workspace file and not whether the line is in place, and its
warning would never end.

The nearest directory with a workspace file is the root. In a workspace
that is nested in a larger one the line is therefore in the inner file,
which a run from the outer workspace does not read. Measured on Bazel
9.3.2 with gazelle 0.54.0, outside the committed tests: from the outer
root `bazel build //...` loads the packages of the inner tree, a BUILD
file in the copy among them, and `bazel run //:gazelle` writes a
BUILD.bazel into the copy, after which the inner build fails as above;
with the line in the outer file, by its path from the outer root,
neither happens. The writes are not widened for that. The docs name
these limits and the line to add by hand.

What is written

- While `<project>/.socket/vendor/golang` or
  `<project>/.socket/go-patches` exists, the root's `.bazelignore`
  names it by its path from the root, on a line of its own under the
  comment line `# socket-patch: patched Go module copies, not Bazel
  packages (to opt out, comment out the next line)`. The pair is added
  at the end of the file, in the file's line breaks, and the file is
  created when missing. Never `.socket` alone: other things live there.
- Nothing is added when a line already covers the directory: the path
  or a directory above it, with or without a trailing `/` or a leading
  `./`. Bazel reads a line literally, so a line with a blank before or
  after it, a pattern or a string prefix covers nothing.
- Nothing is added either when the user declined the pair: the comment
  line with the path line commented out under it (`#`, blanks, the
  path, which may end in one `/` or start with `./` as in a line that
  covers). No command adds a line for that directory, warns about it or
  touches the two lines again, on removal either. Deleting the pair is
  no opt-out: the next command writes it back. Neither is commenting
  out both lines, or a path line changed in another way.
- socket-patch knows its pair by the start of the comment line,
  `# socket-patch:`, not by the whole sentence: a path line under a
  line that starts so is its own, and that path line commented out is
  the opt-out. A later release can reword the comment without leaving
  the pairs of this one behind.
- Only a directory that is not found is gone. One that cannot be probed
  (a directory above it that may not be searched, a transient error)
  keeps its pair, and gets none.
- Once the directory is gone the pair is removed, and the file is the
  one of before, byte for byte. A file whose last line has no line
  break gets a line break and the pair without a final one, and loses
  that line break again with the pair: exactly the one the comment line
  ends in, which is the one that was written before it, so that a last
  byte that is a carriage return on its own stays. Bazel and gazelle
  honour a last line without a line break: the agent test on real Bazel
  has one.
  A file left empty is deleted, an empty one the user had included:
  it cannot be told from one socket-patch created. Only a line under
  such a comment line is ever removed.
- The line follows the directory, not the `replace`:
  `rollback --preserve-state` drops the `replace` and keeps the
  vendored copy, whose BUILD files would be back in the workspace
  without the line.
- A read-only file is neither replaced nor deleted. The file is opened
  for appending before any change, a removal included, because a
  rename or an unlink succeeds in a writable directory.
- A file that is not updated is the new warning
  `bazelignore_not_updated`: it could not be read or written (a
  directory or a symbolic link in its place, a read-only directory, a
  read-only file). The detail names the line to add, or says that the
  lines of a copy that is gone can be deleted. The command succeeds as
  before.
- A human run reads `Updated <path>` or `Removed <path>` on stdout when
  the file changed, once for each file, in words that hold for lines
  that came and for lines that went, and the warning on stderr. Under
  `--json` the warning is a run-level `warnings[]` entry; there is no
  new field.

Which commands

`commands::sync_bazelignore` is the one place the CLI asks for the
file, behind one gate: not in a dry run and not in a `--global` run.
Each command that can write or remove a copy calls it once, after its
last step that can change a copy or take one back: `apply` (and with
it `scan --mode agent` and `get`), the vendored step of `scan` and
`get`, `vendor`, `vendor --revert`, `rollback`, `remove`, `repair`
(also when it failed), and a hosted scan that took the lock, since a
takeover removes the vendored copy. A hosted scan that took no lock may
write nothing (`patches.enabled: false` in `socket.yml`, a rollout cap,
no granted reference) and leaves this file alone too. The eject of a
hosted project calls it after its rollback, so that an eject which
vendored the Go module and was then rolled back leaves no pair for a
copy that is gone again. `apply` and `vendor` in a project with no
manifest end before that step.

A run whose `--ecosystems` leaves `golang` out adds no line. It still
takes away the pair of a copy that is gone, because `remove` of a Go
patch and `vendor --revert` remove the Go copy whatever that option
says.

With a `--manifest-path` into another project the agent copies are
those of `--cwd` and the vendored ones those of the manifest's project,
so the helper brings the file of each project's Bazel root in line.

`scan --prune` comes to the file a second time, after a pass that
reverted a vendored entry or swept an orphan directory, which can
remove the last copy after the scan's own step. That second call only
takes a pair away: it adds no line and gives no warning, so the run
warns once and no state is kept between the two. What it costs: a
warning the scan's own step gave for a copy the pass then removed is
out of date, and a file the pass cannot write is reported by the next
command. The scan's own call cannot be left to that pass instead: the
pass also follows the nested apply of `scan --mode agent --prune`, and
it does not run at all when it cannot take the apply lock.

The file is written after the commands' group commits, outside them:
it is no part of a commit journal. A run that dies in between leaves a
copy without its line, which the next command adds; a command that
fails after it removed a copy can leave the pair behind, which ignores
nothing, until the next command.

A file several projects share

Two projects under one Bazel root share the file, and each command
holds only its own project's apply lock. So the edit, from its read to
its write, is made under an advisory lock on the root directory itself:
`fs2` on a handle to the directory, with contention told as the apply
lock tells it (`apply_lock::is_lock_contended`). No lock file is made,
in the workspace or anywhere else. A run that finds nothing to change
takes no lock, also when the file cannot be read and the project has no
copy to name in it. Where the directory cannot be locked (Windows, where
it cannot be opened this way; a file system without such locks), or the
lock stays held for a second, the edit is made without it: an add is
still one appending write, which keeps what another project adds at that
moment, and a removal replaces the file and can then lose such a pair
until the next command in that project. With the lock, a removal in one
project against an add in its sibling keeps the added pair in every one
of 25 rounds of a unit test, which asserts that half on Unix only;
without the lock that test fails.

What a run costs

The Bazel root and the bound of the checkout come from one walk up
(`search_dirs`), which runs with the rest of the edit on the blocking
pool. For a project outside a Bazel workspace, `d` directories below
the root of its checkout, that is 2 path canonicalisations, `d + 2`
stats of `.git` and `4 (d + 1)` stats of the four names, and nothing
else. In a Bazel workspace it adds two stats of the copy directories
and one read of `.bazelignore`; the lock and the write come only when
something changes. (Counted from the code, not traced.)

A side effect

The line does more than keep gazelle out. Bazel leaves an ignored
directory out of every `glob()` of a package above it (9.3.2, 8.8.2 and
7.7.2), so a target that hands the project's Go files to a `go` command
of its own through such a glob no longer receives the copies. Built on
Bazel 9.3.2 with a genrule that runs the Go SDK's `go build` over
`glob(["**/*.go", "**/go.mod", "**/go.sum"])`, outside the committed
tests: without the line it builds patched until the first
`bazel run //:gazelle`, whose BUILD file in the copy takes the copy out
of the glob in the same way, and then fails (`replacement directory
./.socket/vendor/golang/... does not exist`) together with every
rules_go target that uses the module. With the line the rules_go
targets build, and that genrule fails with the same error from the
start; it builds when it names the copy's files as labels beside the
glob, or runs outside the sandbox. A workspace that has such a target
and never runs gazelle can decline the line as above.

Not covered

Only Go module copies get a line. Other ecosystems keep unpacked
packages under `.socket/vendor/<ecosystem>` too (a crate can ship a
BUILD.bazel); nothing was measured for them under Bazel, so nothing is
written for them. A BUILD file that gazelle wrote into a copy before
the line existed stays there: the next `scan --mode vendored` rebuilds
the copy, and in agent mode the BUILD files under `.socket/go-patches`
have to be deleted by hand. A project directory whose path from the
root starts with `#` or white space, or holds `*`, `?` or `[`, cannot
be named in `.bazelignore`: its line is written, and Bazel or gazelle
does not honour it. `ignore_directories` in REPO.bazel is not read; a
workspace that has it gets the line too.

Tests

The real-Bazel tests now assert the fixed outcome: the build prints
the patched marker after the command and `bazel build //...` passes,
the two tests of a module without a BUILD file build it again after
`bazel run //:gazelle`, which writes nothing, and the undo takes the
line away. The agent test starts from a `.bazelignore` of the user's
whose last line has no line break, and ends with that file as it was.

Tests without Bazel hold: the root finder (each of the four names, a
directory of such a name, a link, a file above the checkout, a checkout
of an owner that is not trusted and a project in no checkout, which
both reach no further than the project); the line rules (what covers,
the opt-out and what is none, a pair under another wording of the
comment, the pair in LF and CRLF files and after a last line without a
line break, the removal that leaves the file of before, a last
carriage return included, a run that leaves Go out); the write
(appended to the file that is there, a read-only file and a link left
alone on an add and on a removal, a copy directory that cannot be
probed, the lock on the root directory and none where nothing can
change); two edits at once; and through the built binary each
command's call: that a dry run of ten commands writes nothing in either
mode, that a declined pair stays declined over scan, repair, apply,
rollback and revert, that a rolled-back eject leaves the project as it
was, that a prune pass and a hosted takeover take the line away with
the last copy, that `--ecosystems npm` adds no line and takes the pair
of a copy it removed away, that a scan which `socket.yml` lets write
nothing leaves the file alone in every mode, that a manifest in another
project brings both files in line, that a file which cannot be written
is one warning for each command (in the envelope, and on stderr for a
scan whose prune pass comes to the file a second time), what a human
run prints for lines that came, lines that went and a file that went,
that a project in no git checkout below a Bazel root gets no line and
no warning, and that the same run in a project with no Bazel workspace
file writes the same files, byte for byte but for the time in a
vendored copy's marker, and no `.bazelignore`. No test depends on what
lies above the temp directory: they pass with it inside a git checkout
and outside one.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`vex` and `--vex` read what socket-patch wrote and what the project's
package manager installed. They read no Bazel file, so under Bazel a
document can say `not_affected` for a package Bazel builds unpatched.
Before the product learns to tell, this records where the document and
the build agree today. It changes tests, one docs section and four
workflow path lists; no file under `crates/*/src`.

Each of the eight real-Bazel flows whose build is patched (Go hosted,
vendored, agent, and vendored with a module that ships a BUILD file; npm
hosted and vendored; PyPI hosted; RubyGems hosted) now also asserts:

- the command of the mode, given `--vex`, writes the document of its own
  run in the checkout Bazel has built in;
- `vex` writes one before the patched build and one after it, and one
  with `--no-verify`;
- after the undo `vex` writes none and removes the last: exit 2
  `manifest_not_found`, or exit 1 `no_patches` after an agent rollback,
  which keeps its emptied manifest;
- the command and `vex` write the same two documents in a checkout that
  no Bazel has built in, whose files outside `.socket/` are those of the
  checkout that built patched.

A document is held to one statement: `not_affected`,
`inline_mitigations_already_exist`, the advisory of the record, the
package as the one subcomponent of the product, and `Patched via Socket
patch <id>` with the id of this run, ` (redirected)` or ` (vendored)`
by mode, and `; not verified on disk` exactly under `--no-verify`. The
envelope is held to its exact warnings. Agent mode's `apply --vex` and
the second scan of the npm flows are held to the same.

All of it passes on Bazel 9.3.2, 8.8.2 and 7.7.2 (macOS arm64) as the
product is: no expectation had to follow a wrong document. One thing a
reader of such a document should know is now asserted. For a hosted pin
no form hashes a file, since the bytes come with the next build and
`vex` never reads Bazel's output: the statement rests on the lock entry
and the patch record. The scan says so (`vex_hosted_unverified` in
`vex.warnings`); stand-alone `vex` gives no warning, before the build
or after it. The added socket-patch runs take 0.2 to 0.5 seconds per
flow.

`e2e_vex_lockfile/bazel_beside.rs` holds what later changes must keep.
A pnpm project in `web/`, beside a root `MODULE.bazel` or `WORKSPACE`
that builds Java and names none of its files, gets from `vex --json`,
`vex` and `apply --vex` the exit code, both streams and the document
it gets without Bazel, byte for byte but for the checkout's path, the
document id and the time, for a hosted pin and for an installed patch.
With Bazel files that do name the project's lock the output is the same
today as well (tried, not kept): that is the case later work changes.

In the harness a VEX document goes beside the workspace copy, so no
comparison of a checkout's files sees one, and `Cell::twin` is a
shutdown plus the new `Cell::unbuilt`. The push paths of the four
Bazel workflows gain `crates/socket-patch-core/src/vex/**`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A code review of the VEX assertions in the real-Bazel flows found gaps
in what the tests hold. This closes them. It changes tests, one docs
sentence and the path lists of the four Bazel workflows; no file under
`crates/*/src`.

- The documents of a flow are compared with each other. Each one was
  checked alone, and its package through a normalising function, so the
  `%40` and the `@` spelling of an npm scope both passed and nothing
  showed that the forms write the same document. Now every document
  read in a checkout (of the run, of `vex`, of `vex --no-verify`) must
  equal the first one read there in every string but the document id,
  the timestamps and the `; not verified on disk` mark, and the
  documents of the checkout that Bazel has not built in must equal
  those of the one it has. The check of each document alone stays. The
  product spells all of it alike in all eight flows on Bazel 9.3.2,
  8.8.2 and 7.7.2: no expectation had to differ per form.
- `vex --output <file>` with no `--product`, the command a user types,
  runs once after the patched build in every flow. In the npm and the
  Go checkouts it exits 0 without a warning and writes the same
  document for the product of the project's own file, beside Bazel's
  links: `pkg:npm/socket-fixture@0.0.0` from `package.json`,
  `pkg:golang/example.com/consumer` from `go.mod`. The PyPI and the
  RubyGems fixture have no file a product is read from: there it exits
  2 with `product_undetected` and writes no document.
- The marker of a vendored copy is compared between the two checkouts
  as well, as JSON without `vendoredAt`, its one time field. The whole
  file was left out before, so a marker with another purl, patch id or
  advisory passed.
- The `; not verified on disk` mark is the constant the product
  exports, `socket_patch_core::vex::NOT_VERIFIED_SUFFIX`.
- The two hermetic tests of `e2e_vex_lockfile/bazel_beside.rs` tell
  each form the id of its document (`--doc-id`, and `--vex-doc-id` for
  `apply`) in place of rewriting the ids in what a run printed.
- `docs/ecosystems.md` says that for PyPI on Bazel 8.5 and later a
  hosted scan leaves `MODULE.bazel.lock` stale: a build with
  `--lockfile_mode=error` fails until the lock is updated and
  committed. The PyPI flow already asserts both.
- The pull request path lists of the four Bazel workflows gain
  `crates/socket-patch-core/src/vex/**` and
  `crates/socket-patch-cli/src/commands/vex*.rs`, the three files of
  the `vex` command. The flows hold exact VEX output, and the first
  commit added the core directory to the push lists only: a pull
  request that changed VEX code started no Bazel leg and could break
  all eight flows on main unseen.

One hermetic test holds the two comparisons themselves: two spellings
of a scope are two wordings, and a marker that names another package
is another tree. The fixture checks hold the two product names to the
fixtures' `package.json` and `go.mod`. Each new or changed assertion
fails under one mutation, the real-Bazel ones on Bazel 9.3.2.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Whether a patch reaches a Bazel build depends on which file the
workspace's rules read: `npm.npm_translate_lock(pnpm_lock = ...)`,
`pip.parse(requirements_lock = ..., requirements_by_platform = {...})`,
`ruby.bundle_fetch(gemfile_lock = ..., gem_checksums = {...})`,
`go_deps.from_file(go_mod = ...)`. socket-patch has no reader of Bazel
files. This adds one, as library code in
`crates/socket-patch-core/src/bazel/` beside `bazel_root`. Nothing calls
it yet and no command changes: its first caller is the VEX step that
withholds a statement for a copy Bazel does not build.

What it reads

`starlark.rs` lists every call `name(...)` and `a.b(...)` of a file, at
any depth: the callee as written, its line and bytes, and each argument,
positional, by keyword, `*` or `**`. An argument is a string literal
(either quote, tripled or raw, decoded as Bazel's lexer decodes it), a
list of strings, a dict from strings to strings or lists of strings, a
bare name, or "other". A call says whether it is a whole statement, an
argument of another call, in a comprehension; only the first says that
it runs, and once. Beside the calls it lists what each statement binds
(`x = f(...)`, `x = y`, the symbols of a `load` with their aliases) and
every other place a name stands, marked where the name may be given a
value there: a tuple target, the variable of a comprehension. A name
means what the last statement before it bound it to. That is how these
files run: Bazel allows no `if`, `for` or `def` statement and no
`lambda` in them (`DotBazelFileSyntaxChecker`, the same at 7.7.2, 8.8.2
and 9.3.2). Tokens end where Bazel's lexer ends them: a name that ends a
line and a parenthesis that starts the next are two statements, and the
`for` of `0for` is a word of its own.

`workspace.rs` reads MODULE.bazel and the files it includes, through a
view: a function from a path below the Bazel root to text, absent or
unreadable, so the same code serves a checkout on disk and files held in
memory. `disk()` is the view of a checkout and opens nothing outside the
Bazel root. `Workspace::tags(extension, tag)` returns the calls of one
tag of one module extension, with the file and line of each. An
extension is known by the module and the `.bzl` file that define it
(through the name a `bazel_dep(repo_name = ...)` gives the module, or
the root module itself), never by the name of its proxy: rules_go's
`go_sdk.from_file` and gazelle's `go_deps.from_file` take the same
`go_mod`. `Workspace::label` reads a label of a tag as Bazel does: from
the root package, whichever file the tag is written in
(`StarlarkBazelModule.create`), with the root module's own repository
name as the main repository. `include` is read by Bazel's rules
(`CompiledModuleFile.checkModuleFileSyntax`,
`ModuleFileFunction.advanceHorizon`; it exists from 7.2.0): a statement
of its own with one string that starts with `//` and ends in
`.MODULE.bazel`.

Why nothing is evaluated, and what is reported instead

To evaluate Starlark is to run the workspace's code and its rulesets'.
The reader states what the text says outright and says where it cannot,
as doubts: those of the workspace (`Workspace::doubts`), which are about
every answer, and those of one answer (`Tags::doubts`). With neither,
the calls listed are the calls of that tag which the files of a
workspace Bazel accepts can make. That is held by tests, one for each
way found so far to write a call that would not be listed, and not
proven; what Bazel is told outside the files (a flag, an override on the
command line) is not known to the reader. A doubt is:

- a file that is missing, cannot be read, is not UTF-8, is over 1 MiB,
  is reached through a path or a link that leaves the Bazel root, or
  includes itself; a 257th file, or text past 8 MiB in all;
- a string or a bracket that is never closed, which Bazel refuses too;
- an `include`, `use_extension`, `module` or `bazel_dep` whose label or
  name is not written as a plain string, or that may not run: one that
  gives a name or a file and is not a whole statement (behind `and`, in
  a conditional, in a comprehension);
- an `include` with a second argument (9.3.2 takes `dev_dependency`);
- one of those four names, `use_repo` or `inject_repo` used other than
  to call it: under such a name, `getattr` calls a tag;
- `True`, `False` or `None` where the file may give it another value:
  Bazel then reads `repo_name = None` otherwise;
- for the extension asked about, a proxy used for anything but calling
  a tag on it or as the whole first argument of `use_repo` or
  `inject_repo`. `override_repo` is such a use: it puts another
  repository in the place of one the extension makes.

A computed argument is no doubt: the call is listed and the argument is
"other", never a guess. A label can name a target of a BUILD file
instead of a file; the reader gives its path, and whether the file
exists is for the caller to ask. WORKSPACE files and the `.bzl` files
they load are not read yet; `load` bindings and labels relative to a
package are there for them, and what a name is bound to inside a
function of a `.bzl` file is not told yet.

The reader takes any bytes and panics on none. It makes one pass over
the bytes and one over the tokens, with no recursion, a name bound again
shares what it stands for, and a query looks at each call, binding and
use once, so the work grows with the size of the files. The tests hold
that with the largest file that is read in each shape that nests or
repeats, with one long symbol, call or label that many names stand for,
and with a sample file cut and altered at every byte.

Measured, outside the tree, on the 17,842 MODULE.bazel, *.MODULE.bazel,
WORKSPACE, WORKSPACE.bazel, WORKSPACE.bzlmod and .bzl files of 35
repositories (rulesets with their examples, Bazel itself, the Bazel
Central Registry): 17,841 are read and one is refused, a fixture with
an unclosed string. Of 13,664 directories with a MODULE.bazel, 13,653
are read without a doubt. The four lookups find 941
`go_deps.from_file`, 389 `npm_translate_lock`, 984 `pip.parse` and 42
`bundle_fetch` calls; a second reading of the same files with regular
expressions finds the same calls with the same string arguments in
every directory, and 66 of them were compared by eye. What a person
can read there and the reader reports as a doubt: an include through a
directory link that leaves the Bazel root (8 directories), and a
`repo_name` given as a constant (1). What it lists without a value: 18
lock arguments that are computed, each in a comprehension. The largest
of those workspaces is 55 KiB in 70 files. A workspace made to be
costly, 8 MiB of nothing but names, takes about 1 GiB for under a
second.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The reader of `MODULE.bazel` files in
`crates/socket-patch-core/src/bazel/` still has no caller. This closes
the cases where a caller would have got a certain answer that was
wrong, or a reader that held far more than its input. No command
changes.

What a reader holds is bounded

The bounds were 1 MiB for a file, 256 files and 8 MiB of text for a
workspace. That bounds the text, not the index: every call, argument
and use owns its strings and vectors. `MODULE.bazel` and seven included
files of 1 MiB of `f(a,b,c,d)` lines made a release build hold 541 MiB
of live allocations (790 MiB resident), nested `f(f(f(` 1,082 MiB, and
one `tags()` query over a proxy that is used on every line 749 MiB.

Now a file may have 131,072 tokens (`starlark::MAX_TOKENS`), and so may
the files of one workspace together: `index` refuses a file with more,
and `Workspace::read` hands each file what the ones before it left. A
file that does not fit is a doubt about every answer ("it is too large
to read with certainty ...") and takes nothing from what is left, so a
smaller file after it is still read. An index holds at most one call,
argument, binding, use or string for a token; a test asserts that for
27 shapes. Two things grew with the input beside the index and are
bounded too. A list of doubts keeps its first 1,024: a file that names
`use_repo` on every line held 180 MiB, most of it doubts. And the label
of an included file may be 4,096 bytes long, because every doubt names
the path of its file.

Measured in a release build as peak live allocations, with the resident
size in brackets, for the largest workspace of each shape that is still
read:

  calls `f(a,b,c,d)`               14.7 MiB (20.6)
  arguments `f(a,a,...)`           13.9 MiB (19.2)
  uses `a a a`                     13.4 MiB (20.8)
  bindings `a=b`                   12.3 MiB (18.3)
  nested calls `f(f(f(`            27.0 MiB (31.1)
  strings of a list                 6.9 MiB  (8.9)
  a proxy used on every line,
  with one query                   13.4 MiB (21.1)
  nested calls, and seven files
  of one 1 MiB name each           34.0 MiB (43.3)
  255 files of 32 KB of calls      10.3 MiB (15.9)

The seven-file inputs above are now refused, and take 6 to 7 MiB. The
bound is far from real files: the largest of 13,664 real workspaces has
4,669 tokens in 70 files, 28 times fewer; the largest `MODULE.bazel`
has 3,316; and the largest of 17,842 files of any kind, a 289 KB `.bzl`
file that no workspace reads yet, has 39,954.

A WORKSPACE file beside MODULE.bazel is reported

Bazel 7 takes repositories from a `WORKSPACE` file beside
`MODULE.bazel` by default, Bazel 8 under `--enable_workspace`, Bazel 9
never: the flag defaults to true at 7.7.2 and to false at 8.8.2
(`BuildLanguageOptions.java` 7.7.2:265, 8.8.2:289) and is a no-op at
9.3.2 (`BazelRulesModule.java`:880), which has no
`WorkspaceFileFunction`. The reader said nothing of that file: a
`MODULE.bazel` without a pip tag beside a `WORKSPACE` that calls
`pip_parse(requirements_lock = ...)` gave no call and no doubt.

`Workspace::read` now asks the view for the file Bazel would take:
`WORKSPACE.bzlmod`, else `WORKSPACE.bazel`, else `WORKSPACE`
(`WorkspaceFileFunction.compute` 7.7.2:124-137, 8.8.2:132-145;
`BazelSkyframeExecutorConstants.java` 7.7.2:51, 8.8.2:32). Bazel takes
the first that is a file (`ExternalPackageHelper.checkWorkspaceFile`
7.7.2:69, 8.8.2:75), so a directory of that name is passed over: a
disk that folds case has one for `workspace`. When the file holds a
call other than `workspace(...)`, `Workspace::legacy` holds its name
and its index, or why it could not be read.

It is a field of its own and no doubt, because whether Bazel reads the
file is not in these files. A caller that knows the release, from a
`.bazelversion`, can pass over it; a caller that looks for one ruleset
can see whether the file calls it; and both can tell it from a
`MODULE.bazel` that could not be read, which is a doubt whatever the
release. Without either, an answer is certain only when the field is
`None` too. The file is read with or without a `MODULE.bazel`, last,
and within the bounds of the workspace.

Of the 13,664 real workspaces 137 have such a file, 22 of them one that
defines something, and 4 of those call a rule that reads a lock or
names packages: `maven_install` twice, `go_repository`, and a gazelle
repository macro. None calls `pip_parse`, `npm_translate_lock` or
`bundle_fetch`.

Statements Bazel refuses are doubts

A call in the body of an `if`, `for` or `def` statement was listed as a
statement that runs, with no doubt: `if False:` and an indented
`pip.parse(...)` came back as a call that runs. Bazel refuses such a
`MODULE.bazel` (`DotBazelFileSyntaxChecker.java`, identical at 7.7.2,
8.8.2 and 9.3.2: `visit(DefStatement)` :120, `visit(ForStatement)`
:138, `visit(IfStatement)` :149, and `visit(LoadStatement)` :110 for a
file that may not load, which a module file is:
`CompiledModuleFile.java` 7.7.2:96, 8.8.2:111, 9.3.2:109), and the
reading rested on that alone. `starlark::File::blocks` now lists the
statements that start with one of the three words, and in a module
file each is a doubt about every answer. So is a `load`. None of the
13,787 real module files has either, so no real workspace gains a
doubt.

`disk()` reads what the run has written

A later caller writes `MODULE.bazel` and reads the workspace in the
same run. `disk()` opened files itself, so it did not see a write that
a group commit still holds in memory. It now asks the group commit
first, for a path made of plain names only, and puts what it gets
through the same size and UTF-8 checks. A file the run has removed is
absent.

`disk()` also reads one byte more than the bound of a file, and refuses
a file that has it. Before, a file that grew after its size was taken
was cut at 1 MiB and parsed as if it ended there. The root is resolved
once, when the view is made, and no longer for every file. Its doc now
says what is not guaranteed: another process that swaps a directory for
a link between the resolving of a path and its opening is not seen.

Smaller changes

- The bindings of `load` (`Bound::Loaded`) are gone: 18 code lines and
  two tests. Bazel takes no `load` in a module file, no reader used
  them, and they come back with the reader of `WORKSPACE` files that
  needs them. `load` stays a call in the index.
- `tags()` takes the `use_repo` arguments of each file from
  `Workspace::read` instead of collecting them again for every query,
  and passes over a file that does not ask for the extension.
- A file with a byte that is not UTF-8 is still refused, although Bazel
  builds one whose byte is in a comment: 0 of 17,842 real files have
  one, and the module doc now names the limit.

Checked

- 17,842 real Bazel files: 17,841 indexed, the same one refused, no
  panic. 13,664 workspaces: none gains a doubt, and the files read and
  the hub calls with every argument are the same as before in all of
  them. An independent reading by regular expressions agrees on every
  hub call.
- 161 hand-written hostile cases give the same output as before, but
  for the four new doubts of one case. 82,000 fuzz inputs: no panic,
  none over 200 ms.
- 20 mutations, at least one for each new check: each is caught by a
  named test.
- The `bazel::` unit tests are 75, from 69. The two files hold 937 code
  lines, from 888, and the cap of the `bazel` group in
  scripts/loc-budget.json follows the code: 1,131, from 1,082.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Windows refuses to open a directory with "Access is denied", so the
regular-file check after the open never ran there: a WORKSPACE.bazel
directory became a doubt instead of being passed over for WORKSPACE,
and the_checkout_on_disk_is_read_through_the_same_code failed on the
Windows test shard. Check for a directory before opening.

Assisted-by: Claude Code:claude-opus-5-5
A rules_jvm_external hub (`maven.install` with a `lock_file` in
MODULE.bazel) builds each jar that its own lock, maven_install.json,
names, at the sha256 the lock holds. It reads no pom.xml, no Gradle file
and no Maven local repository, so nothing socket-patch does for a Maven
artifact reaches a Bazel build. No test held that, and Maven had no
real-Bazel leg.

This adds Maven's module of the real-Bazel tests, its fixture and its
workflow, with two flows that assert what the code does today:

- maven::a_pom_patch_beside_a_pinned_hub: a checkout that Maven builds
  too. `get <purl> --mode hosted --yes` pins the artifact in pom.xml
  (three files), reports it applied and gives no warning. `bazel run
  //:consumer` prints the upstream marker before and after, and Bazel
  never asks for the patched jar. `rollback --yes` restores every file.
- maven::a_tree_only_bazel_builds: the same checkout without a pom.xml.
  The command writes nothing, reports the patch skipped
  (redirect_unconfirmed) and explains it with redirect_maven_no_pom, "no
  pom.xml present".

Both pass on Bazel 9.3.2 (macOS arm64) with the product code of this
commit, from empty caches; the other two releases were not run for this
commit.

The fixture, tests/fixtures/bazel/rules_jvm_external/bzlmod, has one era
per Bazel release, because the ruleset decides the format of the lock:
rules_jvm_external 7.2 on Bazel 9 (format 3), 6.9 on Bazel 8 and 6.5 on
Bazel 7 (format 2). No lock is committed. A flow writes its loopback
server into MODULE.bazel as the hub's one repository and pins with the
ruleset's own `REPIN=1 bazel run @fixture_maven//:pin`, so the lock is
the one that release writes. Cell::bazel_env is the harness's part of
it: a Bazel command with variables of its own.

No flow asks a public Maven repository, for a pin or for a build:

- The hub is named fixture_maven. A hub named maven, the default, also
  takes the artifacts that other Bazel modules of the build add to a hub
  of that name; protobuf does, in the module graph of every era. A pin
  resolves those from the repositories the root gives the hub, so such
  a fixture has to list Maven Central, and every pin of every run asks
  it, with the empty Coursier cache a test gives its pin. Nothing but
  the fixture adds to fixture_maven.
- Its one repository is the loopback server. The two artifacts are made
  by the test under the group dev.socket.fixture, which only the owner
  of socket.dev can publish to Maven Central, with an id of the run in
  the jar: Coursier resolves them from that server, the pinned lock
  holds the sha256 of this run's jar, the build takes it from that
  server, and no cache can supply a jar of the run.
- The hub named maven that protobuf still declares is never fetched.
  The ruleset's extension keeps one entry per hub name and only declares
  repositories (private/extensions/maven.bzl at 6.5, 6.9 and 7.2: it
  reads files of the workspace and of other modules, and downloads and
  runs nothing). Coursier runs in the repository rule of an unpinned hub
  (_coursier_fetch_impl in private/rules/coursier.bzl), which Bazel runs
  when a label of that repository is asked for, and neither
  `@fixture_maven//:pin` nor //:consumer asks for one of that hub.

A flow asserts that the lock its pin wrote names the two artifacts and
the loopback repository and nothing else. The test that runs without
Bazel asserts that each era's MODULE.bazel has that hub name and no
other URL. The jar under test holds one text file, which //:consumer
prints, so no class file is generated or committed.

Measured on Bazel 9.3.2, 8.8.2 and 7.7.2, each from empty caches, with
the flows of the next commit (the fixture is this one) and every child
of the tests behind a loopback proxy that logs each request and refuses
the hosts of public Maven repositories: no request to such a host on any
release, and of the repositories of the ruleset's extension Bazel
fetched the fixture's hub, its unpinned twin and the two jars only. The
proxy does see the Coursier that pins: on each release, a pin that was
given a second repository on such a host, and an artifact the loopback
server lacks, was refused there and failed.

Each era's .bazelrc names one JDK for every Java role, the one its
rules_java runs javac on, so a build takes no Java from the machine and
downloads one JDK. A cold leg on Bazel 9.3.2 downloaded 397 MB into its
repository cache: JDK 25 at 215 MB, java_tools 50 MB, the archive of
rules_kotlin (a Bazel module the ruleset depends on) 46 MB, Coursier 41
MB, a Python toolchain 18 MB, and the archives of the other modules. It
was 345 MB on 8.8.2 and 327 MB on 7.7.2. With only the run-time JDK
named it was 777 MB on 9.3.2, for three JDKs. The Coursier that pins
gets a cache directory of the test: before 7.2 the ruleset leaves the
choice to Coursier, which takes the home directory from the system, not
from HOME, and would write the developer's own cache.

bazel-maven.yml is bazel-npm.yml for Maven: its own path lists, the
nightly minute 27 5, three Linux legs and the macOS leg on 9.3.2. Era e7
starts Coursier with the Java of JAVA_HOME, else of PATH; that the
runner images have one is not known until the legs have run in CI.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…h does not reach

A pinned rules_jvm_external hub builds the jar its lock names, whatever
a pom.xml, a Gradle build or an installed jar holds. So in a checkout
that Bazel builds too, `get --mode hosted` pinned pom.xml, reported the
patch applied, and the Bazel build kept the upstream jar without a word;
in a tree that only Bazel builds, the same command explained its skip
with "no pom.xml present". The flows of the previous commit hold both.

socket-patch still does not patch a hub. From now on it says so, for
each Maven artifact of a run that a hub builds:

- maven_bazel_hub_unpatched: a pinned hub of the root MODULE.bazel
  fetches the jar at the patch's version. The warning names the lock, the
  hub and the file and line of its `maven.install`.
- maven_bazel_unreadable: whether a hub builds the jar could not be
  told. The warning names the file, the line and the reason.
  - When no hub that was read holds the jar: a hub without `lock_file`,
    tags of one hub that name different locks, a lock that is missing,
    empty, not format 2 or 3, over 16 MiB or no JSON, or the WORKSPACE
    file Bazel would take (WORKSPACE.bzlmod, else WORKSPACE.bazel, else
    WORKSPACE) when it calls `maven_install` or cannot be read, unless
    .bazeliskrc or .bazelversion names Bazel 9 or later, which reads no
    such file.
  - Whether or not a hub's lock holds the jar: a `maven.install` whose
    `name` or `lock_file` is not a plain string or that is not a
    statement of its own, and a doubt of the workspace reader. The
    ruleset takes a hub's lock from the last of its root tags, so a tag
    that was not read may change the lock of any hub, and no lock is
    named beside one.
  - When a hub's lock holds the jar: a `maven.override` of the artifact,
    which puts a target of the checkout in the jar's place, or one whose
    `coordinates` are no string. It is matched as the ruleset matches
    it, by the name of the artifact's target, for every hub.

Nothing else changes. Events, exit codes and every written file are
those of the same run without the workspace. In a hosted run of a tree
without pom.xml the warning takes the place of redirect_maven_no_pom
when a hub is named for every Maven patch of the run; otherwise both are
given. Nothing is said for a project outside a Bazel workspace, for an
artifact that no hub holds as a plain jar at that version, or under
--global, and no Bazel file is looked for in a run without a Maven
patch.

bazel/maven.rs reads the hubs (the `install` tags of the ruleset's
`maven` extension, through the workspace reader, so under any name for
the ruleset or the proxy and in included files), their locks and the
`override` tags, once per run, and bazel/rc.rs the Bazel release a
launcher is told. A hub's `name` is taken only when it is made of what a
repository name is made of, because a warning prints it. The WORKSPACE
file is the one the reader reports (Workspace::legacy); a
`maven_install` in it is a call of that name, or of the name a `load` of
the file gives the symbol. Nothing is evaluated, no Bazel is run and
nothing is written. The reader gains disk_up_to: the same view of the
checkout with a bound of the caller's, because a lock is data and can be
larger than the 1 MiB of a Starlark file. `disk` is that view at 1 MiB,
as before.

commands::bazel_maven_notices is called from three places, which cover
every command that pins or applies: the hosted flow (`get` and `scan`
with --mode hosted), VendoredBackend::apply (`vendor`, an eject, `get`
and `scan` with --mode vendored) and the apply run (`apply`, and the
agent `get` and `scan` that end in one). A vendored or agent `get` that
fails before it patches anything says what it said before, `apply` says
nothing for a patch whose package it does not find, and `vex` does not
look at the hub yet.

Tests:

- The two real-Bazel flows now expect the warning, with its exact text,
  and read the lock through Lock::parse. They pass on Bazel 9.3.2
  (rules_jvm_external 7.2, lock format 3), 8.8.2 (6.9, format 2) and
  7.7.2 (6.5, format 2), macOS arm64, each from empty caches: the build
  prints the upstream marker before and after the command, and the
  patched jar is never asked for. With the product code of the previous
  commit they fail at the warning.
- The fixture's hub has a name of its own (previous commit), so the
  flows read a lock of the fixture's two artifacts and expect the hub
  "fixture_maven" in the warning. A hub of the default name, `maven`,
  whose lock also holds an artifact that another Bazel module added to
  it, under two repositories, is what tests/e2e_bazel_maven_beside.rs
  writes for its checkouts, and the unit tests read a hub whose tag has
  no `name`.
- tests/e2e_bazel_maven_beside.rs holds "nothing else changes" without a
  Bazel: a hosted `get` and an agent `apply`, as JSON, as a person reads
  them and as a dry run, print the same bytes and write the same files
  in a checkout without a Bazel file, in one whose workspace has only
  another ruleset's hub beside a lock that holds the artifact, and in
  one whose pinned hub holds the artifact at another version. A hub that
  builds it adds exactly one warning; a tree only Bazel builds gets it
  in the place of redirect_maven_no_pom, and beside it when the hub
  cannot be read; a --global run says nothing. vendor_jvm_cli.rs has the
  same twin for `vendor`, as JSON and as a person reads it.
- Unit tests in bazel/maven.rs and bazel/rc.rs, over cut-down copies of
  the ruleset's own locks at its tags 6.9 and 7.2.

The `bazel` group of scripts/loc-budget.json goes from 1134 to 1441
lines, the code of the two new files and of disk_up_to.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The previous commit made get, scan, vendor and apply say when a pinned
rules_jvm_external hub of a Bazel workspace builds the jar of a Maven
patch. This one corrects eight things in it. No event and no exit code
changes, and a checkout without a Bazel workspace, or one whose hubs do
not hold the artifact, gets the output it got.

What a run reports

- The notice is added to a hosted run's warnings and no other warning is
  removed for it. In a tree without pom.xml the run used to drop
  `redirect_maven_no_pom` when a hub was named for every Maven patch, by
  matching the code as text and comparing counts. Now it gives both: "no
  pom.xml present" and, after it, the hub. Both are true.
- The notice no longer goes into the lock rewriters' own list. The human
  "(see the warning below)" pointer counts that list, so a package
  without a lock entry was pointed at a hub warning that does not
  explain it. The notice now joins the run's merged warnings after the
  rewriters' ones. scan/hosted.rs loses 19 lines and gains 6.
- `vendor --ecosystems npm` no longer warns about a Maven patch of the
  manifest that the run did not vendor: the notice is asked for the
  purls the run vendors, not for every record.
- A human `vendor` prints the notice above its closing summary and "Next
  steps:", not below them. The call moved from the vendored backend into
  the vendoring engine, beside the Go audit that prints the same way,
  and `bazel_maven_notices` prints for a site that asks it to (`tell`),
  never under --json or --silent. apply and hosted mode print the
  warnings of their run themselves and pass `false`. A `vendor` that is
  refused before it vendors anything (an unreadable ledger, a ledger
  that git ignores) says what it said before the notice existed.

What is read (crates/socket-patch-core/src/bazel)

- A hub is also made by `maven.artifact` and `maven.from_toml` tags
  (`private/extensions/maven.bzl` of the ruleset at 6.5, 6.9 and 7.2;
  `from_toml` from 6.9). A hub that only those tags make has no lock and
  Bazel resolves it when it builds, so a patch for an artifact now gets
  `maven_bazel_unreadable` with the tag's file and line, as a
  `maven.install` without `lock_file` does. Before, it got nothing. Such
  a tag that cannot be read is a doubt; it names no lock, so the hubs
  that were read stay. A pinned hub with such tags stays pinned.
  `override` and `amend_artifact` make no hub.
- A lock with `m2local`, in format 2 and 3: the ruleset takes a jar that
  no repository of the lock lists from the Maven local repository, at
  the lock's sha256 (`download_pinned_deps.bzl`). Such a jar now counts
  as one the hub builds. The docs no longer say that a hub reads no
  Maven local repository.
- `.bazeliskrc` and `.bazelversion` are read as bazelisk v1.30.0 reads
  them (config/config.go, core/core.go, versions/versions.go): the last
  `USE_BAZEL_VERSION` line wins, the blanks around the key and the value
  are dropped, an empty value leaves it to `.bazelversion`, whose first
  line is taken as it is written, and only three numbers name a release.
  The old reader took the first line that began `USE_BAZEL_VERSION=` and
  trimmed `.bazelversion`, so it could name Bazel 9 where bazelisk runs
  Bazel 7, and then pass over a `WORKSPACE` file that Bazel reads. The
  variable of the environment and the `.bazeliskrc` of the home
  directory are not read: socket-patch does not run in the environment
  of the build.
- `MODULE.bazel`, the files it includes, the `WORKSPACE` file and the
  two release files are read through the reader's own view of 1 MiB
  again, and only a hub's lock through the one of 16 MiB. One view
  served both, so a `MODULE.bazel` of 15 MiB was read whole before it
  was refused, and with another reason than the reader gives.

Tests

Each change failed a unit or a hermetic test before it was made, and 26
single changes to the product each fail a named test.

- bazel::maven: three new tests (the two tag classes, `m2local` in both
  lock formats, a file over 1 MiB). One existing expectation changes: in
  `a_hub_is_a_tag_of_the_rulesets_maven_extension` (renamed) the
  `artifact` tag of the fixture now makes a second hub, without a lock.
- bazel::rc: two tables, each row under the lines of bazelisk's source
  it rests on. One existing row changes: a `.bazelversion` line with
  blanks around the release names none.
- tests/e2e_bazel_maven_beside.rs: the tree without pom.xml expects both
  warnings, and one pointer above them.
- tests/vendor_jvm_cli.rs: where a human `vendor` prints the notice,
  --silent and --json, and `--ecosystems npm`.
- tests/e2e_bazel_build/maven.rs: the flow of a tree that only Bazel
  builds expects `redirect_maven_no_pom` and then the hub. Both flows
  pass on Bazel 9.3.2, 8.8.2 and 7.7.2 on macOS, and that one fails with
  the binary of the previous commit.

scripts/loc-budget.json: the cap of the bazel group follows the code,
1441 to 1459.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 19, 2026 09:05
@cursor

cursor Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches hosted scan, apply, and vendor warning surfaces and adds Bazel/Maven lock parsing, but only emits additive advisories without changing patch writes or exits.

Overview
Maven patches still do not reach rules_jvm_external hubs: Bazel builds jars from maven_install.json, not from pom.xml / Gradle changes. This PR adds static workspace inspection and run-level warnings so users see when their patch cannot affect the Bazel build.

A new socket-patch-core bazel::maven module discovers hubs from MODULE.bazel (install, artifact, from_toml), parses format 2/3 locks (up to 16 MiB via disk_up_to), handles m2local, respects maven.override, and treats legacy WORKSPACE maven_install as uncertain below Bazel 9 using bazel::rc (bazelisk-style .bazeliskrc / .bazelversion parsing). Warnings are maven_bazel_hub_unpatched (hub pins the upstream jar) and maven_bazel_unreadable (cannot tell). bazel_maven_notices hooks hosted scan, apply, and vendor; --global and non-Maven vendor selections stay quiet. Patch application, exit codes, and writes are unchanged; redirect_maven_no_pom is preserved and the hub warning is additive.

CI and tests: .github/workflows/bazel-maven.yml runs real-Bazel flows on 7.7.2 / 8.8.2 / 9.3.2 with era-specific fixtures; e2e_bazel_build/maven.rs, e2e_bazel_maven_beside.rs, and JVM vendor tests lock in warning text and behavior. Docs (CLI_CONTRACT.md, docs/ecosystems.md) document the new codes.

Reviewed by Cursor Bugbot for commit 1e773ab. Configure here.

The tests of e2e_bazel_maven_beside.rs start socket-patch with an
environment built from nothing and hold each run to the files it wrote
in the project. A binary built for coverage writes its profile where
LLVM_PROFILE_FILE names, and without the variable into the working
directory, which is that project: in the coverage job every run then
"wrote" a default_*.profraw and the four tests failed.

The variable is now among the few that reach the child. Outside a
coverage build it is not set and nothing changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does
In a Bazel workspace, get, scan, vendor and apply now read MODULE.bazel (and its includes), the rules_jvm_external hubs' maven_install.json locks, WORKSPACE and .bazelversion/.bazeliskrc. The reads are static and bounded. When a pinned hub fetches the jar of a Maven artifact that a patch is for, the run adds a maven_bazel_hub_unpatched warning. When it can't tell, it adds maven_bazel_unreadable instead. Nothing is written, and no event or exit code changes.

Risk: low. It only adds run-level warnings, and only when the run has a Maven purl inside a Bazel workspace. File reads are size-bounded and stay inside the workspace (no symlinks out). The worst case is a noisy warning, not a broken build.

Look here

Verified

  • Read every code change against bazel-vex/02-reader.
  • CLI_CONTRACT.md gains two additive warnings[] rows, and the JSON shape is unchanged.
  • No exit code or --strict effect, and --global gets no notices.
  • CRLF in .bazelversion/.bazeliskrc is handled, and paths are joined so they work on Windows.
  • CHANGELOG.md is untouched, and there are no debug leftovers.
  • The hermetic e2e tests assert the exact warning text and order, so they fail without the change.
  • No open review threads. ci-ok and clippy pass on 8211193.
  • I did not run the tests locally: the sandbox ran out of memory compiling the core test crate. The checks above rely on CI.

Changes I made: none.

Open questions

  1. A workspace-level doubt empties the hub list, and so does an unreadable WORKSPACE below Bazel 9. Either way every Maven purl gets maven_bazel_unreadable, even in a workspace that never uses rules_jvm_external, for example a Maven project that uses Bazel only for Go. That is only a warning, but it can be noise. Should it be raised only when the ruleset is a bazel_dep or its extension is used?
  2. A maven_install reached through a WORKSPACE macro reads as "not built" with no warning. This is documented, so it's fine if intended.

Nits (not blocking):

  • text() in workspace.rs formats its bound in whole MiB.
  • Warning dedup is on the raw purl string, so qualifier spellings can repeat a warning.
  • In vendor, the hub line prints before a possible eject rollback.

Lands after #2148 (stacked), so auto-merge stays off for now.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[agent] Reviewed at 8211193. The change only adds warnings (no writes, exit codes or events change), and every doubt degrades to maven_bazel_unreadable rather than silence. Non-blocking: (1) maven.rs:302 treats WORKSPACE as possibly read for every Bazel below 9, so a Bazel 8 workspace with a leftover maven_install gets the unreadable warning for every Maven patch; (2) vendor.rs prints the hub warning before the eject outcome is known; (3) a jar with a null sha256 and no repository listing is treated as not fetched and stays silent. Lands after #2148.

Base automatically changed from bazel-vex/02-reader to main November 19, 2026 21:22
…tice

# Conflicts:
#	crates/socket-patch-cli/CLI_CONTRACT.md
#	crates/socket-patch-cli/src/commands/mod.rs
#	crates/socket-patch-core/src/bazel/mod.rs
#	crates/socket-patch-core/src/bazel/workspace.rs
#	scripts/loc-budget.json
Merged via the queue into main with commit 15afe93 Nov 19, 2026
83 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the bazel-maven/01-hub-notice branch November 19, 2026 21:46
Mikola Lysenko (mikolalysenko) pushed a commit that referenced this pull request Nov 19, 2026
…e-repo

The parent branch landed on main as #2157. Taking its last tip first lets
the merge with main below see what the squash already holds.

Assisted-by: Claude Code:claude-opus-5-5
Mikola Lysenko (mikolalysenko) pushed a commit that referenced this pull request Nov 19, 2026
The parent branch landed on main squashed (#2157), so every file it added
conflicted add/add. The merge takes the parent's last tip as its base, so
only what main changed since then is merged in: #2159's VEX attestation,
#2153's terminal UI and the rest.

- scan/hosted.rs: keep this branch's removal of the hub notice from the
  hosted run. A hosted run patches a pinned hub or says why not among its
  rewriters' warnings, so the notice would repeat or contradict them.
- scripts/loc-budget.json: the bazel group's cap is 2486, the count after
  the merge (this branch's 775 lines over main's 1711).

cargo clippy -D warnings, the core lib tests, vendor_jvm_cli,
e2e_bazel_maven_beside and the Maven CLI tests pass.

Assisted-by: Claude Code:claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants