Repository navigation
Ci/docs and busy beaver sharding - #31
Conversation
… 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.
ed32a89 to
cd14ed3
Compare
TomZahavy
left a comment
There was a problem hiding this comment.
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.
| .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 }} |
There was a problem hiding this comment.
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 }}:
| 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) }} |
| - 'BusyBeaver/BB6/M_*.lean' | ||
| - 'BusyBeaver/BB6/Accelerations/M_*.lean' | ||
| - 'BusyBeaver/BB33/M_*.lean' | ||
| - 'BusyBeaver/Calculi/**' |
There was a problem hiding this comment.
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.
| 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) }} |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
Two subtle cache interactions here when falling back to bb-shard-v1-${{ matrix.shard }}-of-8-${{ runner.os }}-:
- Unpack order:
foundation.tar.zstis unpacked beforeshard.tar.zst. If a pure leafM_*module is later imported by another proof (promoting it from this leaf shard intofoundation), restoring an older fallbackshard.tar.zston top will overwrite the freshly builtfoundation.olean/.tracefor that module with a stale copy. Unpackingshard.tar.zstbeforefoundation.tar.zstensures fresh foundation artifacts always win. - 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 ifNUM_SHARDSis changed.
| "Cryptids.Zf380", | ||
| "Cryptids.Riemann120", | ||
| "Cryptids.Riemann104", | ||
| "Cryptids.Riemann95", |
There was a problem hiding this comment.
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.
No description provided.