Repository navigation
Keep Go module copies under .socket out of Bazel packages - #2123
Conversation
`scan --mode vendored` and agent mode (`scan --mode agent`, `apply`) patch a Go module by keeping a patched copy of it in the checkout, under `.socket/vendor/golang` or `.socket/go-patches`, and pointing `go.mod` at it with a directory `replace`. Only the hosted flow had a test on a real Bazel. This adds the two other modes for the same gazelle `go_deps` workspace, on Bazel 9.3.2, 8.8.2 and 7.7.2, and records what the code does there today. The next build is patched in both modes, and the undo is clean (`vendor --revert`) or leaves only the emptied `.socket/manifest.json` (`rollback`). The user's next step breaks the build: - `bazel run //:gazelle` writes a BUILD.bazel into the copy. gazelle's `go_deps` copies the directory with that file, and every target that uses the module fails to load: `No repository visible as '@rules_go'`. - When the module ships a BUILD file of its own, `bazel build //...` fails right after the command: the copy is a package of the checkout whose load of `@io_bazel_rules_go` nothing maps. Each test asserts that break by its error, so that the commit that fixes it has to change the expectation. The fixture gains a `gazelle` target, and its BUILD file is now the one gazelle writes, so a gazelle run on the unpatched checkout changes nothing and what a later run writes comes from the patch. Agent mode copies the module from the user's module cache; the test lays that directory out itself, so the runner needs no Go toolchain beyond the one rules_go downloads. gazelle is built from Go modules of its own: a flow that runs it has proxy.golang.org last in its GOPROXY list, after the stand-in that serves the module under test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryLow Risk Overview Adds a shared Updates the gazelle Bzlmod fixture with a Reviewed by Cursor Bugbot for commit 6f85989. Configure here. |
|
[agent] PR shepherd: this PR holds only the tests-only commit Question for the owner: please push Generated by Claude Code |
Vendored and agent mode patch a Go module by keeping a copy of it under the project's `.socket` directory and pointing `go.mod` at it with a directory `replace`. In a Bazel workspace that copy is a directory Bazel and gazelle walk like any other. The next build is patched, and then the user's ordinary steps break it, on Bazel 9.3.2, 8.8.2 and 7.7.2 with gazelle's `go_deps`: - `bazel run //:gazelle` writes a BUILD.bazel into the copy, `go_deps` copies the directory with it, and every target that uses the module fails to load (`No repository visible as '@rules_go'`); - when the module ships a BUILD file of its own, `bazel build //...` fails right after the command. One line in the `.bazelignore` at the root of the workspace prevents both, and socket-patch now writes it. This is the first Bazel file socket-patch writes. Where it applies A project is in a Bazel workspace when its directory, or one above it up to the root of its git checkout, holds a regular file `MODULE.bazel`, `REPO.bazel`, `WORKSPACE` or `WORKSPACE.bazel`. Those are the names Bazel's client looks for from the working directory up (`WorkspaceLayout::InWorkspace`, src/main/cpp/workspace_layout.cc line 36 at the tags 7.7.2, 8.8.2 and 9.3.2). The nearest such directory is the Bazel root; a directory of that name does not count. Without such a file nothing is read or written, and the run writes the same files as before, byte for byte. The checkout is the one `repo_root::find_git_repo` finds, and it counts only when its `.git` belongs to a trusted owner (`GitRepo::trusted`: the user, root, or the user sudo ran for; a root process trusts any), which is the rule the `socket.yml` lookup has for the repository root. Without it, another user's `/tmp/.git` and `/tmp/MODULE.bazel` on a shared machine would make a command in `/tmp/job/proj` create `/tmp/.bazelignore`. A project in no such checkout (a Docker build context, an unpacked source archive, a checkout of another user) is looked for in its own directory only: nothing above it is read, so a workspace file there gives no line and no warning. Neither does a Bazel root above the root of the checkout (a git submodule, several checkouts below one workspace): this repository reads no project file outside the checkout, so a look there could see the workspace file and not whether the line is in place, and its warning would never end. The nearest directory with a workspace file is the root. In a workspace that is nested in a larger one the line is therefore in the inner file, which a run from the outer workspace does not read. Measured on Bazel 9.3.2 with gazelle 0.54.0, outside the committed tests: from the outer root `bazel build //...` loads the packages of the inner tree, a BUILD file in the copy among them, and `bazel run //:gazelle` writes a BUILD.bazel into the copy, after which the inner build fails as above; with the line in the outer file, by its path from the outer root, neither happens. The writes are not widened for that. The docs name these limits and the line to add by hand. What is written - While `<project>/.socket/vendor/golang` or `<project>/.socket/go-patches` exists, the root's `.bazelignore` names it by its path from the root, on a line of its own under the comment line `# socket-patch: patched Go module copies, not Bazel packages (to opt out, comment out the next line)`. The pair is added at the end of the file, in the file's line breaks, and the file is created when missing. Never `.socket` alone: other things live there. - Nothing is added when a line already covers the directory: the path or a directory above it, with or without a trailing `/` or a leading `./`. Bazel reads a line literally, so a line with a blank before or after it, a pattern or a string prefix covers nothing. - Nothing is added either when the user declined the pair: the comment line with the path line commented out under it (`#`, blanks, the path, which may end in one `/` or start with `./` as in a line that covers). No command adds a line for that directory, warns about it or touches the two lines again, on removal either. Deleting the pair is no opt-out: the next command writes it back. Neither is commenting out both lines, or a path line changed in another way. - socket-patch knows its pair by the start of the comment line, `# socket-patch:`, not by the whole sentence: a path line under a line that starts so is its own, and that path line commented out is the opt-out. A later release can reword the comment without leaving the pairs of this one behind. - Only a directory that is not found is gone. One that cannot be probed (a directory above it that may not be searched, a transient error) keeps its pair, and gets none. - Once the directory is gone the pair is removed, and the file is the one of before, byte for byte. A file whose last line has no line break gets a line break and the pair without a final one, and loses that line break again with the pair: exactly the one the comment line ends in, which is the one that was written before it, so that a last byte that is a carriage return on its own stays. Bazel and gazelle honour a last line without a line break: the agent test on real Bazel has one. A file left empty is deleted, an empty one the user had included: it cannot be told from one socket-patch created. Only a line under such a comment line is ever removed. - The line follows the directory, not the `replace`: `rollback --preserve-state` drops the `replace` and keeps the vendored copy, whose BUILD files would be back in the workspace without the line. - A read-only file is neither replaced nor deleted. The file is opened for appending before any change, a removal included, because a rename or an unlink succeeds in a writable directory. - A file that is not updated is the new warning `bazelignore_not_updated`: it could not be read or written (a directory or a symbolic link in its place, a read-only directory, a read-only file). The detail names the line to add, or says that the lines of a copy that is gone can be deleted. The command succeeds as before. - A human run reads `Updated <path>` or `Removed <path>` on stdout when the file changed, once for each file, in words that hold for lines that came and for lines that went, and the warning on stderr. Under `--json` the warning is a run-level `warnings[]` entry; there is no new field. Which commands `commands::sync_bazelignore` is the one place the CLI asks for the file, behind one gate: not in a dry run and not in a `--global` run. Each command that can write or remove a copy calls it once, after its last step that can change a copy or take one back: `apply` (and with it `scan --mode agent` and `get`), the vendored step of `scan` and `get`, `vendor`, `vendor --revert`, `rollback`, `remove`, `repair` (also when it failed), and a hosted scan that took the lock, since a takeover removes the vendored copy. A hosted scan that took no lock may write nothing (`patches.enabled: false` in `socket.yml`, a rollout cap, no granted reference) and leaves this file alone too. The eject of a hosted project calls it after its rollback, so that an eject which vendored the Go module and was then rolled back leaves no pair for a copy that is gone again. `apply` and `vendor` in a project with no manifest end before that step. A run whose `--ecosystems` leaves `golang` out adds no line. It still takes away the pair of a copy that is gone, because `remove` of a Go patch and `vendor --revert` remove the Go copy whatever that option says. With a `--manifest-path` into another project the agent copies are those of `--cwd` and the vendored ones those of the manifest's project, so the helper brings the file of each project's Bazel root in line. `scan --prune` comes to the file a second time, after a pass that reverted a vendored entry or swept an orphan directory, which can remove the last copy after the scan's own step. That second call only takes a pair away: it adds no line and gives no warning, so the run warns once and no state is kept between the two. What it costs: a warning the scan's own step gave for a copy the pass then removed is out of date, and a file the pass cannot write is reported by the next command. The scan's own call cannot be left to that pass instead: the pass also follows the nested apply of `scan --mode agent --prune`, and it does not run at all when it cannot take the apply lock. The file is written after the commands' group commits, outside them: it is no part of a commit journal. A run that dies in between leaves a copy without its line, which the next command adds; a command that fails after it removed a copy can leave the pair behind, which ignores nothing, until the next command. A file several projects share Two projects under one Bazel root share the file, and each command holds only its own project's apply lock. So the edit, from its read to its write, is made under an advisory lock on the root directory itself: `fs2` on a handle to the directory, with contention told as the apply lock tells it (`apply_lock::is_lock_contended`). No lock file is made, in the workspace or anywhere else. A run that finds nothing to change takes no lock, also when the file cannot be read and the project has no copy to name in it. Where the directory cannot be locked (Windows, where it cannot be opened this way; a file system without such locks), or the lock stays held for a second, the edit is made without it: an add is still one appending write, which keeps what another project adds at that moment, and a removal replaces the file and can then lose such a pair until the next command in that project. With the lock, a removal in one project against an add in its sibling keeps the added pair in every one of 25 rounds of a unit test, which asserts that half on Unix only; without the lock that test fails. What a run costs The Bazel root and the bound of the checkout come from one walk up (`search_dirs`), which runs with the rest of the edit on the blocking pool. For a project outside a Bazel workspace, `d` directories below the root of its checkout, that is 2 path canonicalisations, `d + 2` stats of `.git` and `4 (d + 1)` stats of the four names, and nothing else. In a Bazel workspace it adds two stats of the copy directories and one read of `.bazelignore`; the lock and the write come only when something changes. (Counted from the code, not traced.) A side effect The line does more than keep gazelle out. Bazel leaves an ignored directory out of every `glob()` of a package above it (9.3.2, 8.8.2 and 7.7.2), so a target that hands the project's Go files to a `go` command of its own through such a glob no longer receives the copies. Built on Bazel 9.3.2 with a genrule that runs the Go SDK's `go build` over `glob(["**/*.go", "**/go.mod", "**/go.sum"])`, outside the committed tests: without the line it builds patched until the first `bazel run //:gazelle`, whose BUILD file in the copy takes the copy out of the glob in the same way, and then fails (`replacement directory ./.socket/vendor/golang/... does not exist`) together with every rules_go target that uses the module. With the line the rules_go targets build, and that genrule fails with the same error from the start; it builds when it names the copy's files as labels beside the glob, or runs outside the sandbox. A workspace that has such a target and never runs gazelle can decline the line as above. Not covered Only Go module copies get a line. Other ecosystems keep unpacked packages under `.socket/vendor/<ecosystem>` too (a crate can ship a BUILD.bazel); nothing was measured for them under Bazel, so nothing is written for them. A BUILD file that gazelle wrote into a copy before the line existed stays there: the next `scan --mode vendored` rebuilds the copy, and in agent mode the BUILD files under `.socket/go-patches` have to be deleted by hand. A project directory whose path from the root starts with `#` or white space, or holds `*`, `?` or `[`, cannot be named in `.bazelignore`: its line is written, and Bazel or gazelle does not honour it. `ignore_directories` in REPO.bazel is not read; a workspace that has it gets the line too. Tests The real-Bazel tests now assert the fixed outcome: the build prints the patched marker after the command and `bazel build //...` passes, the two tests of a module without a BUILD file build it again after `bazel run //:gazelle`, which writes nothing, and the undo takes the line away. The agent test starts from a `.bazelignore` of the user's whose last line has no line break, and ends with that file as it was. Tests without Bazel hold: the root finder (each of the four names, a directory of such a name, a link, a file above the checkout, a checkout of an owner that is not trusted and a project in no checkout, which both reach no further than the project); the line rules (what covers, the opt-out and what is none, a pair under another wording of the comment, the pair in LF and CRLF files and after a last line without a line break, the removal that leaves the file of before, a last carriage return included, a run that leaves Go out); the write (appended to the file that is there, a read-only file and a link left alone on an add and on a removal, a copy directory that cannot be probed, the lock on the root directory and none where nothing can change); two edits at once; and through the built binary each command's call: that a dry run of ten commands writes nothing in either mode, that a declined pair stays declined over scan, repair, apply, rollback and revert, that a rolled-back eject leaves the project as it was, that a prune pass and a hosted takeover take the line away with the last copy, that `--ecosystems npm` adds no line and takes the pair of a copy it removed away, that a scan which `socket.yml` lets write nothing leaves the file alone in every mode, that a manifest in another project brings both files in line, that a file which cannot be written is one warning for each command (in the envelope, and on stderr for a scan whose prune pass comes to the file a second time), what a human run prints for lines that came, lines that went and a file that went, that a project in no git checkout below a Bazel root gets no line and no warning, and that the same run in a project with no Bazel workspace file writes the same files, byte for byte but for the time in a vendored copy's marker, and no `.bazelignore`. No test depends on what lies above the temp directory: they pass with it inside a git checkout and outside one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
[agent] PR shepherd: review brief for the approver What it does. In a Bazel workspace, the Go modes that keep patched module copies under Risk: medium. The code is careful, but this is the first time socket-patch writes a Bazel file in a user's repo. The first agent-mode Look here
Verified. The fix commit Changes I made: none. Open questions: none that block a merge. Minor points:
This PR is the base of the stack #2139 → #2148 → #2157, which is already approved. Generated by Claude Code |
The parent branches landed on main as squash commits (#2123, #2139, #2148), so this re-applies only this PR's own changes on top of main. main (#2155) turned build_document_with into the one builder, taking an Attested struct and adding code_not_present; this PR had added a separate build_document_with_affected. The affected PURLs are now an `affected` field of Attested, handled by build_document_with: - an affected PURL still gets a statement of its own with status `affected` and its action statement; - a not_affected statement keeps main's justification rule (vulnerable_code_not_present only when no subcomponent is patched); - `vex` passes both code_not_present and affected. Tests of the affected statements now go through build_document_with. CLI_CONTRACT.md keeps main's folded warning text and adds this PR's partialFailure-on-affected sentence. The bazel LOC budget is main's plus this PR's growth. Assisted-by: Claude Code:claude-opus-5-5
Go vendored and agent mode in a Bazel workspace: socket-patch names its module copies in the root's
.bazelignore, so the build stays patched afterbazel run //:gazelle, andbazel build //...passes.Two commits on
mainat89c482d80. The first (tests only) was pushed first, so that CI records what today's code does: it is green on GitHub's Linux runners on Bazel 9.3.2, 8.8.2 and 7.7.2 (run 44193996968: the four Go flows pass while asserting today's break). The second (the fix,cdf3a5fb6) is green too, all 63 checks. Because the shared test harness changed slightly, its run covers the Bazel legs of all four ecosystems on 9.3.2, 8.8.2 and 7.7.2: Go (four flows: 192 s, 243 s, 215 s), npm (64 s, 38 s, 40 s), PyPI (52 s, 26 s, 34 s) and RubyGems (65 s, 41 s, 45 s). The Windows and macOS test jobs were run by dispatch on the same commit (Windows, macOS); both are green. The macOS run needed one rerun of one job:utils::process::tests::an_interrupt_pass_ends_the_whole_build_groupfailed once and passed on the rerun; that test and its file (utils/process.rs) are not part of this change.mainhas moved since the branch was cut; the pull request merges with it without a conflict, and CI tests the merged tree.Decisions for the owner
(a) socket-patch writes a Bazel file for the first time. Decided by the owner on 2026-11-17: yes. It is the
.bazelignoreat the root of the workspace, which gets two lines for each directory of copies:What the yes costs:
glob()above them. That is (b), and a user can decline it..bazelignorein every Bazel workspace that already has a Go copy. Theapplyof a CI install is such a command in an agent-mode project. A job that checks for a clean tree sees that change until the file is committed.The alternative was a warning that names the line to add. That leaves the break in place for everyone who does not act on it: on today's code the build breaks at the first
bazel run //:gazelle, and at once forbazel build //...when the module ships a BUILD file.(b) The line also takes the copies out of every
glob()above them. A user can decline it. Measured once as a build on Bazel 9.3.2 (macOS arm64, sandboxed, gazelle 0.54.0, rules_go 0.65.0, Go 1.26.0), in a scratch copy of the Go fixture with a vendored copy, outside the committed tests and not repeated for this revision. A genrule there runs the Go SDK'sgo build .overglob(["**/*.go", "**/go.mod", "**/go.sum"]):bazel run //:gazellewrote a BUILD file into the copyreplacement directory ./.socket/vendor/golang/... does not existNo repository visible as '@rules_go'--spawn_strategy=localThe workspace this makes worse has such a target, never runs gazelle, and patches a module without a BUILD file: it builds today and fails with the line. That workspace comments the path line out and leaves the comment line above it:
After that no command adds a line for that directory, warns about it, or touches the two lines again. The commented path may end in one
/or start with./. Deleting both lines is no opt-out: the next command writes them back. Neither is commenting out both lines, or changing the path line in another way (a space after it, a second#). socket-patch knows its two lines, and the opt-out, by the start of the comment line,# socket-patch:, so a later release can reword the rest of that line. Recommended: accept.(c) An empty
.bazelignorethe user had is deleted with the last pair. When the last pair is removed and nothing else is left, the file is deleted, whether socket-patch created it or the user had it empty; socket-patch keeps no record of which. An empty file that never held a pair is left alone. Every other file comes back byte for byte, a missing final line break and a last byte that is a carriage return on its own included. Recommended: accept.(d) The file is edited under an advisory lock on the Bazel root directory itself. Projects under one Bazel root share the file, so each edit, from its read to its write, is made under a lock:
flockon a handle to the root directory, released when the edit is done. No lock file is made, in the workspace or anywhere else (the previous revision kept one per Bazel root in the system's temporary directory, for ever). A command that has nothing to change takes no lock. Where the lock cannot be taken, the edit is made without it and one race is back: a pair that one project adds while another project's pair is removed can be lost until the next command in that project. That is the case on Windows (a directory cannot be opened this way), on a file system without such locks, and when the lock stays held for a second. Pairs that are only added are safe without it: each is one write at the end of the file. Measured through the built binary, two commands at the same moment in sibling projects, 200 rounds: no added pair lost with the lock, 47 lost without it. Recommended: accept.(e) A Bazel root that socket-patch does not look for gets no line and no warning. socket-patch looks for the workspace file in the project's own directory and, when the project is in a git checkout it trusts, up to the root of that checkout. Nothing above that is read. So three shapes get nothing, and the docs tell their users to add the line by hand, with the directory's path from that root:
.gitbelongs to another user. This is the rule socket-patch already has for the repository root: on Unix.gitmust belong to the user, to root, or to the usersudoran for (a root process takes any owner's).The second shape had a warning in the previous revision: the walk went on above the project, read the
.bazelignoreit found there, and warned on every command until that file held the line. The third review asked for it to go. It read a file above a project that is in no checkout, which nothing else in socket-patch does, and an unrelatedWORKSPACEfile in a parent directory made every command warn. Two ways to give these shapes a warning, neither built: allow this one read above the boundary (the warning then ends once the line is there), or accept a warning that never ends. Recommended: accept the limit.(f) In a Bazel workspace nested in a larger one, the line is in the inner file only. The Bazel root is the nearest directory with a workspace file. With
outer/MODULE.bazel,outer/inner/MODULE.bazeland the project ininner, the line goes intoinner/.bazelignore, which only a run frominnerreads. Measured on Bazel 9.3.2 (macOS arm64, gazelle 0.54.0, rules_go 0.65.0), in two scratch workspaces made from the Go fixture, outside the committed tests:inner:bazel run //:consumerouter:bazel query //...inneras//inner:...: the inner tree is part of the outer workspace's packagesouter, with a BUILD file the module ships in the copy:bazel build //...andbazel query //...error loading package 'inner/.socket/vendor/golang/...'innerouter:bazel run //:gazelleBUILD.bazelinto the copyinner, after that:bazel run //:consumerUnable to find package for @@[unknown repo 'rules_go' ..., the break this change is aboutinner/.socket/vendor/golanginouter/.bazelignore: the gazelle run, the build and the query fromouter, then the build frominnerinnerprints the patched markerThe writes are not widened for this. The docs name the limit and the line to add in the outer file, unless that file already names
inner. Recommended: accept.(g) A question: should
--jsonname the file when it changed? Under--jsona file that could not be updated is awarnings[]entry. A file that was created, changed or deleted is not mentioned; a human run readsUpdated <path>orRemoved <path>. The envelope has no place for it today. A hosted scan lists the lock and registry files it rewrote (redirect.rewrittenFiles),rollbackgives a count (hosted.editedFiles), and the vendored and agent commands, which are the ones that write a Go copy, name no file they wrote,go.modincluded. So nothing was added. If it should be there, it is a new additive key on those commands' envelopes: a few lines and a contract entry.What it contains
Two signed commits on
89c482d80.6f85989f7Test the vendored and agent Go flows through a gazelle run on real Bazel. Tests only: agazelletarget in the Go fixture, and three real-Bazel tests that pass on today's product code while asserting today's break.cdf3a5fb6Keep Go module copies under .socket out of Bazel packages.bazel::bazel_rootandbazel::ignore::syncin core, one helper in the CLI with ten call sites, the same three tests flipped to the fixed outcome, tests without Bazel, docs. The test harness gains a runner without--json, for what a person reads.crates/*/srcoutside test modules)Implementation by file:
bazel/ignore.rs264 lines (167 code),bazel/mod.rs51 (25), the helper incommands/mod.rs58 (42), its ten call sites 37 (25),lib.rs,repo_root.rsandgo_mod_edit.rsone line each. Code lines are counted with the rules ofscripts/loc-budget.py, where the new groupbazelis at 192 / 192.lock-readersandlock-writersare unchanged and were over onmain.What today's code does (commit 1)
On Bazel 9.3.2, 8.8.2 and 7.7.2 with gazelle's
go_deps:scan --mode vendored, and agent mode (scan --mode agent,apply): the next build prints the patched marker. Thenbazel run //:gazellewrites aBUILD.bazelinto the copy, and the build fails:No repository visible as '@rules_go'.bazel build //...fails right after the command:No repository visible as '@io_bazel_rules_go'.vendor --revert; an agentrollbackleaves the emptied.socket/manifest.json.What changes
Only for a project in a Bazel workspace: its directory, or one above it up to the root of its git checkout, holds a regular file
MODULE.bazel,REPO.bazel,WORKSPACEorWORKSPACE.bazel. Those are the names Bazel's client looks for (src/main/cpp/workspace_layout.ccline 36, the same at the tags 7.7.2, 8.8.2 and 9.3.2). The nearest such directory is the Bazel root; a directory of that name does not count. The checkout is the one socket-patch already trusts as the repository root, and a project in no such checkout looks at its own directory only: see (e). Without a workspace file there, nothing is read or written.<project>/.socket/vendor/golangor<project>/.socket/go-patchesexists, the root's.bazelignorenames it by its path from the root, under the comment line shown above. The pair is added at the end of the file, in the file's line breaks, and the file is created when missing. Never.socketalone./or a leading./), or when the user declined it as in (b). A line with a blank before or after it, a pattern or a string prefix covers nothing.# socket-patch:. A path line under a line that starts so is its own, whatever the rest of that line says, and only such a line is ever removed.replace:rollback --preserve-statekeeps the vendored copy, and with it the line.bazelignore_not_updated: it could not be read or written (a directory or a link in its place, a read-only directory, a read-only file). The detail names the line to add, or says that the lines of a copy that is gone can be deleted. The command succeeds as before.Updated <path>orRemoved <path>on stdout when the file changed, once per file, and the warning on stderr.--jsoncarries the warning inwarnings[]; there is no new field (see (g)).socket.ymllets write nothing (patches.enabled: false).Which commands keep the file in line: every command that can write or remove a copy, once, at its end:
scan,get,apply,vendor,vendor --revert,rollback,remove,repair. Not in a--globalrun.--ecosystemsleavesgolangout adds no line. It still takes away the pair of a copy that is gone, becauseremoveof a Go patch andvendor --revertremove the Go copy whatever that option says.vendorin a hosted project) does it after its rollback, so a rolled-back eject leaves no pair for a copy that is gone again.scan --prunecomes to the file a second time after a pass that removed a vendored copy. That second look only takes a pair away: it adds nothing and warns of nothing.--manifest-pathinto another project, the agent copies are those of--cwdand the vendored ones those of the manifest's project, and the command brings the file of each project's Bazel root in line.applyandvendorin a project with no manifest end before that step.After the first review: ten findings
scan --prunecomes a second time after a pass that removed a copy, only to take its pair away. A repair of another ecosystem adds no line for a Go copy, a prune pass no longer leaves a stale pair, no command warns twice.ddirectories below its checkout root, 2 path canonicalisations,d + 2stats of.gitand4 (d + 1)stats of the four names. Counted from the code, not traced.After the second review: one defect and ten smaller points
.bazelignorewhose last byte is a carriage return on its own lost that byte when the pair was added and removed againremoveandvendor --revertwith--ecosystems npmremoved the Go copy and left its pairUpdatedwas printed in words that fit only an added linescan --prunecame to the file twice, and a flag kept for the life of the process hid the second warningscan --mode agent --prune, and it does not run at all when it cannot take the apply lock, so a scan that left its call to the pass could warn twice or leave a new copy without its line. Instead the scan's own call stays, and the pass's look only takes a pair away and reports nothing. The cost is in Caveats./or start with./.--manifest-pathinto another project was untested, and printedUpdatedtwice for one filesocket.ymlsayspatches.enabled: false(report only, nothing is written) writes.bazelignore: measured with the test dropped.After the third review: nine findings
.gitof another user above the project let socket-patch write there: with another user's/tmp/.gitand/tmp/MODULE.bazel, a command in/tmp/job/projcreated/tmp/.bazelignore.bazelignorebeside any workspace file above it, and warned on every command.gitlies above the temporary directoryGIT_CEILING_DIRECTORIES; without that it fails inside a checkout.# socket-patch:, is the mark. A pair under another wording stays, alone, while the copy is there, goes with the copy, and is declined by a commented-out path line; no second pair is appended.--jsondoes not say that the file changedcargo test.The review's two other points change nothing here: the line is on by default and takes the copies out of
glob()(decided, (a) and (b)), and other ecosystems (Not covered).Product code over the three reviews: implementation went from 289 to 416 added lines in the first, stayed at 416 in the second (code lines 273 to 269), and went to 413 in the third (code lines 269 to 262). In the third,
bazel/ignore.rslost 4 lines (8 code lines) andbazel/mod.rsgained one. What went: the root above a project in no checkout, with its flag and its warning, and the lock file's name and open options. What came: the trust rule, the mark, and a probe that tells "not found" from "cannot tell".What it proves, and where
Everything ran locally on macOS arm64 with the pinned Bazel binaries, on the tree of
cdf3a5fb6.bazel build //...and a--lockfile_mode=errorbuild. The two tests of a module without a BUILD file build it again afterbazel run //:gazelle, which writes nothing. The agent test starts from a.bazelignoreof the user's whose last line has no line break, and Bazel and gazelle honour the line that then ends the file. The undo removes the pair, and the build prints the unpatched marker again.main's product code on 9.3.2 while asserting the two errors above. Not run again for this revision.REPO.bazel) were not repeated: their code and tests did not change, apart from the mark.--dry-runin both modes write nothing; six scans underpatches.enabled: falsewrite nothing; a declined pair stays declined over scan, repair, apply, rollback and revert; a file that cannot be written is exactly one warning for each command, in the envelope and on a person's stderr, and the patch stands; a project in no git checkout below a Bazel root gets no line and no warning; the same run in a checkout without a Bazel workspace file writes the same files, byte for byte, and no.bazelignore(the timestamped marker of a vendored copy is left out of that comparison).cli,spawn_env_hygiene,command_module_layeringandhelp_text_hygiene(136), the script tests (411): all pass, and no test that is onmainhad to change.cargo fmt, both clippy runs,cargo check,actionlintand the tool-pin check pass.Not covered
.socket/vendor/<ecosystem>too, and a crate can ship aBUILD.bazel. Nothing was measured for them under Bazel, and for Cargo a wider ignore line is suspected to break the ruleset's own tooling, so nothing is written for them.scan --mode vendoredrebuilds the copy. Agent mode: delete theBUILD.bazelfiles under.socket/go-patchesby hand.scanorgetthat patches in the project's mode,repair,rollback,remove,vendor --revert, andapplyorvendorwhere the project has a manifest. Notscan --mode agentin a vendored project, not a scan that writes nothing else, notlist,vexor the--checkaudits..bazelignorecannot name. A project directory below the root whose path starts with#or white space, or holds*,?or[, gets its line, and Bazel or gazelle does not honour it.ignore_directoriesinREPO.bazelis not read; a workspace that has it gets the line too, which is harmless.flockcall on a directory, in a container, on overlayfs and tmpfs); a lock on a network file system; a checkout of another user through the built binary (the unit test hands the owner in); commit 1 on any release at this revision; the mutations on 8.8.2 and 7.7.2; the other ecosystems' real-Bazel tests on 8.8.2 and 7.7.2; the nested-workspace measurement on 8.8.2 and 7.7.2;WORKSPACEgo_repositoryworkspaces; gazelle 2.0.0-beta.2; a project below the root on real Bazel; two patched modules; the merge with today'smainbeyond what the second paragraph says.Caveats
flockon the workspace root directory, held for the edit. Another tool that takes the same kind of lock on that directory waits for that long; none is known to.proxy.golang.org, which is last in theirGOPROXYlist after the loopback stand-in. The hosted flow's list is unchanged.BUILD.bazelchanged, so the repository-cache key of the Go legs changes and the first CI run downloads again.Generated by Claude Code