Skip to content

Decline Composer vendored mode in a Bazel workspace - #2186

Open
Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
mainfrom
bazel-guard/composer-vendored
Open

Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
mainfrom
bazel-guard/composer-vendored

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

Vendored mode now declines a Composer package of a project in a Bazel workspace, where it used to exit 0 and could leave the Bazel build broken; --mode hosted writes no such path, and the new --allow-vendored-in-bazel flag brings the old behaviour back.

Based on main, in three commits. The first is tests only and records what main does today. The second is the change, with the expectations of the first changed to match. The third applies a review of the first two (see "Code review").

What the code does today

No Bazel ruleset builds PHP or takes Composer packages. A PHP project under Bazel brings its packages into the build with a few lines of its own: a repository rule or a genrule that runs composer install from the committed composer.lock, or a committed vendor/ tree.

Vendored mode rewrites the lock entry to a path dist, .socket/vendor/composer/<uuid>/<vendor>/<name>@<version>. Composer reads that path from the directory it runs in. A repository rule or a build action runs Composer in a directory of Bazel's that holds composer.json and composer.lock and nothing else, so the path names nothing.

The first commit records this on real Bazel (composer::vendored_repository_rule):

  1. socket-patch scan --mode vendored --yes exits 0 with status success and reports the package vendored.
  2. The next bazel build fails: Source path ".socket/vendor/composer/<uuid>/<vendor>/<name>@<version>" is not found for package <vendor>/<name>.
  3. vex attests the package all the same.
  4. vendor --revert puts every file back, and the build with them.

Measured on Bazel 9.3.2, 8.8.2 and 7.7.2: of sixteen vendored runs over the shapes such a project is written in, eight left the build broken and the other eight built the unpatched package.

What changes

What a workspace's rules do with the lock cannot be read from its files. A rule may take the lock through a glob, or live in another module. A committed vendor/ tree does not settle it either: it shows that Composer has run in the project's directory, not that no rule runs it somewhere else as well. A workspace with both a committed tree and a repository rule that installs from the lock fails the same way (Bazel 9.3.2). So the refusal reads none of that. Every Composer project in a Bazel workspace is declined for a package the run would newly vendor, and the user's word is the one thing that lifts it.

The condition. The project's directory, or one above it up to the root of its git checkout, holds MODULE.bazel, REPO.bazel, WORKSPACE or WORKSPACE.bazel (bazel::bazel_root). Then every command that would vendor a Composer package refuses it with vendor_composer_bazel_workspace:

Command Result
scan --mode vendored, get --mode vendored, vendor for a patch the manifest records failed event, status partialFailure, exit 1
a run for a package whose lock entry already names the copy of the same patch: an in-sync run of a project that was vendored before, a scan or get with no --mode included not refused: the run leaves the lock as it is
a vendored scan over a hosted pin the same, and the pin stays
vendor that would eject a hosted pin status: error, eject_refused, the pin stays; the detail starts kept hosted:
scan or get with --dry-run listed as one the run would refuse, exit 0
vendor --dry-run reported failed, exit 1, as that command does for any package it could not vendor

Nothing is written and no patch is downloaded. The refusal looks for the workspace file and reads composer.lock: it starts no program and asks no service.

The message names the Bazel root and the mode that writes no such path, --mode hosted, which names the patched archive by a URL that Composer fetches from any directory. It does not promise that hosted mode patches every Bazel build. Hosted mode patches the build when Bazel runs Composer on the rewritten lock. Where Bazel does not, the hosted run exits 0 and the build stays the unpatched one, as before this change: a repository rule that links the lock with rctx.symlink is not run again on Bazel 8 and 9 until its repository is fetched again, and an http_archive of the package never reads the lock. The docs now list this as a limit.

The exception is the user's word: --allow-vendored-in-bazel, or SOCKET_ALLOW_VENDORED_IN_BAZEL=1. It is for a project where Composer only runs in the project's directory, or where the build finds the copy all the same:

  • a project that Bazel does not build, for example one where a Dockerfile runs composer install;
  • a project that commits its vendor/ tree, when no rule installs from the lock as well. The build is the patched one after the next composer install in the project, as without Bazel;
  • a project whose rule brings the project's .socket directory to where it runs Composer.

