Repository navigation
Test Cargo hosted and vendored modes under rules_rust on real Bazel - #2147
Conversation
The real-Bazel suite held flows for Go, npm, PyPI and RubyGems. This
adds the two modes that reach a crate Bazel builds: rules_rust's
crate_universe runs cargo over the workspace's Cargo.toml and Cargo.lock
(crate.from_cargo under Bzlmod), so what those two files name is what
the next `bazel build` compiles. No file under crates/*/src changes.
Two tests, `cargo::hosted_from_cargo_with_config` and
`cargo::vendored_from_cargo_with_config`, on Bazel 9.3.2 and 8.8.2 with
rules_rust 0.75.0 (Rust 1.99.1) and on Bazel 7.7.2 with rules_rust
0.56.0 (Rust 1.83.0). The hub is the one of the rules_rust README with
`cargo_config = "//:.cargo/config.toml"` added, and no cargo-bazel lock.
Each test, in a fresh output base:
- builds the fixture workspace and reads "OUT: PRISTINE <id>" from
`bazel run //:consumer`; the stand-in registry was asked for the index
file of the crate and at least twice for the crate file. The test
counts requests. The stand-in records no sender, so the test does not
tell the hub's cargo from Bazel's downloader;
- runs the one command of its mode and holds the changed files to its
list. `scan --mode hosted --yes` adds the patch registry to
.cargo/config.toml, names it on the dependency in Cargo.toml and
gives the crate's entry of Cargo.lock that registry as its source and
the checksum of the patched crate file. `scan --mode vendored --yes`
commits the unpacked crate under .socket/vendor/cargo/<uuid>/ with
its ledger, adds a [patch.crates-io] entry to Cargo.toml and gives
the lock's entry the copy's version and no source;
- runs the same two Bazel commands, with no step in between and no
repin, and reads the patched marker, which holds an id made for the
run. Hosted: the stand-in patch host was asked for its index file of
the crate and at least twice for the crate file, and the upstream
crate file was not asked for again. Vendored: the build asked the
stand-in for nothing;
- runs `vex` in the checkout Bazel has built in. Hosted: it exits 0 and
its document names the crate as patched by the patch, and a second
`scan --mode hosted` applies the patch again and changes no file.
Vendored: per ruleset, below;
- runs the undo (`rollback --yes`, or `vendor --revert`): every file
the command wrote is the one of before, byte for byte, and the build
prints the upstream marker again;
- on a second machine, against a second patch: a patch host that
serves another crate file than the lock pins fails the hosted build
on the checksum, both when its index names the pinned checksum (cargo
refuses the download) and when it names the one of the file it serves
(cargo refuses the lock's entry), and the upstream crate is not asked
for in its place. In vendored mode the first build there is the
patched one; the scan runs a second time, as on every run of a
pipeline, and after it the next build writes nothing, `vendor --check`
passes and `vex` attests the crate. Then the library of the committed
copy is changed. Nothing in a build holds that copy to a checksum, as
for any crate a workspace takes from a path: the test holds that the
changed library is what Bazel builds next, and that `vendor --check`
reports it (vendor_hash_mismatch).
Known gaps. Two assertions of the vendored flow hold what the release
does with rules_rust 0.75.0, which is not what a user needs. They are
marked KNOWN GAP in cargo.rs and listed under "Known gaps" in its module
docs. cargo-bazel 0.75.0 writes a BUILD.bazel into the committed copy,
which the scan did not record, so right after a build that is the
patched one:
- `vendor --check` exits 1 (vendor_inventory_mismatch);
- `vex` leaves the patch out under the same code, exits 1
(no_applicable_patches) and writes no document.
The flow also holds the way out a user has today: a second
`scan --mode vendored` downloads the crate again, reports the copy
rebuilt and removes the file. The build after that scan does not write
the file again, since nothing the hub reads has changed, and the check
and `vex` pass. `vendor --revert` removes the file with the copy. A fix
of the product makes both commands pass right after the build, and the
two marked branches of the test go.
What else a build writes into the checkout depends on the ruleset, and
each release is held to its case:
- rules_rust 0.75.0 has Bazel watch the files the hub reads, and
MODULE.bazel.lock has an entry for the hub. Right after either
command, and again right after the undo, a `--lockfile_mode=error`
build fails ("MODULE.bazel.lock is no longer up-to-date") until a
build that may update the lock has run. The first patched build
rewrites that lock, which in hosted mode then names the crate file on
the patch host; the undo leaves it behind, and the next build writes
the lock of before.
- With rules_rust 0.56.0 the lock has no entry for the hub and a build
writes no file: the undo restores the checkout at once,
`vendor --check` passes, `vex` attests the crate, and a second scan
reports the copy already_vendored.
- rules_rust 0.75.0 gives the hub's cargo a home inside the output
base that is empty at every evaluation of the hub, so each one reads
the index and downloads the crate file again: the stand-in was asked
for the upstream crate file once more by the build after `rollback`.
rules_rust 0.56.0 runs cargo with the home it is given, and that
build sent no request.
rules_rust 0.75.0 builds the fixture on Bazel 7.7.2 as well. Bazel 7
keeps the older release so that both behaviours stay covered.
The crate under test never comes from crates.io. No downloader config
reaches cargo, so the workspace names a mirror of crates.io in its
.cargo/config.toml (a source replacement), which is the loopback
stand-in, and the hub names that file: cargo-bazel leaves the cargo
config of a checkout out unless the hub does. That is why the hub of
the vendored flow names a config too. The crate's name has 69
characters and crates.io takes none of more than 64, so a build that
gets past the stand-in finds nothing there: with the mirror taken out
of the config, the first build fails with "no matching package named".
The upstream crate file and each patched one are built for the run,
and the test writes the upstream checksum into the Cargo.lock of its
workspace copy, so no repository cache can supply them.
One edit of the shared harness, for the Bazel children of every
ecosystem's flows: every variable whose name starts with CARGO_, and
REPIN, is removed from them. The cargo a ruleset starts reads the
caller's CARGO_NET_OFFLINE, CARGO_SOURCE_*, CARGO_REGISTRIES_* and
CARGO_HTTP_*, and rules_rust reads CARGO_BAZEL_REPIN or REPIN as its
switch for a repin; `cargo test` itself sets CARGO_MANIFEST_DIR,
CARGO_MANIFEST_PATH and CARGO_PKG_* for the test process. The hermetic
test that guards those lists gains one name for each. The Cargo flows
set CARGO_HOME (a directory of the test: under Bzlmod rules_rust 0.56.0
runs its cargo with the cargo home of the environment) and
CARGO_BAZEL_ISOLATED after that scrub, through the cell's repo_env.
With CARGO_NET_OFFLINE=true, CARGO_BAZEL_REPIN=1 and REPIN=1 exported
both flows pass on 9.3.2; with the prefix taken out of the list again,
both fail under CARGO_NET_OFFLINE=true at the first build (cargo: "no
matching package named").
A test removes its first workspace copy (the Bazel server stopped, the
scratch root deleted) before its second machine builds, when the run
names a repository cache, as CI does. Without one the cache both
machines read is inside the first copy's scratch root, and that copy
stays until the test ends.
- crates/socket-patch-cli/tests/e2e_bazel_build/cargo.rs: the crate
builder, the stand-in (the Socket API, the sparse index and the
crate file of the patch registry, and the two hosts of crates.io),
the two flows, and a hermetic test that holds the fixture and the
workflow's legs to the table in the test code.
- crates/socket-patch-cli/tests/e2e_bazel_build/harness.rs: the two
names above in the lists of what no Bazel child sees, and in the
list of the test that guards them.
- crates/socket-patch-cli/tests/fixtures/bazel/rules_rust/bzlmod/
{common,e9,e7}: the workspace, with a placeholder for the crate's
checksum in Cargo.lock and no cargo config (the test writes it, with
the port of its stand-in).
- .github/workflows/bazel-cargo.yml: the caller of
bazel-compatibility.yml for `cargo::`. Three Linux legs on a pull
request that touches these files or a Cargo file of
socket-patch-core, on a main push that also touches the shared engine
code and test helpers, nightly at 04:57 UTC and on dispatch; one
macOS leg nightly and on dispatch. Not required for merge.
Measured on macOS arm64 on this tree, each release in a fresh output
root, two tests at a time, on a machine that ran other builds, with a
repository cache that earlier runs had filled: 70 s and 91 s (hosted,
vendored) on 9.3.2, 69 s and 92 s on 8.8.2, 61 s and 73 s on 7.7.2.
The run that filled the cache of rules_rust 0.56.0 took 164 s and
167 s. A cold leg downloads about 230 MB with rules_rust 0.75.0 and
155 MB with 0.56.0: the Rust toolchain from static.rust-lang.org (about
120 MB of the 230), the cargo-bazel binary and the ruleset archives
from GitHub, and the crates rules_rust builds its own tools from, from
static.crates.io (60 with 0.75.0, one with 0.56.0). Every workspace
copy unpacks the toolchain for itself, 1.7 to 1.8 GB. With the first
copy removed before the second machine builds, a leg holds two copies
at its peak, one per test: 3,619 MB on 9.3.2 (3,719 MB on 8.8.2,
3,485 MB on 7.7.2), where the four copies of before came to 7,062 MB
on 9.3.2.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryLow Risk Overview It adds Reviewed by Cursor Bugbot for commit 04ce7d6. Configure here. |
|
[agent] PR shepherd: review brief for the approver What it does. Adds two real-Bazel Cargo flows under rules_rust, one for hosted mode and one for vendored mode. Each reads the result from what Bazel builds. Two branches marked Risk: low. No product code changes. The Bazel flows are Look here
Verified
Changes I made: none. Open questions (minor, none blocking):
Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed at 04ce7d6. Tests, fixture and workflow only, plus the harness scrubbing REPIN and CARGO_* from Bazel children. Both flows ran and passed on 7.7.2, 8.8.2 and 9.3.2, and they assert the built binary's marker, exact lock, manifest and config contents, request counts and a tampered-crate refusal. Non-blocking: two KNOWN GAP branches pin today's behaviour where vendor --check and vex fail after Bazel writes a BUILD.bazel into the vendored copy; the mod cargo; line in main.rs will conflict with #2146.
No user-visible change.
What this is
Tests only. The real-Bazel suite (
e2e_bazel_build) held flows for Go, npm, PyPI and RubyGems. This adds Cargo: hosted and vendored mode for a crate that rules_rust's crate_universe resolves from a Cargo workspace (crate.from_cargounder Bzlmod), withvexafter the patched build. crate_universe runs cargo over the workspace'sCargo.tomlandCargo.lock, so what those two files name is what the nextbazel buildcompiles. No file undercrates/*/srcchanges.One file that the other ecosystems' Bazel tests share changes: twelve lines of
harness.rskeep the caller's cargo settings away from every Bazel process a test starts (see "The shared harness edit"). Because of that edit, this pull request starts the Go, npm, PyPI and RubyGems Bazel workflows as well as the Cargo one.Contents
crates/*/src)crates/socket-patch-cli/tests/e2e_bazel_build/cargo.rs(1,081 lines, 665 of them code): the crate builder, the loopback stand-in, the two flows, and one test that needs no Bazel. Onemodline inmain.rs.crates/socket-patch-cli/tests/e2e_bazel_build/harness.rs(12 lines added): two more entries in the lists of variables no Bazel process of a test sees, and in the list of the test that guards them. The reusable workflow and the other ecosystems' files are untouched..github/workflows/bazel-cargo.yml(141 lines): the caller ofbazel-compatibility.ymlfor thecargo::tests.crates/socket-patch-cli/tests/fixtures/bazel/rules_rust/bzlmod/{common,e9,e7}(six files, 71 lines, no binary): arust_binarythat prints one constant of the crate,Cargo.toml, aCargo.lockwith a placeholder for the crate's checksum, and oneMODULE.bazelper ruleset release. The hub is the one of the rules_rust README withcargo_config = "//:.cargo/config.toml"added, and no cargo-bazel lock (lockfile).What it proves, and where
Two tests, each one flow in a fresh output base:
cargo::hosted_from_cargo_with_configbazel buildandbazel run //:consumerprintOUT: PRISTINE <id>. The stand-in registry was asked for the crate's index file, and at least twice for the crate file (twice in every run here). The test counts requests by path. It does not tell which program sent them.socket-patch scan --mode hosted --yeschanges exactly.cargo/config.toml(adds[registries.socket-patch-<uuid>], keeps what the project had),Cargo.toml(registry = "socket-patch-<uuid>"on the dependency) andCargo.lock(the patch registry as the entry's source, the checksum of the patched crate file).OUT: PATCHED <uuid>. The stand-in patch host was asked for its index file of the crate, and at least twice for the crate file (twice in every run here); the upstream crate file was not asked for again.socket-patch vexexits 0, and its document names the crate and the patch (Patched via Socket patch <uuid>); no file of the checkout changes. A secondscan --mode hosted --yes, as a pipeline runs it every time, applies the patch again and rewrites no file.socket-patch rollback --yesputs the three files back byte for byte, and the build prints the upstream marker again.failed to verify the checksum of ...), or its index names the checksum of what it serves (cargo:checksum for ... changed between lock files). That patch host was asked for the file (once in every run here), and the upstream crate file was not asked for in its place.cargo::vendored_from_cargo_with_configsocket-patch scan --mode vendored --yeschanges exactly: the unpacked crate under.socket/vendor/cargo/<uuid>/<name>-<version>/(Cargo.toml,src/lib.rs),socket-patch.vendor.jsonbeside it,.socket/vendor/state.json,Cargo.toml(a[patch.crates-io]entry with the path of the copy) andCargo.lock(the entry gets the copy's version,<version>+socket.<uuid>, and loses its source and checksum).socket-patch vex, right after that build, changes no file. With rules_rust 0.56.0 it exits 0 and its document names the crate and the patch. With rules_rust 0.75.0 it exits 1 and writes no document (a known gap, below).socket-patch vendor --revertremoves the copy and puts the two files back byte for byte, and the build prints the upstream marker again.scan --mode vendored --yesthen runs a second time, as a pipeline runs it every time (what it does depends on the ruleset, below). After it, with either ruleset, the next build is still the patched one and writes no file,vendor --checkpasses, andvexexits 0 and names the crate and the patch. Then the library of the committed copy is changed. Nothing in a build holds that copy to a checksum, as for any crate a Cargo workspace takes from a path. The test holds what is true: the changed library is what Bazel builds next, andsocket-patch vendor --checkreports it (vendor_hash_mismatch).Both markers are read from what Bazel built, and each holds an id made for the run.
Releases and seconds per test at this commit (macOS arm64, one fresh output root per release, a repository cache that earlier runs had filled, two tests at a time as the workflow runs them, on a machine that ran other builds). A leg is one job of the workflow: one Bazel release on one platform.
The run that filled the cache for rules_rust 0.56.0 took 164 s and 167 s on Bazel 7.7.2.
The other ecosystems' flows, once each on Bazel 9.3.2 at this commit, because
harness.rschanged:go::hosted_go_depspass (56 s),npm::hosted_npm_translate_lockpass (20 s),npm::vendored_npm_translate_lockpass (20 s),pypi::hosted_pip_parsepass (20 s),ruby::hosted_bundle_fetchpass (104 s).rules_rust 0.75.0 also builds the fixture on Bazel 7.7.2: both flows passed there in an earlier form, before the
vexand second-scan steps were added, and that was not run again. Bazel 7 keeps 0.56.0 because that release behaves differently in ways the flows record below.On Linux, on GitHub's runners, the three Cargo legs of this pull request pass at its head: Bazel 9.3.2 in 343 seconds, 8.8.2 in 317 and 7.7.2 in 293, with a cold cache (the two flows together take 213 seconds on 9.3.2). The Go, npm, PyPI and RubyGems legs, which the harness edit starts, pass too, with the other checks (69 in all). The macOS leg on a GitHub runner first runs in the nightly.
Runs that each changed one thing and checked that the tests then fail. With the review's changes in place (the test logic as in this commit; only comments, one variable name and the base commit changed after), all as expected:
CARGO_entry taken out of the harness list andCARGO_NET_OFFLINE=trueexported, both flows fail at the first build on Bazel 9.3.2 (cargo:no matching package named, with its note about offline mode);CARGO_entry or theREPINentry removed (the guarding test fails witha child sees CARGO_SETTING,a child sees REPIN), or either name removed from the test's own list (CARGO_* is removed and not tested,REPIN is removed and not tested).Eleven more were run on Bazel 9.3.2 before the review changes and before the last two rebases, and were not run again; the assertions they target did not change. All eleven failed as expected: the first scan as a dry run; the files the scan wrote put back before the build; the upstream bytes granted as the patch; the tampering left out; the undo as a dry run; the second machine's index left at the pinned checksum; the mirror taken out of the cargo config (cargo:
no matching package named, which is what a build that gets past the stand-in meets);vexexpected the other way round in each flow; the second vendored scan run before any build of its machine; the second vendored scan as a dry run; the hosted flow's second scan run in vendored mode.Why both hubs name a cargo config
The crate under test never comes from crates.io. cargo reads no Bazel downloader config, so the test's workspace says where its crates come from the way a project behind a crates.io mirror does:
.cargo/config.tomlreplaces thecrates-iosource with the loopback stand-in. cargo-bazel leaves the cargo config of a checkout out of the workspace it resolves unless the hub names it, so a hub withoutcargo_configcan only resolve against crates.io itself. Hosted mode needs the attribute anyway (the patch registry is defined in that file); the vendored flow has it only for the stand-in.The crate's name has 69 characters. crates.io takes no name of more than 64 (the Cargo Book, the
namefield), so nobody can publish it there. The upstream crate file and each patched one are built for the run, and the test writes the upstream checksum into theCargo.lockof its workspace copy, so no repository cache can supply them.The shared harness edit
Every Bazel process a test starts, in every ecosystem's flows, now runs without any variable whose name starts with
CARGO_and withoutREPIN. Before, the cargo that rules_rust starts read the caller'sCARGO_NET_OFFLINE,CARGO_SOURCE_*,CARGO_REGISTRIES_*andCARGO_HTTP_*, and rules_rust readCARGO_BAZEL_REPINorREPINas its switch for a repin; the Cargo flows stopped with a failure when one of those two was set.cargo testitself puts under that prefix into the test process was read from a run:CARGO_MANIFEST_DIR,CARGO_MANIFEST_PATHand fourteenCARGO_PKG_*names (andCARGO_HOME, where the shell or rustup sets it). The tests read those at compile time, and no Bazel process needs them. The bare nameCARGOis not under the prefix and stays; rules_rust 0.75.0 sets it itself for its tool.CARGO_HOME(a directory of the test, because rules_rust 0.56.0 runs its cargo with the cargo home of the environment) andCARGO_BAZEL_ISOLATED. Both are set after the removal, as before. Checked two ways: a temporary test, not committed, printed what a Bazel command of a Cargo flow gets, and it showed both names with the flow's values, as variables and as--repo_envoptions, and every otherCARGO_*name of the process andREPINremoved; and on Bazel 7.7.2 the last step of the hosted flow passes only when the hub's cargo uses the cargo home the test names.CARGO_NET_OFFLINE=true,CARGO_BAZEL_REPIN=1andREPIN=1exported, both Cargo flows pass on Bazel 9.3.2 (67 s and 88 s). That run was made with the harness edit as it is here, before the last changes to the wording of three failure messages and before the last rebase.What starts on main
bazel-cargo.ymlcallsbazel-compatibility.ymlwith three Linux legs (9.3.2 and 8.8.2 on the rules_rust 0.75.0 fixture, 7.7.2 on the 0.56.0 one) and one macOS leg (9.3.2).cargo.rsorharness.rs, the rules_rust fixture, any file of socket-patch-core withcargoin its name or in the name of one of its directories (among themvex/discover/cargo.rs, whichvexreads a Cargo project with), orpatch/user_patches.rs(it reads theCargo.tomland the cargo config of every scan).main.rsof the test target,patch/redirect/**,vendor/**,hosted/**, the CLI'scommands/**, the shared test helpers, or the toolchain files (Cargo.lock,Cargo.toml,crates/*/Cargo.toml,rust-toolchain.toml,.cargo/**). The rest of the VEX code is in neither list, as in the npm caller; a change there gets its run in the nightly.merge_grouptrigger, and no job is aneedsofci-ok.Sizes below are as
duprints them (1 MB = 1,048,576 bytes).Outside hosts of a leg, beyond what every Bazel leg needs (GitHub for the Bazel release and the ruleset archives, bcr.bazel.build): static.rust-lang.org (the Rust toolchain: six archives, 116 MB with Rust 1.99.1 and 128 MB with Rust 1.83.0 for macOS arm64 as downloaded, and 167 MB for Linux x86_64 with Rust 1.99.1 by the sizes that host publishes), GitHub again for the cargo-bazel binary (15 MB) and for more ruleset archives than other legs fetch (the rules_rust 0.75.0 archive alone is 63 MB), and static.crates.io for the crates rules_rust builds its own tools from (60 with 0.75.0, one with 0.56.0). By the build event files of a cold build, Bazel's downloader fetched 15 files from github.com, 6 from static.rust-lang.org and 60 from static.crates.io on Bazel 9.3.2, and 14, 6 and 1 on 7.7.2, beside what it reads from the Bazel registry. No leg asks crates.io about the crate under test: Bazel's own fetches of it went to the loopback stand-in.
Cache: the repository cache of the reusable workflow, one per ruleset release, came to 228 MB (9.3.2) and 232 MB (8.8.2) with rules_rust 0.75.0, each from empty, to 241 MB when 8.8.2 filled the cache 9.3.2 had left, and to 155 MB with 0.56.0, on macOS arm64.
Disk: every workspace copy unpacks the Rust toolchain for itself (1.7 to 1.8 GB). A test now removes its first copy, with its Bazel server stopped, before its second machine builds, so a leg holds two copies at its peak, one per test, where it held four. Measured with
duover the tests' scratch directories every four seconds during a run on Bazel 9.3.2: 7,062 MB at the largest reading before the change (four copies: 1,807, 1,791, 1,732 and 1,730 MB), 3,619 MB after (two copies: 1,818 and 1,801 MB). After the change the largest reading was 3,719 MB on 8.8.2 and 3,485 MB on 7.7.2. Not measured on Linux. A run that names no repository cache (SOCKET_PATCH_BAZEL_E2E_REPO_CACHEunset, which is how a developer starts a test by the module docs) keeps the first copy to the end, because the cache both machines read is inside that copy's scratch directory; that path ran once, the hosted flow on Bazel 7.7.2, and passed.Known behaviour the flows record
With rules_rust 0.75.0 (Bazel 9.3.2 and 8.8.2):
Known gap:
vendor --checkfails right after a patched build. cargo-bazel writes aBUILD.bazelinto the committed copy under.socket/vendor/cargo/, which the scan did not record.socket-patch vendor --checkthen exits 1 (vendor_check_failed:vendor_inventory_mismatch). The test asserts this because it is what the release does; it is not what a user needs.Known gap:
vexattests nothing in vendored mode right after a patched build. For the same reasonsocket-patch vexleaves the patch out undervendor_inventory_mismatch, exits 1 (no_applicable_patches) and writes no document.Both assertions are marked
KNOWN GAPincargo.rsand listed under "Known gaps" in its module docs. When the product is fixed, the two marked branches are deleted and the vendored flow expectsvendor --checkto pass andvexto attest the crate with every ruleset, as it does with rules_rust 0.56.0 today.The flow also holds the way out a user has today: a second
scan --mode vendoreddownloads the crate again from the patch host, reports the copyrebuiltand removes theBUILD.bazel. The next build is still the patched one and does not write the file again, because nothing the hub reads has changed;vendor --checkpasses andvexattests the crate. The file comes back when Bazel evaluates the hub again (seen once, on Bazel 9.3.2, after an edit ofCargo.lock; a restart of the Bazel server did not bring it back; neither is asserted).vendor --revertremoves the file with the copy.A frozen Bazel lock fails after the command. Bazel records the hub's input files in
MODULE.bazel.lock. Right afterscanin either mode, and again right after the undo,bazel build --lockfile_mode=errorfails withMODULE.bazel.lock is no longer up-to-date, until a build that may update the lock (orbazel mod deps --lockfile_mode=update) has run and the user has committed the lock. Any edit ofCargo.lockdoes this.The first patched build rewrites
MODULE.bazel.lock. In hosted mode the lock then names the crate file on the patch host, token segment included, asCargo.lockand.cargo/config.tomlalready name the index.The undo leaves Bazel's lock behind. socket-patch's files are back at once;
MODULE.bazel.lockis the one of the patched build until the next build writes the one of before.The hub's cargo starts from an empty cargo home whenever the hub is evaluated, so each evaluation reads the registry index and downloads the crate file again: the stand-in was asked for the upstream crate file once more by the build after
rollback. In hosted mode the patch host has to be reachable at each of those evaluations.With rules_rust 0.56.0 (Bazel 7.7.2):
MODULE.bazel.lockhas no entry for the hub and a build writes no file. The undo restores the checkout at once, a frozen lock keeps passing,vendor --checkpasses after a build,vexattests the crate in vendored mode right after the build, and a second vendored scan reports the copyalready_vendoredand leaves it alone. The hub's cargo runs with the cargo home of its environment and asks a registry only for what that home does not hold: the build afterrollbacksent no request for the crate file. The tests give every Bazel process aCARGO_HOMEof their own for that reason.On both:
vexattests the crate after the patched build, and a second hosted scan applies the patch again without rewriting a file.Build is not hermetic - path dependency pulling in crate at ...for the copy (its source prints that for every path dependency; not asserted).error evaluating module extension ... crate), not one target. The flow holds cargo's two messages; the Bazel line is seen in the build output, not asserted.rollbackprints its usualreinstall_requiredwarning (not asserted); under Bazel the next build is that install.Not claimed
cargo_config, which is the README's hub as written: neither mode is tested there.lockfile),crate.spechubs,crates_vendor,crates_repositoryunder WORKSPACE, rules_rs.[workspace.dependencies], two versions of one crate, a crate with a build script.vexin a checkout with more than one patched crate.socket-patch repairunder Bazel: no flow runs it.BUILD.bazelinto the copy.Code review
A review of this pull request found eight things. Five are fixed here and three are left open.
vendor --checkexits 1 andvexwrites no document right after a patched build with rules_rust 0.75.0). The assertions stay, because they are what the release does. Each is now markedKNOWN GAPin a comment that says what a fix of the product changes in the test, the module docs name both under one heading, "Known gaps", and they come first under "Known behaviour the flows record" above.CARGO_HOMEand one more variable were set, soCARGO_NET_OFFLINE,CARGO_SOURCE_*,CARGO_REGISTRIES_*andCARGO_HTTP_*of the shell went through. Fixed in the harness: everyCARGO_*name is removed from every Bazel process of a test ("The shared harness edit").CARGO_BAZEL_REPINorREPINwas set, instead of keeping those names away from Bazel. Fixed by the same edit, which also removesREPIN; the check that stopped the test is deleted.asked_for, and its doc, its failure message, the evidence lines and the steps above say that the stand-in was asked for the crate file, with the count. Telling the two programs apart needs the stand-in to record more than the path of a request, which is a harness change, so it is not asserted.bazel-cargo.ymlname files that exist; the PyPI module has such a test for its caller. Not changed here.The three open items belong to one change of the harness for all five modules, not to the pull request that adds one of them.
Decisions for the owner
cargo_config, because that is the only hub a stand-in registry can reach. The README hub as written stays without a test unless a flow may fetch a real crate from crates.io. Is that acceptable?BUILD.bazelin the copy, cargo home of the environment) stays covered. One release for all three would drop a 155 MB cache and that coverage.vendor --checkfails andvexattests nothing in vendored mode, and the next vendored scan downloads the crate again, all because cargo-bazel writes aBUILD.bazelinto the vendored copy. The staleMODULE.bazel.lockafter a scan is a separate rough edge with a cause of its own. Fix the gaps before more Cargo flows land, or after?Generated by Claude Code