Skip to content

Vendor a gem for a Bazel hub as its archive, named by a relative file: URL - #2211

Merged
Mikola Lysenko (mikolalysenko) merged 42 commits into
mainfrom
bazel-vendored/gem-file-source
Nov 25, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 42 commits into
mainfrom
bazel-vendored/gem-file-source

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

Vendored mode now patches a RubyGems dependency that a rules_ruby ruby.bundle_fetch hub builds, by committing the patched gem and naming it in Gemfile and Gemfile.lock with a relative file: URL, wherever the checkout shows that Bazel builds that form; everywhere else it declines as before.

Stacked on the pull request that makes vendored mode decline beside a hub ("Decline PyPI and RubyGems vendored mode where a Bazel hub reads the lock").

Decisions for the maintainer

  1. The form itself. A relative file: source in Gemfile and Gemfile.lock, with the patched gem committed under .socket/vendor, was decided by the maintainer on 2026-11-20. Its price is that Bundler by itself does not install from that source in the same checkout (see Limits); the run says so in a warning, and hosted mode is the mode that serves both builds. The other forms that built were labels written into the ruby.bundle_fetch call, and a committed Bazel extension; neither is built here.
  2. A checkout that names no Bazel release is declined. The form relies on Bazel opening a relative file: URL. Bazel 9.1.0 fails on one (Bazel's own history: "Migrate from URL to URI" in 9.1.0, "downloader: fix opaque file URI names" in 9.1.1 and 9.2.0; read, not run). Without three numbers in .bazelversion, or in USE_BAZEL_VERSION of .bazeliskrc, nothing says that the build is not on 9.1.0, so the gem is declined and the message says what is missing. latest and a release candidate count as no release. The alternative is to go on with a warning, which can leave a broken build behind a command that exited 0.
  3. Which Bazel releases count. Every release of Bazel 7, 8 and 9 except 9.1.0. Built: 9.3.2, 8.8.2 and 7.7.2. A stricter rule (only the built releases and later ones of each line) would decline many checkouts that pin an older 7.x or 8.x.
  4. Which Bundlers count. rules_ruby installs the Bundler that the lock's BUNDLED WITH names in the hub and runs it there. The form is built with 4.0.15 and with 2.6.9, on the three Bazel releases, and both fail the build on a changed byte. A lock is taken when it names 2.6 or later of the 2 line, or a Bundler 4. A lock of Bundler 2.2 to 2.5 is declined, although rules_ruby itself builds from one: no build here ran the form with such a Bundler. To widen the rule, add an older Bundler to ruby::file_source_by_hand.
  5. The tests download one more gem from rubygems.org. Bazel fetches bundler-2.6.9.gem there, with the sha256 of rules_ruby's own table, as the three flows already fetch bundler-4.0.15.gem. No gem under test comes from a public registry.
  6. socket-patch never edits the ruby.bundle_fetch call. Where gem_checksums has an entry for the gem, the run declines until you write the sha256 of the patched gem there, and an undo leaves that value in place: the build then fails until you put the upstream one back or delete the entry. The undo says so in a warning. The alternative is to write a Bazel file.
  7. The switch keeps its meaning. --allow-vendored-in-bazel still writes the unpacked copy named by its path, also where the new form would be written without it.
  8. A hosted pin can now be taken over or ejected into this form by scan --mode vendored or vendor, where the conditions hold. On the base both were declined and the hosted pin stayed.
  9. The project must be the root of the Bazel workspace. Bazel opens the URL from the root, so a project below it is declined; that shape was not built.
  10. Size. 785 lines of code outside tests (sizes below). Most of it is one new file; the two files a build reads are written by the hosted planner that already exists. Two paths could go if size matters more: writing the gem again when the pair is in place and the ledger has no entry, and a newer patch taking the source over in place (about 40 lines together; each is a working path today).

Today

Where a ruby.bundle_fetch call of the workspace reads the project's Gemfile or Gemfile.lock, vendored mode declines the gem with vendor_gem_bazel_hub and writes nothing: the copy it commits is named by a path, rules_ruby runs bundle install in a repository of Bazel's that does not hold that path, and the build fails.

What changes

For such a gem vendored mode commits the archive the patch service serves and writes the pair that hosted mode writes, with a relative URL of the checkout in the place of the patch registry's:

gem "rack", "~> 2.2", source: "file:.socket/vendor/gem/<uuid>/"     # Gemfile

GEM                                                                 # Gemfile.lock
  remote: file:.socket/vendor/gem/<uuid>/
  specs:
    rack (2.2.3)

DEPENDENCIES
  rack (~> 2.2)!

CHECKSUMS
  rack (2.2.3) sha256=<the patched gem>

.socket/vendor/gem/<uuid>/gems/rack-2.2.3.gem                       # the patched gem

rules_ruby asks Bazel for <remote>gems/<name>-<version>.gem, Bazel opens the URL from the root of the workspace, and Bundler holds the file to the CHECKSUMS line. No file of Bazel's is written. The directory of the patch also gets the marker and a .gitignore / .gitattributes of its own (stock ignore templates name *.gem).

It is written only where all of these hold, each read from files of the checkout:

  • the checkout names a Bazel release of 7, 8 or 9 other than 9.1.0, as three numbers;
  • the project is the root of the Bazel workspace;
  • the module files are read with certainty, no WORKSPACE file defines a repository, every ruby.bundle_fetch call writes out the files it reads, and a call that reads one of the two files reads both;
  • something holds the gem to its bytes in the hub of every call that reads the two files: the lock has a CHECKSUMS section, or each such call has a gem_checksums entry for the gem;
  • every gem_checksums entry for the gem, in any of those calls, is the sha256 of the patched gem (known after the download; the message names the call and the value to write);
  • the lock's BUNDLED WITH names Bundler 2.6 or later of the 2 line, or a Bundler 4;
  • the lock holds the gem as its ruby-platform entry.

Where one does not hold the gem is declined with the same code and exit code as before, nothing is written, and the message names the condition. What vendored mode refuses for every gem (a native extension, a declaration it cannot edit) is refused first, as outside Bazel.

Nothing changes for a project outside a Bazel workspace, for a project in a workspace whose hubs read none of its files, or for any other ecosystem.

The other commands follow. A later run is in sync. vendor --check holds the committed gem to the patch and to the ledger. repair downloads it again. vendor --revert, rollback and remove take the source off the Gemfile, put the lock's entry back where Bundler sorts it with its DEPENDENCIES and CHECKSUMS lines as they were (byte for byte for a lock in Bundler's own order), and delete the directory; a pair whose source: or GEM section is no longer what the run wrote is left alone. list and vex show the gem as vendored. A person who runs the command is told to build with Bazel as the next step, not to reinstall.

Limits

The run says the first two in a warning (vendor_gem_bazel_file_source):

  • Bundler by itself does not install from that source. bundle install on a machine that has not installed the gem fails, and so does every bundle lock --update. On a machine that installed the gem before the patch, bundle install passes and the program runs that unpatched copy, with no error. The checkout then builds its gems through Bazel only. Hosted mode serves both builds.
  • Bazel does not watch the committed gem. An output base that fetched the gems before keeps building what it fetched when only the gem changes; it never builds the changed bytes. The other way too: one that fetched a damaged gem keeps failing after repair until it fetches the hub again. A change of Gemfile.lock or a new output base fetches again.
  • An undo leaves the gem_checksums entry you wrote. After vendor --revert, rollback or remove the build fails on it (Checksum was ... but wanted ...) until it holds the upstream sha256 again or is deleted. The undo warns (vendor_gem_bazel_checksum_left).
  • The gem's bytes are held by the lock's CHECKSUMS line or by gem_checksums, and by nothing else; with neither the gem is declined. vex holds the committed gem to its patched files; vendor --check and a fresh build hold it to its bytes.
  • A dry run downloads nothing, so it does not show the decline for a gem_checksums entry that holds other bytes.
  • The Bazel release is the one the checkout names. A release that a machine's environment names instead is not seen.
  • A hub that Bazel does not fetch again (pinned in a vendor directory made before the patch, or built with --nofetch) keeps the gems it has, in every mode.
  • The form rests on Bazel's server opening a relative URL from the root of the workspace, which Bazel documents nowhere.

Contents

Lines
Code outside tests +1125 / -54 (785 lines of code): vendor/gem/bazel.rs (new: the conditions, the write, the undo and its warning, the archive check) 664; lock discovery 32; the gem backend's hooks 28; the refusal layer 21; the hosted planner's entry point 15; the workspace reader 11; repair and vendor --check 9; the next-step line of the CLI 5
Unit tests in the same files +803 / -5
Real-Bazel and hermetic tests (e2e_bazel_build/ruby.rs) +681 / -103
Docs (docs/ecosystems.md, CLI_CONTRACT.md) +183 / -22
Workflow paths, loc budget +7 / -4

Two commits. The first is tests only: a flow that writes the three files by hand and builds them, which passes on the code as it was. The second is the change, with the flow of vendored mode rewritten to hold the command to those files.

What it proves, and where

  • Real Bazel 9.3.2, 8.8.2 and 7.7.2, macOS arm64, at the head of this pull request. Written by hand: a second machine with a new output base, no patch host and no copy of the gem in the repository cache prints the patched marker, and one changed byte fails a third machine's build (Bundler found mismatched checksums); the same again on two machines whose lock names Bundler 2.6.9, where the hub holds that Bundler. Written by the command: the same three files byte for byte, the next build prints the patched marker with no request for a patched or an upstream gem, vendor --check passes and catches one changed byte, a second machine's build fails on it, vendor --revert restores every file and the upstream build, and the VEX documents are held to the patched build. In a checkout that names no release the command declines and the build stays as it was. The legs of bazel-ruby.yml run the three releases.
  • With the change taken out (a binary of the parent), the flow of vendored mode fails on Bazel 9.3.2, and so do three of the five tests without Bazel.
  • Without Bazel, through the binary: the run, its dry run, in-sync runs, vendor --check, repair, the three undos with the warning for an entry left in the call, the next step a person is given, a lock of Bundler 2.6.9, the switch, a hosted scan over the vendored gem, the takeover of a hosted pin, and every condition that declines, a second call that reads the same two files among them.
  • Do no harm: for 40 runs in four places without a hub that reads the project's files, a binary of this change and a binary of its base print the same output, exit the same and leave the same files, byte for byte.
  • Unit tests: one case per condition; two calls over the same pair; the undo over a declared gem, an undeclared one, CRLF files and a lock without CHECKSUMS; the warning of the undo; a newer patch that follows an older one; a pair that drifted; a ledger record that names another gem's line; the backend against a stand-in for the patch service; lock discovery.
  • Deliberate breaks of the code. Four were run on the final code and each was caught by the test written for it. Sixteen more are written and were not run on the final code.

Not covered

  • rb_bundle_fetch in a WORKSPACE file, a project below the Bazel root, a gem locked as platform gems and a lock of a Bundler older than 2.6: declined.
  • Windows, releases of rules_ruby other than 1.0.0-rc2, and a Bundler other than 4.0.15 and 2.6.9 inside the hub: not run. Local runs were on macOS only.
  • A gem that the Gemfile does not declare builds patched by hand on Bazel 9.3.2; no test here builds one. A newer patch that follows an older one is tested without Bazel only.
  • Two ruby.bundle_fetch calls over the same pair: the conditions are tested without Bazel. No test here builds two hubs.
  • Measured by hand and not by a test here: the failing build after an undo with a gem_checksums entry (9.3.2), plain Bundler on the vendored checkout (4.0.15), a hub pinned in a vendor directory and --nofetch (9.3.2).
  • vex still says nothing of a gem vendored by its path with --allow-vendored-in-bazel, whose build fails, as before.

Code review

Nine findings, each checked against the code. Six are fixed in one commit on top ("Close six gaps of a gem vendored for a Bazel hub that a review found"), each with a test except the second:

  • The gate did not read the rc files. A .bazelrc, or a file it imports, that names --experimental_remote_downloader, --repository_disable_download or --vendor_dir now declines the gem, as does an rc file that cannot be read. Under the first a remote downloader is handed the URL in the place of Bazel's own (read in Bazel's source: 9.3.2 keeps a file: URL to itself, 7.7.2 does not); none of the three was built.
  • A dry run showed a gem that the run then refused, where git ignores the directory. The check now comes before the download and before the dry run returns. No test was added for the order.
  • An undo wedged on a half-restored pair. With one of Gemfile and Gemfile.lock put back by hand, every undo warned and left the other file and the gem. The other file now goes back by itself.
  • A planner refusal named a way on that is hosted mode's. The decline now says so.
  • The closing step named the Bazel build only when every package was such a gem. A run that vendored other packages too adds a line for it.
  • The two wiring kinds were not among the kinds whose file the ledger checks.

The real-Bazel flow also builds the unpacked copy under --allow-vendored-in-bazel again, and asserts the failing bundle install: the rewrite of the flow had dropped the one build that shows what the decline is for.

Not changed:

  • The rules_ruby release is not part of the gate. The finding feared an older ruleset that does not ask the lock's remote for the gem. Every release that has bundle_fetch (0.5.0 to 1.0.0-rc2) downloads <remote>gems/<name>-<version>.gem with Bazel's downloader (read in the ruleset's source); hosted mode rests on the same line and has no such gate. Built with 1.0.0-rc2 only.
  • The refusals of every vendored gem answer first, also where the committed gem would not need them (a declaration inside a group block, a gem with a native extension, a patch without a stub specification). They are false declines, not broken builds; narrowing them is a change of its own.
  • The workspace is read more than once per gem. Time only.
  • The remote a ledger record names for the undo is not checked against where the gem came from. It needs a changed state.json, which is a committed file, and the record's lines for the gem are checked.

Generated by 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
Tests only. rules_ruby's `ruby.bundle_fetch` copies `Gemfile` and
`Gemfile.lock` into a repository of Bazel's, has Bazel download
`<remote>gems/<name>-<version>.gem` for every gem of a `GEM` section, and
runs `bundle install --local` there. Vendored mode names its copy by a
path, which that repository does not hold, so beside such a hub the
command declines (ruby::vendored_bundle_fetch, which stays as it is).

ruby::file_source_by_hand shows a vendored form that this hub does
build, written by hand in the fixture of the two other flows (rules_ruby
1.0.0-rc2, a lock with a `CHECKSUMS` section, no `gem_checksums`). It is
the pair hosted mode writes, with a relative `file:` URL of the checkout
in the place of the patch registry's:

    gem "sp-victim", "1.0.0", source: "file:.socket/vendor/gem/<uuid>/"

    GEM
      remote: file:.socket/vendor/gem/<uuid>/
      specs:
        sp-victim (1.0.0)

    DEPENDENCIES
      sp-victim (= 1.0.0)!

    CHECKSUMS
      sp-victim (1.0.0) sha256=<the patched gem>

and the patched gem committed at
`.socket/vendor/gem/<uuid>/gems/sp-victim-1.0.0.gem`, where rules_ruby
asks that source for it. No file of Bazel's is written. Bazel's server
runs in the root of the workspace and opens the URL from there, and
Bundler holds the file to the lock's `CHECKSUMS` line.

The flow builds the unpatched checkout, writes the three files, and
builds them on a second machine: a new output base (on Bazel 9 a new
contents cache too), a downloader config that sends nothing to a patch
host and refuses its URLs, and a repository cache that holds no copy of
the patched gem. `bazel build` and `bazel run //:consumer` print the
patched marker, Bazel changes no file, a `--lockfile_mode=error` build
passes, and the stand-in was asked for no patched gem and for no
further upstream one. On a third machine the last byte of the committed
gem is another one. That byte is padding of the tar, so RubyGems still
reads the file, and the build fails in the `bundle install` action with
"Bundler found mismatched checksums", which names the sha256 of the
lock and the one of the file.

rules_ruby installs the Bundler that the lock's `BUNDLED WITH` names in
the hub and runs it there. The fixture's lock names 4.0.15, and most
locks today name a Bundler of the 2 line, so a fourth and a fifth
machine do both again with 2.6.9 in the lock: the hub holds
`@bundle//:bundler-2.6.9`, the build prints the patched marker, and the
changed byte fails it with the same message. Bazel downloads that
Bundler from rubygems.org with the sha256 of rules_ruby's own table, as
it does the 4.0.15 of the other flows.

The flow passes on Bazel 9.3.2 with the product code as it is, and on
8.8.2 and 7.7.2 with the change that follows, which it does not use
(macOS arm64).

The downloader rules of a flow are now a function (`routes`), so that a
machine without a patch host keeps the two rules for the gems of
rubygems.org. Bundler's message is compared without white space in one
place for both flows.

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

Vendored mode declined every gem whose `Gemfile` or lock a
`ruby.bundle_fetch` call of the Bazel workspace reads
(`vendor_gem_bazel_hub`): the copy it commits is named by a path, and
rules_ruby runs `bundle install` in a repository of Bazel's that does not
hold it. It now vendors such a gem in a form that the hub builds, where
the files of the checkout show that it builds, and declines everywhere
else as before.

The form. The patched gem is committed as the archive the patch service
serves, at `.socket/vendor/gem/<uuid>/gems/<name>-<version>.gem`, and the
two files name it as hosted mode names a patch registry, with the
relative URL `file:.socket/vendor/gem/<uuid>/` in the registry's place:
a `source:` option on the gem's declaration (or the line hosted mode
adds for a gem the Gemfile does not declare), a `GEM` section of the
gem's own with that remote, a source-pinned `DEPENDENCIES` entry, and
the sha256 of the patched gem in `CHECKSUMS`. These are the three files
of ruby::file_source_by_hand, byte for byte. rules_ruby asks Bazel for
`<remote>gems/<name>-<version>.gem`; Bazel's server runs in the root of
the workspace and opens the URL from there; Bundler holds the file to
the `CHECKSUMS` line. No file of Bazel's is written. Beside the gem the
directory of the patch holds the marker and a `.gitignore` (`!*`) and
`.gitattributes` of its own, because stock ignore templates name
`*.gem`, and the ledger records the archive with its sha256 and size.