socket-patch checks none of these.

The switch is shared. It is not Composer's alone. It lets vendored mode write for a package although the project is in a Bazel workspace, where the build may not find the vendored copy. A refusal of the same kind for another ecosystem is to read the same switch; its binding sits beside the dispatch of the refusals (vendor::refusals::ALLOW_IN_BAZEL_ENV, read by vendor::refusals::bazel_workspace_refusals, the one answer every vendored command takes, the eject included). The Composer refusal is the only one it lifts today, and a refusal's code keeps its ecosystem.

vendor --revert is never refused. Neither is a package that is already vendored: where composer.lock already names the copy of the same patch, the run leaves the lock as it is, so a project that was vendored before (by an earlier release, or with the flag) keeps passing its runs. What is refused is the write of the path: a new patch for that package, or another package.

What a person reads. No line is new. The refusal prints where every refused vendored package does:

  • scan: [error] <purl> (vendor_composer_bazel_workspace): <detail>, then Nothing was vendored: 1 patch failed (see above). The closing totals count the package's advisories as left in packages the run did not patch.
  • scan --dry-run, get --dry-run: [dry-run] Would download and vendor 0 of 1 patch (1 would be refused). No changes made. and [would-refuse] <purl> (<code>): <detail>.
  • get: the [error] line and No vendorable patches in scope.
  • vendor: Error: Cannot vendor <purl>: <detail> and Vendored 0 packages; 1 failed. For the eject the detail starts kept hosted:.

Nothing changes outside a Bazel workspace, for another ecosystem, or for hosted and agent mode.

Contents

Part Files Size
The refusal, with the in-sync exemption vendor/composer_lock/bazel.rs (new) 188 lines with its unit tests
One dispatch for every vendored command, and the shared switch's binding vendor/refusals.rs +60 / -2
The eject asks before it fetches, and the report of a refused eject as one function commands/vendor.rs +58 / -29
The flag args.rs, and one row each in utils/process.rs, utils/env_compat.rs, composer_lock.rs +28 / -3
Real-Bazel flows and tests that need no Bazel tests/e2e_bazel_build/composer.rs +392 / -7
Flag rows tests/cli_global_args.rs, tests/common/clap_parse.rs +14 / -3
Docs docs/ecosystems.md ("Bazel workspaces: Composer"), CLI_CONTRACT.md (four rows) +75 / -2
Workflow bazel-composer.yml: comments, and its legs now start for a change to bazel/mod.rs, utils/repo_root.rs and vendor/refusals.rs +17 / -8

13 files, +832 / -54 in three commits. No fixture changed. The bazel budget group of scripts/loc-budget.py is unchanged at 2486 of 2486. lock-writers grows by 77 code lines to 101455; it was over its cap before, and the cap is not raised here.

What it proves and where

Everything below ran on one macOS arm64 machine, with PHP 8.4.23 and Composer 2.11.2. Nothing here has run in GitHub Actions yet.

Real Bazel 9.3.2, 8.8.2 and 7.7.2, the five composer:: flows on each, run the way the reusable workflow's step runs them. All pass; the legs took 38, 50 and 35 seconds.

  • composer::vendored_repository_rule:
    • the vendored scan declines (exit 1, the code, a detail that names --mode hosted and the flag), no file differs and the patched archive is not requested;
    • the same build passes on the upstream package;
    • hosted mode then patches the build, and rollback restores every file;
    • with the flag the old behaviour is back: vendored, then the build fails with Composer's message.
  • composer::vendored_committed_vendor: the project that commits its tree is declined too, and nothing is written. With the flag the package is vendored; the build stays the unpatched one until the developer's composer install, then it is the patched one.
  • The three existing flows (hosted through the rule and the genrule, agent on the committed tree) pass unchanged.

The first commit on main's product code: all five flows pass on 9.3.2.

With the product change reverted, both vendored flows fail on 9.3.2 at the exit-code assertion, and the two new tests that need no Bazel fail.

Thirteen mutations, one at a time, each caught by a test:

  • the refusal never fires, or fires outside a workspace;
  • the flag or the variable is not read, or the environment binding is dead;
  • the eject does not ask first, does not ask on a dry run, or does not say the pin was kept;
  • the refusal becomes a skip;
  • the message loses hosted mode, names a flag that does not exist, or names the project's directory in place of the Bazel root;
  • the dispatch refuses other ecosystems.

Outside a Bazel workspace, compared with a binary built from main: 14 runs (vendored scan, check, rescan, revert, dry run, get, eject and takeover, in JSON and human output, with and without a .git directory). Exit codes, both output streams and the file tree after every command are byte for byte the same; only timestamps were normalised. With a MODULE.bazel added, all 14 differ and no file is written.

A project whose vendor/ tree git tracks, in a Bazel workspace, run by hand outside the test suite: declined, nothing written. The vendored scan, its dry run and the dry run of get start no git process there. In a checkout whose vendor/composer directory is laid out as a git repository with a configuration that names a program, none of the three ran that program.

Without Bazel, PHP or Composer (these run in every plain cargo test):

  • every command that would vendor refuses and writes nothing, the dry runs of vendor and of its eject among them; the eject's detail starts kept hosted: , and a refused eject sends the service no request;
  • vendored mode goes on in no workspace, with the flag and with the variable;
  • a later run without them passes and writes nothing, a scan with no --mode among them: the lock already names the copy of that patch;
  • vendor --revert needs neither.

The rest of the gate, on the final head:

  • the core unit suite: 8324 passed;
  • the CLI unit suite: 1024 passed;
  • 26 Composer, vendored and argument-parsing test targets: 1454 passed, 0 failed. No existing expectation changed but the count of global flags;
  • e2e_bazel_build without Bazel: 51 passed; the cli and spawn_env_hygiene ratchets: 130 passed;
  • clippy with -D warnings, cargo check on all targets and features, rustfmt --check on the changed files, the script tests, actionlint and the tool-pin check on bazel-composer.yml: all pass.

Not covered

  • Linux and Windows.
  • A workspace that has both a committed tree and a rule that installs from the lock has no flow of its own. The refusal does not read the tree, so it is the code path of the repository-rule flow; its command was run by hand as above, its Bazel build was not run on this head.
  • The genrule project has no vendored flow, and neither has a workspace without Bzlmod or a rule that takes the lock with rctx.symlink. The refusal reads the workspace file and nothing else, so it is the same code path.
  • The flag together with a rule that brings .socket to where it runs Composer. The docs name that use; no test here builds it.
  • A scan over several project directories with a declined Composer project among them. Each directory asks for itself, but no test here runs that.
  • vex after a refusal, the uuid form of get --mode vendored, --silent output, and repair or rollback of a vendored Composer package under Bazel.
  • A Bazel root that the lookup does not reach is not seen, and vendored mode goes on there as before: one above the git checkout (a project that is a checkout of its own, such as a submodule, inside a Bazel repository), one above a project in no checkout or in one whose .git belongs to another user, and the home directory for a project below it. This is the limit of the lookup that the .bazelignore code on main uses as well, and the docs list the cases.
  • Hosted mode's own misses under Bazel, named above, are not changed here. They are in the docs' limits.
  • Composer other than 2.11.2 and PHP other than 8.4.23.

Code review

