Skip to content

fix(Bazel): Setup BB Bazel CI - #729

Merged
marvin-hansen merged 5 commits into
deepcausality-rs:mainfrom
marvin-hansen:main
Aug 12, 2026
Merged

fix(Bazel): Setup BB Bazel CI#729
marvin-hansen merged 5 commits into
deepcausality-rs:mainfrom
marvin-hansen:main

Conversation

@marvin-hansen

@marvin-hansen marvin-hansen commented Aug 12, 2026

Copy link
Copy Markdown
Member

Describe your changes

  • Setup BB Bazel CI
  • Worked on rules lean

Issue ticket number and link

Code checklist before requesting a review

  • I have signed the DCO?
  • All tests are passing when running make test?
  • No errors or security vulnerabilities are reported by make check?

For details on make, please see BUILD.md

Note: The CI runs all of the above and fixing things before they hit CI speeds
up the review and merge process. Thank you.


Summary by cubic

Set up BuildBuddy Bazel CI and removed the old GitHub “Tests” workflow. Lean builds are now lazy and cache-friendly; non-Lean builds and CI no longer fetch Lake/Mathlib, and Lean uses a content-addressed lock for reproducible, remotely cacheable fetches.

  • Refactors

    • Vendor patched rules_lean and split toolchain declarations so @lake_deps and the Lean dist are fetched only when building //lean/...; replaced @lake_deps//:packages.bzl with local lean/lake_packages.bzl.
    • Added lean/lake-lock.json and generators (build/scripts/lean_lock.sh, build/scripts/lean_packages_bzl.py) to pin Lake/Mathlib to sha256 archives; updated MODULE.bazel and lean/BUILD.bazel.
    • Proof headers document the minimal-imports rule to keep cache_roots small.
  • CI

    • Renamed workflow to “LEAN Formalization”; configured buildbuddy.yaml to run bazel build/test -- //... -//lean/... with reduced memory/disk.
    • Removed .github/workflows/run_tests.yml in favor of BuildBuddy Bazel CI.

Written for commit cfa2be5. Summary will update on new commits.

Review in cubic

@lake_deps was fetched by every bazel command in the workspace, including
ones that build no Lean at all -- `bazel build //deep_causality_num:...` and
CI's own `bazel test -- //... -//lean/...` both materialized 7.5 GB of
Lake/Mathlib before doing anything. Two independent causes:

register_toolchains() pointed at @lake_deps//:lean_toolchain_def. Registering
a toolchain forces Bazel to fetch the repo the toolchain() target lives in so
resolution can evaluate it, which happens for every target in every build.
rules_lean declared toolchain() next to the implementation, so there was no
cheap repo to register. Adds lean_toolchain_decls: a downloadless repo holding
only the declaration, created per Lean version. Resolution reads it for free
and the 2.6 GB distribution is fetched lazily, only when the Lean toolchain is
actually selected -- the same split rules_rust uses for @rust_toolchains.

lean/BUILD.bazel loaded @lake_deps//:packages.bzl. A load() from an external
repo forces that repo to be fetched before the loading package can be
evaluated, and //... evaluates every package. The list is now generated
locally (lean/lake_packages.bzl, from lake-manifest.json); labels in
attributes stay lazy where load() cannot.

Measured on a cold output base building one Rust crate: lake_deps and
lean_dist_4_32_0 both absent, only the 4 KB declaration repo present, build
green in 10.6s. `bazel build -- //... -//lean/...` builds 1463 targets in
4.1s with no Lean fetch. Building //lean/... still fetches both, as it must.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
The Mathlib closure is set by what these files import, and the cost is
invisible at the point of writing an import: Mathlib.Analysis.Quaternion
reached 8,639 of 9,450 modules to supply four algebraic laws. Records the
rule, and the number, in the header block of all 65 proofs -- import the
narrowest module that type-checks, and mirror new imports into cache_roots
in //MODULE.bazel, which tree-shakes the olean download to those roots plus
their closure.

Complex/Quaternion.lean's inline comment is trimmed to the file-specific
fact now that its header carries the general rule.

All 65 tracked proof files type-check after the edits.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
@marvin-hansen marvin-hansen self-assigned this Aug 12, 2026
…flow.

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
@marvin-hansen
marvin-hansen merged commit 51490ea into deepcausality-rs:main Aug 12, 2026
19 checks passed
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.

1 participant