Skip to content

chore(deps): upgrade rules_python from 1.9.0 to 2.4.6 - #12041

Merged
basvandijk merged 1 commit into
masterfrom
bas/rules-python-2.4.6
Nov 6, 2026
Merged

basvandijk merged 1 commit into
masterfrom
bas/rules-python-2.4.6

Conversation

@basvandijk

Copy link
Copy Markdown
Collaborator

Upgrades rules_python from 1.9.0 to 2.4.6, its latest release (2.5.0-rc0 is a release candidate). The
bazel_dep version in MODULE.bazel is the only edit: what the repo uses (python.toolchain, pip.parse,
@rules_python//python:defs.bzl and :pip.bzl, py_console_script_binary, the @python_deps labels
requirement(), :pkg and :whl, and the bootstrap_impl setting) still works unchanged. In the module graph
only package_metadata moves from 0.0.6 to 0.0.7 and toml.bzl 0.4.1 is added; protobuf, rules_cc,
bazel_skylib and platforms stay where they are.

The released IC-OS images don't change. Built unstamped with 1.9.0 and with 2.4.6 in the same output base, these are
byte-identical: the GuestOS disk and update images and its launch-measurements.json, the HostOS disk and update
images, and the SetupOS disk image. Python only runs as a build tool there: the //toolchains/sysimage tools,
rules_pkg's build_tar, sev-snp-measure and rules_foreign_cc's meson.

Behaviour changes (no repo edit needed)

  • Interpreter: python_version = "3.12" now resolves to CPython 3.12.16 (python-build-standalone 20261026)
    instead of 3.12.12. The interpreter links libpython statically, so the 100+ MB libpython3.12.so is no longer part
    of every Python tool's runfiles.
  • Every py_binary/py_test starts through a venv (2.0.0, refactor!: create full venv for bootstrap=system_python bazel-contrib/rules_python#3473). Its runfiles get
    _<name>.venv/pyvenv.cfg and an unresolved bin/python3 symlink, and sys.executable is that venv's python.
    Namespace RBE has to accept the symlink as an action input, which this PR's CI exercises. If it doesn't, the fallback
    is --@rules_python//python/config_settings:venvs_use_declare_symlink=no in
    .github/actions/bazel-namespace/rbe.bazelrc.
  • pip.parse uses the Bazel downloader (2.0.0, feat!(pypi): enable bazel downloader by default bazel-contrib/rules_python#3691). Evaluating the pip extension
    fetches the PyPI simple-API page of every pinned package (about 80, including rules_python's own publish deps). We
    run with --lockfile_mode=off, so every new Bazel server does that again, and a PyPI outage now fails loading
    @python_deps (IC-OS builds, //...), not just fetching uncached wheels. Bazel then downloads the wheels with their
    pinned hashes and unpacks them itself. The native ones (cryptography, bcrypt, pynacl, used by the bare-metal dev tools
    and by sev-snp-measure's id-block path) switch from their manylinux_2_34 to their manylinux2014 builds, independent
    of the build host's glibc.
  • compile_pip_requirements runs pip 26.2.2 and pip-tools 7.6.2; //:python-requirements.test passes as is.
  • Build data: none of our targets is stamped in rules_python's sense (--config=stamped only stamps through
    workspace_status.sh, it doesn't pass Bazel's --stamp). For such targets <name>.build_data.txt is now written
    with ctx.actions.write (fix(stamping): skip build data spawn when --stamp=false bazel-contrib/rules_python#4160), so Build-without-the-Bytes no longer re-runs those actions
    in every command. That makes the build_data.txt download that chore(ci): rehearse the move of bazel-test-all to Namespace RBE in the evaluation job #12032 adds to rbe.bazelrc unnecessary; whichever
    of the two PRs lands second removes it.
  • Deprecation warning (2.2.0): analysis prints a warning about implicit __init__.py creation for every Python
    binary and test, including external tools (rules_pkg's build_tar, rules_foreign_cc's meson). Opting in to explicit
    __init__.py files is left for a follow-up.
  • The runtime's __pycache__ directories are now symlinks into /tmp/rules_python_pycache
    (fix: prevent stdlib pyc files from invalidating runtime repos bazel-contrib/rules_python#3661); 2.5.0 moves them to a per-user cache (fix(toolchains): exclude pycache symlinks from runtime files bazel-contrib/rules_python#4233). The risk
    is low in CI and in the dev container, whose /tmp is private.

Testing (dev container)

  • bazel build //... --nobuild; buildifier.
  • All 26 py_* targets build. The 5 non-manual py_tests pass (including //:python-requirements.test), and so do
    //ci/githubstats:query_help_test and //rs/recovery/subnet_splitting:integration_test, which launch our Python
    binaries.
  • //:mke2fs, //:fuse2fs and //:debugfs (e2fsprogs, built with libfuse through rules_foreign_cc's Python-based
    meson).
  • The IC-OS images above, byte-identical with 1.9.0 and 2.4.6.
  • This PR's CI builds and tests //... on the dind runners and on Namespace RBE.

🤖 Generated with Claude Code

rules_python 2.4.6 is the latest release. The APIs the repo uses are
unchanged, so the version is the only edit; in the module graph only
package_metadata moves from 0.0.6 to 0.0.7 and toml.bzl 0.4.1 is added.

Behaviour changes: Python 3.12 resolves to 3.12.16 instead of 3.12.12;
every py_binary and py_test starts through a venv; pip.parse looks up
the pinned packages on PyPI's simple API whenever a new bazel server
evaluates the pip extension and downloads the wheels itself; and build
data of unstamped targets is written with ctx.actions.write, so that
Build-without-the-Bytes no longer re-runs those actions. The released
IC-OS images and the GuestOS launch measurements are byte-identical to
the ones built with 1.9.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Namespace RBE compatibility with the new unresolved venv symlink inputs remains unverified because this PR’s CI runtime results are unavailable in the supplied review context.

No open issues 🎉

What changed in this PR

Upgrades the repository’s Bazel Python rules from 1.9.0 to 2.4.6, keeping existing Python build configuration unchanged.

Changes:

  • Updates only the rules_python dependency version.
  • Adopts upstream Python runtime and tooling changes; the PR reports byte-identical IC-OS images.
File Description
MODULE.bazel Bumps rules_python from 1.9.0 to 2.4.6.

Review effort: Balanced

@basvandijk
basvandijk marked this pull request as ready for review November 6, 2026 16:05
@basvandijk
basvandijk requested a review from a team as a code owner November 6, 2026 16:05
@github-actions github-actions Bot added the @infra label Nov 6, 2026
@basvandijk
basvandijk merged commit ab7ff25 into master Nov 6, 2026
44 checks passed
@basvandijk
basvandijk deleted the bas/rules-python-2.4.6 branch November 6, 2026 16:17
basvandijk added a commit that referenced this pull request Nov 6, 2026
Picks up #12041 (rules_python 2.4.6), which makes the build_data.txt download in rbe.bazelrc unnecessary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
basvandijk added a commit that referenced this pull request Nov 6, 2026
rules_python 2.4.6 (#12041) writes the build data of unstamped targets,
which all of ours are, with ctx.actions.write. Those files are ordinary
local outputs now, so Build-without-the-Bytes no longer re-runs their
actions in every later command, and downloading them is unnecessary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
basvandijk added a commit that referenced this pull request Nov 6, 2026
…e evaluation job (#12032)

## Why

`bazel-test-all` (ci-main.yml, dind-large) is to be replaced by the
implementation of `bazel-test-all-rbe`
(ci-rbe-evaluation.yml: Namespace runner + Bazel Remote Execution,
`_local` system-tests), as the first
step of moving CI off the self-hosted dind runners. Three things the
required job does are not yet done
by the evaluation job and can only be validated by running them, so this
PR makes the still non-blocking
evaluation job rehearse them on every master push before the switch:

* the `execlogs-bazel-build` execution log that `build-determinism`
compares with `build-ic`'s;
* the `Upload artifacts` step (`bazel run --check_up_to_date
//:upload-artifacts`) on a Namespace runner,
under Build-without-the-Bytes and through the Namespace bazel wrapper,
including AWS OIDC role
  assumption from a Namespace container job;
* the `_local` variants of the system-tests listed in
`PULL_REQUEST_BAZEL_TARGETS`, which the evaluation
job silently drops today (it excludes `farm_system_test` *after* the
explicit targets are added).

The required jobs keep their behaviour; only the mechanics of the
artifact upload change (see below).

## What

* **`.github/actions/upload-execlogs`** (new): the execlog2csv
install/convert/upload steps of
`.github/actions/bazel`, as a composite that both bazel actions call, so
the execlog2csv pins and the
  list of known non-reproducible targets live in one place.
* **`.github/actions/bazel-namespace`**: new `execlogs-artifact-name`
input (the wrapper writes
`--execution_log_compact_file` for build and test when it is set); the
wrapper no longer writes a BEP
file/profile for `bazel run` (a BEP records the client environment, and
the artifact upload is a
`bazel run`); the OIDC token request variables are unset before `run`,
as in the dind action.
* **`.github/actions/upload-artifacts`**: runner-agnostic
(`bazel-action: bazel | bazel-namespace`) and
credentials only where rclone runs. The uploader is built with `bazel
run --script_path` (new
`build-uploader.sh`; under Build-without-the-Bytes `bazel run
--check_up_to_date` downloads the target's
outputs and runfiles by the digests the build step recorded, and on
Namespace it runs with
`--experimental_remote_cache_eviction_retries=0`, so a lost blob fails
on that output instead of a retry
that re-resolves everything through fresh remote cache lookups) and run
by
a separate step, the only one whose environment holds the AWS/Cloudflare
credentials, now passed as
inputs instead of step `env`. Neither the BEP files nor Namespace's
Build Event Service (to which
`nsc bazel setup` streams every bazel command's events, client
environment included) see them anymore.
This relies on rules_python 2.4.6 (#12041): with 1.9.0, every
`<name>.build_data.txt` had constant
metadata, which bazel can only validate on disk, so under
Build-without-the-Bytes every later command
re-ran those `PyWriteBuildData` actions (21 in a Namespace test step;
two are tools in the upload closure,
  which would have failed `--check_up_to_date`).
`ci/src/artifacts/upload.bzl`: the generated run script gets its shebang
on the first line, which the
`exec` of the `--script_path` script needs (`bazel run` hid this by
running it through bash).
* **`ci-main.yml`**: the two upload call sites use the new inputs
(`bazel-test-all` also passes its
build step's options to `bazel run`); `build-determinism` prints how
many artifacts the comparison covers
and warns outside PRs when the cache side misses more than half of
build-ic's artifacts (a build that
bazel retried after a remote-cache eviction has a partial execution
log).
* **`ci-rbe-evaluation.yml`**: uploads `execlogs-bazel-build-rbe`; on
release builds (master pushes) runs
`Configure AWS credentials` (role assumption only: `output-credentials:
false`, the session never leaves
that step) and a `DRY_RUN=1` artifact upload with placeholder
credentials and `--check_up_to_date`
through the Namespace wrapper (`environment: upload-artifacts`,
`id-token: write`; both steps
  `continue-on-error`).
* **`ci-kickoff.yml`**: the evaluation also runs on dfinity/ic-private
PRs, since the Namespace GitHub App
was given access to that repository today (so that `bazel-test-all`
needs no repository gate after the
switch; note that ic-private PR code, undisclosed hotfixes included,
then builds on Namespace and shares
the workspace's RBE cache with public builds, like it shares DFINITY's
cache today); temporary
`rbe-build-determinism` shadow job comparing `execlogs-bazel-build-rbe`
with `execlogs-build-ic`
(fails on mismatches like ci-main's job; not a required check, so it
doesn't block merging; a missing
  execution log is not a mismatch).
* **`PULL_REQUEST_BAZEL_TARGETS`**: lists the `_local` variant next to
every `_farm`/`_farm_colocate`
entry (24 lines; the dind job drops the former, the evaluation job the
latter, so this changes nothing
for CI Main and makes the evaluation job run on PRs exactly the tests
that become blocking). The two
nested `*_upgrade_from_latest_release_to_current_local` entries are
runnable since #12029.
* **`ci/scripts/targets.py`**: `check` honours `--exclude_tags` like
`test` does (CI doesn't pass it yet;
the switch will pass `--exclude_tags=farm_system_test`, which then
rejects `_farm*` entries) and its
  hint no longer suggests `_colocate`.

## Not in this PR

The switch itself (rewriting `bazel-test-all`, deleting the evaluation
workflow and the shadow job,
`_local`-only `PULL_REQUEST_BAZEL_TARGETS`, githubstats job names)
follows after a soak of the rehearsal:
shadow determinism `No mismatches` with ~34k joined rows, green dry-run
uploads with
`--check_up_to_date`, green OIDC step, `_local` flakiness not worse than
dind.

## Testing

* `build-uploader.sh` + the generated script, locally with
`--config=local` and `//:artifact-uploader`:
`--check_up_to_date` after a build reports `0 total actions`, the dry
run
prints `VERSION: 0000…` and one well-formed `<sha256> ic/<version>/…`
manifest line per file. This dry
run is what found the shebang problem in `upload.bzl` (the uploader died
under `/bin/sh` with
  `set: Illegal option -o pipefail`).
* `ci/scripts/targets.py check` passes with the dual listing (all 48
system-test labels are non-manual);
`check --exclude_tags=farm_system_test` fails on exactly the 24 `_farm*`
lines with the new hint.
* `bazel run //pre-commit:ruff-check`, `//pre-commit:shfmt-check`,
`//:buildifier`; all changed YAML parses.
* The Namespace upload path (`bazel run --check_up_to_date` without
eviction retries) follows from reading
  the Bazel 9.2.0 sources and the profiles of a Namespace job, reviewed
adversarially; `build-uploader.sh` was exercised with a stub bazel for
every exit code. It first runs for
  real in the rehearsal on the first master push after merge.
* This PR touches `.github/*`, so its own CI builds and tests `//...` on
both jobs; the evaluation job
shows the `execlogs-bazel-build-rbe` artifact and the shadow job's
comparison. The upload/OIDC
rehearsal and the dind upload mechanics only run on release builds:
first master push after merge.

## First rehearsal result (this PR's run 42102800890)

Both `bazel-test-all` jobs of this run built `//...` for the same
commit, so their execution logs can be
compared directly: **396 of 62,164 shared artifacts differ between dind
and RBE** (the RBE log is complete:
62,169 rows, all with digests). Against build-ic, the shadow job finds
76 mismatches in 34,266 artifacts,
all downstream of jemalloc, while the dind `Build Determinism` is clean.

**Root cause of the release-relevant part: jemalloc's configure reads
the CPU's virtual-address width.**
`@@+http_archive+jemalloc` (`third_party/BUILD.jemalloc.bazel`) runs
jemalloc 5.3.0's configure on the
machine that executes the action. On x86-64 it takes `LG_VADDR` from
CPUID leaf 0x80000008, which sizes
jemalloc's radix tree, so the compiled code of `libjemalloc.a` changes
with it. Reproduced locally: the
unmodified build gives the dind digest (`3c2559eb…`), the same build
with `--with-lg-vaddr=57` gives the RBE
digest (`b8f113b5…`) exactly, so the Namespace workers report 57 bits
where the dind machines report 48. The
`tikv-jemalloc-sys` rlib only bundles that archive (`JEMALLOC_OVERRIDE`;
its `build.rs` returns before it
reads `JEMALLOC_SYS_WITH_LG_*`), and the replica, `pocket-ic-server`,
`ic-boundary`, `ic-gateway`, the
GuestOS/SetupOS images and the publish bundles inherit it. Fixed by
#12033, which pins
`--with-lg-vaddr=48 --with-lg-page=12 --with-lg-hugepage=21`. That build
gives the dind digest again, so
the shipped binaries did not change.

The other leaves are outside build-ic's closure (no shipped artifact
contains them) and do not block the
switch: OpenSSL's `libcrypto.a` (build date and sandbox path), the
`libsqlite3-sys` build-script
environment (absolute path compiled into the build script) and the Go
SDK `builder` (records
`CGO_ENABLED`).

With #12033 merged into this branch, the shadow job compares the same
34,266 artifacts with **no
mismatches** (run of 27fb17f), so it now fails on mismatches like
ci-main's `Build Determinism`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
basvandijk added a commit that referenced this pull request Nov 6, 2026
…#12042)

Since rules_python 2.4.6 (#12041), analysis prints a 20-line deprecation
warning for every `py_binary` and `py_test` that relies on implicit
`__init__.py` creation (bazel-contrib/rules_python#2945), for example on
every `bazel run //ci/githubstats:query`. `bazel build //... --nobuild`
prints it for 23 targets on master and for none on this branch:

* **`MODULE.bazel`** opts this module out with the `config` extension's
`explicit_init_py(default = True)` (rules_python 2.3.0+). That covers
all 22 of our Python executables: the 18 that `//...` analyses and the 4
manual `launch_bare_metal_main`.
* **`bazel/conf/.bazelrc.build`** sets
`--incompatible_default_to_explicit_init_py` for the 5 targets of other
modules, which the module setting doesn't reach: rules_pkg's
`build_tar`, rules_foreign_cc's meson, rules_python's
`py_console_script_gen_py`, and `@bazel_tools`' `sha256` and
`proguard_allowlister`. None of them is fixed upstream yet; rules_pkg's
fix is bazelbuild/rules_pkg#1082, still open. Every Bazel invocation
loads this file, including the Namespace RBE ones.
* rules_python's MODULE.bazel aliases the flag to its
`@rules_python//python/config_settings:incompatible_default_to_explicit_init_py`.
* The flag renames no `bazel-out/` directory, so only the actions that
run one of the five tools miss the cache, once.
* **Real `__init__.py` files** go to the Python packages our code
imports: `toolchains/`, `toolchains/sysimage/` and BuildBuddy's `proto/`
(the latter in `ci/githubstats/BUILD.buildbuddy-proto.bazel`). Without
them these would become namespace packages, which a same-named package
elsewhere on `sys.path` can shadow (see below).

## What changes when the programs run

Their runfiles no longer get an empty `__init__.py` in every directory
that holds Python files. A directory without a real one imports as a
namespace package (PEP 420), and a namespace package loses to a regular
package of the same name anywhere on `sys.path`:

* **The packages our code imports get real `__init__.py` files.** They
stay regular packages, so they keep winning over same-named packages
later on `sys.path`, for example in a user site-packages, as the
generated files made them do:
* `toolchains` and `toolchains.sysimage`, which
`//toolchains/sysimage:build_{fat32,vfat,lvm}_image` import. These get
`toolchains/__init__.py` and `toolchains/sysimage/__init__.py`. PyPI has
a `toolchains` package.
* BuildBuddy's `proto`, `proto.api` and `proto.api.v1`, which
`//ci/githubstats:query` imports. The `buildbuddy_proto` archive gets
their files through `patch_cmds`, and the new
`@buildbuddy_proto//:buildbuddy_py` ships them with the generated
modules. proto-plus's top-level package is `proto`.
* **Protobuf runtime of `query` and `query_test`:** they now use the
`protobuf==6.33.5` wheel they depend on (`requirement("protobuf")`),
with its upb C backend.
* Before, they used the protobuf Bazel module's pure-Python 6.33.0
sources, which `py_proto_library` also puts in the runfiles.
* That copy comes first on `sys.path`, but it only won because of a
generated empty `google/__init__.py`. The wheel's `google/__init__.py`
is a pkgutil namespace that rules_python writes.
* The `_pb2` modules, generated by protoc 33.0, accept the newer
runtime.
* **The five external tools:** apart from the standard library they
import only packages with a real `__init__.py`. The exceptions are `pkg`
and `pkg.private.tar` (rules_pkg, until bazelbuild/rules_pkg#1082) and
`python` (the rules_python runfiles library), which are now namespace
packages. PyPI has no `python` package, and its `pkg` is a single
release from 2020.

## Testing

All of this ran in the dev container, building master and this branch in
the same output base:

* **Warnings:** `bazel build //... --nobuild` reports 23 targets on
master and 0 here. buildifier is clean.
* **Programs:**
  * All 22 Python executables build.
* The 16 `py_binary`s other than `//:python-requirements.update` (which
would rewrite `requirements.txt`) print the same `--help` as on master.
* A `PYTHONVERBOSE` trace of each shows the same files imported, except
the protobuf switch above. The real `__init__.py` files sit where the
generated ones were.
* **Shadowing:** I put a regular stand-in package in a Python 3.12 user
site-packages: `proto` for `query --help`, and `toolchains` for
`build_{fat32,vfat,lvm}_image --help`. Without the new `__init__.py`
files these fail: `cannot import name 'target_pb2' from 'proto'` and `No
module named 'toolchains.sysimage'`. With them they work, and the
stand-in is never imported.
* **BuildBuddy path:** `get_all_log_urls_from_buildbuddy` sends a
request and parses a fake response correctly with the upb backend.
`query_test` mocks this function, so the tests don't cover it.
* **Tests:** all of these pass:
  * `//:python-requirements.test`
* `//bazel/inject_version_into_wasm_tests:inspect_stamped_trivial_wasm`
  * `//ci/githubstats:query_test` and `:query_help_test`
  * `//ci/scripts:repro_check_test`
  * `//rs/recovery/subnet_splitting/split_finder:split_finder_test`
  * `//rs/recovery/subnet_splitting:integration_test`
* **Byte-identical to master:** the GuestOS disk and update images and
`launch-measurements.json`, the HostOS disk and update images, and the
SetupOS disk image.
* **Byte-identical with and without the flag:**
  * all 17 `pkg_tar` outputs in `//...`
* `@libfuse//:libfuse` (built with meson), `//:mke2fs`, `//:fuse2fs` and
`//:debugfs`
  * sev-snp-measure's generated entry point
* the `SHA256SUMS` of `//ic-os/guestos/envs/prod:bundle-disk` and
`//ic-os/setupos/envs/prod:bundle`
* **Effect of the flag on the build:** it created no new `bazel-out/`
directory, and only 23 actions re-ran. `build_tar`,
`py_console_script_gen_py` and `proguard_allowlister` print the same
`--help`, and `sha256` the same usage message, as without it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
AleDema pushed a commit to AleDema/ic that referenced this pull request Nov 18, 2026
…finity#12175)

Commits `MODULE.bazel.lock` again (it was removed in dfinity#1990) and adds CI
that keeps it current.

## Why

With `--lockfile_mode=off`, every new Bazel server:
- re-evaluates every module extension;
- fetches registry files without checksums;
- fetches `metadata.json` for every module, so an upstream yank can
break the build;
- refetches what the extensions look up on the network: the PyPI index
for pip (dfinity#12041), go.dev for go_sdk, and for
rules_distroless 0.9.x about 84 MB of apt indices (this blocks dfinity#12153).

## What changes

- **The lockfile.** `MODULE.bazel.lock` (Bazel 9.3.2, lockFileVersion
28, 0.39 MB) is committed, and `common --lockfile_mode=off` is
  gone, so Bazel's default `update` mode applies everywhere.
- **New reusable workflow `.github/workflows/bazel-lockfile.yml`.** It
runs on Namespace (`namespace-profile-rbe-driver-amd64-linux-16x32`,
  or its `-no-cache` copy for reviewed fork code) and has two modes:
- **update**, called from CI PR Only: when a PR changes an input of the
lockfile, regenerate it with `bazel mod deps`. If it changed,
a separate push job commits "Automatically updated MODULE.bazel.lock"
onto the head branch. Fork PRs get the diff and an artifact
instead. The push job is the only job that holds the bot's key, and it
runs no Bazel.
- **check**, called from CI Main: fail when the lockfile isn't what
Bazel generates. This keeps an outdated lockfile out of the merge
    queue, where `ci-pr-only-status` is always green.
- On PRs and merge groups that touch an input, it re-derives the module
extension results, which catches bad merges.
    - On pushes it does a plain update.
- **Generated on amd64-linux only.** Every module extension records a
platform-independent (`general`) result today. A new last step of
Bazel Test arm64-{linux,darwin} fails when Bazel rewrites the file on
those platforms. On pushes that step only reports, so it can't
  block artifact uploads.
- **Small adjustments.**
- `bazel/workspace_status.sh` ignores `MODULE.bazel.lock` in its dirty
check, so a stale lockfile on a release branch can't produce
    `-dirty` artifacts.
- Autofix doesn't stage the file, and Lock Generate tolerates a
malformed one.
- The cargo jobs no longer trigger on it, and `targets.py` treats it
like `MODULE.bazel`.
  - The buildifier pre-commit regex no longer matches it.
- **Docs.** A new "MODULE.bazel.lock" section in `bazel/README.md`, and
the check-bazel-files skill.

## For developers

- After changing `MODULE.bazel`, `bazel/*.MODULE.bazel`, a module
override patch, `.bazelversion` or `requirements.txt`, run
`bazel mod deps >/dev/null` and commit the lockfile. On a PR from a
branch in this repository the bot also does it.
- Before pulling this change, delete any untracked `MODULE.bazel.lock`
left over from earlier experiments.
- Parallel `bazel_dep` bumps will often conflict in the lockfile. The
recipe is in `bazel/README.md`.

## Notes for review

- **CODEOWNERS is unchanged.** `MODULE.bazel.lock` falls under the
`*.lock` No-Approvals rule. What CI does with each part of the file:
- it re-derives the module extension results on every PR that touches an
input;
  - registry hashes are checked against what Bazel downloads;
  - facts (go_sdk, pip, msvc_runtime) are used as recorded.

Requiring infra approval would take a `/MODULE.bazel.lock
@dfinity/infra` line after the No-Approvals block.
- **Exercised in CI so far:**
- This PR: the update job found nothing to push, CI Main's check passed,
and the new step of Bazel Test arm64-linux and
arm64-darwin passed. The darwin leg builds all of `//rs/...` and
`//packages/...`.
- Throwaway dfinity#12176 hand-edited a recorded extension result. The update
job re-derived it, the push job committed the repaired file
    byte for byte, and the run for the bot's commit was green.
- Pushes to `dev-gh-bazel-lockfile`: the plain check passed for this
commit. For a commit with one registry hash deleted, it failed
with the expected annotation and uploaded the repaired file as
`bazel-lockfile-check`.
- **Not exercised yet:** the fork path through CI Kickoff Manual, to be
tried after merge.

## Verified locally

These all produced identical bytes in the dev container:
- two from-scratch generations;
- a generation with CI's rc set;
- the check job's strip and regeneration;
- a plain update.

`bazel build //... --nobuild` leaves the file unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants