Repository navigation
Make vendored mode work for a NuGet package of a rules_csharp hub, or decline it - #2223
Mikola Lysenko (mikolalysenko) wants to merge 6 commits into
Conversation
…b on real Bazel
Tests only. rules_csharp's `nuget.from_lock` downloads every package of
`packages.lock.json` from the package sources of `nuget.config` and holds
each file to the lock's `contentHash`. The real-Bazel NuGet flows ran
hosted mode in that workspace, and vendored mode in none.
nuget::vendored_from_lock records what vendored mode does there today, on
the machine that restored the project:
- `scan --mode vendored --yes` exits 0 with status `success` and reports
the package vendored. It downloads the patched package from the patch
service once and keeps it at
`.socket/vendor/nuget/<uuid>/<id>.<version>.nupkg`, names that folder
as a package source in `nuget.config`
(`<add key="socket-patch-<uuid>" value=".socket/vendor/nuget/<uuid>" />`,
with a source mapping) and re-pins the lock to the patched package.
`vex` attests the package.
- The next `bazel build` fails. NuGet takes a folder as a package source;
the hub reads the same line as the URL of a feed. Bazel 9.3.2 crashes in
the module extension (exit 37, "NullPointerException thrown during
Starlark evaluation"); Bazel 8.8.2 and 7.7.2 refuse the URL ("Bad URL:
.socket/vendor/nuget/<uuid>"). Bazel asks no host for the package and
changes no file.
- `vendor --revert` puts every file back, and the build with them.
The flow records a defect: a command that exits 0 leaves a build broken.
It is here so that the change which removes the defect shows as a change
of this test's expectations.
The grant names the patched package by its URL on the patch host, and
vendored mode downloads it itself, so the flow passes `--patch-server-url`
with the loopback stand-in, which serves the package under the path of
that URL. No build and no command reaches nuget.org or a Socket host.
Run on Bazel 9.3.2, 8.8.2 and 7.7.2 on macOS arm64: the flow passes on
each, in about ten seconds. The workflow's comments name the flow.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… decline it
Vendored mode commits the patched package under
`.socket/vendor/nuget/<uuid>/`, names that folder as a package source in
`nuget.config` and re-pins the lock. NuGet takes a folder as a source.
rules_csharp's `nuget.from_lock` reads the same line as the URL of a feed:
after `scan --mode vendored` had exited 0 and reported the package
vendored, the next `bazel build` crashed Bazel 9.3.2 in the module
extension (exit 37) and failed on 8.8.2 and 7.7.2 with `Bad URL:
.socket/vendor/nuget/...`. That is the flow of the previous commit.
What the hub does take
A feed `file:<folder>`, which Bazel reads from the root of the workspace,
with the package at `<folder>/<id>/<version>/<id>.<version>.nupkg`; and
the last `nuget.from_lock` that has `feeds` decides the hub's sources
(`_nuget_impl` in csharp/extensions.bzl at 0.5.0). So in the root of a
Bazel workspace whose one `nuget.from_lock` reads the project's lock,
`scan --mode vendored`, `get --mode vendored` and `vendor` now write:
- the package at
`.socket/vendor/nuget/<uuid>/<idLower>/<version>/<idLower>.<version>.nupkg`,
the one copy;
- `nuget.config` with that directory as the source, so `dotnet restore`
outside Bazel takes the same file, and the lock as before;
- one block at the end of the root `MODULE.bazel`, after one blank line:
# >>> socket-patch: NuGet patches for Bazel (managed block: socket-patch writes and removes it) >>>
socket_patch_nuget = use_extension("@rules_csharp//csharp:extensions.bzl", "nuget")
socket_patch_nuget.from_lock(
feeds = [
"file:.socket/vendor/nuget/<uuid>",
"https://api.nuget.org/v3/index.json",
],
packages_lock_json = "//:packages.lock.json",
)
# <<< socket-patch <<<
A second tag of the same hub, after every tag of the user's: the folder
of each vendored patch, then the sources the hub had without the block
(those of the tag's `nuget_config`, read line by line as the ruleset
reads them, or else its `feeds`), with the label of the user's
`use_extension`, their `packages_lock_json`, and the hub's `name` where
the tag gives one. No call of the user's is edited.
On Bazel 9.3.2, 8.8.2 and 7.7.2 with rules_csharp 0.5.0 the build then
prints the patched marker and asks no host for the package, also with the
stand-in stopped, a new output base and the package in no repository
cache. One changed byte of the committed package fails the build
("Checksum was ... but wanted ...") and `vendor --check`. `bazel query
//...` lists what it listed. `vendor --check`, `list` and `vex` see the
package as any vendored NuGet package, and a later vendored run keeps the
block in step with the tag (a source added to `nuget.config` reaches it).
The undo
`vendor --revert`, `rollback` and `remove` take the folder of a patch out
of the block, and the block goes with its last folder: `MODULE.bazel` is
then byte for byte what it was. With one vendored patch every other file
is too. With several, `nuget.config` can keep the source mapping that the
first of them created: once another patch has changed the file, the
config revert takes out only the two elements of its own patch, as it
does without Bazel.
A block that was changed by hand cannot be taken out. Reverting the lock
and the config beside it would leave the hub holding the committed
package to the upstream `contentHash`, and the build would fail after an
undo that exited 0. So the undo checks the block before its first write
and fails with nothing changed (`revert_failed` from `vendor --revert`,
`vendor_revert_failed` from `rollback` and `remove`, exit 1). The message
names the line of the block and the two ways on: put the block back as
socket-patch wrote it, or delete it, and run the command again.
Where it declines
The block is written only where the checkout shows that it works.
Otherwise the package is refused with `vendor_nuget_bazel_workspace`
through `vendor::refusals::bazel_workspace_refusals`, the dispatch that
Composer's refusal uses: before any download, a `failed` event, exit 1; a
dry run of `scan` or `get` lists it and exits 0; a hosted pin stays, and
its eject says `kept hosted: ...`. The detail names the reason, with file
and line where there is one, and `--mode hosted`. The reasons:
- the project is below the root of its workspace, or another workspace
lies above it in the checkout (built from there, Bazel reads the folder
from the other root);
- more than one `nuget.from_lock`, or tags that cannot be read with
certainty; a tag that is not a call of its own with every argument
written out, or on an isolated or dev-dependency `use_extension`;
- `local_package_dirs`, which the hub asks before every feed, and
`netrc` or `auth_patterns`, which the block was not built with;
- a `nuget_config` that cannot be read, a source that cannot stand in a
string;
- `feeds` beside a `nuget_config` that has no package source. The run
names its folder in that file (and nuget.org, where NuGet had it by
default), rules_csharp takes the sources of a `nuget_config` in place
of `feeds`, and so would the next run: it would write the block
without the tag's feeds, and a package that only they hold would fail
the build after a run that exited 0. Hosted mode withholds in the same
shape, with the same way on: name the feeds in the file;
- `MODULE.bazel.lock` does not show that Bazel selected rules_csharp
0.5.0;
- the checkout does not name Bazel 9.3.2, 8.8.2 or 7.7.2 (`.bazelversion`,
`.bazeliskrc`). The block rests on Bazel reading a relative `file:` URL
from the root of the workspace, which Bazel does not document, and
9.1.0 has other code for such a URL than 9.0.2 and 9.1.1
(DownloadManager.java), so no release is taken for its neighbour's
sake;
- an rc file names `--repository_disable_download` or `--vendor_dir`, or
a directory at the root holds `VENDOR.bazel`;
- an rc file names a remote downloader
(`--experimental_remote_downloader`), which takes no `file:` feed. Read
in Bazel's source and not built: 7.7.2 hands the feed to the
downloader, which cannot read the folder, and 8.8.2 and 9.3.2 download
every package of the lock without it
(GrpcRemoteDownloader.java);
- `MODULE.bazel` is a symbolic link, or its block was changed by hand.
`--allow-vendored-in-bazel` (SOCKET_ALLOW_VENDORED_IN_BAZEL) lifts the
refusal, and the package is vendored as in a project without Bazel. The
help text, the contract and the docs said that Composer's was the one
refusal the switch lifts; they now name both. A package that is wired
already passes without the switch, as Composer's does.
Nothing changes for a NuGet project in no Bazel workspace, and for one
whose locks no `nuget.from_lock` reads: the same files, byte for byte,
and no line of `MODULE.bazel`.
Hosted mode beside the block: the block's tag is the hub's last one, so
hosted mode writes nothing for another package of the project
(`redirect_bazel_nuget_config_undeclared`) and now says to vendor that
package too or to take the vendored ones out, instead of telling the user
to edit the block.
How
- bazel/nuget.rs: `vendored` reads the tags (without the block), the
ruleset's release, the Bazel release and the rc files through the
existing readers, and gives the block's contents or the reason;
`with_folder` and `without_folder` edit the block.
- bazel/block.rs is new and holds what the Maven block and this one
share, moved out of bazel/maven.rs: finding a block by its first line,
putting one at the end of a file in the file's line break, cutting it
out to the byte, and the file as it reads without it. `proxy` (the
label of a `use_extension`), `asked` and the stale check of a ruleset's
release are shared from maven.rs as they are.
- vendor/nuget_feed.rs decides the layout, writes the block after the
lock, records it in the ledger (`nuget_bazel_feed`, which may name the
root `MODULE.bazel` alone) and reverts it; a failed block write unwinds
the config and the locks, and a revert asks the block before it writes.
- vex/discover/nuget.rs and vendor/path.rs read the package below
`<idLower>/<version>` as well.
Limits, all in docs/ecosystems.md "Bazel workspaces: NuGet": the block
works in the root module only; a module this one depends on with its own
`nuget.from_lock` sources replaces the block's feeds; `--nofetch`, in an
rc file or on a command line, and a vendor directory made before the
patch, can build the unpatched package with exit 0; a machine whose
repository cache holds the package under the sha256 of Bazel's lock
builds the cached, patched file and does not read a changed or missing
copy, which `vendor --check` catches; a checkout deleted and made again
under a running Bazel server does not find the package until the server
restarts; a frozen lock fails right after the run, as in hosted mode;
three WARNING lines per other package and vendored patch when the
extension runs. An earlier release does not know the layout or the
block: on a checkout this one vendored its `vendor --check` fails, its
vendored run writes a second copy, and its `vendor --revert` exits 0 and
leaves the block and the package beside the restored lock, so the Bazel
build fails (measured on 9.3.2); undo with the release that vendored.
Built on macOS arm64, with packages that carry no signature.
"Bazel workspaces: what is supported" in the same file follows: the
NuGet row of its table says vendored mode is supported with the Bazel
release in `.bazelversion`, and VEX with a vendored patch as well; the
list of what was tested names the shape; NuGet leaves the known problem
"vendored mode ... the next Bazel build fails" for an entry of its own
(the switch, a package an earlier release vendored, and the two shapes
the checkout does not show); the build that may not fetch is listed
among those that pass on the unpatched package; and "Bazel workspaces:
VEX" names the vendored flow and the cases in which the document says
`not_affected` of a package whose block is not in `MODULE.bazel`.
Tests: nuget::vendored_from_lock now holds the flow above on real Bazel,
with one decline (a checkout that names no release: nothing written, the
build still passes on the upstream package) and the document of `vex`,
which names the package.
nuget::vendored_mode_keeps_the_block_or_declines runs the commands
through the binary without Bazel: the unchanged layout without a hub,
the block and its three undos, the three undos beside a block that was
changed by hand (exit 1, no file changed, then the undo once the block is
deleted), the declines, the eject and the switch.
Unit tests cover the gate row by row, the block's text and its byte-exact
undo, the ledger record, the revert beside a changed block wherever its
record stands, and the path git is asked about for a hub's package. The
`bazel` group of the line budget follows the code, 3337 to 3758.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main gained the gem_checksums withhold and the scan of a pinned Maven hub. Two conflicts: - crates/socket-patch-core/src/bazel/maven.rs, the imports: main's `build_maven_purl` is kept; the line-ending helper is no longer imported there, because this branch moved the code of the managed block, its only user outside the tests, into bazel/block.rs. - scripts/loc-budget.json: the cap of the `bazel` group is the count of the merged tree, 4036. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…atch and a second run Four defects of vendored mode for a NuGet package of a rules_csharp hub, each with a unit test. An undo that leaves `nuget.config` wired took the block out. When the config was written anew since the vendored run and still names the folder, the undo keeps the config, the lock pin and the package (`vendor_lock_entry_drifted`). The block went first all the same, so the hub read the folder in `nuget.config` as the URL of a feed and the Bazel build failed on a package that built before the undo. The block now goes last, after the lock and the config, and stays where the config is left wired. A lock that cannot be restored leaves the block too, so the build is as it was for the retry. A later patch of the same package left the earlier patch's folder in the block. The config keeps the earlier patch's source with its pattern set aside; the folder that source names is now taken out of the block when the later patch is written into it, so the block names the later folder alone and goes with it on the undo. The first run for a tag whose `nuget_config` has no package source wrote a block without nuget.org, and the second run added it: the run gives such a config nuget.org beside the folder, and the block was read before that. The block is now read from the tag after the config is written, so a second run writes no file. A lock that spells the package's version otherwise than NuGet writes it (`1.2.3.0` for `1.2.3`) was vendored, and the hub did not find the package: rules_csharp 0.5.0 asks a feed for the lock's `resolved` as it is written. Such a package is declined with `vendor_nuget_bazel_workspace`, by the backend and by the refusal every way in asks first. The refusal looked for the project's locks before it knew that the project is in a Bazel workspace; it asks for the workspace first. Also: one function for the folder of a hub's package in place of the two places of the backend that wrote it out, and the real-Bazel NuGet legs start on a push to main that changes the ledger or the artifact paths of vendored mode (vendor/state.rs, vendor/path.rs), which hold the record of the block and the place of a hub's package. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryHigh Risk Overview Shared Docs/CLI describe the new refusal and layout; CI bazel-nuget paths include vendored flow files; real-Bazel and hermetic e2e tests cover vendored success, decline, revert, and tamper cases. Reviewed by Cursor Bugbot for commit fadf0e9. Configure here. |
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>
|
[agent] PR shepherd: review brief for the approver What it does. In vendored mode, a NuGet package that a rules_csharp Risk: medium. It writes the user's root Look here
Verified
Changes I made. I updated the stale Open questions. Not blocking; the description already lists this. Make a second patch of the same package, then Update for
One leg fails: Generated by Claude Code |
Resolve the conflicts with the vendored Maven hub (#2207): keep both the uncache and cached harness helpers, keep with_patch on the shared block module and make it public as main needs, dispatch the Maven hub refusals next to the Composer and NuGet ones, and raise the bazel line budget by both sides' growth. Assisted-by: Claude Code:claude-opus-5-5
Vendored mode now works for a NuGet package that a rules_csharp
nuget.from_lockhub builds under Bazel: it keeps the package where the hub finds it and one managed block in the rootMODULE.bazel, and where the checkout does not show that the block works it declines the package withvendor_nuget_bazel_workspaceand writes nothing.Based on main, in three commits and a merge of main. The first commit is tests only and records what main does today; the second is the change, with the expectations of the first changed to match; the third, after the merge, holds the fixes of the code review below.
All of the Bazel support, this included, is being labelled experimental in the docs by another open pull request (#2222).
Decisions for the maintainer
MODULE.bazel: the block adds a secondnuget.from_locktag. Vendored mode appends one managed block there and removes it byte for byte, as hosted mode does for Maven. Unlike the Maven block, which overrides one repository, this one is a tag of the user's own hub: itsfeedsname the folder of each vendored patch and then the sources the hub had. It writes no other file of Bazel's. The alternative is to decline every NuGet package of a hub.MODULE.bazel.lockshows it, and Bazel 9.3.2, 8.8.2 or 7.7.2, named in.bazelversionor.bazeliskrc. A checkout on any other release, or one that names none, is declined. The block rests on Bazel reading a relativefile:URL from the root of the workspace, which Bazel does not document, and 9.1.0 has other code for such a URL than its neighbours. Taking ranges of releases is a small change, and a risk this change does not take.failed, exit 1, like the Composer refusal; a dry run ofscanorgetlists the package and exits 0. The alternative is a warning with exit 0.--allow-vendored-in-bazellifts the decline, and the Bazel build then fails. With the switch the package is vendored as in a project without Bazel, which the hub reads as a bad URL. That is for a project whose lock a tag names and which Bazel does not build. The alternative is that the switch does nothing for NuGet.vendor --revertand a new vendored run.vendor --revert,rollbackandremoveexit 1 and name the line of the block. The alternative is to revert the lock andnuget.configand leave the block with a warning: that exits 0 and leaves a Bazel build that fails on the committed package, with no command of socket-patch that gets out of it.vendor --revertexits 0, restores the lock and leaves the block and the package. The docs say to undo with the release that vendored. Whether the ledger should make an earlier release refuse such an entry is open; this change does not do it.--nofetchin an rc file does not. The first is read in Bazel's source and not built. With the second the build lags until the project's next fetch, as after any change of a lock, so it is a documented limit and no refusal. The same holds for a vendor directory made before the patch: socket-patch declines when it sees--vendor_dirin an rc file or a directory withVENDOR.bazelat the root, and it cannot see one named on a command line. In both cases the build takes the unpatched package and exits 0 with a warning of Bazel's.name, a tag withfeedsof its own, a tag withoutnuget_config, and two patches in one block. Each was built by hand on Bazel 9.3.2 and 7.7.2 and printed the patched marker; unit tests cover what is written for them. The cautious alternative is to decline them until a committed test builds each.vexdoes not read the block. For a vendored package whose block is not inMODULE.bazel(the switch, an earlier release, a block taken out by hand) it saysnot_affectedwhile the Bazel build fails. The docs list this..socket/vendor/nuget/<uuid>/<id>/<version>/<id>.<version>.nupkg(the id in lower case), the shape of a folder feed, andnuget.confignames<uuid>as before: one copy serves NuGet and Bazel. Every other NuGet project keeps the flat file. The alternative, one layout everywhere, changes what every vendored NuGet project commits.What the code does today
scan --mode vendored,get --mode vendoredandvendorcommit the patched package under.socket/vendor/nuget/<uuid>/, name that folder as a package source innuget.configand re-pinpackages.lock.json. NuGet takes a folder as a source. rules_csharp'snuget.from_lockreads the same line as the URL of a feed.So in a workspace whose hub reads the project's lock, the command exits 0 and reports the package vendored, and the next
bazel buildfails. Bazel 9.3.2 crashes in the module extension (exit 37,NullPointerException thrown during Starlark evaluation). Bazel 8.8.2 and 7.7.2 stop atBad URL: .socket/vendor/nuget/<uuid>. The first commit adds a real-Bazel test that records exactly this; the second changes its expectations.What changes
In the root of a Bazel workspace whose one
nuget.from_lockreads the project's lock, the three commands write:.socket/vendor/nuget/<uuid>/<id>/<version>/<id>.<version>.nupkg, with the id in lower case. It is the only copy.nuget.configwith that directory as the source, sodotnet restoreoutside Bazel takes the same file, and the lock as before.MODULE.bazel, after one blank line:The block is a second
nuget.from_lockof the same hub, after every tag of the user's. Itsfeedsare the folder of each vendored patch, which Bazel reads from the root of the workspace, and then the sources the hub had without the block: those of the tag'snuget_config, read line by line as the ruleset reads them, or else the tag'sfeeds. It carries the label of the user'suse_extension, theirpackages_lock_json, and the hub'snamewhere the tag gives one. No call of the user's is edited, and nothing is written to.bazelrcor.bazelignore.The build then takes the committed package and asks no host for it.
vendor --check,listandvexsee the package as any vendored NuGet package. A later vendored run keeps the block in step with the tag, so a source added tonuget.configreaches the hub once socket-patch has run again. A later patch of the same package takes the place of the earlier one's folder in the block.The undo.
vendor --revert,rollbackandremovetake the folder of a patch out of the block, and the block goes with its last folder:MODULE.bazelis then byte for byte what it was. With one vendored patch every other file is too. With several,nuget.configcan keep the source mapping that the first of them created, as it does without Bazel.The block goes last, after the lock and the config. A
nuget.configthat was written anew since the vendored run and still names the folder is left as it is with a warning (vendor_lock_entry_drifted), as without Bazel: its lock pin and its package stay, and so does the block, through which alone the hub takes that package.A block that was changed by hand is not taken out, and then nothing is. The three commands fail with exit 1 (
revert_failedfromvendor --revert,vendor_revert_failedfromrollbackandremove), nameMODULE.bazel:<line>and leave every file as it is: with the lock restored beside such a block the hub would hold the committed package to the upstreamcontentHash, and the build would fail. Put the block back as socket-patch wrote it, or delete it, and run the command again.Where it declines. The package is refused with
vendor_nuget_bazel_workspace, through the dispatch that the Composer refusal uses: before any download,failed, exit 1, nothing written. A hosted pin stays, and its eject sayskept hosted: .... The message names the reason, with file and line where there is one, and--mode hosted. The reasons:nuget.from_lock, or tags that cannot be read with certainty;use_extension;local_package_dirs, which the hub asks before every feed, ornetrcorauth_patterns;nuget_configthat cannot be read, or a source that cannot stand in a string;feedsbeside anuget_configthat has no package source. The run names its folder in that file, rules_csharp takes the sources of anuget_configin place offeeds, and the next run would write the block without the tag's feeds: a package that only they hold would then fail the build. Name the feeds in the file;MODULE.bazel.lockdoes not show that Bazel selected rules_csharp 0.5.0;--repository_disable_downloador--vendor_dir, or a directory at the root holdsVENDOR.bazel;--experimental_remote_downloader), which takes nofile:feed;MODULE.bazelis a symbolic link, or its block was changed by hand;1.2.3.0for1.2.3): the hub asks its feeds for the lock's spelling, and the folder holds the onedotnet restorewrites.--allow-vendored-in-bazel(SOCKET_ALLOW_VENDORED_IN_BAZEL) lifts the refusal. 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.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). It now says to vendor that package too, or to take the vendored ones out.Nothing changes for a NuGet project in no Bazel workspace, and for one whose locks no
nuget.from_lockreads: the same files byte for byte, and no line ofMODULE.bazel.Limits
nuget.from_lockwith sources of its own. The hub takes that tag after the block, and the build fails on the re-pinned lock. Hosted mode fails the same way.--nofetchin an output base that built the unpatched project, and a build from a vendor directory made before the patch, build the unpatched package and exit 0, with a warning of Bazel's. Such a build still rewritesMODULE.bazel.lockto the pins of the patched package. socket-patch sees--vendor_dirand--repository_disable_downloadin an rc file and a vendor directory at the root; it does not see--nofetch, in an rc file or on a command line.MODULE.bazel.lockrecords: Bazel builds the cached file there, which is the patched one.vendor --checkcatches the change on every machine.MODULE.bazel.lockis stale right after the run, as after a hosted run: a build with--lockfile_mode=errorfails until a build that may update the lock has run.WARNING: Download from file:...lines for every other package of the lock, for each vendored patch, when the module extension runs.nuget.configreaches the hub only after socket-patch has run again.vendor --checkfails (vendor_check_failed), its vendored run writes a second copy of the package in the folder of the patch, and itsvendor --revertexits 0, restores the lock and leaves the block and the package: the Bazel build then fails on the lock'scontentHash(measured by hand on Bazel 9.3.2). Undo with the release that vendored.Each of these is in docs/ecosystems.md, "Vendored mode under a rules_csharp hub".
Code review
A review of the whole change at the merge gave seven findings. Each was checked against the code, and those about the hub against the source of rules_csharp 0.5.0. The third commit holds the fixes.
Fixed:
nuget.configwired took the block out. Where the config was written anew and still names the folder, the undo keeps the config, the lock pin and the package. The block went first all the same, so the hub read the folder innuget.configas the URL of a feed, and the Bazel build failed on a package that built before the undo. The block now goes last and stays where the config is left wired. A lock that cannot be restored leaves the block too.nuget_confighas no package source. The run gives such a config nuget.org beside the folder, and the block was read before that. It is now read from the tag after the config is written.resolvedas it is written. Such a package is declined, by the backend and by the refusal that every way in asks first.dotnet restorewrites the normalized version, so this needs a lock written by hand.Fixed in part:
vendor/path.rsandvendor/state.rs, which this change touches for the layout and the ledger record. Both are in the push list now. They are not in the pull request list: every ecosystem's vendored mode shares them, and the workflow keeps shared engine code out of that list by its own rule.Not fixed:
MODULE.bazel, its lock and the rc files. An answer kept across packages would have to be dropped after every write of the block, and a stale one writes a wrong block; the cost did not seem worth that.Each of the four behaviour fixes has a unit test. The tests were not run against the code of before the fixes.
Contents
bazel/nuget.rsbazel/block.rs(new)bazel/maven.rsblock.rs; shares the label of ause_extensionand the release check of a rulesetbazel/mod.rsvendor/nuget_feed.rsvendor/refusals.rs,path.rs,state.rs,mod.rsvex/discover/nuget.rs<id>/<version>args.rstests/e2e_bazel_build/nuget.rs,harness.rsdocs/ecosystems.md,CLI_CONTRACT.mdbazel-nuget.yml,scripts/loc-budget.jsonbazelcap, 4041 after the merge and the fixes (main: 3615)vendor/nuget_feed.rs+169 −35 and unit tests +135;bazel/nuget.rs+35 −11 with its test; the docs, the contract row, the workflow's push list, the capImplementation of the first two commits: +1042 −167 lines, 629 code lines net. Unit tests +830. The first commit is tests only (+170 −1, and 4 lines of the workflow's comments).
What it proves, and where
Everything below ran on macOS arm64, with rules_csharp 0.5.0 and packages that carry no signature. No build and no command reached nuget.org or a Socket host.
nuget::vendored_from_lockon real Bazel 9.3.2, 8.8.2 and 7.7.2. A checkout that names no release is declined and its build stays on the upstream package. With.bazelversion, the scan writes the layout and the block;vendor --checkpasses;vexnames the package;bazel query //...lists what it listed. The build prints the patched marker with no request for the package, and again with the registry stand-in stopped, a new output base and the package out of the repository cache. One changed byte failsvendor --checkand the build.vendor --revertrestores every file and the upstream build. The two hosted NuGet flows pass beside it on the three releases.nuget::vendored_mode_keeps_the_block_or_declines, through the binary without Bazel: the unchanged layout outside a hub; the block and its three undos; the three undos beside a block changed by hand (exit 1, no file changed, and the full undo once the block is deleted); the declines byscan,get, a dry run and for a person, among them the tag withfeedsbeside a config without a source; the eject; and the switch.feedsalone, a tag withoutnuget_config, a patched package as a transitive dependency, a private source innuget.config, CRLF files and two patches each built the patched package, and the upstream build came back after the undo.After the merge of main and the review fixes
The merge had two conflicts: the imports of
bazel/maven.rs, and thebazelcap ofscripts/loc-budget.json, which is the merged count.cargo checkof the workspace with all targets, clippy as CI runs it, 397 unit tests of the modules this change touches, ten CLI test targets, the three NuGet flows on real Bazel 9.3.2 (3 of 3) and the Maven flows on real Bazel 9.3.2 behind a proxy that logs every request (5 of 5; no request to a public Maven host).e2e_bazel_buildwithout Bazel (66),in_process_vendor(157),e2e_vex_vendor(39),vendor_revert_tamper_e2e(25) ande2e_nuget(2). All pass.nuget::vendored_from_lockruns through; the hermetic flow through the binary passes. The legs in GitHub Actions run them when the pull request leaves draft.Not covered
name, a tag withfeedsof its own, a tag withoutnuget_config, two patches at once, a patched package with dependencies of its own. They were built by hand only.file:feed to the downloader; 8.8.2 and 9.3.2 download every package of the lock without it). No build ran with one.nuget.configkeeps the first patch's source mapping is main's behaviour without Bazel too, and is not changed here.dotnet restoreof the new layout ran in a test.vendor --revertthen puts back the config and the lock pin of the first patch, whose folder the second run removed. That is main's behaviour without Bazel too and is not changed here; with a hub, the block is gone as well.Generated by Claude Code