Skip to content

Attest a Maven patch as affected in VEX where a pinned Bazel hub fetches the jar from its lock - #2236

Merged
Mikola Lysenko (mikolalysenko) merged 30 commits into
mainfrom
bazel-vex/05-maven-installed
Nov 25, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 30 commits into
mainfrom
bazel-vex/05-maven-installed

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

socket-patch vex and --vex now say affected of a Maven artifact whose patch a pinned rules_jvm_external hub of the Bazel workspace does not take: the hub fetches the jar from its own lock, and the block in MODULE.bazel holds no entry of the patch.

Decisions for the maintainer

  • Every Maven patch is held to the hub, whichever mode holds it. An agent patch of an installed jar, a hosted pin of a pom.xml or a Gradle file and a copy vendored for such a build are all affected while a pinned hub fetches the jar and the block has no entry of that patch. So the document after a hosted or vendored command that declined (maven_bazel_*) still says affected, where it said not_affected before. To reverse: one condition in commands/vex.rs, and that false statement is back.
  • The hub that fetches the jar decides, not every hub. Beside a second hub without a lock, or a maven_install of a WORKSPACE file, the statement is affected, as apply already warns there. It stays not_affected where that hub is in doubt: an override of the artifact, a block changed by hand that still overrides a repository. To reverse: one word in maven::upstream.
  • Nothing is said where the checkout does not show that Bazel reads MODULE.bazel. That is a named Bazel before 7.0; no named release beside a WORKSPACE file that defines a repository; and an rc file that names enable_bzlmod off or --ignore_dev_dependency, or cannot be read. The last part is not what review asked for (an entry that an rc file switches off should give affected). Such an option is found on whatever line, so it may hold for one --config alone, and where it holds it takes the hub out with the entry. Neither is certain, so the statement stays as without Bazel; before, a checkout with Bzlmod off got affected from a file Bazel does not read. To get affected there: drop one condition in maven::upstream.
  • An entry counts for its own patch, and only where it reaches the hub. The entry of another patch gives affected and is named: Bazel builds that patch's jar. So does the entry of the patch itself beside a hub on an isolated use_extension (isolate = True), which no override_repo of the block reaches: Bazel 9.3.2 builds the upstream jar there. Where a hub's use_extension cannot be read it may be a shared one, so the entry keeps its not_affected.
  • A hub's lock belongs to no project. A Maven service that Bazel does not build is affected too, beside a hub that pins the same artifact and version, now in every mode. --no-bazel is its way out, and so is SOCKET_NO_BAZEL=1.
  • A WORKSPACE file. While a Bazel from 7.0 on is named, Maven keeps its finer rule: such a file changes nothing for a jar that a pinned hub of MODULE.bazel fetches. A maven_install there, also one behind a function of a .bzl file, which is not seen, is another hub: no mode patches it, and it cannot put the patch into the hub that was read. Where only such a hub fetches the jar, nothing is said. Whether the Bazel of the checkout may read such a file at all is asked of main's rc::reads_workspace_file (never from 9.0 on), for the doubt about a maven_install and for the guard of the third decision alike. That guard's own threshold, 7.0, is another question on the same reading of the release.
  • The line cap. The bazel group of scripts/loc-budget.py holds 4276 lines here, 92 more than main's 4184. Its cap in scripts/loc-budget.json goes to 5300, the one value each change of this series sets so that they stop meeting on that line, until a later change lowers it to the count.
  • The Maven VEX cell of "Bazel workspaces: what is supported" is "Supported", with its limits in the two sections.

What changes

Agent mode patches no hub, and hosted and vendored mode patch one only where they can show that an entry works. On the base, vex said not_affected of such a patch while bazel build printed the upstream jar (measured on Bazel 9.3.2 and 7.7.2; the first commit holds it as tests). Now each advisory of the patch gets a statement of the package's own with status: "affected":

Bazel builds this package from maven_install.json (`maven.install`, MODULE.bazel:22), which does not name Socket patch <uuid>: the patch is only in what Maven or Gradle builds from. Run `socket-patch get pkg:maven/<group>/<artifact>@<version> --mode hosted` at the Bazel root to patch the hub, or with `--mode vendored` to commit the patched jar. If what you ship is what Maven or Gradle builds and not what Bazel builds, pass `--no-bazel` (`--vex-no-bazel` on scan, apply and vendor).

Where hosted and vendored mode would write no entry, the statement names no command. It gives the code and the reason of their warning:

Hosted and vendored mode write no entry for this hub (`maven_bazel_release`): the checkout names Bazel 7.3.0 (`.bazeliskrc` or `.bazelversion`), and an entry needs `override_repo`, which Bazel has from 7.4.0.

Everything else is what the other five ecosystems have, through the same code: the warning vex_bazel_not_in_build, a skipped event with details.status: "affected", the partialFailure envelope, exit code 0, vex.affected, and --no-bazel. Their statements are word for word what they were.

The answer comes from bazel/maven.rs, the reader hosted and vendored mode write entries by: built::unbuilt asks maven::upstream, which gives the hub and what to do.

Unchanged: an entry of the patch in the block, a jar no hub fetches, a project in no Bazel workspace, --global, a hosted pin of another ecosystem, and every run without a Maven package.

Limits

  • not_affected is still written where the hub that fetches the jar is not read with certainty, in the cases of the third decision, and for what the Maven section lists as not seen (a hub of another Bazel module, a maven_install inside a .bzl function).
  • Only a patch that the run finds in place is judged. Where the installed jar is missing or is not the patched one, vex exits 1 with no document, as without Bazel.
  • A jar that a hub takes from the Maven local repository (m2local) counts as fetched. The lock's sha256 is not compared with the patch.
  • Where only the hosted command declines (an rc option about downloads), the statement still names the command: --mode vendored writes the entry.
  • --vex-no-bazel is about the document: apply and an agent scan still warn maven_bazel_hub_unpatched.
  • Go and Composer are not part of this.

Code review

  1. Any doubt, also about another hub, gave not_affected: fixed. upstream asks Hubs::built, and the block for an entry.
  2. Any entry of the block counted: (a) fixed, an entry counts only for its own patch; (b) not as asked, see the third decision: an rc option leaves the statement as without Bazel, for an entry and for the hub.
  3. The remedy named a command that declines, and the next document was false: fixed both ways (first decision; the remedy is the command or the reason). No existing test expected not_affected for a hosted or vendored Maven patch whose hub got no entry: each writes the entry and passes unchanged.
  4. Maven judged beside a WORKSPACE file: kept, with the guard of the third decision.
  5. The workspace parsed twice: fixed for a run of Maven packages alone. The hubs are still read once more than lock discovery reads them: the two are different layers, and handing one read through costs more code than it saves.
  6. The purl unquoted in a shell command: fixed. The command names the coordinates alone; a Maven key can carry ?type=jar.
  7. The sentence and "maven.install" in two files: fixed, one helper in bazel/maven.rs for the warning and the statement.
  8. The workflow's path lists: fixed (patch/jar_manifest.rs added, three redundant entries removed).
  9. The contract row said that a --no-bazel run reads no Bazel file: fixed.
  10. (Review thread.) An entry of the patch counted without asking whether its override_repo reaches the hub: fixed in 752c70b. upstream says affected where a pinned hub that fetches the jar is on an isolated usage, names that hub, and gives the reason hosted and vendored mode decline with (maven_bazel_unreadable).

What it proves, and where

  • maven::an_agent_patch_beside_a_pinned_hub, real Bazel: the build prints the upstream marker before and after agent mode; the run, apply, vex and vex --no-verify each write one affected statement; after get <purl> --mode hosted the build prints the patched marker and vex says not_affected.
  • Without Bazel, in e2e_bazel_build/maven.rs: agent mode, then the hosted and the vendored command, in three checkouts. Where the command writes its entry, vex says not_affected after it. Under Bazel 7.3.0 and beside a second hub without a lock, the documents are affected before and after the command, with the code and the reason. After either command wrote its entry, an isolated usage of the hub turns not_affected into affected. vex --no-bazel, SOCKET_NO_BAZEL=1, three hubs of which nothing is said, an rc file that names --noenable_bzlmod, a WORKSPACE file beside no named release and Bazel 6 give what the checkout gives without Bazel.
  • Unit tests: maven::upstream for each case of the decisions, a purl with qualifiers, m2local, and an entry beside an isolated usage, one that cannot be read, and two hubs; built::unbuilt on disk for a committed copy and a project below the root.

What was run, and what was not

Run on macOS arm64 at the final commit, which merges the vendored-hub guard and main:

  • rustfmt check of the changed files; clippy of the workspace and of the e2e_bazel_build target with -D warnings; cargo check --workspace --all-targets --all-features.
  • The whole socket-patch-core unit suite (8579 passed) and the CLI unit suite (1070 passed).
  • Seven integration targets, all green: e2e_bazel_build (without Bazel), e2e_bazel_maven_beside, vendor_jvm_cli, e2e_vex, e2e_vex_vendor, and the two that read the contract, contract_paid_required and contract_gradle_codes.
  • The script tests, scripts/loc-budget.py, actionlint and the tool-pin check on the Maven workflow.
  • Real Bazel: all eight maven:: flows on 9.3.2, behind a logging proxy that refuses public Maven repositories; it refused no request.
  • Three mutations of the WORKSPACE rule in the Maven reader, which now stands on rc::reads_workspace_file: the rule not asked, the rule turned round, and a WORKSPACE file beside no named release not looked at. A unit test fails for each.

Run at the commit before those two merges, and not repeated after them:

  • The other 21 integration targets of that round, all green, no existing expectation edited: cli, four more VEX targets, the four cli_parse_* ones, four more JVM ones, apply, scan, vendor, rollback, repair and the three in_process_* ones.
  • The eight flows on Bazel 7.7.2, behind the same proxy, which refused no request.
  • Mutations of the fix of the review thread and of the off-switch row, one merge of main earlier still: with the fix undone, its unit row and its test without Bazel fail; five more are each caught. No merge since changed a line they change. The sixteen of the first round were not repeated.
  • Measured once on Bazel 9.3.2, with a flow that is not committed: after the hosted command, isolate = True on the hub's use_extension builds the upstream jar with the entry in place.

Not run: Linux and Windows; Bazel 8.8.2 and 7.4.0; on real Bazel, a command that declines, a second hub (also an isolated one beside a shared one), an rc file and a WORKSPACE file; scan --mode hosted --vex beside a hub that declines; the warning on a terminal at 80, 100 and 120 columns; the test targets that need real package managers, Docker or a public registry; a coverage build.

One harness helper changed in the first round: Cell::patches_outside compares the installed file as bytes (a jar is no text). Its Cargo and NuGet callers are unchanged.

🤖 Generated with Claude Code

Tests only. rules_python's `pip.parse` and rules_ruby's
`ruby.bundle_fetch` hand a lock of the checkout to Bazel. The real-Bazel
flows ran hosted mode beside both hubs, and vendored mode beside the
Python one (pypi::vendored_pip_parse, which holds `vex` to saying that
the build is not the patched one). No flow ran vendored mode for a gem,
and the PyPI flow did not build between its undo and its hosted scan.

ruby::vendored_bundle_fetch records what the command does today, in the
fixture of the hosted flow (rules_ruby 1.0.0-rc2; the call names the
`Gemfile` and the `Gemfile.lock` of the root). `scan --mode vendored
--yes` exits 0 with status `success` and one package applied. It commits
the unpacked gem with its specification and the ledger under
`.socket/vendor/gem/<uuid>`, gives the gem's declaration in `Gemfile` a
`path:`, and moves the gem's entry of `Gemfile.lock` into a `PATH`
section. The next `bazel build` fails in the `bundle install` action of
the hub. rules_ruby copies the two files into a repository of Bazel's
and runs Bundler there, which stops with

    The path
    `<execroot>/external/<hub>/.socket/vendor/gem/<uuid>/sp-victim-1.0.0`
    does not exist.

`vex` attests the gem as patched meanwhile: it reads the committed copy,
and what rules_ruby builds from one is not judged. `vendor --revert`
puts every file back, and the build with them.

pypi::vendored_pip_parse now names the failure it asserts. rules_python
makes the name of a repository from the path of the vendored line, and
Bazel stops with `invalid user-provided repo name
'pip_311__/_socket/vendor/pypi/<uuid>/spvictim_1_0_0_py2_py3_none_any_whl'`.
The flow also builds right after `vendor --revert`: the unpatched build
is back before hosted mode pins the patch.

Both flows pass on Bazel 9.3.2 with the product code as it is. Each
compares the tool's message without white space: Bundler breaks its
message at the width of the console it runs in, which differs from one
machine to the next.

The two Ruby flows share their stand-in. `Served::to` builds the gems of
a run, serves them, grants the patch and routes Bazel's downloads, as
the hosted flow did inline. The grant now holds what the patch service
grants for a gem: the patched gem with a sha512, and its specification.
Vendored mode downloads both, and hosted mode neither. The record of the
patch holds the hashes of the gem's one file, in place of the
placeholders of the shared stand-in.

bazel-ruby.yml says in its header that the legs run both modes, and a
pull request that changes vendor/gem.rs now starts them: the file was
in the list of the pushes to main alone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
rules_python's `pip.parse` and rules_ruby's `ruby.bundle_fetch` build
the packages of a lock in repositories of Bazel's own. Vendored mode
makes that lock name the patched copy by a path under `.socket/vendor`,
and neither ruleset builds from such a lock. The command exited 0 with
status `success`, and the next `bazel build` failed for everything the
hub serves (Bazel 9.3.2, 8.8.2 and 7.7.2, the flows of the previous
commit):

- PyPI: rules_python 2.5.0-rc4 makes the name of a repository from the
  path of the vendored line, `invalid user-provided repo name
  'pip_311__/_socket/vendor/pypi/<uuid>/<wheel>'`.
- RubyGems: rules_ruby 1.0.0-rc2 runs `bundle install` in a repository
  that holds the Gemfile and its lock and not the copy, `The path
  .../.socket/vendor/gem/<uuid>/<name>-<version> does not exist.`

Vendored mode now declines such a package before it downloads or writes
anything, with `vendor_pypi_bazel_hub` or `vendor_gem_bazel_hub`. The
refusal rests on what the files of the workspace say and on what the
run would write, so it is for a run that would write a file a hub
reads, and for no other.

When it declines. The project is in a Bazel workspace
(`bazel::bazel_root`), and a call of its files names, by a label
written out as a string, a file of the project that the run for the
package would point at a copy:

- a `pip.parse` whose `requirements_lock`, `requirements_by_platform`,
  `requirements_darwin`, `requirements_linux`, `requirements_windows`
  or `uv_lock` names a requirements file of the project that the run
  would write (`requirements.txt` or a file it includes with `-r`), or
  the `uv.lock` of a uv project;
- a `ruby.bundle_fetch` whose `gemfile` or `gemfile_lock` names the
  project's `Gemfile` or `Gemfile.lock`;
- a call of a `WORKSPACE` file that passes one of those attributes,
  which is how the older form of either ruleset is called there
  (`pip_parse`, `rb_bundle_fetch`).

Which files a PyPI run writes is asked of the backend's own router
(`vendor::pypi::hub_files`). A project with no tool lock is wired
through its requirements files, so they count. A uv, Pipenv or PEP 751
lock is wired together with a pin of the package in the requirements
files beside it, so they count for a package they name (a pin, a
hosted pin that a takeover restores first, or the vendored line of an
earlier patch) and not for one they do not name. A Poetry or PDM lock
is wired alone: such a project is not declined beside a hub that reads
the requirements file exported from its lock, and is vendored as it is
without Bazel.

Every such call counts, also one that may not run (in a comprehension).
Every package whose run would write a file the call names is declined,
since the lock is the project's, but one that is already vendored
(below).

What an uncertain reading does. Where the files of the workspace
cannot be read with certainty and a call of the hub may be behind
that, every package whose run would write such a file is declined, in
every project of the workspace:

- a call of the hub whose file is not a plain string, or that passes
  `*` or `**`, and a hub proxy handed to anything but `use_repo` or
  `inject_repo`;
- a module file that is missing or cannot be read, or a statement of
  one that cannot be read, where the workspace calls the hub or a file
  that was read names its ruleset (a `bazel_dep` on it, or a
  `use_extension` of the hub's `.bzl` file under any repository name);
- a root `MODULE.bazel` or a `WORKSPACE` file that cannot be read at
  all.

The last two matter because Bazel builds files that are not read here:
one byte that is not UTF-8 is enough, in a comment too, and so is a
file over 1 MiB. Without them the call in such a file was not seen and
the run went on. Going on there can leave a broken build behind a
command that exited 0, and declining costs a vendored run that the
switch brings back. A workspace whose root `MODULE.bazel` and
`WORKSPACE` file were read or are not there, and in which no file that
was read calls the hub or names its ruleset, is never declined for it,
whatever else cannot be read.

Where nothing changes. Outside a Bazel workspace, in a workspace that
calls neither hub, and for a package whose run writes no file that a
call names (a project beside the one a hub reads, one whose
`requirements.txt` is not the file the hub is given, a Poetry or PDM
project whose exported requirements the hub reads), vendored mode
prints what it printed and writes what it wrote. Other ecosystems,
hosted mode and agent mode are not touched.

Where it is asked. `bazel::built` already says for `vex` which hub
reads which lock; `reader` there answers this question from the same
table and the same reader of workspace files, and takes `uv_lock` as
one more attribute. `vendor::bazel_hub::refusals` asks it about the
files the run of each package would write and words the refusal.
`vendor::refusals::bazel_workspace_refusals`, the one answer every
vendored entry point takes for a refusal that rests on the Bazel
workspace, returns it beside the Composer refusal. So it reaches
`scan --mode vendored`, `get --mode vendored`, `vendor` for a patch the
manifest records, the takeover of a hosted pin by a vendored scan, and
the eject of one by `vendor`, which asks once and before it fetches a
record. No command's own code changes.

The package is a `failed` event and the run exits 1 (`partialFailure`;
for the eject `eject_refused`, detail `kept hosted: ...`). A dry run of
`scan` or `get` lists the package as one the run would refuse and exits
0; `vendor --dry-run` reports the refusal and exits 1, as it does for
any package it could not vendor. Nothing is written, no patch is
downloaded, and a hosted pin stays. These are the exit codes of the
Composer refusal. The detail names the call with its file and line, the
lock, the Bazel root and hosted mode:

    `pip.parse` (MODULE.bazel:15) of the Bazel workspace at /repo names
    requirements.txt; vendored mode makes the lock name the patched
    copy by a path under .socket/vendor, and rules_python fails the
    build on such a lock; use `--mode hosted`, which names the patched
    package by a URL that rules_python fetches, or pass
    `--allow-vendored-in-bazel` if no build takes the packages of this
    project from rules_python

For a doubt it names the file, the line and the reason in the place of
the call. Hosted mode pins the patch in the same file, and both
rulesets build it: the two flows end with that build. For a gem the
detail adds the condition under which rules_ruby builds a hosted pin,
"where its call passes no `gem_checksums`": with an entry for the gem
there the hosted build fails, which the docs list as a known problem.

`--allow-vendored-in-bazel` (SOCKET_ALLOW_VENDORED_IN_BAZEL) lifts the
refusal, as it lifts the Composer one: for a hub that no build uses, a
`WORKSPACE` file that the Bazel in use does not read, or a
`ruby.bundle_fetch` that is given the files of the copy as `srcs`. Its
help text, its row in CLI_CONTRACT.md and the sentence of
docs/ecosystems.md that named Composer as the one refusal it lifts now
name the three.

`vendor --revert` is not refused. Neither is a package that is already
vendored, as for Composer. What is declined is the write of the path
into the lock the hub reads, so a package that the file the call names
already names by the copy of the same patch
(`.socket/vendor/pypi/<uuid>/`, `.socket/vendor/gem/<uuid>/`, outside a
comment) is let through: the run adds nothing to what the hub reads. A
project vendored with the switch, or by an earlier release, keeps
passing its in-sync runs without the switch, a `scan` or `get` that
names no mode included, which runs in vendored mode there. A new patch
for that package, and any other package, is declined as before. It is
the named file that decides, not any file of the project: a uv project
whose lock names the copy while the hub reads a requirements file that
still pins the registry's release would have that file rewritten by
the run, and is declined. That file is read as a lock of the workspace
is (`built::lock_text`): up to 64 MiB, and not through a link that
leads out of the Bazel root, so such a link lets nothing through.
Where the reading is in doubt no file is known to be the hub's, so
nothing is let through there. Such a run passing does not make the
build the patched one: for PyPI `vex` says `affected` of that state.

No line a person reads is new: the refusal prints where every refused
vendored package does.

Tests:

- pypi::vendored_pip_parse and ruby::vendored_bundle_fetch (real
  Bazel) now hold the command to the refusal: exit 1, the code, a
  detail that names the call, the lock, `--mode hosted` and the switch,
  no file changed and no request for the patched wheel or gem. The same
  build passes on the upstream package. With the switch the
  expectations of the previous commit are back: the package is
  vendored, the build fails with the ruleset's message, and
  `vendor --revert` restores the build. Hosted mode then builds the
  patched package.
- Hermetic tests of both files, on steps the harness now holds for
  both: every command that would vendor declines and writes nothing,
  the dry runs and the eject among them; vendored mode goes on with
  the switch and with its variable, a later run without them passes
  and writes nothing, a scan that names no mode included, and
  `vendor --revert` needs neither; it goes on with no switch in a
  workspace whose hub reads another file, in a project beside the one
  it reads, and in no workspace; a hub whose file is not written out
  declines. For PyPI also: a Poetry project beside a hub that reads its
  exported `requirements.txt` is vendored with no switch, that file
  stays as it is and the later runs pass; and a `MODULE.bazel` with one
  byte that is not UTF-8 declines.
- Unit tests of `built::reads` (each attribute, a call that may not
  run, `uv_lock`, another project, another repository, a doubt of the
  call, of the proxy and of the workspace, a hub that is not called,
  the `WORKSPACE` file; a root module file, an included file and a
  `WORKSPACE` file that cannot be read, with a root that names the
  ruleset as a dependency, by its extension, or not at all), of the
  refusal (codes, words, the switch, a file brought in with `-r`, the
  `Gemfile` alone, no workspace; a package the named lock already
  names by the patch's copy, and the same copy named in a comment, in
  another file, behind a link out of the root or under a doubt; a
  Poetry and a PDM lock, and a uv and a Pipenv lock beside a
  requirements file that names the package or does not) and of its
  dispatch.

Four tests of pypi.rs vendored a wheel beside the hub that reads the
requirements, to hold `vex` to what it says of that state. The command
that writes the line now has the switch there, and they assert what
they asserted; the in-sync runs after it have none, as before.

Docs: docs/ecosystems.md "Bazel workspaces: PyPI and RubyGems vendored
mode", the two rows of the matrix, and what "Bazel workspaces: VEX"
says of a vendored gem, which a build has now shown; the rows of the
two codes, of the switch and of the vendored table in CLI_CONTRACT.md.
In "Bazel workspaces: what is supported" the two vendored cells stay
"Not supported", and the note on that word now says that the command
declines there. The entry of the known problems for vendored mode
listed commands that exit 0 and leave a failing build: PyPI and
RubyGems leave it, and so does Composer, which declines since the
change before this one; NuGet stays. bazel-pypi.yml and bazel-ruby.yml
start their legs for a change to vendor/bazel_hub.rs and
vendor/refusals.rs, and bazel-pypi.yml for one to vendor/pypi.rs. The
`bazel` group of scripts/loc-budget.json follows the 69 lines added to
built.rs.

Not covered: a hub call in a `.bzl` file that a `WORKSPACE` file
loads, a hub of another Bazel module, another tag or ruleset that reads
the same file under Bzlmod, a `WORKSPACE` call that hides its arguments
behind `**`, a Bazel root above the git checkout, and a hub whose call
and whose `bazel_dep` are both in an included file that cannot be read
while the files that were read name neither: vendored mode goes on
there as before. A package of a uv, Pipenv or PEP 751 project that the
hub's requirements file names in a form that is not wired with the
lock (a range, extras) is declined although the run would leave that
file alone. `vex` still attests a gem that was vendored with the switch
as patched, while its build fails.

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

A review of the PyPI and RubyGems vendored declines found three states in
which the run was let through and would write a file that a hub of the
Bazel workspace reads:

- A Poetry or PDM project whose exported requirements file holds the package
  by a URL, which is what a hosted pin is. The lock of such a project is
  wired alone, so its requirements files did not count, but a vendored run
  that takes a hosted pin over restores that line. The files now count for a
  package they hold by a URL. A package they pin from the registry is
  vendored as before.
- A `WORKSPACE` call that names the lock through the name the file gives
  the main repository (`@shop//api:requirements.txt` beside
  `workspace(name = "shop")`). The label was taken for another
  repository's. It is the main repository now, for the calls of that file.
- A package that is already vendored, where the calls name more than one
  file of the project. Only the first file a call names was read, so a
  `uv.lock` locked again beside a vendored requirements file let the package
  pass, and the run rewrote the lock. Each file a call names that holds the
  package now has to name the copy; one that cannot be read may hold it.

Also from the review: the requirements file is no longer listed twice, the
gem's two files are the gem backend's own constants, and the files of a
package are chosen by its ecosystem and not by the text of its purl type.

The docs and the contract row say what was imprecise: the requirements
files of a project with no tool lock count as one set, also for a package a
file of the set does not pin, because a file the hub reads can bring in the
rewritten one with `-r`; and the `pip_install(requirements = ...)` of an
older rules_python is not seen.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two states in which a vendored PyPI run was still let through and would
write a file a Bazel hub reads:

- A hub that names a requirements file which brings the project's own
  in with `-r` (`all.txt` with `-r requirements.txt`). The files a run
  writes are walked down from `requirements.txt`, so the file the hub
  named was not among them and nothing was declined. A requirements file
  a call names now counts as naming each file its `-r` includes reach,
  read inside the Bazel root as any lock is, and the refusal names it.
- An already-vendored package whose other files a call may name where
  the reading is in doubt: a second attribute that is not written out,
  or a call that may be behind a file that could not be read. Only a
  certain answer had that file read; a doubt was dropped and the package
  let through. A doubt now has the file read as well, so the package is
  declined where that file holds it and not by the copy.

The `bazel` line budget goes from 2574 to 2611.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeQFeU3sKRPzawaNLsm
Assisted-by: Claude Code:claude-opus-5-5
…om the lock

Two flows on real Bazel, tests only, that record what socket-patch does
today in a workspace where a ruleset builds a package from the project's
lock and agent mode patches the copy a package manager unpacked outside
the checkout:

- `cargo::agent_from_cargo_with_config`: rules_rust's
  `crate.from_cargo(cargo_lockfile = "//:Cargo.lock", ...)`, and the crate
  in `$CARGO_HOME/registry/src`, as after `cargo fetch`.
- `nuget::agent_from_lock`: rules_csharp's
  `nuget.from_lock(packages_lock_json = "//:packages.lock.json", ...)`, and
  the package in NuGet's global packages folder, as after `dotnet restore`.

In both, `scan --mode agent --yes` exits 0 with the patch applied to that
copy and writes nothing into the checkout but `.socket/`, and `apply`
passes. `bazel build` and `bazel run //:consumer` print the unpatched
marker before the command and after it: each hub has Bazel download the
package the lock pins, and no build reads a cargo home or NuGet's folder.
The build right after the command is a warm one, which looks at nothing
outside the checkout again, so each flow ends with a build on a second
machine: a copy of the checkout without `MODULE.bazel.lock` and with an
empty output base, whose Bazel has the patched cargo home or NuGet folder
in its environment and evaluates the hub anew. It prints the unpatched
marker too.

Meanwhile `scan --mode agent --vex`, `apply --vex`, `vex` and
`vex --no-verify` each write an OpenVEX document whose one statement says
the package is `not_affected`, "Patched via Socket patch <uuid>". That
document is false for what Bazel builds. The flows assert it as it is
today and mark it KNOWN GAP, with what a fix changes in the test.

The copy in the cargo home is the one the hub's own cargo unpacked there
where the ruleset runs that cargo with the home of the environment
(rules_rust 0.56.0), and is laid out by the test where it does not
(0.75.0); NuGet's folder is laid out as the hosted flow already does. No
cargo and no dotnet runs. The Bazel commands of the NuGet flow get the
two variables of the .NET home that `socket-patch` gets
(`NUGET_PACKAGES`, `DOTNET_CLI_HOME`), so a build that read the folder
would find it.

What the flows share is in the harness: `Cell::patches_outside`, and
`Cell::builds_anew` for the second machine, which removes the first
workspace copy before it builds where the repository cache outlives
that copy. The grant helpers of the two modules are split so that a
patch record can carry the file contents agent mode patches from, and
in the Cargo module the helper that names the hosts of a child takes its
cargo home as well; the hosted and vendored flows call them as before
and assert what they asserted.

The two workflows say that their legs now run agent mode, and start on a
pull request that changes the VEX code (`vex/` of the core, the `vex`
command) or, for NuGet, agent mode's own file.

Both flows pass on Bazel 9.3.2 (macOS arm64) with no change to the
product: NuGet in 14 s, Cargo in 92 s with an empty repository cache.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ilds the package from the lock

Agent mode patches a crate in the cargo home (`$CARGO_HOME/registry/src`)
and a NuGet package in NuGet's global packages folder. In a Bazel
workspace neither copy is built: rules_rust's
`crate.from_cargo(cargo_lockfile = ...)` and rules_csharp's
`nuget.from_lock(packages_lock_json = ...)` have Bazel download what the
project's lock pins. The flows of the commit before this one measured it
on Bazel 9.3.2: `scan --mode agent` exits 0 with the patch applied,
`bazel build` prints the upstream marker before and after, also on a
second machine that evaluates the hub anew, and `scan --vex`,
`apply --vex`, `vex` and `vex --no-verify` each attest the package as
`not_affected`. That document is false for what Bazel builds.

Cargo and NuGet join the table of hubs in `bazel/built.rs`, so what main
does for npm, PyPI and RubyGems holds for them too. When a call that is
a statement of its own names the project's own `Cargo.lock` or
`packages.lock.json` in a plain string, and that lock lists the package
at the patched version without the patch, the document says `affected`
of the package, with an action statement that names the lock, the call
and its line, and what to run. `vex --json` reports a `skipped` event
with `vex_bazel_not_in_build` and `details.status: "affected"`, the
envelope is `partialFailure` and the exit code is 0, as on main.
`--no-bazel` / `--vex-no-bazel` / `SOCKET_VEX_NO_BAZEL` leaves Bazel out
of it.

What the table holds for the two:

- rules_rust: the extension by both files that define it at 0.56.0 and
  0.75.0 (the constant of `bazel/cargo.rs`), the tag `from_cargo`, the
  attribute `cargo_lockfile`. Of the lock, the crates of a registry that
  no `[replace]` swaps out: those are the ones Bazel downloads. A call
  with a cargo-bazel lock (`lockfile`) is passed over, because the hub
  renders its crates from that file until a repin. So is one without
  `cargo_lockfile`, which names no lock.
- rules_csharp: the extension as `bazel/nuget.rs` names it, the tag
  `from_lock`, the attribute `packages_lock_json`. A `packages.lock.json`
  never names a patch (a hosted pin there is a hash), and rules_csharp
  0.5.0 makes one hub of all the `nuget.from_lock` calls: the sources of
  the last call that has any serve every package, and the first lock
  that names a package pins it. So a project patched in agent mode can
  be built patched through the hosted pin of another project of the
  workspace (measured on Bazel 9.3.2 with two calls). The `nuget_config`
  of every call is therefore searched for the id of the patch together
  with the lock. Where one names it, or is not a plain label, or cannot
  be read, or a call passes `*` or `**`, nothing is said of the hub. The
  locks are still read one call at a time, and `feeds` and
  `local_package_dirs` are not read.

The action statement names the modes that a flow of this repository
builds patched on real Bazel under that hub, so a hub carries its own
sentence: hosted mode with the attribute it needs of the call
(`cargo_config`, `nuget_config`), and for a crate vendored mode as well.
The sentence of the three hubs on main is the same bytes as before, and
their calls are judged one at a time as before.

Left as main has them: a hosted pin (the caller hands none over, and
whether a hub takes one is for `bazel/cargo.rs` and `bazel/nuget.rs` to
say), a vendored crate (rules_rust builds it), a vendored NuGet package
(no test builds one under its hub), a project whose lock no call names,
a workspace that is not read with certainty, and a project in no Bazel
workspace.

Tests: unit tests of the table (what a lock lists, which calls are
passed over, the hub of several `nuget.from_lock` calls, a doubt on the
hub by either file of the rules_rust extension, the sentence of each
hub). Two tests without Bazel per ecosystem run the binary in a checkout
of the fixture: one runs the scans the action statement names and holds
the document after each to `not_affected`; the other holds `vex`,
wherever the hub decides nothing and with `--no-bazel`, to what it gives
in the same checkout without its `MODULE.bazel` (exit code, both
streams, the document), through `Cell::keeps_its_statement` of the
harness. For NuGet one of those hubs has a second call whose
`nuget_config` names the patch. The two agent flows now expect
`affected` from the run, from `apply`, from `vex` and from
`vex --no-verify`, and `not_affected` from `vex --no-bazel`, while the
build still prints the upstream marker, on the second machine too. No
assertion of the hosted and vendored flows is edited. One existing unit
test took a Cargo purl for a package of no hub; it takes a Go module
now.

Docs: the VEX cells of Cargo and NuGet in "Bazel workspaces: what is
supported", the section "Bazel workspaces: VEX" and the
`vex_bazel_not_in_build` row of the CLI contract. The two workflows
start their legs on a change to `bazel/built.rs` and to the reader of
the workspace files, each by its path. The size budget of `bazel/`
follows the code (3337 to 3403 lines).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main gained the gem_checksums withhold and the Maven scan of a pinned
hub. Two conflicts:

- docs/ecosystems.md, the table of "Bazel workspaces: what is
  supported": main's RubyGems row (its hosted cell names the
  gem_checksums conditions) with this branch's VEX cells for Cargo and
  NuGet.
- scripts/loc-budget.json: the cap of the `bazel` group is the count of
  the merged tree, 3681.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…he Bazel VEX answer

A NuGet project is every project file below the directory a command runs
in, each with a `packages.lock.json` beside it: agent mode patches what
any of them restored, and hosted mode and `vex` read a pin in each of
their locks. The hub table took only the lock in the run's own directory
for the project's, as it does for the other ecosystems. So for a run at
the root of a solution, where `nuget.from_lock` names
`//src/App:packages.lock.json`, the document kept `not_affected` for a
package that Bazel downloads unpatched. The NuGet hub now takes a lock
at or below the directory of the run. The other hubs are as they were:
a lock below the run is still the lock of another project there.

Three smaller changes to the same function, none of which changes what
is said of a workspace that Bazel can load:

- Whether every `nuget_config` of the hub is a plain label was a
  comparison of two counts: the labels that resolve, and the calls that
  give the attribute. A dict counts once as given and once per key as
  resolved, so the counts could be equal while a config was not read.
  Each call is now asked on its own: no `nuget_config`, or one string
  that names a file of the main repository.
- The attributes with which a call can take its packages from a file
  that is not read (`uv_lock`, `lockfile`) were one list for every hub.
  Each hub now has its own.
- The configs of a rules_csharp hub were read again for every lock. They
  are read once for the hub, when the first lock asks.

The docs and the contract row say which lock is the project's own for
NuGet, and the list of statements that stay wrong names the member of a
Cargo workspace, whose `Cargo.lock` lies above it.

The `bazel` line budget is the new count, 3704.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…gnore line

`cargo::vendored_from_cargo_with_config` comments out the line the scan
wrote in `.bazelignore` and expects `bazel cquery //...` and
`bazel query 'deps(//...)'` to fail on a repository that the main
repository does not see. It looked for the hub's repository
(`@crates__...`) alone. The build file that cargo-bazel writes into the
committed copy names `@platforms` as well, and Bazel reports the first one
it meets: on a Linux runner with Bazel 9.3.2 the query named `@platforms`
and the flow failed on its own check.

The flow now takes either name for that failure. Test only: nothing the
command does changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hub-locks

Three files conflicted. The RubyGems tests of e2e_bazel_build keep one
`Served` (this branch's `Served::to`, with main's `neighbour_gem`), one
`run` and every test of both sides; main's tests beside a `gem_checksums`
use them, and its `checkout` is `checkout_with`, which this branch's
`checkout` is built on. docs/ecosystems.md keeps the entries of both
sides, and its paragraph on hosted mode beside a `gem_checksums` entry
now says what hosted mode does there since main. The `bazel` cap of
scripts/loc-budget.json is the count of the merged tree, 3740.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hub-locks

No file conflicted. Main's change to hosted pnpm pins adds to bazel/pnpm.rs,
so the `bazel` cap of scripts/loc-budget.json is the count of the merged
tree again, 3858.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…gnore line

`cargo::vendored_from_cargo_with_config` comments out the line the scan
wrote in `.bazelignore` and expects `bazel cquery //...` and
`bazel query 'deps(//...)'` to fail on a repository that the main
repository does not see. It looked for the hub's repository
(`@crates__...`) alone. The build file that cargo-bazel writes into the
committed copy names `@platforms` as well, and Bazel reports the first one
it meets: on a Linux runner with Bazel 9.3.2 the query named `@platforms`
and the flow failed on its own check.

The flow now takes either name for that failure. Test only: nothing the
command does changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The check of the commands that fail once the ignore line is commented out
now reads the name out of Bazel's message and takes it only when the
message is about the main repository's view: `platforms`, or a repository
of the crate hub. The same words about another repository's view, or
about another name, are a different failure and no longer pass for the
expected one. A test without Bazel holds the check to the two messages
that were seen and to three it must not take.

The module docs, the comment at the call and the section on the build
file in a vendored crate said the commands end on the dependency's
repository alone. They now name `platforms` as well, which is what a
user who comments the line out can see.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The check of the commands that fail once the ignore line is commented out
now reads the name out of Bazel's message and takes it only when the
message is about the main repository's view: `platforms`, or a repository
of the crate hub. The same words about another repository's view, or
about another name, are a different failure and no longer pass for the
expected one. A test without Bazel holds the check to the two messages
that were seen and to three it must not take.

The module docs, the comment at the call and the section on the build
file in a vendored crate said the commands end on the dependency's
repository alone. They now name `platforms` as well, which is what a
user who comments the line out can see.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Resolve the bazel line budget conflict with the vendored Maven hub
(#2207): the budget is the count of the merged tree.

Assisted-by: Claude Code:claude-opus-5-5
…hub-locks

Two files conflicted. vendor/refusals.rs keeps every refusal of both
sides in the one dispatch of `bazel_workspace_refusals`, which is still
asked once and before any fetch: Composer's, then this branch's for a
PyPI or RubyGems project whose lock a hub reads, then main's for a Maven
jar that only a rules_jvm_external hub builds. Its docs say which of them
the user's word lifts. The `bazel` cap of scripts/loc-budget.json is the
count of the merged tree, 4042.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…m its lock

Two tests, no product change, that record what socket-patch does today
in a workspace where a pinned rules_jvm_external hub
(`maven.install(lock_file = "//:maven_install.json", ...)`) fetches an
artifact and agent mode patches the jar of that artifact in the Maven
local repository:

- `maven::an_agent_patch_beside_a_pinned_hub`, on real Bazel: the
  checkout has a `pom.xml` that declares the artifact, and the jar is in
  the Maven local repository as a Maven build leaves it.
  `scan --mode agent --yes` exits 0, puts the patch service's jar in its
  place and writes nothing into the checkout but `.socket/`; `apply`
  passes and warns `maven_bazel_hub_unpatched`. `bazel build` and
  `bazel run //:consumer` print the upstream marker before the command
  and after it: the hub fetches the jar its lock pins, at the lock's
  sha256, and no build reads the Maven local repository.
- `maven::an_installed_jar_is_attested_beside_a_hub_that_fetches_its_own`,
  without Bazel: the same step in a checkout whose lock is written by
  the test, in the format rules_jvm_external 7.2 writes.

In both, `scan --mode agent --vex`, `apply --vex`, `vex` and
`vex --no-verify` each write an OpenVEX document whose one statement
says the artifact is `not_affected`, "Patched via Socket patch <uuid>".
That document is false for what Bazel builds. The tests assert it as it
is today and mark it KNOWN GAP, with what a fix changes.

What the tests share is in the Maven module: step 0 of a flow is split
into the layout of the checkout and the ruleset's pin, so that a
checkout no Bazel builds in can have the same stand-in, grants and
local repository; `Pinned::patches_the_installed_jar` runs the agent
step. `Cell::patches_outside` of the harness compares the installed
file as bytes, since a jar is no text; the Cargo and NuGet flows call it
as before.

The real-Bazel flow passes on Bazel 9.3.2 and 7.7.2 (macOS arm64) with
no change to the product, in about 20 s each.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hes the jar from its lock

Agent mode patches the jar of a Maven artifact where a build tool
installed it (the Maven local repository, a Gradle or Coursier cache).
In a Bazel workspace a pinned rules_jvm_external hub does not build that
jar: it takes the one its lock (`maven_install.json`) pins, at the
lock's sha256. `apply` already warns of it (`maven_bazel_hub_unpatched`).
The tests of the commit before this one measured the rest on Bazel 9.3.2
and 7.7.2: `bazel build` prints the upstream marker before and after
`scan --mode agent`, and `scan --vex`, `apply --vex`, `vex` and
`vex --no-verify` each attest the artifact as `not_affected`. That
document is false for what Bazel builds.

The document now says `affected` of such an artifact, as it does for
npm, PyPI, RubyGems, Cargo and NuGet: one statement of the package's
own, whose action statement names the lock of the hub, the
`maven.install` with its file and line, and the command that patches a
pinned hub, `socket-patch get <purl> --mode hosted` at the Bazel root,
or with `--mode vendored`. It ends with the `--no-bazel` sentence. The
warning is `vex_bazel_not_in_build`, `vex --json` reports a `skipped`
event with `details.status: "affected"`, the envelope is
`partialFailure`, the exit code is 0, and `--no-bazel`,
`--vex-no-bazel` and `SOCKET_VEX_NO_BAZEL` leave Bazel out of the
document, all through the code those ecosystems already run.

The command comes with a condition, in brackets: "a `maven_bazel_*`
warning of that run means that the Bazel build keeps the upstream jar".
Hosted and vendored mode write no entry for a hub where they cannot
show from the checkout that one works (Bazel before 7.4.0, an unknown
release of the ruleset, an rc file, a jar the lock lists under no
repository, an isolated `use_extension`). The command then exits 0 with
such a warning, and beside a `pom.xml` it has still pinned or vendored
the patch for the Maven build, which `vex` attests as `not_affected`.
That statement is wrong for the Bazel build. It is the one hosted mode
leaves there without an agent patch before it, so it is not new; it
is in the docs' list of where the document is still wrong, and the
action statement must not send a reader there without a word.

Where the answer comes from. The table of hubs in `bazel/built.rs`
decides by the project's own lock: where it lies from the project, what
it lists, and whether its text names the patch. None of that fits a
Maven hub. Its lock is no project's own and never names a patch (the
patch of a hub is an entry of the block in the root `MODULE.bazel`), and
whether a hub fetches a jar takes what `bazel/maven.rs` already reads
for hosted and vendored mode: the tags that make a hub of one name, the
lock in format 2 or 3 with its skipped and local artifacts, a
`maven.override`, a `maven_install` of a `WORKSPACE` file, the block. A
second reader could disagree with that one. So `built::unbuilt` asks
`maven::upstream`, new, which reads the hubs once with `Hubs::read` and
says for each jar what `Hubs::sure` and the block say:

- a pinned hub fetches the plain jar at that version, every hub of the
  workspace was read, and the block holds no entry for the jar: the hub,
  for a statement that says `affected`;
- anything else: nothing, and the statement stays the one of a project
  without Bazel. That is a jar no hub fetches, a jar the block patches,
  and every case in which something was not read: a hub without a
  `lock_file`, a tag or a lock that cannot be read, a `maven.override`
  of the artifact, a `maven_install` of a `WORKSPACE` file that Bazel
  may read, a block that was changed by hand.

`Hubs::sure`, not `Hubs::built`, because a block that was changed by
hand may still patch the jar, and its entries are not read. So `apply`
can warn `maven_bazel_hub_unpatched` (it asks `Hubs::built`) where the
document keeps `not_affected`: beside a hub that was not read. The docs
say so. The warning and the statement share the check of the block
(`Hubs::patches`).

Two things follow from taking that reader, and the docs say both:

- A `WORKSPACE` file. For the hubs of the table any such file that
  defines a repository leaves the statement as without Bazel. The Maven
  reader takes one for a doubt only when it calls `maven_install` or
  cannot be read, and only while the checkout names no Bazel 9 or
  later, which is the rule hosted mode writes its entries by. So beside
  a `WORKSPACE` file that defines other repositories a Maven jar is
  `affected`.
- `m2local`. A lock with it takes a jar that no repository lists from
  the Maven local repository, at the lock's sha256. Such a jar counts
  as fetched, and its statement says `affected`: the patched jar does
  not have that sha256 (read from the ruleset's source at 7.2 and 6.5,
  not built here). The lock's sha256 is not compared with the patch.

`Unbuilt::remedy` is a `String` now, since the Maven command names the
package. A hosted or vendored entry of the block keeps its statement:
the caller hands over no hosted pin, and a committed copy is not asked
about. Nothing is read without a Maven jar among the patched packages,
and nothing outside a Bazel workspace.

Tests. Unit tests of `maven::upstream` (each case above; another
version, a classifier and another packaging of the jar; a block's entry
for another version of the artifact; a `WORKSPACE` file without
`maven_install`; a jar under `m2local`) and of `built::unbuilt` on disk
(the sentence, a project below the Bazel root, a committed copy, the
block's entry). The two tests of the commit before now expect
`affected` with the action statement. Without Bazel, each of the two
modes the statement names is run after agent mode in a checkout of its
own: where the command writes its entry it gives no `maven_bazel_*`
warning and `vex` then says `not_affected`; in a checkout that names
Bazel 7.3.0 it writes none and warns `maven_bazel_release`, and the
`not_affected` that `vex` then writes is held as the known limit it is.
A second test holds `vex`, with `--no-bazel` and beside four hubs of
which nothing is said, to what it gives in the same checkout without
`MODULE.bazel` (exit code, both streams, the document), and
`apply --vex` to the line a person reads. On real Bazel the flow goes
on after the documents: the hosted command pins the Maven build and the
hub, the same build prints the marker of the patched jar, and `vex`
says `not_affected`.

Docs: the Maven cell of "Bazel workspaces: what is supported", the
agent paragraph and the last limit of "Bazel workspaces: Maven", the
section "Bazel workspaces: VEX" (the table of calls, the kinds of
patch, the action statement and its condition, what changes nothing,
what is tested, what is still wrong) and the rows
`vex_bazel_not_in_build` and `maven_bazel_hub_unpatched` of the CLI
contract. Two things that held before are now said. `--vex-no-bazel`
is about the document, and what `scan`, `apply` and `vendor` themselves
say in a Bazel workspace stays, such as `maven_bazel_hub_unpatched`: a
sentence of the docs and of the contract's paragraph on the installed
tree is narrowed to that. And a patch is judged only where the run
found it in place, so `vex` on a machine whose installed jar is not the
patched one ends as it does without Bazel. The Maven workflow names the
agent flow and starts its legs on a change to the VEX code and to the
two files agent mode patches a jar with. The size budget of `bazel/`
follows the code (4006 to 4051 lines).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`vex` and `--vex` say `affected` of a Maven artifact that agent mode
patched in an installed jar while a pinned rules_jvm_external hub
fetches that jar from its lock. This change makes the statement hold in
the cases around it where the document was still false, or said less
than socket-patch knows.

A patch in any mode. A hub reads no `pom.xml`, no Gradle file and no
vendored tree, so a hosted pin or a vendored copy of a Maven or Gradle
build is in the Bazel build only through an entry of the block in the
root `MODULE.bazel`. Hosted and vendored mode write no entry where they
cannot show that one works: they exit 0 with a `maven_bazel_*` warning
and pin or vendor for the other build. `vex` then attested that patch
as `not_affected` while the hub fetched the upstream jar, and the
action statement of an agent patch sent a reader into that state. The
Bazel step of `vex` now asks about every Maven patch, also one with a
hosted pin or a committed copy, so the document after a command that
declined still says `affected`. The statement is one for every mode:
"the patch is only in what Maven or Gradle builds from", and "If what
you ship is what Maven or Gradle builds and not what Bazel builds, pass
`--no-bazel`". The statements of the other ecosystems are word for word
what they were, and a hosted pin of another ecosystem is left alone as
before.

The hub that fetches the jar, not every hub. `maven::upstream` asked
`Hubs::sure`, which is the rule for writing an entry: any doubt, also
one about another hub, gave nothing. So beside a second hub without a
lock `apply` warned that the Bazel build stays unpatched while the
document of the same run said `not_affected`. It now asks
`Hubs::built`: a pinned hub that was read fetches the jar, and no
`maven.override` names the artifact. A block that was changed by hand
may hold an entry, so it still gives nothing.

An entry of this patch. Any entry of the block for the jar counted as
"Bazel builds the patch". The entry of another patch than the one the
document attests does not: the statement is `affected`, and names that
entry first.

Whether Bazel reads `MODULE.bazel`. Nothing is said where the checkout
does not show that it does: `.bazeliskrc` or `.bazelversion` names a
Bazel before 7.0; neither names a release while a `WORKSPACE` file
defines a repository; or an rc file names an option that switches
Bzlmod off or drops tags of the root, or cannot be read. Such an option
is found on whatever line, so it may hold for one `--config` alone:
with it neither the hub nor an entry of the block is certain, which is
why an entry of hosted mode is not attested there either. Before, a
checkout that switched Bzlmod off got `affected` from a file that Bazel
does not read. While a release from 7.0 on is named, Maven keeps its
finer rule for a `WORKSPACE` file: a `maven_install` there is another
hub, and changes nothing for the hub that was read.

What to do. The action statement named `get <purl> --mode hosted`
whether or not that command would write an entry. `upstream` now gives
the remedy with the hub. Where hosted or vendored mode writes the entry
(`Hubs::label` and `settings`, as for a run) it is the command. Where
they do not, it is "Hosted and vendored mode write no entry for this
hub (`<code>`): <reason>.", with the code and the reason of the warning
that the command gives. One helper builds the command for the statement
and for the `maven_bazel_hub_unpatched` warning, from the coordinates
of the jar: a purl with qualifiers (`?type=jar&...`) no longer puts `?`
and `&` into a command for a shell. `"maven.install"` and the sentence
moved from `bazel/built.rs` to `bazel/maven.rs` with it.

`built::unbuilt` no longer parses the workspace for its table of hubs
in a run that has only Maven packages. The hubs and their locks are
still read once more than lock discovery reads them for the block: the
two are different layers of a run, and a read is one `MODULE.bazel`
with the locks it names.

Tests. `maven::upstream` has one unit test with a line per case above.
Without Bazel, `e2e_bazel_build` runs agent mode and then the hosted
and the vendored command in three checkouts: where the command writes
its entry (`not_affected` after it), and under Bazel 7.3.0 and beside a
second hub without a lock (`affected` before and after, with the code
and the reason in the place of the command). It holds the statement of
a project without Bazel beside an rc file that names
`--noenable_bzlmod` for one config, beside a `WORKSPACE` file with no
release named, and under Bazel 6. No existing test expected
`not_affected` for a hosted or vendored Maven patch whose hub got no
entry: each of them writes the entry, and passes as it was.

docs/ecosystems.md, the CLI contract and the line budget of `bazel/`
(4051 to 4084 implementation lines) follow. The contract's row of
`vex_bazel_not_in_build` no longer says that a `--no-bazel` run reads
no Bazel file: the option is about the document, and `apply` still
reads the workspace for its own warning.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The path lists of the Maven real-Bazel workflow name the files agent
mode patches a jar with, because one of its flows does that. They had
`patch/jvm_jar.rs` and `patch/jar_members.rs`. The second calls
`patch/jar_manifest.rs`, which was missing, so a change to how the
manifest of a signed jar is rewritten did not start the legs. It is in
both lists now.

Two kinds of entry said nothing: `vex/**` covers
`vex/discover/maven.rs` and `vex/discover/bazel_maven.rs`, and in the
push list `commands/**` covers `commands/vex*.rs`. They are removed,
and the comment says that lock discovery is under `vex/`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`maven::upstream` gave nothing whenever the block of `MODULE.bazel` was
changed by hand, because such a block may hold an entry. For a block
that can hold one, that check decided nothing: an `override_repo`
outside the block as socket-patch writes it is a call the workspace
reader does not follow, so no hub is read beside it, and nothing is
said of any jar. What the check did decide is a block that overrides
nothing any more (its first and its last line, say). That one holds no
entry and the hub fetches the upstream jar: `apply` warns
`maven_bazel_hub_unpatched` there, and the document said `not_affected`.

The check is removed. Such a checkout gets `affected`, and the statement
says why no mode patches the hub, in the words of the hosted command's
warning: the block was changed by hand (`maven_bazel_unreadable`). The
unit test of `upstream` holds both blocks, and the docs and the CLI
contract say which one keeps the statement of a project without Bazel.

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

cursor Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes VEX attestation semantics for Maven in Bazel workspaces (documents may flip from not_affected to affected), which affects compliance reporting; logic is extensive but heavily tested.

Overview
VEX in Bazel workspaces now treats Maven like other hub ecosystems: when a patch exists in Maven/Gradle’s tree or in agent mode’s local jar, but a pinned rules_jvm_external hub still builds the plain jar and MODULE.bazel has no entry for that patch, statements are affected (with hub lock, maven.install location, and remediation via hosted/vendored get, or the maven_bazel_* reason when no entry can be written). Previously those cases were attested as patched/not_affected while Bazel still used the upstream jar.

Implementation routes Maven through bazel::maven::upstream from built::unbuilt, with Maven-specific action text in vex.rs (including --no-bazel / ship-Maven-vs-Bazel wording). Docs, CLI_CONTRACT.md, CI path filters for the agent + VEX flow, e2e tests (with and without real Bazel), and a small loc budget bump for bazel/ complete the change.

Reviewed by Cursor Bugbot for commit 6016a39. Configure here.

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

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does. In a Bazel workspace where a pinned rules_jvm_external hub (maven.install with a lock) fetches a jar, vex / --vex now says affected for a Maven patch of that jar if the MODULE.bazel block has no entry for that patch. This holds in every mode: agent, a hosted pin of a pom.xml or Gradle file, and a vendored copy. Before, it said not_affected while bazel build used the upstream jar. The action statement names the hosted or vendored command that patches the hub, or the maven_bazel_* reason those modes give for writing no entry.

Risk: medium. It changes no file a user's install or build reads. Only the VEX output changes, and it gets stricter: some documents that said not_affected will now say affected, also after a hosted or vendored command that declined. That is the first "decision for the maintainer" in the description. Any doubt about the hub (a Bazel before 7.0, an rc file that turns Bzlmod off, an override, a block changed by hand) still gives the old not_affected statement. The PR is stacked on #2224 (base bazel-vex/04-cargo-nuget-installed).

Look here.

  • vex.rs:1953: Maven hosted pins are now judged too. This is the one-condition switch behind decision 1.
  • vex.rs:2009: the Maven wording. The other ecosystems' statements keep the same text.
  • built.rs:364: jars merges the Maven verdicts into the table's results.
  • maven.rs:1764 and :1774: upstream and its check that Bazel actually reads MODULE.bazel (release, WORKSPACE, rc options).
  • maven.rs:1787: an entry for a different patch of the same jar still gives affected.

Verified. I read the diff against the base branch (9 files, +984/−132). Non-Maven purls are left alone (upstream returns None for them). The shared action-statement text for the other ecosystems is unchanged, and CHANGELOG.md is untouched. CI on 6016a39: ci-ok and clippy are green. Every maven / bazel leg passed, including 7.4.0 and 7.7.2, as did the Windows Maven and Gradle vendor e2e jobs and Cursor Bugbot. There are no review threads. The only red checks are test (windows-latest, 1) and e2e-windows (… e2e_redirect_pnpm_build …), which fail on main too (#2238, #2235), plus their ci-ok (windows only) rollup.

Changes I made. None.

Open questions.


Generated by Claude Code

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] Approving; one inline note on a false not_affected path.

Base automatically changed from bazel-vex/04-cargo-nuget-installed to main November 25, 2026 15:59
This branch was stacked on the Cargo and NuGet VEX change, which main
now holds as the squash of #2224. The merge resolves against that
change's last head (916924b), so main keeps #2224 as it landed and
this branch adds only its own Maven change on top: the diff from main
is the same 9 files, line for line, as the diff from 916924b before
the merge.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko Mikola Lysenko (mikolalysenko) removed the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 25, 2026
Vendored mode declines a PyPI or RubyGems package whose lock a Bazel hub
reads, and it counted a call of a `WORKSPACE` file that names the lock as
such a hub (`pip_parse`, `rb_bundle_fetch`). Bazel 9 never reads a
`WORKSPACE` file. One that a move to Bzlmod left behind can still name
`requirements.txt` or `Gemfile.lock`, so in a checkout that Bazel 9
builds, a vendored run that worked before exited 1 with
`vendor_pypi_bazel_hub` or `vendor_gem_bazel_hub`, with no hub that takes
the lock.

Where the checkout names a Bazel release of 9 or later, a `WORKSPACE`,
`WORKSPACE.bazel` or `WORKSPACE.bzlmod` file now counts for nothing in
these two refusals: a call of it is no reader of the lock, a call of it
that is not written out is no doubt, and neither is a file that cannot be
read. The run does what it does without the file. The exception for a
package that is already vendored asks the same reader, so it agrees.

The release is read as the Maven reader reads it (`rc::declared_release`:
`USE_BAZEL_VERSION` of `.bazeliskrc`, else `.bazelversion`, and only three
numbers name one). One rule, `rc::reads_workspace_file`, holds "before 9,
or not named", and the Maven reader now asks it in the place of its own
closure. So a checkout that names 7.x or 8.x, `latest`, a release
candidate or no release keeps the refusal: a Bazel 7 or 8 may build it.

What `vex` says is not changed: `built::unbuilt` still says nothing
beside a `WORKSPACE` file.

Tests: unit rows in bazel/rc.rs and bazel/built.rs (the lock a call
names, the call that is not written out and the file that cannot be
read, under nine ways to name a release), and one test each in
e2e_bazel_build/ruby.rs and pypi.rs that runs the built binary without
Bazel. With `.bazelversion` 9.3.2, 9.0.0 or 10.0.0 beside a retained
`WORKSPACE` that names the lock, `scan --mode vendored` vendors the
package and writes the files it writes without that file; with 7.7.2,
8.8.2, no file or `latest` it is declined as before. With the rule
switched off, the test of built.rs and both of those fail on their first
9.x row.

docs/ecosystems.md and the contract row of the two codes say when the
file counts. The `bazel` cap of scripts/loc-budget.json is the new count,
4047.

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

Copy link
Copy Markdown
Collaborator Author

[agent] A local session is working on this branch right now (merging main and making the change the open review thread asks for). Please do not push to it until the agent:claimed label is gone: a second merge of main here makes that work non-fast-forward.

…s the jar

`maven::upstream` took an entry of the patch in the block of
`MODULE.bazel` for "Bazel builds the patch" and said nothing of the jar,
so `vex` attested `not_affected`. It did not ask whether the entry's
`override_repo` reaches the hub. The block overrides a repository of
the shared usage of the ruleset's extension, which reaches no hub whose
`use_extension` is an isolated one (`isolate = True`). `Hubs::label`,
by which hosted and vendored mode write an entry, declines such a hub,
but it was asked only where the block holds no entry.

Measured on Bazel 9.3.2 with a temporary flow: after the hosted command
wrote its entry, the hub's `use_extension` was given `isolate = True`.
Under `--experimental_isolated_extension_usages`, without which Bazel
does not take `isolate` at all, the build passes with the entry in
place and `//:consumer` prints the upstream jar. The document said
`not_affected` of it.

An entry of the patch now counts only where no pinned hub that fetches
the jar is on an isolated usage. Otherwise the statement is `affected`
for that hub, also where another hub does take the entry. It says first
that "the entry that MODULE.bazel holds for this patch does not reach
this hub", and then why hosted and vendored mode write none that does,
with the code and the reason of their warning
(`maven_bazel_unreadable`), as for the other declines.

Only what is certain. `Hub::proxy` is `None` for a usage that is
isolated and for one that cannot be read: an `isolate` that is neither
`True` nor `False`, a label that is no plain string. The second kind may
be a shared usage, which the entry reaches. So the reader keeps the two
apart (`Hub::isolated`: each tag of the hub is on a usage with `isolate
= True`), and beside a usage that cannot be read the entry stands and
the statement stays `not_affected`. Without an entry nothing changes:
the hub fetches the upstream jar whatever its usage is, and the
statement was `affected` already.

Tests. The unit test of `upstream` has the rows: an entry beside an
isolated hub, beside a usage that cannot be read, beside two hubs of
which one is isolated (that one is named), and a hub with tags on both
kinds of usage. Without Bazel, `e2e_bazel_build` runs the hosted and
the vendored command, sees `not_affected`, makes the hub's usage an
isolated one and sees `affected` with those words. Every existing test
of an entry that reaches its hub passes unchanged.

The line budget of `bazel/` goes from 4084 to 4096.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main gained the off switch for a project that Bazel does not build
(`SOCKET_NO_BAZEL`), with the rule that a doubt of the workspace reader
is about no hub where nothing names rules_jvm_external, and the
Experimental marks of the CLI contract. Three files meet this branch:

- `bazel/maven.rs`: both sides add a field to `Hubs` at the same place,
  main's `unread` and this branch's `legacy`. Both are kept, each with
  its initializer.
- CLI_CONTRACT.md: main marks the rows and passages about Bazel
  Experimental, and this branch changes three of the same one-line
  entries (the `--no-bazel` passage and the rows of
  `maven_bazel_hub_unpatched` and `vex_bazel_not_in_build`). Each of the
  three is main's text with this branch's words in it: a three-way merge
  word by word leaves no conflict.
- The line budget: the cap of the `bazel` group is the count of the
  merged tree, 4132 (main's 4042 and the 90 lines of this branch).

Everything else merges without a conflict. Against main, the merged
tree differs in the nine files of this branch and by exactly its own
change.

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

Main gained `SOCKET_NO_BAZEL`, which makes every command do what it
does for a project in no Bazel workspace, and this branch gained a
statement that a Maven patch gets from any project of the workspace: a
`maven_install.json` names no project, so a Maven service that Bazel
does not build is `affected` too, beside a hub that pins the same
artifact. That is the project the switch is for.

The judgement goes through the workspace lookup, so the switch already
turns it off. A test now holds it: beside the hub that fetches the jar,
`apply --vex` with `SOCKET_NO_BAZEL=1` is the run of the same checkout
without its Bazel files, in exit code, output and files, and is not the
run beside the hub.

The docs say it in both places: the list of what a Bazel workspace
changes for a project names the Maven statement, and the Maven limits
name the switch beside `--no-bazel`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hub-locks

Five files conflicted.

bazel/built.rs keeps main's hubs for Cargo and NuGet and what `unbuilt`
says of them, and this branch's `reader` for the two vendored refusals,
on one set of helpers: `reader` goes through every extension of a hub,
`file` knows the name a `WORKSPACE` file gives the main repository, and
the call it finds carries the hub's remedy. `unbuilt` is main's: the rule
that passes over a `WORKSPACE` file under Bazel 9 is `reader`'s alone.

vendor/refusals.rs, CLI_CONTRACT.md and docs/ecosystems.md keep the
entries of both sides. The contract and the docs mark this branch's two
codes experimental as main marks the others, name them among the codes
only a Bazel workspace gives, and say that `SOCKET_NO_BAZEL` turns them
off, which a new test of each holds (`off_is_without_bazel`). The `bazel`
cap of scripts/loc-budget.json is the count of the merged tree, 4184.

Outside the conflicts:
- main's new test of e2e_bazel_build/ruby.rs calls this branch's
  `Served::to` and `checkout_with`;
- a unit test of vendor/bazel_hub.rs stood a Poetry and a PDM project on
  an empty lock. Main no longer wires a lock that resolves no package
  beside a `requirements.txt`, so the test's lock now resolves the
  package, as main's own tests of that change do, and a row holds that
  the empty lock is declined like no lock;
- the docs and the contract say that such a lock is not what is wired.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main now names each patched package as a VEX product of its own, after
the project. Nothing of it meets this branch in a line: the CLI
contract, the harness of `e2e_bazel_build` and docs/ecosystems.md merge
on their own, and the statements of a Maven artifact go through the
same builder and the same assertions as every other package, so they
carry the package product too.

Against main, the merged tree differs in the nine files of this branch
and by exactly its own change. The cap of the `bazel` group is
unchanged, 4132.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The change that declines PyPI and RubyGems vendored mode where a Bazel
hub reads the lock lands before this branch and meets it in three
files. It is merged as it stands, so that the merge of main after it is
clean. Nothing of either side is dropped.

- `bazel/built.rs`: `unbuilt` is both sides. The table's reader is
  asked only for a run that has a package of the table (this branch),
  with the project's path through `slashed` (the other side), and the
  Maven step follows. This branch's `jars` and the other side's
  `reader`, `workspace_as_built`, `reads` and their helpers all stay.
  `reads` hands its remedy over as an owned string, which
  `Unbuilt::remedy` is on this branch.
- `bazel/maven.rs`: the Maven reader's closure for "a Bazel before 9,
  or none named" is the shared `rc::reads_workspace_file`, as on the
  other side. This branch's `Hubs::legacy` (a `WORKSPACE` file defines
  something) is now taken from the value that rule has filtered. It is
  asked only where no release is named, where the file may always be
  read, so what it says is unchanged. The guard of `maven::upstream`
  keeps its own threshold on the same `rc::declared_release`: a named
  release from 7.0 on reads `MODULE.bazel`. That is another question
  than whether a release before 9 may read a `WORKSPACE` file, and one
  rule for both would change a statement.
- `scripts/loc-budget.json`: the cap of the `bazel` group is 5300, the
  one value every change of this series now sets so that they stop
  meeting on that line, until a later change lowers it to the count.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main now holds the vendored-hub guard as one squashed commit, and the
change that says why an apply failed. This branch merged the guard's
own branch in the commit before this one, so the three files where the
two meet (`bazel/built.rs`, `bazel/maven.rs` and the line budget) stay
as that merge left them: main's text of them is the guard branch's,
byte for byte. Against main, the merged tree differs in the nine files
of this branch, and by its own change alone.

The cap of the `bazel` group stays 5300, as the commit before set it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Merged via the queue into main with commit 4ecfd4f Nov 25, 2026
84 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the bazel-vex/05-maven-installed branch November 25, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants