Skip to content

Vendor a PyPI wheel as a download cache of Bazel where a hub reads the requirements - #2212

Merged
Mikola Lysenko (mikolalysenko) merged 59 commits into
mainfrom
bazel-vendored/pypi-download-cache
Nov 25, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 59 commits into
mainfrom
bazel-vendored/pypi-download-cache

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

Vendored mode now works for a PyPI package whose requirements.txt a rules_python pip.parse hub of a Bazel workspace reads: it commits the patched wheel as a download cache that the Bazel build takes, where the checkout shows that this works (rules_python 2.5.0, Bazel 7 to 9), and declines with the reason everywhere else.

Stacked on #2208, the pull request that makes vendored mode decline such a package: this one's base is that pull request's branch, merged in at its current head. Only the commits after it are this change.

Decisions for the maintainer

  1. socket-patch writes .bazelrc, which it has never done. One pair of lines per patch at the Bazel root: a comment line of socket-patch's own and common --distdir=<directory from the Bazel root>. They are kept the way the .bazelignore lines for Go copies are, by the same code: added at the end, removed with the directory so that the file is byte for byte the one of before, never written through a link, and declined for good by commenting the line out. A .bazelrc left empty is removed, also when it was an empty file of yours, as with .bazelignore.
    The alternative was measured by hand and not built: a block at the end of the root MODULE.bazel that puts a repository over the committed wheel in the place of the hub's (http_file with a relative file: URL and the sha256, rules_python's whl_archive, override_repo). It fails the build on a changed copy even when the patch host is reachable, and it works behind a downloader config that blocks every host. Against it: it names a private rule of rules_python, so it needs a table per release; it needs a bazel_dep on package_metadata; Bazel drops it under --ignore_dev_dependency and when the checkout is not the root module; and it replaces the hub's repository without what the hub passes to it, so a user's own pip.override patch of the wheel is dropped without a message (measured on Bazel 9.3.2).
  2. The line of requirements.txt is the hosted line. That is what makes rules_python build it, and it brings the limits below: pip outside Bazel needs the patch host, Bazel replaces a bad copy from the patch host without saying so, a relock leaves a green unpatched build, and vendor --check is the only thing that holds the committed wheel to the patch.
  3. The gate is narrow. rules_python 2.5.0-rc4 and 2.5.0 only (one commit), read from MODULE.bazel.lock. A checkout without that lock is declined with "build once". Every later rules_python release needs a build and one more entry in the list. An rc file that imports an absolute path and a read-only .bazelrc decline too.
  4. Lockfile discovery reads the vendor ledger in this one case. The line looks like a hosted pin, so discovery reads it as one; where a ledger entry of this form wrote the line, discovery makes it the vendored reference of that entry. Without this, list, rollback, a bare scan and the takeover logic would see a hosted pin beside a vendored entry. Everywhere else discovery still decides from lock files alone.
  5. --allow-vendored-in-bazel keeps its meaning. It says that no build takes the project's packages from the hub, so the path line is written, also where the cache form would be.
  6. Size. About 650 lines of implementation code, above the 300 to 500 estimated for this wiring. The bazel line budget is 2865, the count of this tree.

What the code does today

Where a pip.parse reads a requirements file that vendored mode would rewrite, vendored mode declines the package (vendor_pypi_bazel_hub, exit 1, nothing written): the path line it writes, ./.socket/vendor/pypi/<uuid>/<wheel>, makes rules_python fail the build of everything the hub serves. --allow-vendored-in-bazel lifts that and writes the path line.

What changes

Where it works. scan --mode vendored, get --mode vendored and vendor write three things:

  1. the package's line of requirements.txt exactly as hosted mode writes it, by hosted mode's own rewriter: <name> @ <URL of the wheel on the patch host> --hash=sha256:<hex>;

  2. the patched wheel, fetched once, at .socket/vendor/pypi/<uuid>/ under the file name its URL ends in, with its ledger entry;

  3. in the .bazelrc at the Bazel root:

    # socket-patch: the committed copy of a patched wheel, for Bazel's downloads (to opt out, comment out the next line)
    common --distdir=.socket/vendor/pypi/<uuid>
    

rules_python fetches a wheel that a requirement names by its URL with Bazel's downloader, by the sha256 of the line, and Bazel takes a file of that name and checksum from a --distdir before it asks a host. The path is relative because Bazel reads it from the workspace root and takes %workspace% in this option literally. Each patch gets a line for its own directory: a --distdir is flat and searched by file name, and two patches of one release have wheels of one name.

The form is written only where all of this can be read from the checkout:

  • the project pins in requirements.txt alone, with hashes, and the package's requirement is one exact pin (no extras, marker, option, comment or indent);
  • a pip.parse names that file by requirements_lock and names no other file of the project; every call of the hub is written out and runs, nothing of the module files is in doubt, and no WORKSPACE file defines repositories;
  • MODULE.bazel.lock says that Bazel selected rules_python 2.5.0-rc4 or 2.5.0, read the way the release of rules_jvm_external is read (one function now serves both; the messages of the Maven lane are unchanged);
  • the checkout names Bazel 7, 8 or 9, or names none and has a lock of version 13 to 28;
  • no rc file of the checkout names a downloader config, --repository_disable_download or a remote downloader, all of them can be read, and none imports an absolute path: that file is outside the checkout, it is not read, and it is where the settings of a site's mirror usually are;
  • .bazelrc is no symbolic link and not read-only, and the project's path holds nothing an rc line reads otherwise.

Where it declines. Everywhere else, with vendor_pypi_bazel_hub as before, nothing written and no wheel fetched. Where a pip.parse was read with certainty, the message now ends with the condition that failed. The question is asked again where the lock is about to be written, because a run that takes a hosted pin over first puts the registry's pin back; if that pin is one the form is not written for, the run declines under the same code and the hosted pin stays.

A hub that names a file which only brings the project's requirements.txt in with -r is declined: no build through such a file is shown to take a committed wheel. That holds for every call of the hub, whichever is written first. A requirement that names the package by a URL of the user's own is declined before anything is fetched (no scan finds a package in such a line; get for the release does).

A package that already is a download cache keeps passing while requirements.txt holds the line as the run wrote it. A line that has been changed since (a comment after it, its hash moved to a line of its own) declines the package before anything is fetched, and the committed wheel and its .bazelrc line stay: put the line back, or run socket-patch vendor --revert and vendor again.

Two refusals only the download can show: the URL the patch service served the wheel from is not one hosted mode would pin for this patch, or what it serves is not a wheel for every platform (-none-any.whl), which is the one kind the form was built with. Such a run fails as apply_failed with an error that starts vendor_pypi_bazel_hub:, as a wiring failure of every vendored backend is reported, and a wheel that an earlier run committed stays where it is.

The other commands. list shows a vendored package. vex attests it as vendored and not_affected. vendor --check verifies the committed wheel against the patch and that the line is still there. vendor --revert, rollback and remove restore requirements.txt and .bazelrc byte for byte and delete the directory, with no host. A later run writes nothing. A hosted scan takes the package over. A newer patch replaces line, wheel and pair.

Where nothing changes. Outside a Bazel workspace; in a workspace whose hubs read none of the project's files; for a package already vendored by a path; for RubyGems; in hosted and agent mode. A binary of the base and one of this change were run side by side over 80 command sequences in such places, and over 16 in a project already vendored by a path: every exit code, every byte of output and every file is the same, with the time stamps of the run (vendoredAt) set aside.

Limits

  • pip outside Bazel reads the same line and asks the patch host. It does not take the committed copy.
  • With the patch host unreachable, a changed or missing copy fails the build. With the host reachable, Bazel passes over such a copy without a message and downloads the pinned wheel: never other bytes, but it never says the copy is wrong. Run socket-patch vendor --check in CI.
  • A relock (pip-compile, a version bump) writes the registry's pin back over the line. The build is then green and unpatched, and the copy and its .bazelrc line stay behind without effect. socket-patch vendor --check fails on that, and the next scan pins the package again; that scan asks the patch service for the wheel once more, also where the committed copy is intact.
  • A machine whose repository cache already holds the wheel does not read the copy at all.
  • A downloader config that blocks the patch host fails the build although the copy is committed, which is why the form is declined where an rc file of the checkout names one or imports a file from outside the checkout. A config that the checkout does not show is not seen: one given on the command line, in an rc file of the home directory or of the machine, or in a file that a try-import names and this checkout does not have.
  • A --lockfile_mode=error build fails right after the command on Bazel 8.5 and later, until a build has updated MODULE.bazel.lock, as in hosted mode.
  • A .bazelrc that cannot be written when the command gets to it (it became read-only since, or the root directory takes no new file) is the warning bazelrc_not_updated, which names the line to add; without the line the build downloads the wheel from the patch host.
  • vendor --check does not look at the .bazelrc line.

Contents

Lines
Implementation +1056 / -140, 621 of them code
Unit tests in src +480 / -4
Real-Bazel and hermetic flows (e2e_bazel_build/pypi.rs, harness.rs) +722 / -43
Docs (docs/ecosystems.md, CLI_CONTRACT.md) +167 / -11
Workflow path filters +4 / -1

Two new files hold most of it: bazel/distdir.rs (the .bazelrc lines and what the workspace must show) and vendor/pypi_distdir.rs (the line, the gate, the wiring, the claim in discovery). bazel/ignore.rs now lends its line editor to both files, and bazel/maven.rs its reading of a ruleset's release. The first commit is tests only: the same flow with every file written by hand, which passes on the product code of the base.

What it proves, and where

  • Real Bazel 9.3.2, 8.8.2 and 7.7.2 (macOS), the three pypi:: flows as the workflow runs them. In a checkout whose .bazelrc already has a --distdir line of its own, the command writes the three files of the by-hand flow byte for byte; vendor --check passes and names a changed byte; with the patch host stopped, a new output base with no copy in the repository cache fails on one changed byte and builds the patched package from the copy as committed, from a sub-directory too; vendor --revert with the host stopped restores every file and the unpatched build; a checkout without Bazel's lock is declined and builds unpatched.
  • Real Bazel 9.3.2, the first commit alone. With hosted mode's pin, the wheel copied into the checkout and the --distdir line written by hand, on the product code of the base: the same failed and patched builds.
  • Without Bazel, through the binary. The whole life of a cached wheel, a line changed since it was written, a newer patch, a project below the Bazel root, a run that fails after its fetch over a committed wheel, one checkout per condition of the gate (each declined with its reason and nothing fetched), and the takeover of a hosted pin the form is not written for. Held against a binary of the base, the five new flows fail and the other 55 tests of the target pass.
  • By hand, before this change, on Bazel 9.3.2, 8.8.2 and 7.7.2 with rules_python 2.5.0-rc4: the wiring itself, the silent replacement with the host up, and the failure behind a downloader config.

Not covered

  • At the head of this pull request the three pypi:: flows ran on real Bazel 9.3.2 only (they pass, and the two vendored ones fail against a binary of the base's product code, as they must); 8.8.2 and 7.7.2 ran one revision earlier and run in CI. The whole core unit suite was not rerun after the review's commit; the unit tests of the changed modules and the hermetic targets were.
  • get --mode vendored, vendor for a manifest record and the eject of a hosted pin write the form through the same backend; they were run by the side-by-side comparison, not by a test of this repository.
  • A project below the Bazel root: a test without Bazel in this repository; built by hand on Bazel 9.3.2 and 7.7.2.
  • A checkout whose rc file imports an absolute path that names a downloader config was not built on Bazel: the decline rests on the measured failure behind such a config.
  • A wheel with a platform tag and a source distribution are declined, not built. A second Python version in the hub, requirements_by_platform (declined), rules_python releases other than 2.5.0, Linux outside CI, Windows, remote execution.

Code review

Nine findings on the first revision; five are fixed in the last commit, four are not.

Fixed, each with a test that fails without the fix:

  • A URL of the user's own for the package was taken for a hosted pin, so get <purl> --mode vendored fetched the wheel and failed only at the line. It is declined before the fetch now.
  • A second hub that reaches requirements.txt through -r was judged only when its call came first. Every call is asked now.
  • The form was written for a source distribution or a wheel of one platform, which no build has run. Only a -none-any.whl gets it.
  • The .bazelrc line was kept for a project moved to a path with a blank, which would have put a second word on every Bazel command. Such a project gets no line.
  • The ledger was parsed afresh on each ask. The read-only asks share one parse.

Not fixed:

  • After a relock the next vendored scan needs the patch service, where the path form re-wires a committed wheel offline. The line holds the URL of a grant, and a run takes it from the grant; re-using the URL of an earlier grant was not built or measured. It is in the limits.
  • Discovery reads the vendor ledger to tell this line from a hosted pin (decision 4), and only for a checkout on disk. A reader that is handed the files alone sees a hosted pin; if it moves the line to a newer patch, the old wheel, its ledger entry and its .bazelrc line stay behind until vendor --check or the next vendored run finds them. The build is not broken by that: Bazel takes the wheel the line names from the patch host. A marker in the line itself would remove the dependence and changes what the line is; that is the maintainer's call.
  • The gate is asked up to three times per package in one run, each time reading the module files and Bazel's lock. Time only; the second ask is what tells a package already vendored by a path from one that gets this form.
  • About twenty lines that report an unwritable file exist in both line editors. Left for a change of its own.

The branch of the pull request this is stacked on gained a commit during the review (a hub file that brings the project's in with -r is declined there); it is merged in, and the download cache follows it.


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. Vendored mode declines a PyPI package where a rules_python
`pip.parse` reads the project's `requirements.txt`: the path line it
would write breaks the build of everything the hub serves
(pypi::vendored_pip_parse, unchanged). This adds the flow of a form that
rules_python does build from a committed wheel, with every file of it
written by hand, to show what Bazel makes of those files before any
product code writes them.

pypi::vendored_download_cache, in the fixture of the hosted flow
(rules_python 2.5.0-rc4, `pip.parse(requirements_lock =
"//:requirements.txt")`, a hashed `requirements.txt`), in a checkout
whose `.bazelrc` already has a `--distdir` line of the user's own:

- `scan --mode hosted --yes` pins the package as it does today: the line
  becomes `spvictim @ <URL of the wheel on the patch host>
  --hash=sha256:<hex>`.
- By hand, the patched wheel is copied to
  `.socket/vendor/pypi/<uuid>/<the file name its URL ends in>`, and the
  `.bazelrc` of the fixture gets two lines at its end: a comment, and
  `common --distdir=.socket/vendor/pypi/<uuid>`.
- Nothing has fetched the wheel at that point: the patch host has no
  request for it, and Bazel's repository cache has no entry of its
  sha256. The patch host is then stopped. The index stays up, because the
  hub asks it about the other packages of the lock.
- In a new output base, with one byte of the committed copy changed, the
  build fails: Bazel passes over a copy whose sha256 is not the pin's and
  asks the patch host, which refuses the connection.
- In another new output base, with the copy as committed, `bazel build`
  and `bazel run //:consumer` print the patched marker. The repository
  cache holds the wheel afterwards, and Bazel changed no file of the
  checkout but its own lock (from 8.5 on, as after a hosted scan).

rules_python fetches a wheel that a requirement names by its URL with
Bazel's own downloader, by the sha256 of the line, and Bazel looks in
each `--distdir` for a file of the download's name and checksum before it
asks a host. The path is relative on purpose: Bazel reads it from the
workspace root, and takes `%workspace%` in this option literally.

It passes on Bazel 9.3.2 with the product code as it is.

For the flow, the harness gets a stand-in on a listener of its own that a
flow can stop (`StandIn::alone`, `StandIn::stop`: the listeners of
`StandIn::start` come from a pool and go on answering), and a check of
Bazel's repository cache (`Cell::cached`). The stand-ins of the PyPI
flows can now put the Socket API and the patch host on such a server,
apart from the index (`Vendoring::apart`); `Vendoring::new` serves all of
them from one server, as before.

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

Where a rules_python `pip.parse` reads the project's `requirements.txt`,
vendored mode declined the package (`vendor_pypi_bazel_hub`): the path
line it writes breaks the build of everything the hub serves. It now
writes another form there, wherever the checkout shows that Bazel builds
it, and declines as before everywhere else, with the condition that
failed at the end of the message.

What is written. The flow of the previous commit showed, with every file
written by hand, that Bazel builds a committed wheel when three things
are in the checkout. `scan --mode vendored`, `get --mode vendored` and
`vendor` now write them:

1. the package's line of `requirements.txt` exactly as hosted mode
   writes it, by hosted mode's own rewriter:
   `<name> @ <URL of the wheel on the patch host> --hash=sha256:<hex>`;
2. the patched wheel, fetched once, at `.socket/vendor/pypi/<uuid>/`
   under the file name its URL ends in, with what vendored mode keeps
   beside every wheel and its ledger entry;
3. in the `.bazelrc` at the Bazel root, under a comment line of
   socket-patch's own, `common --distdir=<that directory, from the Bazel
   root>`.

rules_python fetches a wheel that a requirement names by its URL with
Bazel's downloader, by the sha256 of the line, and Bazel takes a file of
the download's name and checksum from a `--distdir` before it asks a
host. Measured by hand with rules_python 2.5.0-rc4 on Bazel 9.3.2, 8.8.2
and 7.7.2: a fresh clone builds the patched package with the patch host
stopped, a new output base and no copy of the wheel in the repository
cache, also from a sub-directory and beside a `--distdir` of the user's
own. Bazel reads a relative path from the workspace root and takes
`%workspace%` in this option literally, so the path is relative.

One line per patch directory, not one directory for all patches: a
`--distdir` is flat and searched by file name, two patches of one
release have wheels of one name, and the uuid directory is the unit
that vendored mode writes, checks, sweeps and removes.

This is the first time socket-patch edits `.bazelrc`. The lines are kept
as the `.bazelignore` lines for Go copies are, by the same code:
`bazel::ignore` now takes the file, the comment and what counts as
already there (`Kept`, `update`), and `bazel::distdir::sync` uses it. A
pair is added at the end of the file for the directory of each such
wheel, taken away once the directory is gone, which leaves the file of
before byte for byte, never written through a link, and declined for
good by a user who comments the line out. A `.bazelrc` left empty is
removed, also one that was an empty file of the user's, as with
`.bazelignore`. `commands::sync_bazelignore`, which every command that
can write or remove a copy already calls once, brings both files in
line; a file that cannot be written when the command gets to it is the
warning `bazelrc_not_updated`, which names the line to add.

When it is written (`vendor::pypi_distdir::gate`,
`bazel::distdir::ready`, `bazel::built::alone`). Each condition is read
from the checkout, no Bazel is run, and each failure declines:

- the project pins in `requirements.txt` alone, in pip's hash-checking
  mode, and the package's requirement is one exact pin with its hashes,
  which hosted mode's rewriter turns into the plain line above (extras,
  a marker, an option, a comment or an indent decline);
- a `pip.parse` names that file by `requirements_lock` and names no
  other file of the project; every call of the hub is a statement of its
  own and written out, nothing of the module files is in doubt, and no
  `WORKSPACE` file defines repositories;
- Bazel selected rules_python 2.5.0-rc4 or 2.5.0 (one commit), read as
  the Maven lane reads its ruleset's release: the one `source.json` that
  `MODULE.bazel.lock` records, against what `MODULE.bazel` asks for
  (`bazel::maven::asked` now takes the module, and the reading itself
  is one function for both lanes, `bazel::maven::known_release`, with
  the Maven lane's messages as they were). Releases before it fetch a
  wheel through other code, which no build here has run;
- the checkout names Bazel 7, 8 or 9, or names none and has a lock of
  version 13 to 28, which 7.5.0 to 9.3.2 write;
- no rc file of the checkout names a downloader config,
  `--repository_disable_download` or a remote downloader, all of them
  can be read, and none imports an absolute path: Bazel refuses a
  download that such a config blocks before it looks in a `--distdir`
  (measured), and a file outside the checkout, where a site keeps the
  settings of its mirror, is not read (`bazel::rc::mentions` reports
  such an import to a caller that asks for it; the Maven lane does not);
- `.bazelrc` is no symbolic link and not read-only, and the project's
  path from the Bazel root holds nothing an rc line reads otherwise.

The same question is asked twice: by `vendor::bazel_hub::refusals`,
before anything is fetched, and by the backend where it is about to
write (`bazel_hub::download_cache`), because a run that takes a hosted
pin over is let through to put the registry's pin back and that pin may
be one the form is not written for. The run then declines and the
hosted pin stays.

A package that already is a download cache passes while
`requirements.txt` holds the line as the run wrote it. A line that has
been changed since (a comment after it, its hash moved to a line of its
own) declines the package before anything is fetched: a run over it
would fetch the wheel, find that it cannot write the line, and sweep
the directory, which is the committed one. For the failures that only
the fetch can show (the URL the patch service gave is none hosted mode
would pin), a wheel that an earlier run committed stays where it is.

With `--allow-vendored-in-bazel` the path line is written, here too: the
switch says that no build takes the project's packages from the hub.

How the other commands see it. The ledger entry is an ordinary one of
the requirements flavor whose record holds the URL line in the place of
the path line, so the revert of that flavor restores the pin
(`pypi_requirements` accepts that line as the entry's own). Lockfile
discovery reads the line as a hosted pin; where a ledger entry of this
form wrote it, `pypi_distdir::claim` makes it the vendored reference of
that entry. So `list` shows a vendored package, `vendor --check`
verifies the committed wheel and that the line is still there, a bare
`scan` stays in vendored mode, a later run writes nothing,
`vendor --revert`, `rollback` and `remove` restore `requirements.txt`
and `.bazelrc` byte for byte and delete the directory, a hosted scan
takes the package over, and a newer patch replaces line, wheel and
pair. `vex` attests the package as vendored and not affected: the hub
builds that wheel by the sha256 of the line, as it builds a hosted pin,
so the judgement that a hub builds nothing from a vendored PyPI copy
passes over it.

What it does not do, which the run says in a warning
(`vendor_pypi_bazel_download_cache`) and the docs repeat: pip outside
Bazel reads the same line and asks the patch host; with the host
reachable Bazel passes over a changed or missing copy without a message
and downloads the pinned wheel (never other bytes); `vendor --check` is
what holds the committed wheel to the patch. A `--lockfile_mode=error`
build fails right after the command on Bazel 8.5 and later until a
build has updated `MODULE.bazel.lock`, as in hosted mode. A relock
writes the registry's pin back: the build is then green and unpatched
until the next scan, and `vendor --check` fails meanwhile. A downloader
config that the checkout does not show (the command line, an rc file of
the home directory, a `try-import` of a file the checkout does not
have) is not seen.

Nothing changes outside a Bazel workspace, in a workspace whose hubs
read none of the project's files, for RubyGems, for hosted and agent
mode, or for a package already vendored by a path.

Tests:

- pypi::vendored_download_cache (real Bazel) now has the command write
  the files: they are the three of the hand-written flow, byte for byte;
  with the patch host stopped a new output base fails on one changed
  byte, which `vendor --check` names, and builds the patched marker
  from the copy as committed, from a sub-directory too; `vendor
  --revert` restores every file and the unpatched build.
  pypi::vendored_pip_parse keeps the refusal on real Bazel, in a
  checkout without Bazel's lock, and the switch's path line after it.
  The three `pypi::` flows pass on Bazel 9.3.2, 8.8.2 and 7.7.2 (macOS)
  at this commit; with the product code of the previous commit the two
  vendored ones fail on 9.3.2.
- Hermetic flows through the binary: the whole life of a cached wheel
  (in-sync runs, check, list, vex, a line changed since, the three
  undos, the hosted takeover and back, a commented-out line); a newer
  patch; a project below the Bazel root; a run that fails after its
  fetch over a committed wheel; and one checkout per condition of the
  gate, each declined with its reason, dry run included, with no wheel
  fetched.
- Unit tests of `bazel::distdir` (the lines, and each condition of
  `ready`) and of `vendor::pypi_distdir` (the line, the record, the
  shapes that are not written).

Docs: docs/ecosystems.md has the new section "Bazel workspaces: PyPI
vendored mode as a download cache"; in "Bazel workspaces: what is
supported" the vendored cell of PyPI is "Supported with rules_python
2.5.0", with its entry among the known problems. CLI_CONTRACT.md has
the two new codes and the changed rows. The `bazel` group of
scripts/loc-budget.json follows the code.

Not covered: a wheel with a platform tag, a second Python version in
the hub, `requirements_by_platform` (declined), rules_python releases
other than 2.5.0, Windows, and remote execution.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 branch this change is stacked on gained one commit: a hub that names a
requirements file which brings the project's own in with `-r` is declined,
and a doubt has the second file read as well.

Two conflicts. In bazel/built.rs both sides added a function after `reads`
(`alone` here, `includes_one` there): both are kept. The `bazel` line
budget is the count of the merged tree, 2851.

One thing follows for the download cache. A hub file that only brings the
project's requirements in with `-r` is none the run writes, and no build
through it is shown to take a committed wheel. So such a file does not
count as naming the project's file: the package is declined as on the
base, and the download cache is not asked about. The test of the include
holds that.

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>
…hown to work

A review of the download cache found four cases in which vendored mode let
a package through, or wrote a line, that no build has been run for.

- A requirement that names the package by a URL of the user's own. The
  check before the download took every `name @ <url>` line for a pin that
  hosted mode made, so `get <purl> --mode vendored` fetched the wheel and
  failed only when it came to write the line. Only a URL that names a patch
  id is a hosted pin now; any other is declined before anything is fetched.
  (No scan finds a package in such a line, which is why it took `get`.)
- A second hub that reaches the file through `-r`. The check that the hub
  reads `requirements.txt` and no other file passed over a call that names
  none of the project's files, so `all.txt` with `-r requirements.txt` was
  judged only when its call came first. Every call of the hub is now asked
  whether its file brings one of the project's in.
- A source distribution or a wheel of one platform. The line was written
  for whatever the patch service serves. The form was built with a wheel
  for every platform (`-none-any.whl`) alone, so anything else now fails
  after its download, as the other refusal that only the download can show
  does, writes no line and keeps a wheel an earlier run committed.
- A project moved to a path with a blank. The lines of `.bazelrc` are kept
  for every ledger entry of the form on every command, without the check of
  the path that the first write makes: a blank in the line would be a second
  word on every Bazel command of the workspace. Such a project gets no line.

The read-only asks of the ledger use the shared parse, which is keyed on the
ledger's bytes. The `bazel` line budget is 2865.

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:34
@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches vendored PyPI wiring, Bazel workspace detection, and .bazelrc mutation in builds that use rules_python; mis-gating or rc sync failures could block patches or leave builds fetching from the patch host.

Overview
Adds a Bazel download-cache vendoring path for PyPI when rules_python pip.parse reads the project’s requirements.txt, instead of only refusing (vendor_pypi_bazel_hub) or requiring --allow-vendored-in-bazel for a local wheel path.

Where the workspace gate passes, vendored mode now writes: a hosted-style requirements.txt pin (name @ patch URL + --hash), the wheel under .socket/vendor/pypi/<uuid>/, and common --distdir=… lines in root .bazelrc (via new bazel/distdir + vendor/pypi_distdir). Post-command sync keeps .bazelrc in step with committed wheels, parallel to Go’s .bazelignore. bazel/built::alone and stricter hub refusals encode when this form is allowed vs when decline messages include why.

CLI/contract: new advisory vendor_pypi_bazel_download_cache and bazelrc_not_updated; vex treats download-cache pins like hosted for “affected” semantics; discovery claims ledger-backed URL lines as vendored. Tests/docs/CI: expanded Bazel e2e (vendored_download_cache, gate matrix), workflow path for pypi_distdir.rs, loc budget bump for bazel/.

Reviewed by Cursor Bugbot for commit c6aa228. 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 1 potential issue.

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 c6aa228. 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
`bazel::distdir::sync` reports the file it changed as a person reads a
path, without the `\\?\` prefix that a canonical path carries on Windows,
as the `.bazelignore` writer does. One unit test compared that report
with the root's own path joined with the file name, which keeps the
prefix, so it failed on Windows and nowhere else:

    left: Some("C:\\...\\.bazelrc")
   right: Some("\\\\?\\C:\\...\\.bazelrc")

The test now takes the prefix off its expectation with the same helper.
Tests only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The writability probe in the PyPI download cache's `ready` opened
`.bazelrc` for appending with a plain open(2). A FIFO at that path
blocks that open until a reader comes, so `vendor` and `scan --mode
vendored` could hang instead of declining the package. A directory
there passed the probe and only failed later in the line editor.

Decline any `.bazelrc` that exists and is not a regular file, and open
the probe with O_NONBLOCK on Unix so a FIFO swapped in after the check
fails fast with ENXIO. The test covers a FIFO and a directory.

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

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] Found a fresh-checkout gap in the vendored wheel gate.

…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>
The wheel of a download cache already has a git-ignored guard, but the
.bazelrc line that points Bazel at it did not. An untracked .bazelrc that
git ignores passes the gate, the local build takes the wheel, and a fresh
checkout has no --distdir line, so it downloads from the patch host. The
gate now asks git (without --no-index, so a tracked file passes) and
declines with the ignoring rule.

Assisted-by: Claude Code:claude-opus-5-5
… 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>
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does. Where a rules_python pip.parse hub reads the project's requirements.txt, vendored mode no longer just declines: it writes hosted mode's URL pin, commits the patched wheel under .socket/vendor/pypi/<uuid>/, and adds a common --distdir= line to the root .bazelrc so Bazel takes the committed copy. It only does this where the checkout shows it works (rules_python 2.5.0, Bazel 7 to 9, hashed single pin, no downloader config, a .bazelrc that is writable and, since 3a8f1bd, not git-ignored). Everywhere else it declines as #2208 does.

Risk: medium. It is the first time socket-patch writes .bazelrc, and it changes what lockfile discovery reports for this one line shape. The gate is narrow and the 80-sequence side-by-side in the description shows no change outside it, but the .bazelrc edit reaches every Bazel command in the user's repo.

Look here

Verified. I read the diff against the base branch (bazel-guard/vendored-hub-locks), focusing on the two new modules and the last commit. CHANGELOG.md is untouched. git check-ignore runs without --no-index, so a tracked .bazelrc passes, and its unit test covers ignored, untracked and tracked. I ran cargo test -p socket-patch-core --lib -- bazel:: vendor::pypi locally: 682 passed. CI on 3a8f1bd: ci-ok and clippy are green, with no failing check. All review threads are resolved. Approved by Wenxin-Jiang at b9141ea; that approval still stands.

Changes I made. None.

Open questions


Generated by Claude Code

…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>
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>
…ndored/pypi-download-cache

The gate of the download cache reads the workspace as the two refusals
do now: a `WORKSPACE` file is left out where the checkout names Bazel 9
or later, which never reads one, so a file that a move to Bzlmod left
behind no longer stands against the cache there. With an older release,
or none named, it stands as before. `built::alone` follows the list of
extensions that a hub has on the other side.

Conflicts were in CLI_CONTRACT.md, docs/ecosystems.md and
scripts/loc-budget.json: the rows and entries of both sides are kept,
and the `bazel` cap is the merged count. The codes and the section of
this branch carry the Experimental mark of the other side, and the
sentence of the off switch names the download cache.

Tests: the gate's rows for a `WORKSPACE` file under Bazel 9.0.0, 9.3.2,
8.8.2 and 7.7.2, the same through the CLI in a checkout, and the off
switch in the checkout where a download cache is written.

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
…L set

With the switch set, the sync of the `.bazelrc` lines looked the Bazel
root up through the lookup that the switch turns off, so it neither
added a line nor took one away: the undo of a download cache that an
earlier run committed left its `common --distdir=` line behind. It now
follows the rule of the `.bazelignore` lines: no line is added, and the
line of a wheel that is gone is still taken away.

The test commits a download cache without the variable and undoes it
with the variable set, by `vendor --revert`, `rollback` and `remove`:
the checkout is the one of before, to the byte. With the variable set,
`list` and `vendor --check` see the vendored wheel as well.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…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>
…ndored/pypi-download-cache

This brings in the gem that vendored mode commits for a rules_ruby hub,
which lands before this branch, and with it main as that branch holds
it. The two overlap where each makes an exception to the refusal beside
a hub, and `vendor/bazel_hub.rs` now keeps both in one pass over a
package. What stands in a package's way holds what both need: whether a
call names a file of the project itself, and whether a gem can be
committed for the call. A gem is let through where its archive is known
to build, and a wheel where the download cache is shown to work, each
with its own words in the refusal.

`bazel/built.rs` keeps the helper of each side (`alone`, `hub_calls`).
The gate of the gem calls `rc::mentions` with the argument this branch
added to it, set so that the gate reads what it read before. The help
of the flag, the contract and the docs name both forms, and the list of
known limits counts six.

The `bazel` cap of scripts/loc-budget.json is 5300, as in every
remaining branch of this series; the count here is 4465.

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>
…ndored/pypi-download-cache

This takes in the branch that lands before this one as it stands with
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:

- bazel/maven.rs: each side had lifted the check of a ruleset's release
  out of the Maven reader, this one as `known_release`, the other as
  the methods `Asked::wanted` and `Asked::stale`. There is one of each
  now: the methods say what is asked for and when a lock is stale, and
  `known_release` asks them. The Maven reader calls `known_release`,
  with the words it had.
- commands/vex.rs: a wheel committed as a download cache counts as
  pinned for what Bazel builds, and a hosted pin does unless it is a
  Maven one.
- bazel/nuget.rs calls `rc::mentions` with the argument this branch
  added to it, set so that the NuGet gate reads what it read before.
- The help of `--allow-vendored-in-bazel`, CLI_CONTRACT.md and
  docs/ecosystems.md name the download cache beside the gem committed
  for a hub and the NuGet block.

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

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ndored/pypi-download-cache

That commit records main as merged into the branch this one follows and
changes no file there, so this merge changes none here: it makes this
branch hold main.

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

main holds the branch this one follows as one squashed commit, so every
conflict was of that branch's lines against this branch's later edits
of them, and each resolves to this branch's text. What main has beyond
it (the report of a vendored revert that scan --prune kept or failed,
the remedy for a stale gem in another Ruby's tree, the shared test
helpers and the Windows pnpm tests) merges in by itself, into the
contract and the docs as well.

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

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Merged via the queue into main with commit d88450c Nov 25, 2026
119 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the bazel-vendored/pypi-download-cache branch November 25, 2026 21:24
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