Skip to content

feat: add lake build --summary flag#13454

Open
kim-em wants to merge 1 commit intoleanprover:masterfrom
kim-em:lake-build-summary
Open

feat: add lake build --summary flag#13454
kim-em wants to merge 1 commit intoleanprover:masterfrom
kim-em:lake-build-summary

Conversation

@kim-em
Copy link
Copy Markdown
Collaborator

@kim-em kim-em commented Apr 18, 2026

This PR adds a --summary flag to lake build that prints a build summary table at the end, showing counts of succeeded / succeeded-with-warnings / failed jobs plus a list of failed job captions:

Build summary:
  ✔ 142 jobs succeeded
  ⚠ 3 jobs succeeded with warnings
  ✖ 2 jobs failed
    Mathlib.Topology.Basic
    Mathlib.Order.Filter.Basic

Counts only include jobs that performed actual build work (action > .unknown), so infrastructure wrapper tasks are excluded. Warning classification uses log.entries.any (·.level ≥ .warning).

For the "downstream blocked count" part of #13316, a separate follow-up PR will add script/count-blocked-by-build-error rather than building that reverse-import pass into Lake itself — see the Zulip thread. That keeps Lake's reporting path minimal and keeps the workspace-wide import-graph computation out of the build runner.

Closes #13316

🤖 Prepared with Claude Code

@kim-em kim-em added the changelog-lake Lake label Apr 18, 2026
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Apr 18, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

mathlib-lean-pr-testing Bot commented Apr 18, 2026

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 235aedfaf7e6e4c6573e79b89b42a225cd0e7e1e --onto fed2f32651e1e24a507c12aae234ac59e4d9916a. You can force Mathlib CI using the force-mathlib-ci label. (2026-04-18 01:11:38)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 235aedfaf7e6e4c6573e79b89b42a225cd0e7e1e --onto 80cbab16420b90104647a795a18f9890fd8150e8. You can force Mathlib CI using the force-mathlib-ci label. (2026-04-20 03:38:44)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 235aedfaf7e6e4c6573e79b89b42a225cd0e7e1e --onto 3fc99eef102549c743c6c63547983319bfae6f01. You can force reference manual CI using the force-manual-ci label. (2026-04-18 01:11:40)

@kim-em kim-em force-pushed the lake-build-summary branch from 8d1fa40 to d4bec36 Compare April 19, 2026 03:44
kim-em added a commit to kim-em/lean4 that referenced this pull request Apr 19, 2026
This PR adds a standalone Python script that wraps `lake build`, captures its
output, and for each failed module reports how many modules in the selected
`lean_lib`s transitively import it. The count is an upper bound on how many
downstream modules were blocked by the failure in the workspace.

The script enumerates modules via `lake query <lib>:modules`, builds the
forward import graph using batched `lake query +M:imports --json` calls, and
inverts it locally. A batched query that fails (e.g. because one module has an
unparsable header) is bisected down to singletons so one bad file doesn't drop
the whole report.

This is a follow-up to leanprover#13454 (which added `lake build --summary`). The
original issue leanprover#13316 asked for blocked-downstream counts inside Lake itself;
moving that computation to a standalone script keeps Lake's build-reporting
path minimal and avoids re-parsing every workspace module from within the
build runner.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This PR adds a `--summary` flag to `lake build` that prints a build summary
table at the end, showing the number of jobs that succeeded, succeeded with
warnings, and failed, along with a list of failed job captions.

Closes leanprover#13316

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kim-em kim-em force-pushed the lake-build-summary branch from d4bec36 to ea393b3 Compare April 20, 2026 02:33
kim-em added a commit to kim-em/lean4 that referenced this pull request Apr 21, 2026
This PR adds a standalone Python script that wraps `lake build`, captures its
output, and for each failed module reports how many modules in the selected
`lean_lib`s transitively import it. The count is an upper bound on how many
downstream modules were blocked by the failure in the workspace.

The script enumerates modules via `lake query <lib>:modules`, builds the
forward import graph using batched `lake query +M:imports --json` calls, and
inverts it locally. A batched query that fails (e.g. because one module has an
unparsable header) is bisected down to singletons so one bad file doesn't drop
the whole report.

This is a follow-up to leanprover#13454 (which added `lake build --summary`). The
original issue leanprover#13316 asked for blocked-downstream counts inside Lake itself;
moving that computation to a standalone script keeps Lake's build-reporting
path minimal and avoids re-parsing every workspace module from within the
build runner.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kim-em kim-em marked this pull request as ready for review April 21, 2026 03:18
@kim-em kim-em requested a review from tydeu as a code owner April 21, 2026 03:18
Copy link
Copy Markdown
Member

@tydeu tydeu left a comment

Choose a reason for hiding this comment

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

Looking good! One big design question I have about this is how do you see this interacting with --wfail and --iofail? Currently, I believe these will all be bucket as failures with no granularity. Is that acceptable?

For my two cents, I would suggest bucketing the jobs independent of their success (i.e., without the !failed qualifier) and then determine whether to print "succeeded with" or "failed with" in the report based on the failLv. Would that be more helpful for the use cases you have in mind?

if failed && !optional then
modify fun s => {s with failures := s.failures.push caption}
if !failed && !optional && action ≥ .fetch then
if log.entries.any (·.level ≥ .warning) then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if log.entries.any (·.level ≥ .warning) then
if maxLv ≥ .warning then

This is what maxLv is tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-lake Lake toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: lake build --summary flag to print build outcome table

3 participants