A review of the first two commits gave nine findings. The third commit settles them:

  • Fixed: an in-sync run was refused. A project vendored before failed its next routine run with exit 1 although the run would write nothing. A package whose lock entry already names the copy of the same patch is now let through (decision 5).
  • Fixed: the eject asked the refusal too late. It asked per pin, after fetching every pin's record from the service and planning the upstream restore, so an offline run reported patch_fetch_failed first. It now asks once, before any record is fetched; a test holds that a refused eject sends the service no request.
  • Fixed: two call sites, one per ecosystem. vendor::refusals::bazel_workspace_refusals is the one dispatch, called by vendor_refusals and by the eject.
  • Fixed: the message printed the Bazel root with the verbatim prefix a canonical path has on Windows. It is stripped, as the .bazelignore messages do. Not run on Windows here.
  • Fixed: a unit test read the developer's environment and failed with SOCKET_ALLOW_VENDORED_IN_BAZEL=1 exported. It holds the variable unset.
  • Fixed: the workflow's path filter. The Composer legs started for every file under bazel/, which the Maven work changes often, and not for utils/repo_root.rs, where the walk of the lookup is. They start for bazel/mod.rs and utils/repo_root.rs.
  • Fixed: duplicated test fixture code and a repeated ecosystem test, by an is_composer helper and by building the test tree in place.
  • Not fixed, documented: the lookup of the Bazel root does not look above a project that is its own checkout, above a .git of another user, above a project in no checkout, or into the home directory. There vendored mode goes on as on main. The lookup is the one main already uses to write .bazelignore; widening it changes what that code reads too, so it belongs in a change of its own. The docs now list the four cases.
  • Not fixed: the opt-in reaches the refusal through the process environment (the flag is mirrored into SOCKET_ALLOW_VENDORED_IN_BAZEL, as --offline and --debug are mirrored into theirs), not as a parameter. A parameter would add a field to the download parameters and an argument to the dry-run preview, about fifteen construction sites, most of them tests. The mirror is sticky only in a process that runs the CLI more than once, which the released binary never does.

Also in the third commit: the docs of this section no longer say that agent mode patches a committed vendor/ tree under Bazel. Agent mode is listed as not supported in a Bazel workspace.

Run on the third commit, on the same machine: cargo check on all targets and features and clippy with -D warnings (workspace, and the e2e_bazel_build target); rustfmt --check on the changed files; the unit tests of the changed modules; e2e_bazel_build without Bazel (51 passed), cli (109), cli_global_args (13), spawn_env_hygiene (21); the suites that run the eject and vendored Composer (vendor_eject 14, vendor_eject_fresh_checkout 12, vendor 145, in_process_vendor 157, mode_migration_composer 9, all passed); actionlint and the tool-pin check on the workflow. Two mutations, each caught: the exemption dropped (the unit test and the in-sync test fail), and the eject's question moved behind the fetch (the request count fails). The real-Bazel flows were not run again on the third commit: no flow changed, and the legs run in CI once the pull request leaves draft.

Decisions for the owner

  1. A project that commits its vendor/ tree is declined too. Vendored mode works there today after the developer's composer install; with this change it exits 1 until the project has the flag. An exemption for a tree that git tracks was built and dropped, for two reasons. A workspace that has such a tree and also a rule that installs from the lock passed the exemption: exit 0, then a failed build, which is the defect this change is for. And the question needs a git call in a directory of the project, which in a clone that holds a directory laid out as a git repository runs a program that the clone names, on dry runs too. If you want the exemption back, it comes with that workspace shape as a stated limit, a hardened git call and about 20 more lines of code.
  2. The opt-in. It is one switch for every refusal of this kind, --allow-vendored-in-bazel with SOCKET_ALLOW_VENDORED_IN_BAZEL, shaped like --gem-refresh-shared (a global boolean with an environment binding, off by default), so a repository can set it once in CI. The alternatives:
    • a switch per ecosystem, which makes the consent finer;
    • a flag with no environment binding, like --allow-patch-conflicts, which makes the consent per run;
    • a socket.yml key, which is not used because that file's policy is documented as only narrowing what a run patches.
  3. A project in a Bazel workspace that Bazel does not build. A PHP service in a monorepo with a MODULE.bazel at its root, built by a Dockerfile, is refused like any other until it sets the flag. Nothing in the files tells it apart safely. Should it have to opt in, or is there a signal you would accept?
  4. Exit 1, not a skip. The refusal is a failed event, as for the other shapes vendored mode cannot serve. A pipeline that ran scan --mode vendored on such a project now fails at the scan where it used to fail at the build. The alternative is a skipped event with exit 0, at the price of a quiet miss.
  5. A project that is already vendored in a Bazel workspace keeps passing its in-sync runs without the flag, a scan or get with no --mode included: a package whose lock entry already names the copy of the same patch is not refused, because the run leaves the lock as it is. A pipeline that was green stays green after the upgrade. A new patch for that package is refused until the run has the flag. The alternative is to refuse every vendored run there, which makes such a pipeline exit 1 on a run that would write nothing; say if you want that.

Generated by Claude Code

Tests only. No Bazel ruleset builds PHP, so a PHP project under Bazel
brings its Composer packages into the build with a few lines of its own:
a repository rule or a genrule that runs `composer install` from the
committed lock, or a committed `vendor/` tree. The real-Bazel Composer
flows ran hosted mode and agent mode in those projects, and vendored
mode in none.

Two flows record what vendored mode does there today:

- composer::vendored_repository_rule, in the project whose packages a
  repository rule installs. `scan --mode vendored --yes` exits 0 with
  status `success` and reports the package vendored. It keeps the
  patched package under the project's `.socket/vendor` and rewrites the
  lock entry to a path dist,
  `.socket/vendor/composer/<uuid>/<vendor>/<name>@<version>`, which
  Composer reads from the directory it runs in. The next `bazel build`
  fails: the rule runs Composer in a repository of Bazel's that holds
  the two Composer files and nothing else, and Composer says `Source
  path "<that path>" is not found for package <vendor>/<name>`. `vex`
  attests the package all the same. `vendor --revert` puts every file
  back, and the build with them.
- composer::vendored_committed_vendor, in the project that commits its
  `vendor/` tree. The command vendors the package, and the build passes
  and stays the unpatched one, because Bazel reads the committed tree.
  After the developer's `composer install` in the project's directory,
  which copies the package from `.socket/vendor` without a request to
  any host, the build is the patched one. `vendor --revert` restores
  the lock and removes the copy.

The first flow records a defect: a command that exits 0 leaves a build
broken. It is here so that the change which removes the defect shows as
a change of this test's expectations.

`Machine::composer` now creates the directories of the files it is
given: the committed tree and the vendored copy are nested. The
workflow's comments name the two flows.

Run on Bazel 9.3.2 with PHP 8.4.23 and Composer 2.11.2 on macOS arm64:
the five `composer::` flows pass, the two new ones in about fifteen
seconds each.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Vendored mode makes composer.lock name the patched copy by a path dist,
`.socket/vendor/composer/<uuid>/<vendor>/<name>@<version>`, which
Composer reads from the directory it runs in. No Bazel ruleset builds
PHP, so a PHP project under Bazel brings its packages into the build
with a few lines of its own: a repository rule or a genrule that runs
`composer install` from the committed lock, in a directory of Bazel's
that holds the two Composer files and nothing else. There the path
names nothing. The command exited 0 with status `success`, `vex`
attested the package, and the next `bazel build` failed with Composer's
`Source path "..." is not found for package ...`. Measured on Bazel
9.3.2, 8.8.2 and 7.7.2 over the shapes such a project is written in: of
sixteen vendored runs eight left the build broken, and the other eight
built the unpatched package.

What a workspace's rules do with the lock cannot be read from its
files. A rule may take the lock through a glob, or live in another
module. A committed `vendor/` tree does not settle it either: it shows
that Composer has run in the project's directory, not that no rule runs
it somewhere else as well, and a workspace with both a committed tree
and a repository rule that installs from the lock fails the same way
(Bazel 9.3.2). So the refusal reads none of that. Every Composer
project in a Bazel workspace is declined, and the user's word is the
one thing that lifts it.

When the project's directory, or one above it up to the root of its git
checkout, holds MODULE.bazel, REPO.bazel, WORKSPACE or WORKSPACE.bazel
(`bazel::bazel_root`), every command that would vendor a Composer
package refuses it with `vendor_composer_bazel_workspace`: `scan --mode
vendored`, `get --mode vendored`, `vendor` for a patch the manifest
records, the takeover of a hosted pin by a vendored scan and the eject
of one by `vendor`. A `scan` or `get` that names no mode runs in
vendored mode in a project that is already vendored, and is refused
there too. The package is a `failed` event and the run exits 1
(`partialFailure`; for the eject `eject_refused`). A dry run of `scan`
or `get` lists the package as one the run would refuse and exits 0;
`vendor --dry-run` reports the refusal and exits 1, as it does for any
package it could not vendor. Nothing is written, no patch is
downloaded, and a hosted pin stays. The refusal itself only looks for
the workspace file: it starts no program.

The detail names the Bazel root and the mode that writes no such path,
`--mode hosted`, and promises no more of it than that: hosted mode
names the patched archive by a URL, which Composer fetches from any
directory. It patches the build when Bazel runs Composer on the
rewritten lock. Where Bazel does not, the hosted run exits 0 and the
build stays the unpatched one, as before this change: a repository rule
that links the lock with `rctx.symlink` is not run again on Bazel 8 and
9 until its repository is fetched again, and an `http_archive` of the
package never reads the lock. The docs' limits now say so.

The user lifts the refusal with the new global flag
`--allow-vendored-in-bazel` or SOCKET_ALLOW_VENDORED_IN_BAZEL=1: for a
project that Bazel does not build, for one that commits its `vendor/`
tree where no rule installs from the lock as well, or for one whose
rule brings `.socket` to where it runs Composer. The switch is not
Composer's alone: it lets vendored mode write for a package although
the project is in a Bazel workspace, where the build may not find the
vendored copy, so that a refusal of another ecosystem that rests on the
workspace can read the same one. Its binding is
`vendor::refusals::ALLOW_IN_BAZEL_ENV`, beside the dispatch; the code
of a refusal keeps its ecosystem. The flag is shaped like
`--gem-refresh-shared`: a boolean global with an environment binding,
off by default. The CLI mirrors it into the environment, where core
reads it, as it does for `--offline`. A socket.yml key was not used:
that file's policy only narrows what a run patches and names no
safety switch.

`vendor --revert` is not refused: it takes the path out of the lock. A
project vendored with the flag, or by an earlier release, is refused
again by a later vendored run without the flag, which changes nothing.
Outside a Bazel workspace a vendored run with a Composer package looks
for the Bazel root and does what it did; other ecosystems, hosted mode
and agent mode are not touched.

The answer has one home, `vendor::composer_lock::bazel::refusal`.
`vendor_refusals`, which every vendored entry point reads before it
downloads anything, hands it to each Composer candidate, and the eject
asks it in its preflight, before it restores a pin.

No line a person reads is new. The refusal prints where every refused
vendored package does: `[error] <purl> (<code>): <detail>` from `scan`
and `get`, `[would-refuse] ...` in their dry runs, and `Error: Cannot
vendor <purl>: <detail>` from `vendor` (`kept hosted: <detail>` for the
eject). The scan's closing totals count the package's advisories among
those in packages the run did not patch.

Tests:

- composer::vendored_repository_rule (real Bazel) now holds the command
  to the refusal: exit 1, the code, a detail that names `--mode hosted`
  and the flag, no file changed and no request for the patched archive.
  The same build passes on the upstream package. Hosted mode then
  patches the build and `rollback` restores it. With the flag the
  expectations of the previous commit are back: the package is
  vendored and the build fails with Composer's message.
- composer::vendored_committed_vendor (real Bazel) holds it to the
  refusal in the project that commits its tree too. With the flag the
  expectations of the previous commit are back: the package is
  vendored, the build stays the unpatched one, and after the
  developer's `composer install` it is the patched one.
- Two tests of the same file need no Bazel, PHP or Composer. Every
  command that would vendor refuses and writes nothing, the dry runs of
  `vendor` and of its eject among them, and the eject's detail starts
  `kept hosted: `. Vendored mode goes on in no Bazel workspace, with
  the flag and with the variable; a later run without them is refused
  again, a scan that names no mode included; and `vendor --revert`
  needs neither.
- Unit tests of the refusal (each workspace file name, in the project
  and at the root of its checkout; the detail names that root, hosted
  mode and the flag; a workspace beside the project is not the
  project's) and of its dispatch (every Composer candidate, no other
  ecosystem, not a benign skip).
- cli_global_args and clap_parse have the rows of the flag.

Docs: docs/ecosystems.md "Bazel workspaces: Composer", and the rows of
the flag, its variable, the code and the Composer line of the vendored
table in CLI_CONTRACT.md. bazel-composer.yml starts its legs for a
change to `bazel/` and to vendor/refusals.rs too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e eject's refusal first

Follow-ups to the refusal of Composer vendored mode in a Bazel workspace.

An in-sync run passes. The refusal hit every Composer package of the
project, whatever the lock said. A project that was vendored before (by
an earlier release, or with the flag) then failed its next routine run
with exit 1, a plain `scan` or `get` included, although that run would
have written nothing. What the refusal is for is the write of the path
into composer.lock, so a package whose lock entry already names the copy
of the same patch is now let through. A new patch for that package, and
any other package, is refused as before.

The eject asks first. `vendor` over hosted pins asked the refusal per
pin, after it had fetched every pin's record from the service and
planned the upstream restore. An offline run, or one the service could
not answer, reported `patch_fetch_failed` first and met the refusal only
on the retry. It is now asked once, before any record is fetched, and
the report of a refused eject is one function for both places. The test
holds that a refused eject sends the service no request.

One dispatch. `vendor::refusals::bazel_workspace_refusals` is the answer
every vendored entry point takes, the eject included, so a refusal of
this kind for another ecosystem has one place to go.

Smaller things:
- the message names the Bazel root without the verbatim prefix that a
  canonical path has on Windows, as the `.bazelignore` messages do;
- the unit test of the dispatch holds the switch unset instead of
  reading the developer's environment;
- the Composer legs start for bazel/mod.rs and utils/repo_root.rs, the
  two files the lookup of the root is in, not for every file under
  bazel/;
- the docs list every case in which the lookup does not reach a Bazel
  root, and say that agent mode is not supported in a Bazel workspace.

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

cursor Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes vendored-mode behavior and exit codes for Composer in Bazel workspaces; refusal is broad-by-design with opt-in, but pipelines that previously “succeeded” until build time will now fail at vendoring.

Overview
Composer vendored mode now fails closed in Bazel workspaces instead of succeeding and breaking builds. Vendored wiring puts a path dist in composer.lock; when Bazel runs composer install from another directory, Composer cannot find that path and the build fails after a green CLI run.

The change adds refusal code vendor_composer_bazel_workspace (via composer_lock/bazel.rs and shared bazel_workspace_refusals in vendor/refusals.rs). Detection walks up to the git checkout root for MODULE.bazel, WORKSPACE, etc. scan/get --mode vendored, vendor, and hosted eject all honor it; eject checks before network fetch. Packages already wired to the same patch path are not refused (in-sync reruns stay green).

Opt-in is global --allow-vendored-in-bazel / SOCKET_ALLOW_VENDORED_IN_BAZEL (mirrored like other toggles). Docs and CI path filters were extended; real-Bazel and hermetic tests cover decline, flag override, and hosted fallback.

Reviewed by Cursor Bugbot for commit bbff7dd. Configure here.

…flow

`composer::vendored_repository_rule` asserts that the build under the flag
fails with Composer's "Source path ... is not found for package ..." message.
Composer prints that message in a box as wide as its console and breaks it
inside a word where it does not fit: on the CI runners (Composer 2.10.3, no
terminal) the path and the package name are each split over two lines, so
the one-line search found nothing and the flow failed on all three Bazel
releases although the build failed exactly as expected.

The flow now compares the message and the build's stderr with white space
removed. Tests only.

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 20, 2026
main (#2178) gave track_outcomes_for_vendor the patch uuids of each run and
changed its inline eject-refused block; this branch had moved that block into
eject_refused(). Keep the helper and pass it the pins' uuids, so both of its
callers, the hosted-pin refusals and the Bazel declines, send the new event.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko Mikola Lysenko (mikolalysenko) removed the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants