Repository navigation
Vendor a Maven patch for a pinned rules_jvm_external hub of Bazel - #2207
Conversation
Hosted mode patches a pinned rules_jvm_external hub: one block in the
root MODULE.bazel puts a repository with the patched jar in the place of
the hub's own. Vendored mode has no test on a real Bazel for such a
hub. This adds one, in the checkout whose only build is Bazel's, and
records what the code does there today.
`socket-patch get <purl> --mode vendored --yes` exits 1. Its event is
`failed` / `vendor_jvm_shape_unsupported` ("no_build_file: no pom.xml,
Gradle, sbt or scala-cli build at the project root"): vendored mode
knows a Maven artifact only as the dependency of one of those builds.
Its one warning is `maven_bazel_hub_unpatched`, which names the hub's
lock and says that the Bazel build stays unpatched. It writes no file
and downloads no jar, the build prints the upstream marker before and
after, and `vendor --revert` has nothing to take out.
The flow asserts that refusal by its code and text, so that a commit
which makes vendored mode patch the hub has to change the expectation.
For a vendored run the test's stand-in now serves what such a run asks
the patch service for: the patched jar at the path of the grant's own
URL for it, with its sha512, and the record of the patch, whose one file
is the one that differs from the upstream jar of the run. A vendored
command is given `--patch-server-url`, so that the URL's host is the
stand-in. The hosted flows read neither.
Run on macOS arm64 with Bazel 9.3.2 (rules_jvm_external 7.2), every
child behind a logging proxy that refuses public Maven hosts: the five
Maven flows pass in 74 s, with no request to such a host.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Hosted mode patches a pinned rules_jvm_external hub of a Bazel workspace
with one block at the end of the root MODULE.bazel: per patch an
`http_file` of the patched jar on the Socket patch host, and Bazel's
`override_repo` of the repository through which the hub fetches that
jar. Vendored mode patched no hub. In a checkout only Bazel builds,
`get <purl> --mode vendored` failed with `vendor_jvm_shape_unsupported`
("no pom.xml, Gradle, sbt or scala-cli build"), and beside a Maven or
Gradle build it vendored for that build and said that the Bazel build
stays unpatched.
With this commit `socket-patch vendor`, `scan --mode vendored` and
`get --mode vendored`, run at the Bazel root, commit the patched jar for
the hub: the jar is downloaded once, from Socket's patch service, and the
build then needs no host. No upstream registry is asked.
What is written
.socket/vendor/maven/<patch uuid>/REPO.bazel
.socket/vendor/maven/<patch uuid>/file/BUILD.bazel
.socket/vendor/maven/<patch uuid>/file/<artifact>-<version>.jar
.socket/vendor/maven/<patch uuid>/.gitignore
and, in the same block of MODULE.bazel, an entry whose repository is
that directory:
socket_patch_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
# pkg:maven/<group>/<artifact>@<version>, Socket patch <uuid>
socket_patch_local_repository(
name = "socket_patch_<repository>",
path = ".socket/vendor/maven/<uuid>",
)
followed by the comment and the `override_repo` of a hosted entry. A
block binds the rule of each kind of entry it holds, `http_file` first,
so a block of hosted entries is byte for byte what it was.
- The hub takes the jar of a repository by its target `//file`
(`@<repository>//file` in the ruleset's dependency_tree_parser.bzl at
6.5, 6.9 and 7.2, copied to the hub's own path), so the BUILD file is
one public filegroup `file` over the jar, whose name does not matter:
it is the upstream jar's.
- `local_repository` and `new_local_repository` are in
`@bazel_tools//tools/build_defs/repo:local.bzl` at Bazel 7.4.0, 7.7.2,
8.8.2 and 9.3.2, and take a `path` from the workspace root
(`rctx.workspace_root.get_child`), not from the file that names it.
`local_repository` links the repository to the directory: nothing is
copied or downloaded, and the repository cache holds no copy of the
jar. Bazel refuses a linked repository without a boundary file ("No
MODULE.bazel, REPO.bazel, or WORKSPACE file found", in
StarlarkRepositoryFunction.java at 7.4.0, 7.7.2 and 8.8.2 and
RepositoryFetchFunction.java at 9.3.2), hence REPO.bazel, which holds
three comment lines. `new_local_repository` with an empty
`build_file_content` also built patched on 9.3.2 without REPO.bazel
(two files instead of three); `local_repository` is the rule Bazel
documents for a directory that has a BUILD file, and it generates
nothing.
- The `.gitignore` is `!*`: a `*.jar` rule of the checkout (the stock
Java one) would drop the jar from the commit. A rule that ignores the
directory itself is refused (`vendor_artifact_gitignored`), as for
every vendored artifact.
- The directory is the unit `.socket/vendor/<ecosystem>/<patch uuid>`
that every vendored artifact has, not a directory by the repository's
name: the ledger, `vendor --check`, `vex`, `repair`, the orphan sweep
and the guard against a linked vendor directory then hold for it as
they are.
- `.bazelignore` gets `.socket/vendor/maven` under a comment line of its
own, by the rules of the Go lines (added while the directory exists,
removed with it, the user's own line or commented-out line respected,
`bazelignore_not_updated` when it cannot be written). Without it
`bazel query //...` lists `//.socket/vendor/maven/<uuid>/file:file`;
the build is the same with and without the line.
- The patch is recorded in the vendor ledger. For a patch that only the
hub takes: ecosystem `maven`, flavor `bazel`, the committed jar as the
artifact, and no wiring records, because the block is read from
MODULE.bazel and from nowhere else.
Integrity
Bazel checks the sha256 of an `http_file` and nothing of a directory: a
changed committed jar is built (measured, and asserted in the flow). No
rule of Bazel's own checks a digest of a file of the main repository, and
a Starlark rule committed into the user's tree is not written. The check
is `vendor --check`, in a checkout only Bazel builds and beside a Maven
or Gradle build alike. It fails when the jar that Bazel builds is not,
byte for byte, the vendored jar whose sha256 the ledger records (beside
a build the hub's jar is a copy of that build's, with the same sha256:
a jar that keeps the patch's files and differs elsewhere fails too);
when REPO.bazel or file/BUILD.bazel is not the file that was written (a
BUILD file that names another jar); when the block no longer names the
directory or was changed by hand; and when the entry is one a build
stops at or may pass without: no pinned hub takes the jar at that
version any more, for which the reason ends with `socket-patch rollback
<purl>` (the undo is what takes such an entry out, and a vendored
`get` of that purl now ends with the same words), or an rc file
switches the entry off. `vex` hashes the same jar before it attests.
When no entry is written
The decision is the hosted lane's (`bazel::maven::site`, now with a
`vendored` flag), with the same codes and texts: `maven_bazel_not_at_root`,
`_not_pinned`, `_unreadable`, `_release`, `_artifact`, `_no_effect`. Not
`maven_bazel_download`: an option about downloads (a downloader config,
`--repository_disable_download`, `--vendor_dir`) does not stand against
a jar in the checkout. A build with `--repository_disable_download` was
run on 9.3.2 and is patched; that Bazel's vendor mode leaves a local
repository alone is read (RepositoryDelegatorFunction.java at 7.4.0,
RepositoryFetchFunction.java at 9.3.2), not run.
- In a checkout with no Maven, Gradle, sbt or scala-cli build the hub is
the patch's only target: the patch fails with that code (exit 1, as a
vendored refusal does) and nothing is written. The decline comes from
`vendor::refusals::bazel_workspace_refusals`, the one dispatch of the
vendored refusals that rest on a Bazel workspace, so a scan, a `get`,
a `vendor` and the eject of hosted pins all take it before anything
is downloaded. `--allow-vendored-in-bazel` does not lift it: the
switch is for a build that may not find a vendored copy, and here no
entry could be shown to work and there is nothing else to write. A
jar that no hub builds still fails with `vendor_jvm_shape_unsupported`.
- Beside such a build, that build is vendored exactly as without the
workspace, the hub gets a copy of the same jar when the build took the
patch, and a hub that cannot be given one is a warning with the code
and the reason, in the place of `maven_bazel_hub_unpatched`.
Switching modes, and the undo
- One entry per jar. A vendored run puts its entry in the place of a
hosted one. `vendor` ejects a hosted patch that only the block wires
where the hub is the project's one build. Beside a Maven or Gradle
build it ejects no such patch, and the entry stays hosted, unless the
same run vendors that patch for the build (a patch of the manifest,
or a pin that the build's own files hold too): the hub's entry is
then the vendored one, and `vendor --revert` takes it out.
- Before `vendor` takes a hosted entry out, the hub is asked about the
checkout as it is, in the eject's preflight (the same dispatch, before
any record is fetched). Where no vendored entry would be written, the
eject is refused whole (`eject_refused`, nothing changed), and the
reason starts with "kept hosted: " and ends with "socket-patch left
the entry that MODULE.bazel holds for it as it is": the Bazel build
keeps the hosted jar.
- A hosted run over a patch that only the hub takes reverts the vendored
entry, its directory, its `.bazelignore` line and its ledger entry
first (the existing vendored-to-hosted takeover), and the checkout is
then the one a hosted run alone leaves. Beside a Maven build the
ledger entry is that build's and no takeover reverts it, so the hosted
run itself removes the hub's directory once its entry is in the place
of the vendored one and nothing names the directory, and the
`.bazelignore` line goes with it. The vendored tree of the Maven build
stays, as it does without the workspace.
- `vendor --revert`, `rollback` and `remove` take the entry out, then
the directory: every file is byte for byte what it was, but for a
`.bazelignore` that was an empty file of the user's, which is deleted
with the last line, as for the Go lines. A MODULE.bazel that names
the directory outside an entry of the block (a block changed by hand)
fails the undo before anything is removed: Bazel stops at a
`local_repository` whose directory is gone.
- `repair` puts a lost or changed jar back; for this artifact it writes
the jar alone, not a pom beside it.
Also
- `list` shows the patch as vendored; discovery reads the vendored entry
as vendored wiring of the committed jar, withheld like a hosted entry
when the hub no longer fetches that version or an rc file switches the
block off.
- The jar's directory beside a Maven or Gradle build belongs to that
build's ledger entry: the orphan sweep and both checks of `repair` and
`vendor --check` for wiring without a ledger entry take a JVM entry
for the owner of `maven/<uuid>`, and read MODULE.bazel for a directory
it still names. `repair` on such a checkout finds nothing to do.
- Beside a Maven or Gradle build, a `vendor` that finds that build in
sync and the hub's copy missing or changed, or its entry gone, writes
them again and reports `vendor_artifact_rebuilt`.
- Beside a Maven or Gradle build `vex` hashes the jar of that build's
tree, as before, not the hub's copy.
- What a person reads. After a run that wrote for a hub, alone or
beside another build, the files to commit name MODULE.bazel and
.bazelignore with .socket/vendor/. For a hub alone the next step is
`bazel build //...` ("MODULE.bazel names their directory"), the undo
names no install to resync and gives no `reinstall_required`: no
installed tree holds the jar. A decline names the purl once.
Tests
Unit, socket-patch-core: the entry and its four files, the declines, and
the warnings of a vendored run (bazel::maven:
`a_vendored_entry_names_the_directory_of_its_patch`,
`a_vendored_entry_is_declined_as_a_hosted_one_but_for_downloads`,
`a_vendored_run_is_warned_of_the_jars_it_wrote_no_entry_for`); the pair
of .bazelignore (`the_jars_of_a_hub_have_a_pair_of_their_own`); the undo
and the ignored directory (vendor::maven_repo:
`the_revert_takes_the_hub_entry_out_before_its_directory`,
`a_hub_directory_that_git_ignores_is_refused`); the way back to hosted
(`a_maven_patch_of_a_bazel_hub_alone_is_in_reach`,
`a_hosted_run_drops_the_hub_directory_that_nothing_names`); discovery
(`an_entry_that_names_a_directory_is_vendored_wiring`) and a row of
`what_is_not_an_entry_of_the_pin`. Unit, socket-patch-cli:
`orphan_sweep_keeps_the_jar_of_a_bazel_hub`, and the commit hint and the
install command of the `bazel` flavor.
Without Bazel (tests/vendor_jvm_cli.rs):
- `vendor_gives_a_pinned_bazel_hub_the_patched_jar`, alone and beside a
Maven reactor: the four files, the block, the ledger entry, a rerun
that changes nothing and downloads nothing, `vendor --check`, `list`,
`repair`, `vex`, a changed jar, a jar that keeps the patch's file
beside a member of its own, a changed BUILD file, a MODULE.bazel
without the entry, a block changed by hand, a lock that no longer
pins the jar, a lost jar put back by `repair` and by `vendor`,
`vendor --revert`, `rollback` and `remove`, each back to the bytes of
before, and the lines a person reads.
- `vendor_declines_for_a_hub_it_cannot_patch`: the code, the exit,
nothing written, and no warning that repeats the failure.
- `vendor_leaves_the_hosted_entry_of_a_bazel_hub_in_place` also holds
`vendor` over a hosted entry beside a Maven build whose hub it can
patch (the vendored entry in its place, taken out by `vendor
--revert`), and in a checkout only Bazel builds: the vendored entry
in its place, or, for a hub it declines, the checkout unchanged and a
reason that says the hosted entry stays.
- tests/e2e_bazel_maven_beside.rs,
`a_hosted_run_removes_the_jar_vendored_mode_kept_for_the_hub`: a
hosted `get` beside a pom, over a vendored entry, leaves the hosted
block and neither the directory nor the `.bazelignore` line.
With a real Bazel (tests/e2e_bazel_build/maven.rs, the patch host played
by a local server):
- `a_vendored_patch_in_a_tree_only_bazel_builds` takes the place of the
flow of the previous commit: the build prints the marker of the
patched jar and changes no file, a `--lockfile_mode=error` build
passes, `bazel query //...` lists no package under .socket, `list` and
`vex` see a vendored patch, `vendor --check` fails for a changed jar
that Bazel builds all the same, a second output base builds patched
with the local server stopped while the repository cache holds the
hub's jar and not the patched one, and `vendor --revert` restores
every file and the first build. On a Bazel before 7.5.0 it first holds
the decline of a checkout that names no release: the failure is the
first event, before a download.
- `a_hub_goes_from_hosted_to_vendored_and_back`: `vendor` over a hosted
entry, `get --mode hosted` over the vendored one, the vendored command
again, and `rollback`; one entry for the jar at every step.
- The harness's local server is no longer taken from wiremock's pool,
so that stopping it closes its port. Every flow of the target starts
its server this way now.
Existing expectations that change:
- `a_bazel_hub_that_builds_a_vendored_jar_adds_one_warning_and_nothing_else`:
its checkout names no Bazel release, so the warning is now
`maven_bazel_release` with that reason, where it was
`maven_bazel_hub_unpatched`.
- `a_takeover_leaves_the_entry_of_a_bazel_hub` (unit): a pin that only
the block wires is among the pins of an eject where the hub is the
only build, and still not beside a pom.
- The flow of the previous commit, which recorded the failure.
Docs: "Bazel workspaces: Maven" in docs/ecosystems.md, and in "Bazel
workspaces: what is supported" the Maven row (vendored: "Supported with
Bazel 7.4.0 or later"; VEX: "Supported with a hosted or vendored patch")
with its entries. No entry is added to the known problems: no state was
found in which a vendored command exits 0 and the next Bazel build
fails. The rows of the codes in CLI_CONTRACT.md. bazel-maven.yml starts
its legs for a change to vendor/maven_repo.rs and vendor/refusals.rs too.
Run on macOS arm64, every child behind a logging proxy that refuses
public Maven hosts: the six Maven flows pass on Bazel 9.3.2 (118 s),
8.8.2 (124 s), 7.7.2 (78 s) and 7.4.0 (72 s), with no request to such a
host. With a binary built from the previous commit the two new flows
fail on 9.3.2. Outside a Bazel workspace this binary and that one print
the same bytes and leave the same files for twelve commands on a Maven
reactor and on a Gradle build.
Not here: `scan` does not find the artifacts of a hub (it vendors a
hub's jar for a package it found elsewhere); an artifact that a Maven
build beside the hub does not use at the patch's version is skipped as
before, where hosted mode patches the hub; agent mode is not supported
for a Bazel build and patches no hub; a hub without a lock and a
`maven_install` of a WORKSPACE file are declined.
scripts/loc-budget.json: bazel 2486 -> 2656.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Each was a state after exit 0 that the change did not hold: - `repair` of a patch that only the hub takes put back the jar alone. A directory that was lost whole then had no REPO.bazel and no BUILD file, and Bazel stopped at the entry that names it. It now writes the other files of the directory as well. - A vendored run said nothing of a decline whenever the block held an entry for the jar. With an rc file that switches the block off, or an override of the jar, the build takes the upstream jar past that entry: the run now warns `maven_bazel_no_effect`, as a hosted run does. Any other entry stands and is not warned of, as before. - The directory of an earlier patch of a jar stayed when a later patch, vendored or hosted, took its entry's place beside a Maven or Gradle build, and `vendor --check` then called a patched build unpatched. Both runs now remove every directory under `.socket/vendor/maven` that MODULE.bazel no longer names and no ledger entry records, not only the ones of the patches the run wrote. - `vendor` took any jar at the hub's path for the vendored one when it carried the patch's files, with no ledger entry, and recorded that jar's own sha256. A committed jar is now taken as it is only when the ledger records its bytes; any other is replaced by the patch's own jar. - A hosted run that was declined counted a vendored entry of the same patch as its own pin and reported the patch as a hosted one. - Beside a Maven or Gradle build the hub's directory was written without the check that git would commit it, which the hub's own vendoring has. Where a rule ignores it the run now writes nothing for the hub and warns `maven_bazel_hub_unpatched` with that rule. A test fails for each without its fix: the vendored and the hosted table of bazel/maven.rs, and in vendor_jvm_cli a directory lost whole, a directory that nothing names, a jar planted without a ledger entry, and a directory that git ignores. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryMedium Risk Overview Lifecycle and edge cases: Vendored runs can replace hosted hub entries (and the reverse on hosted Supporting changes: Reviewed by Cursor Bugbot for commit 8976085. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ 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 8976085. Configure here.
The undo of a Maven patch took the vendored entry out of the block in MODULE.bazel before anything else, and read MODULE.bazel as absent on any read failure. - A MODULE.bazel that exists but cannot be read (not UTF-8, a FIFO, no permission) now fails the undo, `vendor --check` and the repair of a hub's directory. Only NotFound means "no hub", as the other vendor backends already treat their wiring files. Before, the undo deleted .socket/vendor/maven/<uuid>/ while the file might still name it. - unwire_hub now only plans the new text. revert_maven_opts writes it once the JVM revert (or the pre-v5 pom revert) has succeeded, and before the directory is removed. A refused or failed revert now leaves the block naming the directory that stays, so running the undo again still finds the entry and removes the directory. New tests an_unreadable_module_file_is_no_missing_one and a_refused_jvm_revert_leaves_the_hub_entry fail without the change. 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
|
[agent] PR shepherd: this one needs a maintainer's decision before it can be approved I found nothing wrong in the code I checked. It has no conflict, CI is green on e85b883 ( The description lists 12 "Decisions for the maintainer", so I'm not posting a merge brief. Two of them change what a user can rely on:
Please also confirm the other ten (mainly 4, 7 and 12: when Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Found a partial rollback path in mixed Bazel and JVM projects.
|
Decided by the maintainer on 2026-11-24: both questions stand as built. A hosted run removes the vendored directory of the entry it replaces (decision 8), and |
main generalized the .bazelignore sync to a table of copy directories (Go copies and the crates of a rules_rust hub) with one sync(go, cargo) call, and replaced rollback's unwired_any with a count of the packages that still hold patched bytes. The PR's change is re-applied on that structure instead of reverting it: - bazel/ignore.rs: .socket/vendor/maven is a fourth row of COPIES, added under the new `maven` flag of sync(); its comment line keeps the PR's wording, so the docs and the e2e tests are unchanged. sync_jars is gone; its unit test now drives sync(). - commands/mod.rs: sync_bazelignore passes the Maven scope to sync(). - rollback.rs: the reverted jars of a hub alone are left out of the still-patched count, as they were left out of unwired_any. - CLI_CONTRACT.md: bazelignore_not_updated names the crates and the jars; the PR's Maven rows and main's cargo row are both kept. - loc-budget.json: bazel max at main's 3518 (the merged count fits). Assisted-by: Claude Code:claude-opus-5-5
Main gained the hosted scan that takes the jars of the pinned rules_jvm_external hubs for packages, its removal of a stale entry of the block in MODULE.bazel (maven_bazel_entry_stale) and the warning for a hub that was not read (maven_bazel_hub_not_read). This branch adds the vendored entry of the same block. Both are kept whole. Conflicts, and how each was resolved: - crates/socket-patch-core/src/bazel/maven.rs: the module docs name hub_jars and the vendored entry; the code of both merged cleanly. - crates/socket-patch-cli/CLI_CONTRACT.md: this branch's maven_bazel_* rows, with main's clause on the 64 MiB of locks in maven_bazel_unreadable and main's new maven_bazel_hub_not_read row. - crates/socket-patch-cli/tests/e2e_bazel_build/maven.rs: one `grant`, with main's version parameter and returned patch record and this branch's route for the download of a vendored run. - docs/ecosystems.md: the limits of "Bazel workspaces: Maven" say what a hosted and a vendored scan do with a hub. - .github/workflows/bazel-maven.yml: the header names the flows of both. What the two do together: - A hosted scan that finds a hub's jar under a vendored entry writes what `get --mode hosted` writes there: the hosted entry in its place, and the directory of the jar and its .bazelignore line are removed. - The stale entries that hub_jars gives the scan are those of hosted mode only. The scan restores a pin through the hosted undo, which takes no vendored entry: handed one, it warned redirect_withdrawn_restore_failed and left the entry anyway. A stale vendored entry stays for vendored mode's undo (`rollback`, `remove`, `vendor --revert`), which takes the entry, the directory and the ledger entry out; `vendor --check` names it. The scan does not take it out: that needs the vendored undo inside the hosted scan and is a change of its own. - A vendored scan does not look for a hub's jars, as before. Also here: - Docs and contract: the tested shapes on main still said that `scan` does not find a hub's artifacts; the maven_bazel_entry_stale row and the lockfile supplement say that the entry is one of hosted mode. - Tests: a hosted scan leaves a stale vendored entry and warns of nothing, alone and beside a pom (fails without the condition in hub_jars); a hosted scan over a vendored entry does what `get` does; each undo takes a stale vendored entry out, alone and beside a Maven reactor; a unit row for the stale list. - scripts/loc-budget.json: the cap of the bazel group is the count of the merged tree, 3799 (main's 3615 and this branch's part). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Beside a Maven or Gradle build, the undo of a vendored patch edits the files of two builds: the poms and .mvn/maven.config, or the Gradle files, and the entry in the block of MODULE.bazel. It wrote the build's files, removed the build's vendored tree, and only then wrote MODULE.bazel. A MODULE.bazel that could not be written left the Maven or Gradle build on the upstream jar and the Bazel build on the patched one, under a ledger entry that still recorded the patch. A write that failed among the build's own files left those half restored. Found in review. With an entry of the patch in the block, the undo now runs in a group commit, which the vendored apply and the hosted rewrite already use: - Every edit of both builds is captured while it is prepared. A refusal on the way writes nothing. - The files are replaced under the commit's journal. A replacement that fails puts the files already replaced back, and the undo fails with every file as it was. - The build's tree, the hub's directory and the directories they leave empty are removed after the commit, and the caller drops the ledger entry after that. A tree file that could not be removed still fails the undo and keeps the entry. What remains: several renames are not one step. A run that is killed after the journal is written and before the last file is replaced leaves the journal, with nothing removed. The next command that takes the project's lock finishes the files first. The undo run again then removes the tree, the ledger entry and the hub's directory, which it now also removes when no file names it any more. Also: - A patch that only the hub took changes MODULE.bazel alone, which needs no journal. - A group that is already open (the staged revert of a hosted takeover) stays the commit of these edits. - A file among the edits that is a symbolic link fails the undo before anything is written, as the vendored apply does. The undo used to replace the link with a regular file. - The .bazelignore line follows the directory after the undo, as before. - For a patch without an entry in the block, and outside a Bazel workspace, no group is opened and the undo is the one it was. Tests, each failing with the group switched off: a core test of a MODULE.bazel whose directory takes no new file, where the build's tree was removed first, and of the undo that finishes an interrupted one; a CLI test of a Maven reactor beside a hub where the project directory, or the module's, takes no new file, for vendor --revert, rollback and remove; a CLI test that kills rollback after the journal, after the first and after the third file, and runs it again. Docs: the undo in "Bazel workspaces: Maven" and the group commit paragraph of CLI_CONTRACT.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main brought the hosted pnpm registry routes. One conflict, in the hosted scan: both sides add a step after the rewrite has landed, the cleanup of the directories a hosted Maven entry left without a reader here and the removal of an emptied pnpm-workspace.yaml on main. Both stay, in that order, and each adds its warnings to the run. The line cap of the `bazel` group is the count of the merged tree, 3917. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Resolve the conflicts with the vendored Maven hub (#2207): keep both the uncache and cached harness helpers, keep with_patch on the shared block module and make it public as main needs, dispatch the Maven hub refusals next to the Composer and NuGet ones, and raise the bazel line budget by both sides' growth. Assisted-by: Claude Code:claude-opus-5-5
Resolve the bazel line budget conflict with the vendored Maven hub (#2207): the budget is the count of the merged tree. Assisted-by: Claude Code:claude-opus-5-5
main gained vendored mode for a Maven patch of a pinned rules_jvm_external hub (#2207): a committed directory under .socket/vendor/maven, an entry of the block in MODULE.bazel that names it, a line in .bazelignore, and an undo that runs in a group commit. Five conflicts. Each keeps both sides: - bazel/ignore.rs: main gave the sync a third ecosystem, the jars of a hub, and looked the root up with `bazel_root`. This branch had split the sync in two (`sync_at`, for the root of today and for the root an earlier release found) and kept it from adding a pair under the switch. The sync keeps that shape with main's ecosystem: the pair of the jars is added only where pairs are added, and goes with its directory wherever the others go. - bazel/maven.rs: the doc of `hub_jars`, where both sides wrote of the stale entries, and its sweep. main's sweep leaves an entry of vendored mode to vendored mode's undo; this branch's comment says why no entry is called stale beside a doubt (the block is a sign of the ruleset). Both stand. - vendor/refusals.rs: the list of refusals in the module docs. This branch's wording of the Composer item, and main's new item for the Maven jar of a hub. - CLI_CONTRACT.md: five rows of codes that main rewrote for vendored mode and this branch had marked Experimental. Each is main's text with the mark. - scripts/loc-budget.json: the bazel group is the count of the merged tree, 3963 lines: main's 3917 and the 46 of this branch. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

Vendored mode now patches a Maven artifact that a pinned rules_jvm_external hub of a Bazel workspace builds:
vendor,scan --mode vendoredandget --mode vendoredcommit the patched jar under.socket/vendor/maven/<patch uuid>/and add one entry toMODULE.bazelthat makes the hub build it, so the Bazel build needs no patch host.Based on main. The first commit is tests only and records what main did before the change. The second is the change, with the expectations of the first changed to match; the third holds the fixes of the code review. Main is merged in, last with its hosted scan of a hub's jars (#2191): see "Together with the hosted scan of a hub's jars".
Decisions for the maintainer, in short
The full list is at the end. The ones that change what a user can rely on:
vendor --checkis the check, and a changed jar is built until it runs.getorscanremoves the hub's.socket/vendor/maven/<uuid>/once nothing names it.--allow-vendored-in-bazeldoes not lift a Maven decline.rollback <purl>,remove <purl>orvendor --revert;vendor --checknames it. See "Together with the hosted scan of a hub's jars".bazelline budget goes from main's 3615 to 3799.What the code does today
Hosted mode patches a pinned hub (
maven.installwithlock_file) with one managed block at the end of the rootMODULE.bazel: per patch anhttp_fileof the patched jar on the Socket patch host, and Bazel'soverride_repo(7.4.0 and later) of the repository through which the hub fetches that jar.Vendored mode patches no hub, and the table in "Bazel workspaces: what is supported" lists it as "Not supported" for Maven. Measured on Bazel 9.3.2 with the test that the first commit adds:
socket-patch get <purl> --mode vendored --yesexits 1 withvendor_jvm_shape_unsupported("no pom.xml, Gradle, sbt or scala-cli build at the project root"), warnsmaven_bazel_hub_unpatched, writes nothing, and the build keeps the upstream jar.What changes
Only in a Bazel workspace, only for a Maven patch of a plain jar, and only when a rules_jvm_external hub of the root module builds, or may build, that jar at the patch's version. For every other project and package the run is the one it was (see "What it proves, and where").
socket-patch vendor,scan --mode vendoredandget <purl> --mode vendored, run at the Bazel root, download the patched jar once from Socket's patch service and write:and an entry in the same block of
MODULE.bazel:followed by the comment and the
override_repothat a hosted entry has. They also add the line.socket/vendor/mavento the root's.bazelignore, under a comment line of its own, and record the patch in.socket/vendor/state.json. No upstream registry is asked, and no token is written.local_repositorylinks to the directory where it is, by its path from the workspace root: nothing is downloaded or copied, and the repository cache holds no copy of the jar.MODULE.bazel.lockandmaven_install.jsonstay as they are.http_fileand nothing for a directory: a changed committed jar is built. The check issocket-patch vendor --check. It fails when the jar that Bazel builds is not, byte for byte, the vendored jar whose sha256 the ledger records; whenREPO.bazelorfile/BUILD.bazelis not the file that was written; whenMODULE.bazelno longer names the directory, or its block was changed by hand; and when the entry is one a build stops at or may pass without (no pinned hub takes the jar at that version any more, for which the reason namessocket-patch rollback <purl>, or an rc file switches the entry off).socket-patch vexhashes the same jar before it attests.maven_bazel_not_at_root,_not_pinned,_unreadable,_release,_artifact,_no_effect).maven_bazel_downloaddoes not apply: the jar is in the checkout. In a checkout with no Maven, Gradle, sbt or scala-cli build the patch fails with that code (exit 1, nothing written, and nothing downloaded first). Beside such a build that was vendored, it is a warning and the patch isapplied. The decline sits with the other vendored refusals that rest on a Bazel workspace (vendor::refusals::bazel_workspace_refusals), so every vendored command and the eject of hosted pins take the same answer.--allow-vendored-in-bazeldoes not lift it: no entry could be shown to work, and there is nothing else to write for a hub..bazelignoreline and, for a patch that only the hub took, the ledger entry. Beside a Maven build that build's vendored tree stays through a hosted run, as it does without the workspace.vendorover a hosted entry. Where the hub is the project's one build,vendorejects the hosted entry and writes the vendored one. Where it would write none, it is refused whole before any service is asked (eject_refused, "kept hosted: ..."), and the hosted entry stays. Beside a Maven or Gradle buildvendorejects no such entry: it stays hosted, unless the same run vendors that patch for the build (a patch of the manifest, or a pin that the build's own files hold too). The hub's entry is then the vendored one, andvendor --reverttakes it out.vendor --revert,rollbackandremovetake out the entry, then the directory, then the.bazelignoreline: every file is byte for byte what it was, except a.bazelignorethat was an empty file of yours, which is deleted with the last line, as for the Go lines. AMODULE.bazelthat names the directory outside the block's entry fails the undo before anything is removed. Beside a Maven or Gradle build the undo writes that build's files andMODULE.bazelin one journaled commit: a file that cannot be written fails the undo with every file as it was, and the vendored tree, the hub's directory and the ledger entry go only after all of them are written (see "From the review of the pull request").repairfinds nothing to do on such a checkout. A latervendorthat finds the hub's copy missing or changed, or its entry gone, writes them again and reportsvendor_artifact_rebuilt.MODULE.bazeland.bazelignorewith.socket/vendor/. For a hub alone the next step isbazel build //..., and the undo names no package-manager install. A decline names the purl once.get <purl> --mode vendoredtakes any purl.vendortakes the hosted patches of the block, in a checkout only Bazel builds, and the patches of a manifest.scan --mode vendoredvendors a hub's jar for a package it found in a Maven or Gradle build.Together with the hosted scan of a hub's jars
Main now has a hosted
scanthat takes the jars of the pinned hubs for packages, takes a stale entry out of the block (maven_bazel_entry_stale) and warns once when a hub could not be read (maven_bazel_hub_not_read). The merge keeps all of it and all of this change. What the two do together:get <purl> --mode hostedwrites there: the hosted entry takes the place of the vendored one, and the directory and the.bazelignoreline are removed. Tested without Bazel, beside a pom, forgetand forscan.redirect_withdrawn_restore_failedand left the entry anyway. So the list of stale entries that the scan gets now holds hosted entries only (one condition inbazel::maven::hub_jars). The stale vendored entry stays for vendored mode's own undo:rollback <purl>,remove <purl>andvendor --reverttake out the entry, the directory, the.bazelignoreline and the ledger entry, andvendor --checknames the entry with that remedy. Both halves are tested without Bazel: the scan alone and beside a pom, and each undo after the lock moved on, alone and beside a Maven reactor. The new scan test fails without the condition.scanand thenvendorvendor what the hubs build.scandoes not find a hub's artifacts yet" is corrected. Themaven_bazel_entry_stalerow and the lockfile supplement ofCLI_CONTRACT.mdsay that the entry is one of hosted mode.Run on the merged tree, on macOS arm64:
cargo check --all-targets, both clippy runs with-D warnings, the unit tests ofbazel::maven,vendor::maven_repo, the hosted undo of the block, its VEX discovery and the takeover (118 passed),e2e_bazel_maven_beside(26),vendor_jvm_cli(42),scan(267),vendor(145),cli(118),e2e_bazel_buildwithout Bazel (65), and the sevenmaven::flows on real Bazel 9.3.2 behind the logging proxy (7 passed in 105 s; 236 requests, none to a public Maven host). Bazel 8.8.2, 7.7.2 and 7.4.0 were not rerun on the merge; the pull request's CI runs them. The counts and tables further down are those of the earlier state of the branch.Limits
lock_file, and the plain jar of an artifact. Anything else is declined with the reason, as in hosted mode.vendor --checkruns.scandoes not look for the artifacts of a hub; a hosted one does, on main. In a checkout that only Bazel builds, useget <purl> --mode vendored, or a hostedscanand thenvendor.rollback <purl>,remove <purl>orvendor --revertran.vexhashes the jar of that build's vendored tree, not the hub's copy.vendor --checkholds the copy to the same bytes.Contents
Two commits.
Test vendored mode for a Maven artifact that only a Bazel hub builds: tests only (tests/e2e_bazel_build/maven.rs, +133 −9). A real-Bazel flow that records the failure described above. It passes on main's product code on Bazel 9.3.2.Vendor a Maven patch for a pinned rules_jvm_external hub of Bazel: the feature, its tests, the docs and the contract rows (25 files, +2589 −266).Sizes against main, counted as
scripts/loc-budget.pycounts (implementation lines are code lines outside comments, blank lines and test modules):crates/*/srcsocket-patch-core/src/vendor/maven_repo.rssocket-patch-core/src/bazel/maven.rssocket-patch-cli/src/commands/vendor.rssocket-patch-core/src/bazel/ignore.rssocket-patch-cli/src/commands/mod.rs,scan/hosted.rssocket-patch-core/src/vendor/refusals.rscrates/socket-patch-cli/testsvendor_jvm_cli.rs+517 −15,e2e_bazel_build/maven.rs+378 −10,e2e_bazel_maven_beside.rs+49,e2e_bazel_build/harness.rs+27 −1docs/ecosystems.md+129 −25, six rows ofCLI_CONTRACT.md.github/workflows/bazel-maven.yml: header, andvendor/maven_repo.rsandvendor/refusals.rsin both path filtersscripts/loc-budget.jsonbazelgroup: main's 3615 → 3799, the count of the merged treeWhat it proves, and where
Everything below ran locally on macOS arm64.
Real Bazel, behind a logging proxy that refuses public Maven hosts. None was asked in any run.
maven::flowsa_vendored_patch_in_a_tree_only_bazel_builds: the written files and the exact block; the build prints the marker of the patched jar and changes no file; a--lockfile_mode=errorbuild passes;bazel query //...lists no package under.socket;listandvexsee a vendored patch;vendor --checkfails for a changed jar, which Bazel builds all the same; a second output base builds patched with the patch host's stand-in stopped, while the repository cache holds the hub's jar and not the patched one;vendor --revertrestores every file and the first build. On 7.4.0 it first holds the decline of a checkout that names no Bazel release.a_hub_goes_from_hosted_to_vendored_and_back:vendorover a hosted entry,get --mode hostedover the vendored one, the vendored command again, androllback; one entry for the jar at every step.Without Bazel.
tests/vendor_jvm_cli.rs(41 passed): the hub alone and beside a Maven reactor (files, block, ledger, a rerun that changes and downloads nothing,vendor --check,repair,list,vex, a changed jar, a jar that keeps the patch's file beside a member of its own, a changed BUILD file, aMODULE.bazelwithout the entry, a block changed by hand, a lock that no longer pins the jar, a lost jar put back byrepairand byvendor,vendor --revert,rollbackandremoveeach back to the bytes of before, and the lines a person reads); the declines;vendorover a hosted entry beside a Maven build and in a checkout only Bazel builds.tests/e2e_bazel_maven_beside.rs: a hostedgetbeside a pom, over a vendored entry, leaves the hosted block and neither the directory nor the.bazelignoreline..bazelignorepair, the undo, the refusal of a directory git ignores, the removal after a hosted run and its three guards, discovery, and the way back to hosted. Whole core unit suite: 8378 passed. CLI unit tests: 1050 passed.cargo clippy -D warnings,cargo check --all-targets, the script tests (422),actionlintand the tool-pin check pass.Nothing changes outside a Bazel workspace. Twelve commands (
vendor --dry-run,vendortwice,vendor --check,repairdry and wet,list,vex,rollbackdry and wet,vendor --revertdry and wet) on a Maven reactor and on a Gradle build, as JSON and as text: this binary and a build of main print the same bytes, exit with the same codes and leave the same files, in 48 comparisons. The comparison replaces the test server's port and the id and times of the VEX document, and ignores which of two packages avendored_tree_out_of_syncwarning ofvexnames first: main's own binary varies in that from run to run.The tests can fail. Eighteen single changes of the code that the last round of fixes added each make a test fail. The 38 single changes tried on the earlier state of the branch were not repeated.
Not covered
scan --mode vendoredbeside a Maven or Gradle build shares the code ofvendorandgetand has no test of its own here.--vendor_dir) and a downloader config leave alocal_repositoryalone is read from Bazel's source, not run. A build with--repository_disable_download, andbazel mod tidy, were run by hand on 9.3.2 on the earlier state of the branch and have no test.Decisions for the maintainer
.socket/vendor/maven/<patch uuid>/, the directory every vendored artifact has, rather than one named after the Bazel repository. The ledger,vendor --check,vex,repairand the orphan sweep then apply as they are, and.bazelignoregets the one line.socket/vendor/maven.vendor --checkin CI. The alternative is a Starlark rule committed into the user's tree that checks a digest, which this change does not write.local_repositorywithREPO.bazel(three files and a.gitignore) rather thannew_local_repositorywith an emptybuild_file_content(two files), which also built patched on 9.3.2.vendorbeside a Maven or Gradle build, over a hosted entry of the hub. As built: the entry stays hosted unless the same run vendors that patch for the build, and then the vendored entry replaces it. The other choice is to leave a hosted entry alone whenever the block holds one. That keeps the hub on the patch host untilrollback, and leaves the project in two modes.maven_bazel_downloadis not applied in vendored mode, on the reading of Bazel's source noted above.--allow-vendored-in-bazeldoes not lift a Maven decline. The switch is for a build that may not find a vendored copy; a Maven decline says that no entry could be shown to work.getorscanremoves.socket/vendor/maven/<uuid>/whenMODULE.bazelno longer names it, no ledger entry records a file in it, and it holds theREPO.bazelthat vendored mode wrote. Without that,vendor --checkwould report an unpatched build that is patched.vendor --checkis strict about the entry. It also fails when an rc file switches the entry off or the hub cannot be read, not only for the jar's bytes.maven_bazel_*code of the reason, where it gotmaven_bazel_hub_unpatched.bazelline budget goes from main's 3615 to 3799.maven_bazel_no_effect). For any other reason it could not write its own entry it stays silent while the block holds one, so that a run beside a Maven or Gradle build is the run without the workspace. The other choice is to warn for every such reason, as a hosted run does.Code review
Ten findings on the two commits. Six are fixed in a third commit, each with a test that fails without the fix:
repairput back the jar alone. For a patch that only the hub takes, a directory that was lost whole came back withoutREPO.bazeland its BUILD file, and Bazel stopped at the entry.repairnow writes the other files of the directory too.maven_bazel_no_effect. This is narrower than the finding asked: see decision 12.vendor --checkthen called a patched build unpatched. Both runs now remove every directory under.socket/vendor/maventhatMODULE.bazelno longer names and no ledger entry records. This covers two findings.vendoradopted any jar at the hub's path that carried the patch's files, with no ledger entry, and recorded that jar's own sha256. A committed jar is now taken as it is only when the ledger records its bytes.Not changed:
vendorcommand already leaves out of the hub notices every purl that has amaven_bazel_*event.At the review's commit: the unit tests of the three changed core modules,
vendor_jvm_cli,e2e_bazel_maven_beside,vendor,repair,cliande2e_bazel_buildwithout Bazel pass, both clippy runs pass with-D warnings, four reverted fixes each fail their test, and the sixmaven::flows pass on real Bazel 9.3.2 behind the logging proxy with no request to a public Maven host. Bazel 8.8.2, 7.7.2 and 7.4.0 were run on the second commit and not again.From the review of the pull request
The Bazel and the JVM half of the undo are committed together (commit 7c03b76). Beside a Maven or Gradle build the undo wrote the build's files, removed the build's vendored tree, and only then wrote
MODULE.bazel. AMODULE.bazelthat could not be written left the Maven or Gradle build on the upstream jar and the Bazel build on the patched one, under a ledger entry that still recorded the patch.With an entry of the patch in the block, the undo now runs in a group commit, the mechanism the vendored apply and the hosted rewrite already use:
.socket/vendor/.commit-journal.json). A replacement that fails puts the files already replaced back, and the undo fails with every file as it was.What remains. Several renames are not one step. A run that is killed after the journal is written and before the last file is replaced leaves the journal, with nothing removed. The next socket-patch command that takes the project's lock finishes the files before it does anything else. The undo run again then removes the tree, the ledger entry and the hub's directory, which it now also removes when no file names it any more. A run that is killed before the journal is written has changed nothing.
Also:
MODULE.bazelalone, which needs no journal..bazelignoreline follows the directory after the undo, as before, and a failure to write it is a warning.Tests, each of which fails with the group switched off:
MODULE.bazelwhose directory takes no new file. Before, the build's tree was removed first. And the undo that finishes an interrupted one.MODULE.bazeland the root pom) or the module's directory takes no new file.vendor --revert,rollbackandremoveeach exit 1 and every file, the tree, the hub's directory and the ledger are as they were; with the directory writable again the undo restores every byte.rollbackkilled after the journal, after the first file and after the third. Nothing was removed; the same command run again ends with every byte of before.Run at that commit, on macOS arm64:
cargo check --all-targets, both clippy runs with-D warnings, the unit tests ofvendor::maven_repo,bazel::maven, the JVM revert and the group commit (153 passed),vendor_jvm_cli(44),e2e_bazel_maven_beside(26),vendor(145),repair(118),e2e_bazel_buildwithout Bazel (65), and the two vendoredmaven::flows on real Bazel 9.3.2 behind the logging proxy (2 passed in 41 s; 66 requests, none to a public Maven host), which undo a patch that only the hub took. The undo beside a Maven build has no flow on real Bazel. Linux and Windows have not run the new tests; the permission test is for Unix, and the kill test runs on every system.🤖 Generated with Claude Code