Skip to content

Keep the Bazel support from changing a project that Bazel does not build - #2228

Open
Mikola Lysenko (mikolalysenko) wants to merge 12 commits into
mainfrom
bazel-guard/existing-setups
Open

Mikola Lysenko (mikolalysenko) wants to merge 12 commits into
mainfrom
bazel-guard/existing-setups

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

Projects that sit in a checkout with a Bazel workspace file but are not built by Bazel keep working as before the Bazel support: a Composer project that is already vendored is no longer declined, a workspace that has nothing to do with rules_jvm_external adds no Maven warnings, and SOCKET_NO_BAZEL=1 switches the Bazel support off.

Decisions for the maintainer

  1. The switch is SOCKET_NO_BAZEL, environment only. It takes 1, true, yes, on, y or t, like the other switches no flag binds, and a run that honours it prints nothing. There is no flag because vex --no-bazel already means the VEX step alone. To reverse: the name is one constant and the docs.
  2. The switch is for the whole run, not for a project. Programs that socket-patch starts inherit it, and a bare scan covers every project of a checkout: set for a run over a checkout that also holds projects Bazel builds, it drops their guards too and the run exits 0. The docs say to set it for runs in the directory of the project that Bazel does not build. A scope per project (a key in socket.yml) is not built; it would be a new key and a lookup that reads it per project.
  3. With the switch, every command is the command of the same checkout without its workspace file. That one rule decides several cases, each one condition to reverse:
    • A pnpm lock that a rules_js hub reads is routed through the patch's named registry (Route hosted pnpm pins through one named registry per patch #2167), as without the file.
    • A vendored Maven run vendors for the Maven or Gradle build alone and says nothing of a hub (Vendor a Maven patch for a pinned rules_jvm_external hub of Bazel #2207). A Bazel build that is there after all keeps the upstream jar. In a checkout only Bazel builds, the patch is refused for want of a build, and a hosted entry of the block is not replaced.
    • What an earlier run wrote for Bazel is still listed and undone, and read as without the switch: vex and vendor --check still say that no pinned hub takes an entry any more.
    • Beside a Maven build, a hub directory that was lost fails vendor --check, whose remedy (vendor again) needs a run without the switch. The undo works with it.
  4. Composer: what is declined is the first vendored path in a section of the lock that a Bazel rule may install. A copy in packages lets every package through; a copy that only packages-dev names lets through the packages of packages-dev, because a rule may run composer install --no-dev. To reverse brings back the failure of projects an earlier release vendored.
  5. Maven: a doubt of the workspace reader is about no hub only where nothing names rules_jvm_external and every file that is there was read as a whole. A file that could not be read may be the one that names the ruleset, so it still warns, as on main. The cost: a file named WORKSPACE that is not Starlark warns once per Maven patch, and the switch is its way out. The wider rule (no warning unless a file that was read names the ruleset) is one condition.
  6. The scan's own Maven warning keeps main's rule. maven_bazel_hub_not_read is given only in a workspace with a sign of the ruleset. Both reviews asked for the rule of decision 5 there too. Not changed: the warning would come with every hosted scan of a checkout with an unreadable workspace file and make its root a project of the scan. The cost: a hub declared only in such a file is not scanned, and the scan does not say so. One condition in hub_jars.
  7. A Bazel workspace is found as Bazel finds it. The lookup tests that a regular file answers to one of the four names, as Bazel's client does, so on a disk that folds case a file workspace or Module.bazel counts. A stricter match by the exact name was built and taken out after the second review: it left a real workspace spelled in another case without any guard, and cost a directory listing per lookup.
  8. The contract marks all of it Experimental: the flags, the three variables, 18 codes, the .bazelignore lines, the block in MODULE.bazel, the directory and ledger flavor vendored mode keeps for a hub's jar, and each passage about a Bazel workspace.
  9. Three known problems in docs/ecosystems.md are corrected. Hosted Cargo without cargo_config and hosted NuGet without nuget_config no longer leave a failing build: hosted mode writes nothing and warns. Each is now listed among the builds that pass unpatched, and the failing case that remains (a pin already in the files) stays where it was.

What changes

  • Composer (vendor/composer_lock/bazel.rs). The refusal vendor_composer_bazel_workspace is not given where the lock already names a vendored copy in the section that holds the package, or in packages.
  • Maven notices (bazel/workspace.rs, bazel/maven.rs). The reader records the first file that is there and was not read as a whole. Without such a file and without a sign of the ruleset, a doubt gives no warning. A warning names the doubt that caused it. The block in MODULE.bazel counts as a sign of the ruleset, so nothing is said of one of its entries as a fact while a doubt stands.
  • The switch (bazel/mod.rs). bazel_root finds no workspace; the in-memory engine is handed no Bazel file and asks its host for none. Off: the Composer refusal, new .bazelignore lines, the hosted withholds for Cargo, NuGet, gems and pnpm, everything of Maven that rests on a hub, the affected statements of VEX. On: reading and undoing what an earlier run wrote (the block, the vendored hub directory, the .bazelignore pairs).
  • The vendored hub under the switch (vendor/maven_repo.rs). Three judgements read the block without the lookup; they ask the switch in one place. Before, vendor in a checkout only Bazel builds failed with exit 1 where the checkout without the file exits 0.
  • Tests and the environment. The core's unit tests read the switch through the tests' env guard, so a developer who exports the variable does not fail them. Four other tests that judge a workspace in their own process hold the variable unset through the guard, and the in-memory engine's switch test is two tests that hold it, set or unset, before any server starts.
  • Docs. A contract section "Bazel workspaces (experimental)" with the lookup, the switch, its scope and what stays on; a subsection "a project that Bazel does not build" in docs/ecosystems.md; the variable in docs/configuration.md.
  • Merged with main twice: Route hosted pnpm pins through one named registry per patch #2167 (the pnpm registry route) and Vendor a Maven patch for a pinned rules_jvm_external hub of Bazel #2207 (vendored mode for a pinned hub). Each conflict keeps both sides.

Size against main: 29 files, +1927 -173: source 16 files +526 -100, tests 9 files +1206 -16, the contract and docs 3 files +194 -56, the line budget 1 line. Implementation lines by scripts/loc-budget.py: the bazel group goes from 3917 to 3953, which is its cap; lock-writers goes up by 11.

Limits

  • The hosted withholds for Cargo, NuGet and gems beside a hub call that is not written out, and the .bazelignore lines, stay as they are. The switch is the way out.
  • On a disk that folds case a stray file workspace or Module.bazel makes a Bazel workspace, as for Bazel. A stray workspace that is not Starlark warns once per Maven patch there.
  • A bazel_dep whose name is not a plain string is not seen as naming the ruleset.
  • With the switch, no run writes, replaces or sweeps an entry of the block; the in-memory engine reads no block.
  • That composer install --no-dev leaves a path entry of packages-dev alone is taken from Composer's source, not from a run.
  • Not run with the switch: scan and get --mode vendored of a Maven patch (same function as vendor), a hosted pin held by both a pom.xml and the block, and the vendored hub beside Gradle, sbt or scala-cli.

What was run, and what was not

On this head, on macOS:

  • cargo clippy --locked --workspace --all-features -- -D warnings, and the same for the test targets e2e_bazel_build and hosted_memory_bazel_off: clean. rustfmt --check on each of the 25 Rust files the branch changes: clean.
  • cargo check --locked --workspace --all-targets --all-features: passes.
  • The whole core unit suite (8546 passed, 1 ignored) and the CLI unit suite (1065 passed).
  • e2e_bazel_build without Bazel (73 passed, the 30 real-Bazel flows ignored), e2e_bazel_maven_beside (32), hosted_memory_bazel_off (2), cli (120), cli_global_args (13), spawn_env_hygiene (21).
  • The targets for vendored Maven and its undo: vendor_jvm_cli (46), e2e_sbt_vendor, e2e_scala_cli_vendor, vendor_group_commit_e2e, vendor_ledger_schema_e2e, in_process_rollback_all_ecosystems, in_process_vendor, e2e_vex_vendor. Eighteen more targets for vendored Composer, the in-memory engine, VEX and argument parsing, and the hosted pnpm targets of Route hosted pnpm pins through one named registry per patch #2167. All pass.
  • The same suites once more with SOCKET_NO_BAZEL=1 exported in the environment of the test run: all pass. Before this change 56 core unit tests, 2 CLI unit tests and 3 tests of the in-memory engine failed that way.
  • The script tests (423) and the line budget.
  • Each new or changed check was shown to fail without its change: with the sources of the commit before under the new tests, and with 11 single changes to the code of the last commit; 10 and 22 more were run the same way on earlier heads of this branch.
  • Real Bazel 9.3.2: the seven maven:: flows pass, behind a proxy that refuses every public Maven host and logs each request. None was asked for.

Not run: the composer:: flows on real Bazel (no Composer on the machine); the real-Bazel flows of the other modules and the other Bazel releases; tests that need real Maven, Gradle, sbt, scala-cli or pnpm; Windows and Linux; a code review of the last commit.

Code review

First round, ten findings:

  1. An include the reader does not follow left a file unread and lost main's warning: fixed.
  2. The scan's warning does not take the rule for unread files: not changed (decision 6).
  3. A stray file workspace was read as the WORKSPACE file: fixed by the exact-name rule, which is taken out. On a disk that folds case that file is the workspace file, for Bazel too, and warns as on main.
  4. The switch was scrubbed from child processes: fixed, a child inherits it.
  5. The docs named four words for the switch where the reader takes six: fixed.
  6. The undo of a .bazelignore pair missed a root an earlier release wrote in: taken out with the exact-name rule, which was what moved the root.
  7. list and vex called a block entry stale while a doubt stood: fixed.
  8. Four hand-placed checks of the switch for the in-memory engine: fixed, two gates.
  9. The test helper of the switch comparison changed the checkout it compared: fixed, it refuses such a checkout.
  10. The root directory was listed once per name: taken out with the exact-name rule.

Second round, eight findings:

  1. The .bazelignore sync at two roots could hide one root's change or error: taken out, one root again.
  2. A real workspace spelled in another case lost every guard: taken out, the lookup is Bazel's.
  3. The directory was listed for each lookup and each file read: taken out.
  4. A Maven warning named a doubt that did not cause it: fixed.
  5. Tests failed with the variable exported, and one set it halfway through: fixed.
  6. Three hand-placed checks of the switch in the vendored hub code: fixed, one place.
  7. The switch is per run while "Bazel builds it" is per project: written into the docs and decision 2; a scope per project is not built.
  8. The scan's Maven warning goes by the sign of the ruleset alone: not changed (decision 6), flagged in both rounds.

Generated by Claude Code

…s not build

A project can sit in a checkout that has a Bazel workspace file while no
Bazel builds it: a PHP or Maven service in a monorepo whose other parts
use Bazel, or a checkout with a stray file. These tests record what
socket-patch does there today, without a Bazel, so that the change that
follows shows in their expectations.

- composer: a project that an earlier release vendored, whose lock names
  the copy of the patch of then, is declined a newer patch of the package
  (`vendor_composer_bazel_workspace`): `scan --mode vendored` and the
  `scan` that names no mode exit 1 where they exited 0, and write nothing.
- composer: a regular file named `workspace`, in lower case, makes the
  checkout a Bazel workspace on a disk that folds case, and vendored mode
  is declined there. The test asks the disk and prints which branch ran;
  on a disk that does not fold case the project is vendored.
- maven: in a workspace whose MODULE.bazel includes a file that does not
  exist, with no hub that holds the artifact, a hosted `get` and an agent
  `apply` each add one `maven_bazel_unreadable` warning, in a workspace
  that names rules_jvm_external and in one that names only another
  ruleset.

The test of the one warning a pinned hub adds is now a helper that both
Maven tests use; what it asserts is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
socket-patch takes every project below a Bazel workspace file for one
that Bazel builds. A project can sit in such a checkout while no Bazel
builds it: a service of a monorepo whose other parts use Bazel, or a
checkout that kept a workspace file. What the Bazel support does there
could take a working command away from a setup that an earlier release
served. Four changes keep such a setup as it was. For a project in no
Bazel workspace nothing changes.

Composer. Vendored mode was declined (`vendor_composer_bazel_workspace`,
exit 1) for every package whose lock entry did not already name the
copy of the same patch, so a project that an earlier release vendored
failed its next run for a newer patch or another package. Now a package
is let through when `packages` of composer.lock names a copy under
.socket/vendor/composer, or when the section that holds the package
does. Either no Bazel rule installs from that lock, and vendored mode
works there as before; or one does, and its build already fails on a
path in a section it installs, which one more path there does not
change. The section matters because a rule may run `composer install
--no-dev`, which reads `packages` alone: a copy that only `packages-dev`
names breaks no such build, so it lets through the packages of
`packages-dev` and no other. The first vendored path in a section is
still declined, and the message says when a package is not.

Maven. Whatever the workspace reader could not read made apply, vendor
and a hosted scan warn `maven_bazel_unreadable` for every Maven patch,
also in a workspace that has nothing to do with rules_jvm_external.
`Hubs::built` now answers that no hub builds the jar where nothing names
the ruleset (no call of a file that was read, no `maven_install` of the
WORKSPACE file, no maven_install.json at the root) and every file that
is there was read as a whole: an include of a file that does not exist,
and a statement the reader does not follow, are then about no hub. A
file that is there and was not read as a whole (`Workspace::unread`: it
cannot be read or parsed, or lies past a bound), and a WORKSPACE file
that cannot be read while Bazel may read it, may be the one that names
the ruleset, and warn as before. So does a workspace that names it. The
sweep of stale entries keeps its rule that every hub was read, which it
had from that answer and now states itself.

One off switch. A truthy `SOCKET_NO_BAZEL` (`1`, `true`, `yes`, `on`:
`env_truthy`, the reader of the other switches that no flag binds) makes
`bazel_root` answer that there is no workspace. The two judges of the
in-memory engine that read handed-over files (pnpm, gems) answer the
same, and its path selection asks the host for no Bazel file, which
would only count against a session's limits. Every command then does
what it does in the same checkout without the workspace file. It is
read from the environment alone: `vex --no-bazel` exists and means the
VEX step only. No child process inherits it, and a run that honours it
prints nothing. Listing and undoing what an earlier run wrote for Bazel
stays on: the block of MODULE.bazel is read and undone by code that
never asked for the workspace, and the sync of .bazelignore still takes
away the pair of a copy that is gone (it looks the root up itself and
adds nothing).

The lookup. A workspace file was found by a stat, so on a disk that
folds case a regular file `workspace` or `Module.bazel` made a Bazel
workspace. The name now counts as the directory lists it. The listing
is read only after a stat found a file, so a directory without one
costs what it did; a directory that cannot be listed keeps the stat's
answer. This is stricter than Bazel, whose client tests that the name
exists and so takes such a file on a disk that folds case: a workspace
spelled in another case is no longer seen, which the docs say.

The tests of the previous commit change with it: the project vendored
earlier gets its newer patch, the file `workspace` makes no workspace on
either kind of disk, and the workspace of another ruleset with an
include that does not exist is the run without Bazel. An included file
that is there and cannot be parsed keeps the warning. New tests hold a
run with the switch to the same run in the checkout without its
MODULE.bazel, byte for byte in exit code, output and files, for the
Composer refusal, a hosted gem that a hub holds, the VEX judgement, the
.bazelignore lines and the Maven hub; the words that set the switch and
the values that do not; the undo of a .bazelignore pair and of the
MODULE.bazel block with the switch set; and the in-memory engine with
its selection, in a test target of its own because it sets the variable
for its process. The Composer unit test for the pass of one package and
one patch is replaced by one for the pass by section.

CLI_CONTRACT.md marks the Bazel flags, variables, codes and passages
Experimental, as it marks the patch mirror, and describes the lookup and
the switch; docs/ecosystems.md and docs/configuration.md describe the
switch. The budget of the bazel group follows the code: 3615 to 3640
lines.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main gained the route of hosted pnpm pins through one named registry
per patch (#2167). It rewrote bazel/pnpm.rs, where one read of the
Bazel workspace now gives two answers (`hubs`: the hub that hides
pnpm-workspace.yaml from its pnpm, and the hub that reads a pnpm lock,
which keeps the lock off the route), and it widened what the in-memory
path selection asks its host for beside a pnpm lock.

Two conflicts, both where this branch had put the `SOCKET_NO_BAZEL`
switch into code that main replaced. Each keeps main's code and carries
the switch to where the question is now asked:

- bazel/pnpm.rs: the branch answered "no hub" for an in-memory project
  under the switch, in `hidden`. main moved that read into `read`,
  which serves both answers, so the switch is asked there. On disk both
  answers already go through `bazel_root`, which finds no workspace
  under the switch.
- hosted/memory/select.rs: the branch kept the selection from asking
  for the MODULE.bazel beside a root pnpm-lock.yaml under the switch.
  main replaced that condition with a wider one (every file of a Bazel
  workspace, beside a pnpm lock or a pnpm-workspace.yaml), and the
  switch is asked in that one, as it is beside a gem lock.

The budget of the bazel group in scripts/loc-budget.json is the count of
the merged tree, 3758 lines: the 3733 that main holds (over the 3615 its
file still says) and the 25 of this branch. The other two groups are
over their budgets on main as well, and their numbers are left alone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Hosted mode routes a patched pnpm release through a named registry of
pnpm-workspace.yaml, and keeps a lock that a rules_js hub of the Bazel
workspace reads, or may read, off that route. `SOCKET_NO_BAZEL` promises
the run of the same checkout without its Bazel workspace file, so with
it such a lock has to be routed: for that run the hub is not there.

The merge that brought the route in carried the switch to the two places
that ask. One is the read of the hubs for an in-memory project
(`bazel::pnpm::read`; on disk it goes through `bazel_root`), which now
gives both answers: the hub that hides the workspace file and the hub
that reads the lock. The other is the condition of the in-memory path
selection that asks the host for the files of a Bazel workspace beside a
pnpm lock or a pnpm-workspace.yaml. Every user of the answer (the route,
its warning, whether an emptied pnpm-workspace.yaml may be deleted, the
hosted scan that crawls nothing) takes it from that one read. These
tests hold both places.

- e2e_bazel_build, npm: a project that proves pnpm 12, whose patch
  service offers the patch's registry, beside the fixture's hub, which
  reads the lock. With the switch a hosted scan is the scan of the same
  checkout without its MODULE.bazel, byte for byte in exit code, both
  streams and files, as JSON and as text: the lock is routed, the
  workspace file holds the registry, and no run says a word of Bazel.
  Without the switch the lock stays on the trust pin and the warning
  names the hub's call, as the existing test of that checkout holds.
  `Cell::without_and_beside` is the helper of the other switch tests,
  giving both runs.
- hosted_memory_bazel_off: a third project, a pnpm lock that a hub only
  reads. Without the switch the engine pins it, does not route it and
  says that the hub is why. With it the engine gives what it gives for
  the same files without the MODULE.bazel, which is the routed lock.
  The selection is now held for every file of a Bazel workspace
  (MODULE.bazel, a module file it can include, the three WORKSPACE
  names) beside a pnpm lock, beside a pnpm-workspace.yaml whose only
  lock is a member's, and beside a gem lock: each is asked for without
  the switch, and with it the selection is the one of the tree without
  those files.

CLI_CONTRACT.md names the route among what the switch turns off, and
marks the passage about the route in a Bazel workspace Experimental, as
its Bazel section says every such passage is. docs/ecosystems.md adds
what the npm section does to the list of what a Bazel workspace file
changes for a project, which is the list the switch turns off.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The list of known problems under "Bazel workspaces: what is supported"
had three entries that describe what socket-patch did before the guards
for them were built. Each is now what the code and its tests do.

- Hosted Cargo on a hub without `cargo_config`, and hosted NuGet on a
  tag without `nuget_config`, stood in the list of commands that exit 0
  and leave a Bazel build that fails. Hosted mode writes nothing there
  now and warns (`redirect_cargo_bazel_config_unread`,
  `redirect_bazel_nuget_config_undeclared`): the flows
  `cargo::hosted_from_cargo_without_config` and `nuget::hosted_no_config`
  build the unpatched package after the scan, and the tests
  `cargo::a_hub_without_the_config_gets_no_pin_until_it_names_the_config`
  and `nuget::only_a_tag_that_reads_the_lock_without_its_config_is_withheld`
  hold, without Bazel, that no file changes. So both are entries of the
  list of builds that pass on the unpatched package, with the warning's
  way on. What is left in the list of failing builds is a pin that is
  already in the files: those two tests hold that a scan leaves it
  where it is, reports it applied for Cargo and warns for NuGet.
- "Vendored Cargo under rules_rust 0.75.0" said that after a build
  `vendor --check` exits 1 and `vex` writes no document. Under the
  `.bazelignore` line that the scan writes, the `BUILD.bazel` that
  cargo-bazel puts into the copy is no change of it: the flow
  `cargo::vendored_from_cargo_with_config` holds that the check passes
  and `vex` attests the crate. The entry is true with the line
  commented out, which
  `cargo::only_the_build_file_of_cargo_bazel_is_no_change_of_a_vendored_copy`
  holds, and now says so and points to the section that has the other
  cases without the line.

Words only. The tier and the opening statement of that section are not
touched.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A review of this branch found places where it lost a warning that main
gave, where its rules held in one place and not in another, and where
its words and its code differed. Each is fixed here, but for one that is
main's own rule and is now written down.

Maven notices.

- An `include` that the reader does not follow leaves a file unread
  that may be there. Bazel 9 takes `include("//x.MODULE.bazel",
  dev_dependency = True)`, the reader reads no such file, and a workspace
  with its hub and all that names rules_jvm_external in that file got no
  `maven_bazel_unreadable` any more, where main gave one. Such an
  `include` now sets `Workspace::unread`, like a file that cannot be read.
- The block that hosted mode keeps in MODULE.bazel is written for a hub
  alone, so a workspace that holds it has to do with the ruleset. It is
  now one of the signs (`Hubs::ruleset`). Before, in a workspace that
  named the ruleset nowhere else, `list` and `vex` said of an entry that
  no pinned hub takes its jar any more, as a fact, while a doubt stood,
  and the hosted scan neither took the entry out nor said why. Now they
  say that it could not be told, and the scan warns. The separate check
  of the stale sweep is implied again and gone.
- Not changed: the scan's own warning (`maven_bazel_hub_not_read`) is
  given only in a workspace with one of the signs, not for a file that
  is there and could not be read. That is main's rule, and its contract
  row says so. The warning would come with every hosted scan of such a
  checkout, whatever it holds, and make its root a project of the scan,
  which is what this branch is to keep from a checkout with a stray
  file. The code and the docs now say what is not scanned there.

The lookup.

- The reader takes MODULE.bazel and the names of the WORKSPACE file at
  the root by the rule of the lookup: under the name the root lists
  them by. On a disk that folds case, a stray file `workspace` beside a
  MODULE.bazel was read as the WORKSPACE file, failed to parse, and gave
  every Maven patch a warning and the other hub readers a doubt. A file
  that a label names is opened as before, as Bazel opens it.
- The undo of a `.bazelignore` pair finds what main's lookup found. A
  checkout whose only workspace file is spelled in another case was a
  Bazel workspace to a release that went by a stat alone, which wrote
  its pairs there. `roots_of` gives the sync that root beside the root
  of today: the pair of a copy that is gone still goes from its file,
  and no pair is added there.
- A directory is listed once for all the names a stat found, and not at
  all where the disk has nothing under a name in lower case: there the
  stat was of the very name. A project in no Bazel workspace still
  costs four stats per directory.

The switch.

- A child process inherits `SOCKET_NO_BAZEL`. The scrub list is for
  credentials, for URLs that can carry them and for the bindings of
  flags, which the CLI mirrors into its own environment. This variable
  is none of them: it is the user's word about the checkout, like
  `SOCKET_NO_CONFIG` and `SOCKET_NO_UPDATE_CHECK`, which pass through
  too. A socket-patch that a spawned program starts in the checkout (a
  hook of a package manager) then gives the run the switch promises.
- The words and the code agree: the reader takes `1`, `true`, `yes`,
  `on`, `y` and `t`, as the other switches read from the environment
  alone do, and the contract, the docs and the test say so.
- One gate for each way a workspace is come by, in the place of four
  checks: `workspace::memory`, the one view of files handed over in
  memory, holds none under the switch, and `is_workspace_file`, which
  the path selection goes by, names none. A reader of handed-over files
  that is written later gets the switch with the view.

Tests: an `include` with `dev_dependency` keeps the warning (reader,
`Hubs::built`, and through the binary); a stray `workspace` file beside
the MODULE.bazel of another ruleset gives the run without Bazel; the
two roots, and the sync at each; a block entry beside a doubt; the edge
values of the switch (`y`, `T`, `n`, `f`, `yes!`); the scrub list
without the variable. One row of this branch's own changes with the
block rule: the scan now warns where the block is the only sign.

The budget of the bazel group follows the code: 3758 to 3783 lines.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`Cell::off_is_without_bazel` runs a command three times and makes the
checkout anew before each run from its regular files. A link, an empty
directory and the permission bits of an executable file are not among
them, so they were gone from the second run on, although the helper's
doc said that every run starts in the checkout as it is. An empty
`.git` directory is what bounds the lookup of a Bazel root, so the runs
could differ in the one thing the comparison is about.

The helper now refuses such a checkout before any run and names what it
holds beside its files. The four tests that use it have none. A test
holds the refusal: each of the three is named, and nothing is made
anew.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 pinned rules_jvm_external hub. Its gate goes
through the workspace lookup, which the switch for a project that Bazel
does not build answers, so with the switch a `vendor` run already wrote
nothing for a hub. Three judgements of that code read the block of
`MODULE.bazel` without the lookup and still acted on a hub:

- In a checkout only Bazel builds, `vendor` ejected a hosted entry of the
  block. With the switch no vendored entry can take its place, so the run
  failed (`vendor_jvm_shape_unsupported`, exit 1) where the same checkout
  without its `MODULE.bazel` has nothing to do and exits 0.
- The refusal of a Maven patch in a tree without a JVM build ended with
  "MODULE.bazel holds an entry for it that no pinned hub takes any more",
  also of an entry that a hub takes.
- A run that vendored for a Maven build named `MODULE.bazel` and
  `.bazelignore` among the files to commit when the block held the
  vendored entry of the patch, although it wrote neither.

Each of them now asks the switch. With it a vendored Maven run is the run
of the checkout without its `MODULE.bazel`: the exit code, both streams
and every file. That includes what the switch means for a Bazel build
that is there after all: beside a Maven build the run vendors for that
build alone and says nothing of the hub, which keeps the upstream jar.
The docs now say so.

What an earlier run wrote for a hub is still seen and undone with the
switch, and needed no change: the readers of the block, the undo and
`repair` go by the file and the ledger and ask no lookup. `list`, `vex`,
`vendor --check` and `repair` say what they say without the switch, also
of an entry whose jar the lock no longer pins, and `vendor --revert`,
`rollback` and `remove` take the entry, the directory of the jar, its
`.bazelignore` pair and the ledger entry out, to the byte. A hosted run
leaves a patch that vendored mode keeps for a hub alone vendored.

Tests, without a Bazel: the vendored run with the switch against the run
without the workspace file and the run without the variable (a fresh
checkout, an entry of an earlier run, a Maven build that came later, a
hosted entry), what the listing commands and each undo say and leave with
the switch, and a hosted `get` and `scan` over a vendored entry.

The contract's section on Bazel workspaces names the directory and the
ledger flavor of vendored mode among what may change, says what the
switch turns off for a vendored Maven patch and what stays on, and marks
the two passages about the hub that had no Experimental mark (the undo's
group commit, `cleanup_failed`).

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

The exact-name match of the workspace file goes. It made the lookup
stricter than Bazel's own on a disk that folds case, and it was not small:
it brought a listing of the directory for each lookup and each read, a
second root for the undo of a `.bazelignore` pair whose outcome could hide
the first root's, and a rule of its own in the reader of the workspace. A
real workspace whose file is spelled in another case lost every guard,
although Bazel builds it. The lookup and the reader are main's again: a
stat, as Bazel's client does it, so a workspace is seen exactly where
Bazel sees one. On a disk that folds case a regular file `workspace` or
`Module.bazel` counts, as it does for Bazel, and is read as the file it
answers for; `SOCKET_NO_BAZEL` is the way out for a checkout where such a
file is no workspace. The test that records this for the lower-case file
is back to what it held before, and a stray `workspace` file that is no
Starlark gets main's Maven warning again, which the rule for a file that
was not read keeps.

A Maven warning names the doubt that made it. `Hubs::built` answered "not
known" because a file was not read, and reported the first doubt of the
workspace, which may be another one, about no hub: the warning named the
wrong line and stayed after that line was fixed. The reader now keeps the
doubt about the first file it could not read, and that one is reported.

The tests no longer depend on the environment they are run in. With
`SOCKET_NO_BAZEL=1` exported, as the docs suggest for some checkouts, 56
unit tests of the core, 2 of the CLI and 3 tests of the in-memory engine
failed. The core's unit tests now read the switch through the tests' env
guard, like the other lookups that many tests cross. The CLI's two tests
and the two parity tests of the engine hold the variable unset through
that guard and run serially. The engine's switch test is two tests, each
holding the variable set or unset before any server starts, in place of
one that set it halfway. The tests that start the binary were not
affected: their commands drop every ambient `SOCKET_*` variable.

The three judgements of vendored mode that go by the block of
`MODULE.bazel` ask the switch in one place, before anything is read
(`judged_block`, and `judges_hubs` for the one that reads nothing).

The docs and the contract say what the switch is not: it is for the whole
run and every program it starts, while whether Bazel builds a project is
a fact of each project. A run over a checkout that also holds projects
Bazel builds drops their guards too and exits 0.

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

cursor Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches workspace detection, Maven hub logic, and vendoring/refusal paths across core and CLI, though behavior change is gated on an explicit env toggle with broad new test coverage.

Overview
Adds SOCKET_NO_BAZEL (env-only, truthy like other SOCKET_* toggles, inherited by child processes) so monorepo projects that merely sit beside a Bazel workspace get the same behavior as a checkout without workspace markers: no new .bazelignore lines, hosted/npm/gem/Maven hub withholds and warnings are skipped, and vendored Maven runs target JVM builds only instead of patching hubs.

Composer vendored decline is relaxed when composer.lock already points at a .socket/vendor/composer copy in packages or the package’s section (including --no-dev / packages-dev semantics), so projects vendored before the refusal keep working without --allow-vendored-in-bazel.

Maven/Bazel parsing gains Workspace::unread and tighter rules for when a “doubt” implies a hub vs. no hub; block entries are not treated as stale while unreadable workspace state stands, and unreadable rules_jvm_external workspaces get targeted warnings without treating unrelated workspaces as Maven hubs.

Tests & hygiene: test_env guards stabilize unit tests when the variable is exported; large e2e coverage compares runs with/without Bazel files; cargo e2e accepts either @platforms or @crates__* “unseen repo” errors. Docs and line-budget updates document the switch and corrected hosted Cargo/NuGet “no pin + warning” behavior.

Reviewed by Cursor Bugbot for commit f9fbf14. Configure here.

…gnore line

`cargo::vendored_from_cargo_with_config` comments out the line the scan
wrote in `.bazelignore` and expects `bazel cquery //...` and
`bazel query 'deps(//...)'` to fail on a repository that the main
repository does not see. It looked for the hub's repository
(`@crates__...`) alone. The build file that cargo-bazel writes into the
committed copy names `@platforms` as well, and Bazel reports the first one
it meets: on a Linux runner with Bazel 9.3.2 the query named `@platforms`
and the flow failed on its own check.

The flow now takes either name for that failure. Test only: nothing the
command does changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The check of the commands that fail once the ignore line is commented out
now reads the name out of Bazel's message and takes it only when the
message is about the main repository's view: `platforms`, or a repository
of the crate hub. The same words about another repository's view, or
about another name, are a different failure and no longer pass for the
expected one. A test without Bazel holds the check to the two messages
that were seen and to three it must not take.

The module docs, the comment at the call and the section on the build
file in a vendored crate said the commands end on the dependency's
repository alone. They now name `platforms` as well, which is what a
user who comments the line out can see.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 25, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does. A project that sits in a checkout with a Bazel workspace file but that Bazel doesn't build now behaves as it did before the Bazel support. An already-vendored Composer project is no longer declined. A workspace unrelated to rules_jvm_external no longer adds Maven warnings. A new environment switch, SOCKET_NO_BAZEL=1, makes every command act as if the workspace file were absent. Undo of what an earlier run wrote for Bazel still works with the switch on.

Risk: medium. It touches the Bazel lookup that every ecosystem goes through, but the change is gated: without the variable set, only the Composer let-through and the Maven doubt rule behave differently. It also carries nine product decisions (see "Decisions for the maintainer" in the description). The main ones are that the switch covers the whole run rather than one project (decision 2), and that the scan's own Maven warning keeps main's rule (decision 6).

Look here

  • bazel/mod.rs:39 and :92: the switch and its gate in bazel_root. root_of ignores the switch so the undo stays whole.
  • [composer_lock/bazel.rs:106](https://github.com/SocketDev/socket-patch/blob/f9fbf1461b2c7a5639d4563ed800a87bcb22f109/crates/socket-patch-core/src/vendor/composer_lock/bazel.rs#L106): the new let-through. A vendored copy in packages lets every package through; a copy only in packages-dev lets through only that section.
  • maven_repo.rs:287: judged_block. With the switch on, no hub is judged; the undo, the audit and repair still read the block.
  • bazel/ignore.rs:122: with the switch on, no .bazelignore pair is added, but a stale pair is still removed.
  • bazel/workspace.rs:130: the in-memory engine's gate.

Verified

  • Read the full source diff (16 files) and the callers of hub_wired / hub_alone under the switch. Each gate is in one place, and an unset or empty variable leaves main's behavior.
  • The Composer test table covers packages / packages-dev, a sibling's copy, another ecosystem's copy, an unreadable lock and a missing lock.
  • SOCKET_NO_BAZEL is deliberately left off the child-env scrub list, and a test checks that.
  • CHANGELOG.md is untouched.
  • CI on f9fbf1461: ci-ok and clippy are green, no check failed, and there are no open review threads. The branch has no conflict with main.
  • I didn't build or run anything locally; that is left to CI.

Changes I made. None.

Open questions. None block merging. The approver should accept or reverse decisions 2 and 6 in the description; each is a one-condition change.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant