Skip to content

lean_closure.py: score the working tree's repo, merges and faster proofs - #1663

Merged
alex merged 1 commit into
mainfrom
claude/faster-proofs-chacha-poly-closure-fixes
Oct 10, 2026
Merged

alex merged 1 commit into
mainfrom
claude/faster-proofs-chacha-poly-closure-fixes

Conversation

@alex

@alex alex commented Oct 10, 2026

Copy link
Copy Markdown
Member

Why

Other sessions used ci/lean_closure.py score after #1641 and found four ways it misled.

  1. Wrong repository. It read the repository it was installed in, not the working directory's, so running main's copy from another worktree scored main.
  2. Branches behind REF. It compared with REF itself, so a branch behind origin/main counted main's newer changes as its own. In one example, 670 modules looked changed instead of 5.
  3. Merges. A module that merges others took only its own old time, and the other members' time disappeared. A run that rebuilt a merged-away member wasn't counted as rebuilding the merged module either. For one RSA merge plan the tool said −108 s on replayed runs; corrected, it's −31 s.
  4. Faster proofs. Modules the branch changed kept REF's times, so a PR that makes proofs faster scored only as the cost of what it added. One such PR showed +7 s while cutting about 140 s of CPU.

The change

All in ci/lean_closure.py:

  • Every command reads the working directory's repository by default, with --repo for another. The tool sets lean_shards.LEAN accordingly.

  • score compares with git merge-base REF HEAD.

  • score --merge NEW=A,B,… gives NEW the members' times together, less IMPORT_TIME for each member but one. A run's rebuilt members map to NEW. If NEW has a time from the branch (below), that time wins.

  • Branch times for the modules whose sources differ from the fork point:

    • score --times FILE reads them from a JSON object of module names and seconds;
    • score --profile-branch reads them from the profile of the local build under lean/.lake, after building the branch.

    The changed modules left without a branch time are listed on stderr, since they keep REF's time (or the median, if new).

CLAUDE.md's paragraph on the tool mentions --merge and --profile-branch.

Tests

ci/test_check_lean_closure.py gains 7 tests:

  • merged times;
  • a run that rebuilt a merged module: before the fix it rebuilt nothing on the branch, after it rebuilds NEW;
  • a branch time beats the merge sum;
  • a faster proof shortens the replayed run;
  • the changed modules of a git working tree, untracked ones included;
  • the merge base of a branch behind REF;
  • use_repo reading another repository's modules.

python3 -m unittest discover -s ci -p 'test_check_*.py': OK.

Checked by hand: run from the worktree of the closed #1640, the tool now scores that worktree's 5 changed modules, where before it scored 670.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TyNFiywMtzf7eAdKcGMA5z


Generated by Claude Code

Three ways `score` misled:

* It read the repository it was installed in, not the working directory's,
  so running main's copy from another worktree scored main. Every command
  now reads the working directory's repository (`--repo` for another).
* It compared with REF itself, so a branch behind it counted REF's newer
  changes as its own. It now compares with where the branch forked.
* A module that merges others took only its own old time, and a run that
  rebuilt a merged module was not counted as rebuilding it.
  `--merge NEW=A,B` gives NEW the modules' times together (less
  `IMPORT_TIME` for each but one) and maps their rebuilds to NEW.
* Modules the branch changed kept REF's times, so making proofs faster
  scored as nothing. `--times FILE` and `--profile-branch` (the profile of
  the branch's local build) give them the branch's times, and those left
  without are listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TyNFiywMtzf7eAdKcGMA5z
@alex
alex enabled auto-merge October 10, 2026 11:34
@alex
alex added this pull request to the merge queue Oct 10, 2026
Merged via the queue into main with commit 9fb6c0f Oct 10, 2026
28 checks passed
@alex
alex deleted the claude/faster-proofs-chacha-poly-closure-fixes branch October 10, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants