Skip to content

Ci/docs and busy beaver sharding - #31

Merged
mo271 merged 3 commits into
mainfrom
ci/docs-and-busy-beaver-sharding
Nov 25, 2026
Merged

mo271 merged 3 commits into
mainfrom
ci/docs-and-busy-beaver-sharding

Conversation

@mo271

@mo271 mo271 commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

… cache loop

- Target Cryptids and human-authored BusyBeaver framework/hardness/landmark modules in literate.toml (including Stack, WordRunStack, and Defs.* order from #29, while excluding Challenge/BusyBeaverChallenge to avoid Verso Search Duplicate document ID collisions on mirrored declarations).

- Compute minimal lake build targets from literate.toml so lean-action compiles only documented modules and their transitive dependencies.

- Scope pages: write and id-token: write permissions exclusively to jobs.deploy in docs.yml to satisfy zizmor excessive-permissions.

- Split actions/cache into restore + save (persisting partial .lake/build/literate progress on step timeout), update paths-ignore globs, reclaim build disk space before Pages upload, and pin action SHAs.
- Partition BusyBeaver's DAG dynamically into a cached foundation job (BusyBeaverChallenge + non-leaf modules, incl. Calculi and shared donor M_* files), 8 parallel crc32-keyed leaf shards with independent .lake/build/{lib/lean,ir} zstd caches, and a final build job that reassembles artifacts and runs lake comparator inside bubblewrap.

- Run tools/render_challenge.py --check and tools/check_manifest.py fail-fast in foundation and in build, and delete prebuilt BusyBeaverChallenge artifacts right before comparator so BusyBeaverChallenge compiles freshly from read-only source inside bwrap.

- Preserve the exact 'BusyBeaver CI / build' check run name for branch protection.
@mo271
mo271 force-pushed the ci/docs-and-busy-beaver-sharding branch from ed32a89 to cd14ed3 Compare November 23, 2026 21:14
@mo271
mo271 requested a review from TomZahavy November 24, 2026 14:06

@TomZahavy TomZahavy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice setup — dynamic foundation vs crc32-keyed leaf sharding + pruning M_* certificate blobs from Verso cuts compilation latency dramatically (lake build BusyBeaver BusyBeaverChallenge replays in ~4m in the final build job before lake comparator's kernel check).

Left a few inline comments on partial-cache key handling on timeout/reruns, shard unpack order when a leaf gets promoted to a shared donor in foundation, and docs.yml paths-ignore / PR coverage. Also worth copying the two commit message summaries into the currently empty PR description.

Comment thread .github/workflows/docs.yml Outdated
.lake/packages/MD4Lean/.lake/build
.lake/packages/illuminate/.lake/build
.lake/build/literate
key: verso-literate-v2-${{ runner.os }}-${{ hashFiles('lean-toolchain', 'lake-manifest.json', 'literate.toml') }}-${{ github.sha }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Unlike busy_beaver_ci.yml, when Build Verso literate HTML times out (steps.verso.outcome == 'failure'), this saves the incomplete .lake/build/literate directory under the final key ...-${{ github.sha }}. Because Actions cache keys are immutable, re-running the failed job on the same github.sha gets an exact hit (steps.verso-cache.outputs.cache-hit == 'true') on that partial cache, finishes the build, and then skips saving the completed cache — leaving that commit's cache permanently half-built for subsequent restore-keys lookups (and colliding if a second retry also times out).

Using a distinct suffix on failure avoids poisoning ${{ github.sha }}:

Suggested change
key: verso-literate-v2-${{ runner.os }}-${{ hashFiles('lean-toolchain', 'lake-manifest.json', 'literate.toml') }}-${{ github.sha }}
key: verso-literate-v2-${{ runner.os }}-${{ hashFiles('lean-toolchain', 'lake-manifest.json', 'literate.toml') }}-${{ steps.verso.outcome == 'success' && github.sha || format('partial-{0}-{1}-{2}', github.sha, github.run_id, github.run_attempt) }}

Comment thread .github/workflows/docs.yml Outdated
Comment on lines +15 to +18
- 'BusyBeaver/BB6/M_*.lean'
- 'BusyBeaver/BB6/Accelerations/M_*.lean'
- 'BusyBeaver/BB33/M_*.lean'
- 'BusyBeaver/Calculi/**'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Note that BusyBeaver.BB6.HardnessEvidence and BusyBeaver.BB6.Equivalences (both targeted in literate.toml) directly import 26 BusyBeaver/BB6/{,Accelerations/}M_*.lean donor modules, and BusyBeaver/Calculi/Counter.lean is also in the transitive dependency closure of docs-args. With these globs in paths-ignore, a commit touching only Calculi/Counter.lean or one of those donor M_*.lean files will skip docs.yml even if it changes declarations elaborated/linked by documented pages.

Also, since docs.yml only triggers on push to main, PRs editing literate.toml or busy_beaver_ci_shards.py never exercise docs-args before merge — adding a lightweight python3 .github/scripts/busy_beaver_ci_shards.py docs-args smoke check on PRs (or running docs.yml's build job on pull_request when literate.toml / docs.yml changes) would catch config regressions pre-merge.

Comment thread .github/workflows/busy_beaver_ci.yml Outdated
with:
path: .lake/shard-cache/foundation.tar.zst
key: >-
bb-foundation-v1-${{ runner.os }}-${{ hashFiles('lean-toolchain', 'lake-manifest.json', 'lakefile.toml') }}-${{ steps.compile.outcome == 'success' && steps.plan.outputs.foundation_hash || format('partial-{0}', github.run_id) }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Across "Re-run failed jobs" attempts of the same workflow run, github.run_id stays constant while github.run_attempt increments. Including github.run_attempt (format('partial-{0}-{1}', github.run_id, github.run_attempt)) here and in the shard cache key on line 226 ensures a second timed-out retry can still save its incremental progress instead of colliding on the immutable partial-<run_id> key.

Comment thread .github/workflows/busy_beaver_ci.yml Outdated
Comment on lines +176 to +192
tar --zstd -xf .lake/foundation-in/foundation.tar.zst
rm -rf .lake/foundation-in

- name: Restore shard ${{ matrix.shard }} cache
id: cache-restore
if: steps.plan.outputs.shard_count != '0'
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .lake/shard-cache/shard.tar.zst
key: bb-shard-v1-${{ matrix.shard }}-of-8-${{ runner.os }}-${{ steps.plan.outputs.foundation_hash }}-${{ steps.plan.outputs.shard_hash }}
restore-keys: |
bb-shard-v1-${{ matrix.shard }}-of-8-${{ runner.os }}-${{ steps.plan.outputs.foundation_hash }}-
bb-shard-v1-${{ matrix.shard }}-of-8-${{ runner.os }}-

- name: Unpack restored shard cache
if: steps.plan.outputs.shard_count != '0' && steps.cache-restore.outputs.cache-matched-key != ''
run: tar --zstd -xf .lake/shard-cache/shard.tar.zst

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two subtle cache interactions here when falling back to bb-shard-v1-${{ matrix.shard }}-of-8-${{ runner.os }}-:

  1. Unpack order: foundation.tar.zst is unpacked before shard.tar.zst. If a pure leaf M_* module is later imported by another proof (promoting it from this leaf shard into foundation), restoring an older fallback shard.tar.zst on top will overwrite the freshly built foundation .olean/.trace for that module with a stale copy. Unpacking shard.tar.zst before foundation.tar.zst ensures fresh foundation artifacts always win.
  2. Toolchain scoping & NUM_SHARDS: Including ${{ hashFiles('lean-toolchain', 'lake-manifest.json', 'lakefile.toml') }} in the shard key prefix avoids restoring .oleans across Lean/Mathlib version bumps, and using -of-${{ env.NUM_SHARDS }}- avoids silent key skew if NUM_SHARDS is changed.

Comment thread literate.toml
"Cryptids.Zf380",
"Cryptids.Riemann120",
"Cryptids.Riemann104",
"Cryptids.Riemann95",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor nit: "Cryptids.Riemann95Definition" is the only top-level Cryptids/*.lean module omitted from [order_children]."Cryptids", so it sorts at the bottom after Cryptids.Semantics and Cryptids.ReductionSupport instead of next to Cryptids.Riemann95.

…ocs triggers

- docs.yml: use a partial-<sha>-<run_id>-<run_attempt> cache key when Verso times out so retries do not hit or poison the final <github.sha> key; switch push path filtering to paths: with BusyBeaver/Calculi/Counter.lean and BB6 donor M_*.lean included; run build job on pull_request for literate.toml / docs.yml / busy_beaver_ci_shards.py changes (gating Pages upload/deploy off pull_request and scoping concurrency per PR/ref).
- busy_beaver_ci.yml: unpack shard.tar.zst before foundation.tar.zst so freshly compiled foundation artifacts win when a leaf module is promoted to a shared donor; scope shard cache keys by toolchain/manifest/lakefile hash and env.NUM_SHARDS; include github.run_attempt in partial cache keys; add a fast docs-args target check in foundation.
- literate.toml & busy_beaver_ci_shards.py: add Cryptids.Riemann95Definition to [order_children]."Cryptids" and validate library targets in docs-args.
@mo271
mo271 merged commit 0b5b9ba into main Nov 25, 2026
29 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.

2 participants