The pair is not written by new code: it is the hosted planner's own
edit (`plan_gem_source` hands `plan_gem_redirect` the URL and the sum),
so it is what hosted mode writes for the same project, in the lock's own
line endings.

Where it is written (`vendor::gem::bazel::gate`). Only for a gem whose
`Gemfile` or lock a call of the hub names, and only where each of these
holds. All of them are read from the files of the checkout, through the
readers of `bazel/`; no Bazel is run:

- The checkout names a Bazel release of 7, 8 or 9 other than 9.1.0
  (`bazel::rc::declared_release`: `.bazelversion`, or
  `USE_BAZEL_VERSION` in `.bazeliskrc`). Bazel's history says that
  `repository_ctx.download` fails on such a URL in 9.1.0 ("Migrate from
  URL to URI") and that 9.1.1 and 9.2.0 fixed it ("downloader: fix
  opaque file URI names"); that is read, not run. A checkout that names
  no release, or one that is not three numbers, is declined: 9.1.0 may
  build it, or a release to come.
- The project is the root of the Bazel workspace: Bazel opens the URL
  from the root, and the gem lies under the project.
- The module files are read with certainty, no `WORKSPACE` file defines
  a repository, every call of the hub writes out the files it reads, and
  a call that reads the `Gemfile` or the lock of the project reads both.
- Something holds the gem to its bytes in the hub of every call that
  reads the two files: the lock has a `CHECKSUMS` section, or the
  `gem_checksums` of each such call (a dict of strings that is written
  out) have an entry for the gem. With neither, any bytes at that path
  would build in that hub. Two calls may read the same pair, each for a
  hub of its own, and the detail names the call without an entry.
- The lock names a Bundler that a hub was built with (`BUNDLED WITH`):
  2.6 or later of the 2 line, or one of the 4 line. rules_ruby installs
  the lock's Bundler in the hub and runs it; ruby::file_source_by_hand
  builds the form with 2.6.9 and 4.0.15, and both fail the build on a
  changed byte. An older Bundler, and a lock that names none, is
  declined; every lock that passes has one `GEM` section per source.
- The lock holds the gem as its ruby-platform entry.

One more condition is known only once the patched gem is downloaded:
every `gem_checksums` entry for the gem, in any call that reads the two
files, has to hold it to the patched gem, because rules_ruby hands that
sha256 to Bazel. An entry for other bytes declines the gem after the
download and before any write, with the same code, and the detail names
the call, the entry and the sha256 to write there. socket-patch does
not edit the call. A dry run downloads nothing and does not show this
one.

Before any of that the gem meets what vendored mode refuses for every
gem, in the same order as outside Bazel: the refusals of the lock, of
the declaration and of the stub gemspec (a native extension, a
declaration in a `group` block, and the rest).

What declines says so. The refusal keeps its code, its exit code and
its place (before a download, a takeover or an eject), and the detail
names the condition in the place of the sentence about the path:

    `ruby.bundle_fetch` (MODULE.bazel:15) of the Bazel workspace at
    /repo names Gemfile.lock; vendored mode commits the patched gem for
    such a call and names it by a relative `file:` URL, which is not
    known to build here: the checkout names no Bazel release as three
    numbers (`.bazelversion`, or `USE_BAZEL_VERSION` in `.bazeliskrc`),
    and not every release opens such a URL; use `--mode hosted`, ...

A doubt of the reader declines as it did, in the words it had.

What a run that works says. One warning per gem,
`vendor_gem_bazel_file_source`, with what the form costs: Bundler by
itself does not install from such a source (`bundle install` on a
machine without the gem and `bundle lock --update` fail; on a machine
that installed the gem before the patch, `bundle install` passes and
the program runs that unpatched copy; measured with Bundler 4.0.15), so
the checkout builds its gems through Bazel only, and hosted mode serves
both; and Bazel does not watch the gem, so an output base that fetched
the hub before keeps what it fetched. A person who ran the command is
told to build with Bazel as the next step, where a run that vendored
anything else is told to reinstall.

Every entry point. The refusal layer (`vendor::bazel_hub::refusals`)
asks the gate where it declined, so `scan`, `get` and `vendor`, their
dry runs, the takeover of a hosted pin and the eject of one all go on
where it holds. The backend (`vendor_gem`) asks it again and takes the
gem in `vendor::gem::bazel::vendor`; the download plan asks for the
archive and its stub gemspec and stages no tree.

The undo. `vendor --revert`, `rollback` and `remove` take the source
off the `Gemfile` (the option, or the added line, with the helpers the
hosted unwind uses), move the lock's entry back into the section it
came from, where Bundler sorts it, and put its `DEPENDENCIES` entry and
its `CHECKSUMS` line back as the ledger recorded them, then delete the
directory. Both files go back or neither, byte for byte where the
lock's entries are in Bundler's own order: a pair whose `source:` or
`GEM` section is no longer what the run wrote is left alone with the gem
(`vendor_lock_entry_drifted`), and so is a ledger record that would put
back a line that is not this gem's. A pair that names the source nowhere
has been put back by hand, and only the directory goes.

The undo does not edit the call either. Where a `gem_checksums` entry
still holds the gem to the sha256 of the patched gem, which is the
value the run asked for, Bazel fails the download of the upstream gem
that the lock names again (`Checksum was ... but wanted ...`). The undo
says so in a warning, `vendor_gem_bazel_checksum_left`, that names the
call and the entry; the decline that asks for the value says that no
undo puts the old one back.

The other commands. A later run is in sync, with or without the switch.
`vendor --check` holds the committed gem to the patch (the patched
files in it) and to the sha256 of the ledger; `repair` downloads it
again, and so does a run that finds the pair in place and the gem gone.
A newer patch of the gem takes the source over in place. `list` shows
the gem as vendored. Lock discovery reads a `GEM` section whose one
remote is the patch's directory, spelled exactly as written, as a
vendored reference to that archive where the manifest gives the gem the
same source, so `vex` attests the gem as it attests every vendored one:
`not_affected`, which ruby::vendored_bundle_fetch now holds to the
patched build. `vex` holds the committed gem to its patched files, as it
holds every vendored archive; `vendor --check` holds it to its bytes as
well. What `vex` says of a gem vendored by its path is unchanged
(nothing: its build is not judged).

A ledger artifact counts as one committed file by its place,
`<dir>/gems/<file>.gem`, and not by the suffix alone: a copy vendored by
its path is a directory named for its gem and version, and a version
may end in `.gem`.

The switch. `--allow-vendored-in-bazel` means what it meant: with it
vendored mode writes the copy of every other project, named by its
path, also where the archive would be written without it.

Where nothing changes. Outside a Bazel workspace, and in a workspace
whose hubs read none of the project's files, the gem backend takes the
path it took: for 40 scenarios in four such places (scan, check,
rescan, revert, dry runs, `get`, `vendor`, the eject and the takeover,
as JSON and as a person reads them) a binary of this commit prints what
a binary of its parent prints, exits as it does and leaves the same
files, byte for byte.

Tests:

- ruby::vendored_bundle_fetch (real Bazel): the checkout names no
  release, the command declines and the build stays the upstream one;
  with the release in `.bazelversion` it writes the files of the flow
  written by hand, the next build prints the patched marker on a
  machine whose Bazel reaches no patch host, with no request for a
  patched or an upstream gem, `vendor --check` passes, one changed byte
  fails `vendor --check` and the build of a second machine,
  `vendor --revert` restores every file and the upstream build, and
  hosted mode still patches it. The documents of `--vex`, `vex` and
  `vex --no-verify` are held to that build.
- Without a Bazel, through the binary: the run, the dry run, the
  in-sync runs, `vendor --check`, `repair`, the three undos, the switch,
  a hosted scan over the vendored gem and the takeover of a hosted pin;
  the next step a person is given; a lock that names Bundler 2.6.9; and
  each condition that declines, with nothing written and no gem
  fetched: an older Bundler, a second call without an entry, the entry
  for other bytes in the first call and in a second one. With the entry
  for the patched gem the gem is vendored with and without a
  `CHECKSUMS` section, and each of the three undos puts every file back
  and names the entry it leaves.
- Unit tests of the gate, one case per condition; of the undo over the
  planner's own pairs (a declared gem with its requirement, options and
  comment, an undeclared one, CRLF, a lock with no `CHECKSUMS`), of a
  patch that follows another, of a pair that drifted and of a ledger
  record that names another gem's line; of the archive check; of the
  backend against a stand-in for the patch service; and of discovery.

