← Back to Pull requests

doc(README): document fetching Mathlib oleans #1081

Open
cdbattags opened this pull request with 16 lines diff across 1 files
View on GitHub
cdbattags cdbattags commented on Oct 05, 2026 20:40 UTC
Author

The "Using CSLib in your project" section (#206) stops at lake update cslib. The next lake build then compiles Mathlib. This adds lake exe cache get there, which is the same step Mathlib documents for downstream projects.

lake exe cache get does not keep CSLib's own build products. The README also notes LAKE_ARTIFACT_CACHE=true so another checkout of the same toolchain can reuse a local build, and LAKE_RESTORE_ARTIFACTS=true when a tool expects files under .lake/build. lake cache put is only described, not added to CI: it needs LAKE_CACHE_KEY and a cache service (LAKE_CACHE_SERVICE, or LAKE_CACHE_ARTIFACT_ENDPOINT with LAKE_CACHE_REVISION_ENDPOINT).

Drafted with Grok 4.7, the 500k-context high-effort setting, in Cursor. I used it to read LAKE_ARTIFACT_CACHE, LAKE_RESTORE_ARTIFACTS, and LAKE_CACHE_KEY in Lean 4.35 (Lake.Config.Env, PackageConfig.enableArtifactCache) and to write the README paragraph. This repository has no LLM-generated label; the disclosure above is the step CONTRIBUTING.md asks for, via the Mathlib policy.

Diff: 16 lines (+16 / -0) across 1 files Reviewer: arademaker Review duration: 76143m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.32) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.32 · 16 lines diff across 1 files
0.32
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.94 · 2 substantive comment(s)
0.94
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
88%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.170
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
4 items
arademaker arademaker commented on code on Oct 18, 2026 21:18 UTC
Code Review
README.md:1
@@ -32,6 +32,22 @@ require cslib from git "https://github.com/leanprover/cslib" @ "main"
 
 Then run `lake update cslib` to fetch the dependency. You can also use a release tag instead of `main` for the `rev` value.
 
+Download Mathlib's prebuilt files before the first build, or Lake compiles Mathlib from source:
+
+```sh
+lake exe cache get
+```
+
+`lake exe cache get` does not store CSLib's own build products. To reuse a local CSLib build across checkouts of the same Lean toolchain, opt in to Lake's artifact cache:
+
+```sh
+export LAKE_ARTIFACT_CACHE=true
+```
+
+Left unset, Lake may read cached artifacts and will not write this package's outputs into the shared cache. `LAKE_RESTORE_ARTIFACTS=true` copies them back into `.lake/build` when a tool expects that layout.
+
+Uploading those artifacts for other people is separate, and this repository does not do it in CI. After a build with `LAKE_ARTIFACT_CACHE=true`, `lake cache put` publishes the local cache. That command needs `LAKE_CACHE_KEY` and a cache service (`LAKE_CACHE_SERVICE`, or `LAKE_CACHE_ARTIFACT_ENDPOINT` together with `LAKE_CACHE_REVISION_ENDPOINT`).

For this section title, "Using CSLib in your project," I expect it to target people who just want to depend on CSLib. How to share local caches across checkouts and upload to a remote cache service are advanced or maintainer-level topics. Moreover, the remark that this repository doesn't do it in CI isn't relevant to a downstream user.

arademaker arademaker requested changes on Oct 18, 2026 22:49 UTC
Changes Requested Reviewer

I ran some tests with cslib-community/fad, where I always tell students to use lake exe cache get after cloning:

lake exe cache get
lake build

The lake build time is usually 40-50 seconds after the cache has been downloaded.

But I confess I had never stopped to understand exactly how lake exe cache get works, and I didn't know about Lake's cache with LAKE_ARTIFACT_CACHE=true. So, from what I understood:

~/.cache/mathlib/*.ltar    (compressed files, shared across projects)
        │
        │  lake exe cache get  →  downloads whatever is missing here and UNPACKS into ↓
        ▼
<project>/.lake/packages/mathlib/.lake/build/*.olean   (inside each project)
        ▲
        │  lake build  →  only looks here (and in Lake's cache)

(thanks Claude for the diagram)

Without LAKE_ARTIFACT_CACHE, lake exe cache get downloads the files to ~/.cache/mathlib/.ltar and then unpacks them into the project at <project>/.lake/packages/mathlib/.lake/build/.olean, so that lake build is then fast by looking at the project's oleans or Lake cache in ~/.elan/toolchains/.../lake/cache.

lake build will always check Lake's cache in ~/.elan/toolchains/.../lake/cache, from what I understood, regardless of the variable LAKE_ARTIFACT_CACHE being or not set.

With LAKE_ARTIFACT_CACHE=true, the oleans are not copied from Lake's cache into the project, unless we also have LAKE_RESTORE_ARTIFACTS=true. Without LAKE_ARTIFACT_CACHE, Lake's cache is copied into the project.

lake build only writes to Lake's cache in ~/.elan/toolchains/.../lake/cache if we have LAKE_ARTIFACT_CACHE=true.

Given that, we have

Fresh clone of fad
 ├─ toolchain cache has the right versions → lake build (copies from there, fast)
 └─ it doesn't → lake exe cache get → lake build
               └─ with LAKE_ARTIFACT_CACHE=true, this build also fills the toolchain cache

I recommend reducing the README changes to just summarize this understanding. Not sure we should mention the experimental lake cache yet.

arademaker arademaker commented on Oct 18, 2026 22:52 UTC
Contributor

But the README is not the place for an elaborate explanation of lake cache and lake exe cache (from Mahtlib). I guess we should just remind the user about lake exe cache get.

PS: Claude taught me a lot about the caches and helped me with tests, but I wrote all the above messages. Just to be clear. I got the English fixed by http://www.grammarly.com/!

Reviewers
Assignees
cdbattags cdbattags
Labels
risk: low confidence: 88.9% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 31.9% (LOW) · Higher = larger blast radius
31.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 88.9% · Lower = rushed or shallow review
88.9%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 3.5% · Safe to merge
3.5%