The three `ruby::` flows pass on Bazel 9.3.2, 8.8.2 and 7.7.2 at this
commit (macOS arm64), and ruby::vendored_bundle_fetch fails on 9.3.2
against a binary of the parent; the legs of bazel-ruby.yml run them on
the three releases.

The test of the refusal in bazel_hub.rs asserted the sentence about the
path for a gem below the Bazel root; it now asserts the condition that
declines that gem.

Docs: docs/ecosystems.md has "Bazel workspaces: RubyGems vendored mode",
the vendored cell of the RubyGems row ("Supported with the Bazel release
named in `.bazelversion`"), four entries among the known problems (the
two costs, the entry an undo leaves in the call, and a hub that Bazel
does not fetch again), and what "Bazel workspaces: VEX" says of a
vendored gem; CLI_CONTRACT.md has the rows of the code, of the two
warnings, of the switch and of the vendored table. bazel-ruby.yml starts
its legs for vendor/gem/. The `bazel` group of scripts/loc-budget.json
follows the 11 lines added to built.rs.

Not covered: `rb_bundle_fetch` in a `WORKSPACE` file, a project below
the Bazel root, a gem locked as platform gems and a lock of a Bundler
older than 2.6 are declined. Not run: Windows, releases of rules_ruby
other than 1.0.0-rc2, and a Bundler other than 4.0.15 and 2.6.9 inside
the hub. A gem that the Gemfile does not declare was built by hand on
Bazel 9.3.2; no test here builds one. A release that the environment of
a machine names in place of the checkout's is not seen. Measured by
hand on Bazel 9.3.2 and stated in the docs, with no test here: an
output base that fetched a damaged gem keeps failing after `repair`
until it fetches the hub again, and a hub that Bazel does not fetch
again (pinned in a vendor directory, or built with `--nofetch`) keeps
the gems it has.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The pull request this one is stacked on gained a commit (a requirements
file a hub names counts for the files its `-r` includes reach; a doubt has
the hub's other file read too). Two conflicts, both additions side by side:
`bazel/built.rs` keeps this branch's `hub_calls` and that commit's
`includes_one`, and the `bazel` line budget is the count of the merged
tree, 2622.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- The gate did not look at the rc files of the checkout. A `.bazelrc`, or
  a file it imports, that names `--experimental_remote_downloader` (a
  remote downloader is handed the URL in the place of Bazel's own),
  `--repository_disable_download` or `--vendor_dir` (a hub pinned in a
  vendor directory keeps the gems it has) now declines the gem, and so
  does an rc file that cannot be read. None of the three was built.
- A directory that git ignores was refused only after the download and
  after a dry run had returned, so a dry run showed a gem the run then
  refused. The check now comes first, dry run or not.
- An undo treated a pair of which one file had been put back by hand (a
  `git checkout` of the lock, a merge that took the other side) as
  drifted for good: every `vendor --revert`, `rollback` and `remove`
  warned and left the other file and the gem. A file that names the source
  nowhere has been put back already, and the other now goes back by
  itself. A file that still names it and no longer holds what the run
  wrote leaves both alone, as before.
- A refusal of the planner was passed on with the way on it names for a
  hosted run. The decline now says whose way on that is.
- The closing `Next steps:` named the Bazel build only when every package
  of the run was such a gem, and compared a copy of the advisory's code. A
  run that vendored other packages too now adds a line for the Bazel
  build, and the code is the core's constant.
- The two wiring kinds of this form were not among the kinds whose file
  the ledger checks.

The real-Bazel flow builds the unpacked copy under
`--allow-vendored-in-bazel` again: the failing `bundle install` there is
what the decline is for, and the rewrite of the flow had dropped it.

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

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes vendoring and lockfile wiring in Bazel workspaces where builds depend on checksums and hub config; behavior is heavily gated but affects production Ruby/Bazel flows.

Overview
Vendored mode no longer always refuses Ruby gems when a workspace ruby.bundle_fetch hub reads the project's Gemfile / Gemfile.lock. Where checkout conditions show rules_ruby can build from a relative file: source, it now commits the patched .gem under .socket/vendor/gem/<uuid>/, rewrites the pair like hosted mode but with source: "file:.socket/vendor/gem/<uuid>/" and a matching CHECKSUMS line, and advises that only Bazel reliably installs those gems.

Refusal logic in vendor/bazel_hub.rs delegates to a new vendor/gem/bazel gate: missing/unsupported Bazel pin, non-root project, WORKSPACE repos, unreadable module files, Bundler version, platform gems, gem_checksums mismatches, and similar cases still yield vendor_gem_bazel_hub. --allow-vendored-in-bazel unchanged—path-based vendoring when the user opts in.

CLI / ledger: new events vendor_gem_bazel_file_source and vendor_gem_bazel_checksum_left; vendor next-steps prefer a Bazel build when only hub-archive gems were applied; verify/repair/redownload/vex discovery treat archive-shaped gem artifacts.

Tests & CI: e2e_bazel_build/ruby.rs expanded (file_source_by_hand, updated vendored_bundle_fetch, hermetic decline matrices); workflow paths include vendor/gem/**; docs and CLI_CONTRACT.md updated.

Reviewed by Cursor Bugbot for commit dd2651e. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit dd2651e. Configure here.

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

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does. Where a rules_ruby ruby.bundle_fetch hub reads the project's Gemfile / Gemfile.lock, vendored mode now commits the patched .gem under .socket/vendor/gem/<uuid>/gems/ and points both files at it with a relative file: source, in the same form as a hosted pin. It does this only when the checkout shows that form builds: a pinned Bazel 7–9 other than 9.1.0, Bundler 2.6+ or 4, the project at the workspace root, and a CHECKSUMS line or gem_checksums entry that holds the gem to its bytes. In every other case it declines as before. Revert, rollback and remove undo both files.

Risk: high. It adds about 785 lines of new code that writes users' Gemfile and Gemfile.lock. It relies on Bazel opening a relative file: URL from the workspace root, which Bazel doesn't document. After the change, plain bundle install no longer installs that gem; the run warns about this. Outside a Bazel workspace, or where no hub reads the project's files, nothing changes.

Look here

  • gem/bazel.rs:152: the gate (which hubs, which Bundler, which Bazel). Bazel versions are at L280 and the byte-pinning rule is at L304.
  • gem/bazel.rs:515: vendor. It writes the archive, then the Gemfile, then the lock, and undoes the earlier writes if a later one fails.
  • gem/bazel.rs:850: unwire_lock puts the lock entry, the DEPENDENCIES pin and the CHECKSUMS line back. A lock that has drifted is left alone.
  • gem.rs:998: where the gem backend hands off to the new lane.
  • commands/vendor.rs:4768: the next-step text ("Build with Bazel") in the CLI.

Verified. I read the new module's non-test code: the uuid directory goes through vendor_uuid_dir_rel, CRLF locks are edited in LF form and written back with their line endings, and the CLI change only alters a printed line. Locally, cargo test -p socket-patch-core --lib vendor::gem passes (207 tests). CI on dd2651e: 107 checks pass, 0 fail (92 skipped), including ci-ok, clippy and the Windows legs. Both Bugbot threads are resolved. CHANGELOG.md is not touched.

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] Reviewed the stacked diff against #2208, including the loaded Gemfile pair, checksum gate, archive verification and undo. This approval covers the gem archive change. The finding on the parent PR still applies to the stack.

…b on real Bazel

Tests only. rules_csharp's `nuget.from_lock` downloads every package of
`packages.lock.json` from the package sources of `nuget.config` and holds
each file to the lock's `contentHash`. The real-Bazel NuGet flows ran
hosted mode in that workspace, and vendored mode in none.

nuget::vendored_from_lock records what vendored mode does there today, on
the machine that restored the project:

- `scan --mode vendored --yes` exits 0 with status `success` and reports
  the package vendored. It downloads the patched package from the patch
  service once and keeps it at
  `.socket/vendor/nuget/<uuid>/<id>.<version>.nupkg`, names that folder
  as a package source in `nuget.config`
  (`<add key="socket-patch-<uuid>" value=".socket/vendor/nuget/<uuid>" />`,
  with a source mapping) and re-pins the lock to the patched package.
  `vex` attests the package.
- The next `bazel build` fails. NuGet takes a folder as a package source;
  the hub reads the same line as the URL of a feed. Bazel 9.3.2 crashes in
  the module extension (exit 37, "NullPointerException thrown during
  Starlark evaluation"); Bazel 8.8.2 and 7.7.2 refuse the URL ("Bad URL:
  .socket/vendor/nuget/<uuid>"). Bazel asks no host for the package and
  changes no file.
- `vendor --revert` puts every file back, and the build with them.

The flow records a defect: a command that exits 0 leaves a build broken.
It is here so that the change which removes the defect shows as a change
of this test's expectations.

The grant names the patched package by its URL on the patch host, and
vendored mode downloads it itself, so the flow passes `--patch-server-url`
with the loopback stand-in, which serves the package under the path of
that URL. No build and no command reaches nuget.org or a Socket host.

Run on Bazel 9.3.2, 8.8.2 and 7.7.2 on macOS arm64: the flow passes on
each, in about ten seconds. The workflow's comments name the flow.

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

Vendored mode commits the patched package under
`.socket/vendor/nuget/<uuid>/`, names that folder as a package source in
`nuget.config` and re-pins the lock. NuGet takes a folder as a source.
rules_csharp's `nuget.from_lock` reads the same line as the URL of a feed:
after `scan --mode vendored` had exited 0 and reported the package
vendored, the next `bazel build` crashed Bazel 9.3.2 in the module
extension (exit 37) and failed on 8.8.2 and 7.7.2 with `Bad URL:
.socket/vendor/nuget/...`. That is the flow of the previous commit.

What the hub does take

A feed `file:<folder>`, which Bazel reads from the root of the workspace,
with the package at `<folder>/<id>/<version>/<id>.<version>.nupkg`; and
the last `nuget.from_lock` that has `feeds` decides the hub's sources
(`_nuget_impl` in csharp/extensions.bzl at 0.5.0). So in the root of a
Bazel workspace whose one `nuget.from_lock` reads the project's lock,
`scan --mode vendored`, `get --mode vendored` and `vendor` now write:

- the package at
  `.socket/vendor/nuget/<uuid>/<idLower>/<version>/<idLower>.<version>.nupkg`,
  the one copy;
- `nuget.config` with that directory as the source, so `dotnet restore`
  outside Bazel takes the same file, and the lock as before;
- one block at the end of the root `MODULE.bazel`, after one blank line:

      # >>> socket-patch: NuGet patches for Bazel (managed block: socket-patch writes and removes it) >>>
      socket_patch_nuget = use_extension("@rules_csharp//csharp:extensions.bzl", "nuget")
      socket_patch_nuget.from_lock(
          feeds = [
              "file:.socket/vendor/nuget/<uuid>",
              "https://api.nuget.org/v3/index.json",
          ],
          packages_lock_json = "//:packages.lock.json",
      )
      # <<< socket-patch <<<

  A second tag of the same hub, after every tag of the user's: the folder
  of each vendored patch, then the sources the hub had without the block
  (those of the tag's `nuget_config`, read line by line as the ruleset
  reads them, or else its `feeds`), with the label of the user's
  `use_extension`, their `packages_lock_json`, and the hub's `name` where
  the tag gives one. No call of the user's is edited.

On Bazel 9.3.2, 8.8.2 and 7.7.2 with rules_csharp 0.5.0 the build then
prints the patched marker and asks no host for the package, also with the
stand-in stopped, a new output base and the package in no repository
cache. One changed byte of the committed package fails the build
("Checksum was ... but wanted ...") and `vendor --check`. `bazel query
//...` lists what it listed. `vendor --check`, `list` and `vex` see the
package as any vendored NuGet package, and a later vendored run keeps the
block in step with the tag (a source added to `nuget.config` reaches it).

The undo

`vendor --revert`, `rollback` and `remove` take the folder of a patch out
of the block, and the block goes with its last folder: `MODULE.bazel` is
then byte for byte what it was. With one vendored patch every other file
is too. With several, `nuget.config` can keep the source mapping that the
first of them created: once another patch has changed the file, the
config revert takes out only the two elements of its own patch, as it
does without Bazel.

A block that was changed by hand cannot be taken out. Reverting the lock
and the config beside it would leave the hub holding the committed
package to the upstream `contentHash`, and the build would fail after an
undo that exited 0. So the undo checks the block before its first write
and fails with nothing changed (`revert_failed` from `vendor --revert`,
`vendor_revert_failed` from `rollback` and `remove`, exit 1). The message
names the line of the block and the two ways on: put the block back as
socket-patch wrote it, or delete it, and run the command again.

Where it declines

The block is written only where the checkout shows that it works.
Otherwise the package is refused with `vendor_nuget_bazel_workspace`
through `vendor::refusals::bazel_workspace_refusals`, the dispatch that
Composer's refusal uses: before any download, a `failed` event, exit 1; a
dry run of `scan` or `get` lists it and exits 0; a hosted pin stays, and
its eject says `kept hosted: ...`. The detail names the reason, with file
and line where there is one, and `--mode hosted`. The reasons:

- the project is below the root of its workspace, or another workspace
  lies above it in the checkout (built from there, Bazel reads the folder
  from the other root);
- more than one `nuget.from_lock`, or tags that cannot be read with
  certainty; a tag that is not a call of its own with every argument
  written out, or on an isolated or dev-dependency `use_extension`;
- `local_package_dirs`, which the hub asks before every feed, and
  `netrc` or `auth_patterns`, which the block was not built with;
- a `nuget_config` that cannot be read, a source that cannot stand in a
  string;
- `feeds` beside a `nuget_config` that has no package source. The run
  names its folder in that file (and nuget.org, where NuGet had it by
  default), rules_csharp takes the sources of a `nuget_config` in place
  of `feeds`, and so would the next run: it would write the block
  without the tag's feeds, and a package that only they hold would fail
  the build after a run that exited 0. Hosted mode withholds in the same
  shape, with the same way on: name the feeds in the file;
- `MODULE.bazel.lock` does not show that Bazel selected rules_csharp
  0.5.0;
- the checkout does not name Bazel 9.3.2, 8.8.2 or 7.7.2 (`.bazelversion`,
  `.bazeliskrc`). The block rests on Bazel reading a relative `file:` URL
  from the root of the workspace, which Bazel does not document, and
  9.1.0 has other code for such a URL than 9.0.2 and 9.1.1
  (DownloadManager.java), so no release is taken for its neighbour's
  sake;
- an rc file names `--repository_disable_download` or `--vendor_dir`, or
  a directory at the root holds `VENDOR.bazel`;
- an rc file names a remote downloader
  (`--experimental_remote_downloader`), which takes no `file:` feed. Read
  in Bazel's source and not built: 7.7.2 hands the feed to the
  downloader, which cannot read the folder, and 8.8.2 and 9.3.2 download
  every package of the lock without it
  (GrpcRemoteDownloader.java);
- `MODULE.bazel` is a symbolic link, or its block was changed by hand.

`--allow-vendored-in-bazel` (SOCKET_ALLOW_VENDORED_IN_BAZEL) lifts the
refusal, and the package is vendored as in a project without Bazel. The
help text, the contract and the docs said that Composer's was the one
refusal the switch lifts; they now name both. A package that is wired
already passes without the switch, as Composer's does.

Nothing changes for a NuGet project in no Bazel workspace, and for one
whose locks no `nuget.from_lock` reads: the same files, byte for byte,
and no line of `MODULE.bazel`.

Hosted mode beside the block: the block's tag is the hub's last one, so
hosted mode writes nothing for another package of the project
(`redirect_bazel_nuget_config_undeclared`) and now says to vendor that
package too or to take the vendored ones out, instead of telling the user
to edit the block.

How

- bazel/nuget.rs: `vendored` reads the tags (without the block), the
  ruleset's release, the Bazel release and the rc files through the
  existing readers, and gives the block's contents or the reason;
  `with_folder` and `without_folder` edit the block.
- bazel/block.rs is new and holds what the Maven block and this one
  share, moved out of bazel/maven.rs: finding a block by its first line,
  putting one at the end of a file in the file's line break, cutting it
  out to the byte, and the file as it reads without it. `proxy` (the
  label of a `use_extension`), `asked` and the stale check of a ruleset's
  release are shared from maven.rs as they are.
- vendor/nuget_feed.rs decides the layout, writes the block after the
  lock, records it in the ledger (`nuget_bazel_feed`, which may name the
  root `MODULE.bazel` alone) and reverts it; a failed block write unwinds
  the config and the locks, and a revert asks the block before it writes.
- vex/discover/nuget.rs and vendor/path.rs read the package below
  `<idLower>/<version>` as well.

Limits, all in docs/ecosystems.md "Bazel workspaces: NuGet": the block
works in the root module only; a module this one depends on with its own
`nuget.from_lock` sources replaces the block's feeds; `--nofetch`, in an
rc file or on a command line, and a vendor directory made before the
patch, can build the unpatched package with exit 0; a machine whose
repository cache holds the package under the sha256 of Bazel's lock
builds the cached, patched file and does not read a changed or missing
copy, which `vendor --check` catches; a checkout deleted and made again
under a running Bazel server does not find the package until the server
restarts; a frozen lock fails right after the run, as in hosted mode;
three WARNING lines per other package and vendored patch when the
extension runs. An earlier release does not know the layout or the
block: on a checkout this one vendored its `vendor --check` fails, its
vendored run writes a second copy, and its `vendor --revert` exits 0 and
leaves the block and the package beside the restored lock, so the Bazel
build fails (measured on 9.3.2); undo with the release that vendored.
Built on macOS arm64, with packages that carry no signature.

"Bazel workspaces: what is supported" in the same file follows: the
NuGet row of its table says vendored mode is supported with the Bazel
release in `.bazelversion`, and VEX with a vendored patch as well; the
list of what was tested names the shape; NuGet leaves the known problem
"vendored mode ... the next Bazel build fails" for an entry of its own
(the switch, a package an earlier release vendored, and the two shapes
the checkout does not show); the build that may not fetch is listed
among those that pass on the unpatched package; and "Bazel workspaces:
VEX" names the vendored flow and the cases in which the document says
`not_affected` of a package whose block is not in `MODULE.bazel`.

Tests: nuget::vendored_from_lock now holds the flow above on real Bazel,
with one decline (a checkout that names no release: nothing written, the
build still passes on the upstream package) and the document of `vex`,
which names the package.
nuget::vendored_mode_keeps_the_block_or_declines runs the commands
through the binary without Bazel: the unchanged layout without a hub,
the block and its three undos, the three undos beside a block that was
changed by hand (exit 1, no file changed, then the undo once the block is
deleted), the declines, the eject and the switch.
Unit tests cover the gate row by row, the block's text and its byte-exact
undo, the ledger record, the revert beside a changed block wherever its
record stands, and the path git is asked about for a hub's package. The
`bazel` group of the line budget follows the code, 3337 to 3758.

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

- crates/socket-patch-core/src/bazel/maven.rs, the imports: main's
  `build_maven_purl` is kept; the line-ending helper is no longer
  imported there, because this branch moved the code of the managed
  block, its only user outside the tests, into bazel/block.rs.
- scripts/loc-budget.json: the cap of the `bazel` group is the count of
  the merged tree, 4036.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…atch and a second run

Four defects of vendored mode for a NuGet package of a rules_csharp hub,
each with a unit test.

An undo that leaves `nuget.config` wired took the block out. When the
config was written anew since the vendored run and still names the folder,
the undo keeps the config, the lock pin and the package
(`vendor_lock_entry_drifted`). The block went first all the same, so the
hub read the folder in `nuget.config` as the URL of a feed and the Bazel
build failed on a package that built before the undo. The block now goes
last, after the lock and the config, and stays where the config is left
wired. A lock that cannot be restored leaves the block too, so the build
is as it was for the retry.

A later patch of the same package left the earlier patch's folder in the
block. The config keeps the earlier patch's source with its pattern set
aside; the folder that source names is now taken out of the block when the
later patch is written into it, so the block names the later folder alone
and goes with it on the undo.

The first run for a tag whose `nuget_config` has no package source wrote
a block without nuget.org, and the second run added it: the run gives such
a config nuget.org beside the folder, and the block was read before that.
The block is now read from the tag after the config is written, so a
second run writes no file.

A lock that spells the package's version otherwise than NuGet writes it
(`1.2.3.0` for `1.2.3`) was vendored, and the hub did not find the
package: rules_csharp 0.5.0 asks a feed for the lock's `resolved` as it is
written. Such a package is declined with `vendor_nuget_bazel_workspace`,
by the backend and by the refusal every way in asks first.

The refusal looked for the project's locks before it knew that the project
is in a Bazel workspace; it asks for the workspace first.

Also: one function for the folder of a hub's package in place of the two
places of the backend that wrote it out, and the real-Bazel NuGet legs
start on a push to main that changes the ledger or the artifact paths of
vendored mode (vendor/state.rs, vendor/path.rs), which hold the record of
the block and the place of a hub's package.

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>
The tests of a package of a rules_csharp hub start from a `nuget.config`
that names nuget.org, through a helper of the test module that was held
to Unix for the file-mode tests it was written for. The hub tests are not
held to Unix, so the test build of the core crate failed on Windows
(`cannot find function preexisting_cfg`). The helper is a string and now
builds everywhere. Test only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ndored/gem-file-source

This brings main in, through the two merges of the declines' branch. Four
files conflicted. The RubyGems tests of e2e_bazel_build keep every test of
this branch, of that branch and of main, with one `Served`, one `run`, one
`squeezed` and the two checkouts of that merge. patch/redirect/mod.rs keeps
`plan_gem_source` beside main's `gem_pair`. docs/ecosystems.md keeps the
entries of both sides: main's cell and sentences on hosted mode beside a
`gem_checksums`, this branch's on vendored mode. The `bazel` cap of
scripts/loc-budget.json is the count of the merged tree, 3869.

Outside the conflicts, the two `DepOverride` values that vendor/gem/bazel.rs
builds name the `npm_registry_url` main added to that type.

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>
…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 conflicts with the vendored Maven hub (#2207): keep both the
uncache and cached harness helpers, keep with_patch on the shared block
module and make it public as main needs, dispatch the Maven hub refusals
next to the Composer and NuGet ones, and raise the bazel line budget by
both sides' growth.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: updated review brief (new commits since the brief for dd2651ed8)

What it does
The PR's own change is the same as in the earlier brief. Since then the head has gained:

  • a merge of bazel-guard/vendored-hub-locks, which only brings in main;
  • two commits that make the real-Bazel vendored Cargo test accept @platforms as well as @crates__... as the repository Bazel can't see.

Those two commits are line for line the change in #2227, which is reviewed there.

Risk
Low for the new commits: test code and one docs sentence. The risk of the PR's own change is unchanged.

Look here

Verified

Open questions
The PR is approved, but it is stacked on #2208, which carries agent:needs-human. Auto-merge stays off until #2208 lands and this PR is retargeted to main.


Generated by Claude Code

…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>
…ndored/gem-file-source

This brings main in, through the merge of the declines' branch. Two files
conflicted. The docs of vendor/refusals.rs keep this branch's words on a
gem that is committed for the hub and main's item on a Maven jar that only
a rules_jvm_external hub builds; the one dispatch of
`bazel_workspace_refusals` is the merged one of that branch. The `bazel`
cap of scripts/loc-budget.json is the count of the merged tree, 4053.

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

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] Re-reviewed the commits since the last approval; no major findings.

Claude (claude) and others added 10 commits November 25, 2026 16:39
Main added an agent-mode NuGet flow and VEX attestation for Bazel hubs
(#2224); this branch adds vendored mode for NuGet. Both are kept:

- bazel-nuget.yml: the path lists are the union of both sides; the
  comments describe the agent, VEX and vendored flows together.
- e2e_bazel_build/nuget.rs: vendored_from_lock and agent_from_lock both
  stay, with their helpers.
- docs/ecosystems.md: the NuGet row keeps this branch's vendored column
  and main's VEX column; the VEX paragraph keeps both additions; the
  vendored-NuGet caveat keeps this branch's text, since vendored mode now
  builds with the block in MODULE.bazel.
- loc-budget.json: bazel group at the merged count, 4432 (+426 here,
  +89 on main).

Assisted-by: Claude Code:claude-opus-5-5
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>
Main gained "Keep the Bazel support from changing a project that Bazel
does not build" (#2228): the off switch `SOCKET_NO_BAZEL`, a doubt of the
workspace reader about a file that is there and was not read as a whole
(`Workspace::unread`), the Composer refusal by section of the lock, and
the "Experimental" marks of the CLI contract.

Five files had conflicts. Each is resolved by keeping both sides:

- `bazel/mod.rs`: main's switch (`OFF_ENV`, `off`, `root_of`) and this
  branch's `mod block`, `root_above` and `roots_in` stand together.
  `bazel_root` is main's, so the switch holds for the NuGet gate as for
  every other caller; `root_in` keeps this branch's body over `roots_in`
  and takes main's doc line. `root_above` is asked only after
  `bazel_root` found a workspace, so it does not ask the switch itself.
- `vendor/refusals.rs`: one sentence of the module docs. It lists the
  Composer and the NuGet refusal, as this branch has it, and says of
  Composer's what main now says (a vendored copy in `packages` or in the
  package's section lets a package through).
- `CLI_CONTRACT.md`: the row of `--allow-vendored-in-bazel` and the row
  of its variable carry main's "Experimental" mark and name both
  refusals; the row of the flag has main's sentence on when a Composer
  package meets its refusal. The Composer code row is main's. The NuGet
  code row is this branch's, with the same mark, and names
  `SOCKET_NO_BAZEL=1` beside the flag among the runs that are not
  refused, as main's Composer row does.
- `docs/ecosystems.md`: the list of known problems keeps this branch's
  entry on vendored NuGet and takes main's new wording of the entry on a
  hosted Cargo pin.
- `scripts/loc-budget.json`: the cap of `bazel` is the count of the
  merged tree, 4468 (4432 here, and 36 lines more on main).

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>
…r a hub

Two changes of main say something of every package that a Bazel hub
builds, and were written before vendored mode kept a block for a
rules_csharp hub. The merges took both as they are. This brings their
statements in line with the block and tests what they do beside it. No
product code changes.

The VEX answer for a hub that builds from the lock. Three places said
that no test builds a vendored NuGet package under its hub, so nothing
is said of one: the paragraph on vendored copies in "Bazel workspaces:
VEX", the `vex_bazel_not_in_build` row of the CLI contract, and two
comments of `bazel/built.rs`. A flow does build one now, through the
block. They say that, and that `vex` does not read the block, so the
statement is the same where the block is missing and the build fails
(the list of documents that are still wrong has that entry, and now says
why that build fails).
`nuget::vendored_mode_keeps_the_block_or_declines` asks `vex` after the
vendored run in the hub's checkout, on a machine that restored nothing:
one `not_affected` statement through the committed copy, and no warning.

The switch for a project that Bazel does not build (`SOCKET_NO_BAZEL`).
It holds for the NuGet gate through `bazel_root`, and the undo of the
block never asked for the workspace. The same flow holds both: with the
switch a vendored scan is the scan of the same checkout without its
Bazel files, to the byte, where the block would be written and where the
package would be declined; and `vendor --revert` with the switch set
takes the folder out of the block and leaves every file as it was. The
docs section on a project that Bazel does not build and the section on
experimental Bazel support of the CLI contract name the NuGet block and
its refusal among what the switch turns off, and the undo of the block
among what stays on.

The module docs of the NuGet flows name the three modes they run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ndored/gem-file-source

This brings in main and, from the declines' branch, the rule that a
`WORKSPACE` file does not count where the checkout names a Bazel release
of 9 or later.

The gate of a gem that is committed for a hub (vendor/gem/bazel.rs) had
its own "a `WORKSPACE` file defines repositories" and now reads the
workspace as the two refusals do (`built::workspace_as_built`). So the
gate holds beside such a file under a named Bazel 9, and still declines
under an older release, `latest` or none. Its two rows that held the
decline under `.bazelversion` 9.3.2 (the unit row and the row of
e2e_bazel_build/ruby.rs) now name 7.7.2, and a new row of each holds that
under 9.3.2 the gem is committed for the hub.

Five files conflicted. bazel/built.rs and vendor/refusals.rs keep the
words of both sides on a vendored gem. CLI_CONTRACT.md and
docs/ecosystems.md keep the rows and entries of both sides: main's marks,
codes and NuGet entries, this branch's on a gem committed as its archive.
The `bazel` cap of scripts/loc-budget.json is the count of the merged
tree, 4200.

Outside the conflicts: `built::hub_calls` goes through every extension of
a hub, as main's hubs now have a list of them; the section of the docs on
the gem committed for a hub carries main's line on experimental support
and says when a `WORKSPACE` file counts, as does the contract row.

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

For a NuGet package of a rules_csharp hub, vendored mode keeps a block in
the root `MODULE.bazel`, or declines the package where it cannot show
that the block works. Where it found no `nuget.from_lock` that reads a
lock of the project, it vendored the package as without Bazel, in the
folder of the patch alone. In two cases a hub reads the lock all the
same. The package is then in none of its feeds: the next Bazel build
fetches the upstream package and fails on the `contentHash` that the run
re-pinned, after a command that exited 0.

- The tag may be hidden. A `MODULE.bazel` that cannot be read (a link
  that leads out of the workspace, a file over the reader's 1 MiB) read
  as an empty file, and what the reader could not read was asked only
  once a tag was found. Where no tag is found, the package is now
  declined when a file of the workspace that is there was not read as a
  whole (`Workspace::unread`), since it may be the one that names the
  ruleset, and when the reader has any doubt in a workspace that names
  rules_csharp. A doubt in a workspace of other rulesets whose files
  were all read is about no hub, as it is for a Maven hub since #2228:
  a project there that Bazel does not build keeps its vendored run.
- The tag is gone and the block is still there. The reader does not see
  the block, so it found no tag, and a second package was written
  outside the block that still hands the lock to the hub. The package
  is now declined when the block's own `packages_lock_json` names a
  lock of the project. A block for the lock of another project of the
  workspace changes nothing for this one.

Both are the refusal this gate already has,
`vendor_nuget_bazel_workspace`: exit 1, nothing asked of the patch
service and nothing written, a dry run of `scan` and `get` lists the
package, `--allow-vendored-in-bazel` and `SOCKET_NO_BAZEL` lift it, and
a package that is already wired for the hub stays as it is, with the
reason as a warning. The reason names what could not be read, in the
words the gate has for a doubt beside a tag, or the line of the block
and the two ways on: put the tag back, or `socket-patch vendor
--revert`.

In the code, `reads` shares the lock a label names with the check of
the block (`named`), the words for a doubt are one function (`unsure`),
and `bazel/maven.rs` shares its test for a workspace that names a
ruleset (`names`). The cap of `bazel` in the line budget follows:
4468 to 4496.

Tests, each of which fails without the change it holds:

- `bazel/nuget.rs`: the gate over files in memory (a doubt in a
  workspace of the ruleset, the same doubt where nothing names it, a file
  that is there and is not read, the root file itself), and `vendored`
  on disk (the block without its tag, the same block for a project below
  the root, a `MODULE.bazel` over 1 MiB, and on Unix one that links out
  of the workspace).
- `vendor/nuget_feed.rs`: after a vendored run, with the tag taken out,
  a later patch is refused with nothing written, by the backend and by
  the dispatch that every way in asks first, and the wired package keeps
  its files and gets the warning.
- `nuget::vendored_mode_keeps_the_block_or_declines`, through the
  binary: both shapes are declined by `scan` and `get`, listed by a dry
  run and told to a person; with the flag and with its variable they are
  vendored as without Bazel; and with `SOCKET_NO_BAZEL=1` the run is the
  one of the same checkout without its Bazel files, to the byte.

One expectation of this branch changes. The test of a project whose
lock no tag reads held a workspace of rules_csharp with a use of the
extension's proxy that is no call of a tag to the run without Bazel. It
is declined now, and the row moved to the new test of the gate. The
docs section "Vendored mode under a rules_csharp hub", the entry of the
section on a project that Bazel does not build and the contract row of
the refusal say the same.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main gained "Name each patched package as a VEX product so Trivy and
Grype match it" (#2243). No file has a conflict.

That change is to the VEX document and to the test harness that reads
one, which the NuGet flows of this branch go through where they hold
`vex` to a vendored package. They pass on the merged tree:
`nuget::vendored_mode_keeps_the_block_or_declines` finds the vendored
package as a product of its own in the document, beside the project.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`vendor_gem_bazel_file_source` and `vendor_gem_bazel_checksum_left` are
codes that only a Bazel workspace can produce. They join the list of the
"Bazel workspaces (experimental)" section and carry the mark in their
rows, as that section says every such code does.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The docs entry on a tag that may be hidden said that such a hub takes
the upstream package and fails on the re-pinned lock. That is one of two
ways. A hub whose tag names the project's `nuget.config` reads the
folder that vendored mode names there as the URL of a feed, and fails
on that, as measured for a flat vendored run under a hub on Bazel 9.3.2,
8.8.2 and 7.7.2. The entry names both. Docs only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Base automatically changed from bazel-guard/vendored-hub-locks to main November 25, 2026 18:58
…a NuGet hub

`bazel-guard/vendored-hub-locks` declines PyPI and RubyGems vendored
mode where a Bazel hub reads the lock, and passes over a `WORKSPACE`
file where the checkout names Bazel 9 or later. It lands on main before
this branch, so its conflicts with this branch are resolved here. Seven
files had conflicts, and each keeps what both sides say.

- `vendor/refusals.rs`: the one dispatch of the refusals that rest on a
  Bazel workspace asks every backend once, before any fetch: Composer's,
  the PyPI and RubyGems one of that branch (`bazel_hub::refusals`),
  NuGet's (`nuget_feed::bazel_refusals`) and Maven's. The module docs
  and the docs of the dispatch list them all, and the unit tests of both
  sides stand.
- `bazel/built.rs`: two comments on what a hub builds of a vendored copy.
  They say of rules_ruby what that branch measured (a vendored gem builds
  only where the call lists the copy among its `srcs`) and of
  rules_csharp what this branch built (through the block of vendored
  mode).
- `bazel/maven.rs`: the imports of both.
- `args.rs`: the help text of `--allow-vendored-in-bazel` names the
  three kinds of refusal the flag lifts.
- `CLI_CONTRACT.md`: the row of the flag, the list of experimental codes
  and the list of what `SOCKET_NO_BAZEL` turns off name the refusals of
  both sides; the table of vendored artifacts has that branch's PyPI row
  and this branch's NuGet row; both new code rows stand. The row of
  `vex_bazel_not_in_build` had no marker and said that no test builds a
  vendored gem under its hub: it now says what that branch measured.
- `docs/ecosystems.md`: the known problem "Vendored mode for PyPI,
  RubyGems and NuGet" is gone. That branch took PyPI and RubyGems out of
  it, since vendored mode declines them now, and this branch took NuGet
  out, which has an entry of its own for the cases its refusal does not
  see. The list of what the Bazel support does for a project, the
  sentence on the switch in the Composer section, the paragraph on
  vendored copies in the VEX section and the list of documents that are
  still wrong each hold the entry of both.
- `scripts/loc-budget.json`: the cap of the `bazel` group is 5300, the
  one value every open change of this series sets, so that they stop
  conflicting on that line; the count of this tree is 4638.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main gained the PyPI and RubyGems vendored refusals (#2208) and the
reason of a failed apply in its telemetry and `--json` events (#2247).

#2208 is the squash of the branch that the merge before this one
brought in. Main's tree is that branch merged with #2247, so the seven
files that conflicted there conflict here again, with the same two
sides: `vendor/refusals.rs`, `bazel/built.rs`, `bazel/maven.rs`,
`args.rs`, `CLI_CONTRACT.md`, `docs/ecosystems.md` and
`scripts/loc-budget.json`. Each is what the merge before this one made
of it, and #2247 touches none of them. So this tree is the last one with
#2247 added and nothing else: 16 files, none of which this branch
changes.

The cap of the `bazel` group in `scripts/loc-budget.json` stays 5300,
the one value every open change of this series sets so that they stop
conflicting on that line; the count of this tree is 4638.

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

With the switch set, the undo of a gem that an earlier run committed for
a rules_ruby hub put every file back, but did not say that the
`gem_checksums` of a call still hold the gem to the patched one
(`vendor_gem_bazel_checksum_left`): the warning looked the Bazel root up
through the lookup that the switch turns off. It now reads the workspace
whatever the switch says, as the undo of the `.bazelignore` lines does.

Two tests through the CLI. With the variable, vendored mode in the
checkout where a gem is committed for the hub is the run of the same
checkout without its `MODULE.bazel`, to the byte. And a gem committed
without the variable is listed, checked and undone with it, by
`vendor --revert`, `rollback` and `remove`, with the codes that the undo
names without the variable.

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

main holds the base of this branch as one squashed commit, so every
conflict was of that base's lines against this branch's later edits of
them, and each resolves to this branch's text. What main has beyond the
base (each patched package as a VEX product of its own, and the reason
of a failed apply) merges in by itself, into the contract and the docs
as well.

The `bazel` cap of scripts/loc-budget.json is 5300 from here on, the
same value in every remaining branch of this series, so that they no
longer conflict on that line; the count here is 4200.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main now passes over a `WORKSPACE` file where the checkout names Bazel 9
or later: Bazel reads none there, so the file is no reader of a lock and
no doubt (#2208). The gate of vendored mode for a rules_csharp hub never
counted that file on any release. rules_csharp has no form for it, the
tags are read from the module files alone, and the reader keeps what it
makes of a `WORKSPACE` file apart from its doubts and from the file it
names as not read (`Workspace::legacy`), which the gate does not ask.

The test of a tag that may be hidden holds that now. A `WORKSPACE` file
that cannot be read, and one that defines something, decline nothing
where no tag is found and leave the block as it is beside a tag, in a
checkout that names Bazel 9.3.2 and in one that names 7.7.2. Test only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main brought the pnpm route under a rules_js hub. One conflict, in the
contract: both sides add to the same sentences of the section on Bazel
workspaces (the experimental list, the off switch, what stays on). Each
keeps the words of both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main brought the VEX answer for a Maven patch beside a pinned hub. Two
conflicts. In the Maven hub reader, main's `proxy` now says whether a
usage is isolated for certain; this branch had opened it to the NuGet
reader: it is main's function, visible to that reader, which takes a
usage that is not shared as it did. In the contract both sides add to the
same sentences of the section on Bazel workspaces: each keeps the words
of both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… into bazel-vendored/gem-file-source

This takes in the change that lands before this one, vendored mode for
a NuGet package of a rules_csharp hub, and with it main as that branch
holds it. Both sides are kept where they met:

- The help of `--allow-vendored-in-bazel`, the module comment of
  vendor/refusals.rs and two comments of bazel/built.rs name the NuGet
  refusal and its block beside the gem committed for a hub.
- In CLI_CONTRACT.md the flag's row, the list of experimental codes,
  the sentences of the off switch and of what stays on with it, and the
  row of `vex_bazel_not_in_build` carry the clauses of both.
- In docs/ecosystems.md the entries that each side added to the same
  lists stand side by side, and the two VEX passages say of a gem what
  this branch says and of a NuGet package what the other one does.

The `bazel` cap of scripts/loc-budget.json stays 5300; the count here
is 4936.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main is now the NuGet vendored change as one commit, whose tree is the
tree of the branch head this branch merged in its last commit
(3599739). So this merge changes no file: it records main as merged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Merged via the queue into main with commit 9a2a946 Nov 25, 2026
119 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the bazel-vendored/gem-file-source branch November 25, 2026 20:41
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