feat: add /check-golf bot verifying statements are unchanged#1355
feat: add /check-golf bot verifying statements are unchanged#1355Vilin97 wants to merge 1 commit into
Conversation
Add scripts/check_golf.py and a check-golf GitHub workflow. When a `/check-golf` comment is posted on a PR, the bot compares the PR's base and head, checks that no declaration statement (signature/type) changed and only proofs/bodies changed, and upserts a single findings comment (posting it once, editing it on later runs). The Lean sources are parsed textually (no build): comments and whitespace are ignored, declarations are segmented on column-0 command starts, each statement is split from its body at the top-level `:=`, `where`, or equation `|` arm, and `by` proof terms embedded inside a type are treated as proof-irrelevant. Co-authored-by: Claude Opus 4.8 <no-reply+claude-opus-4-8@anthropic.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vjiv6nckrp5cJT9rpgZaKT
|
Thank you for this PR, which will now be reviewed. If submitting to ./Physlib or ./QuantumInfo, please see our review guidelines if you are not familiar with the process. You should expect a back and forth with a reviewer before your PR is merged. See also that link for how to add appropriate labels to your PR. The PR will also go through a number of automated checks. You can learn more about these here, including how to run them locally. If you are submitting to ./PhyslibAlpha there will be a lighter review process, though your PR must still pass the automated checks. If you want to bring attention to this PR, please write a message on this thread of the Lean Zulip. Important: If a reviewer adds an |
What
Adds a
/check-golfbot that verifies a PR only golfs proofs: that no declaration statement (its signature/type) changed and only proofs and definition bodies changed. Comment/check-golfon any PR and the bot posts its findings as a single comment, editing that same comment on subsequent runs.Files
scripts/check_golf.py— compares two revisions of the repo. For every named declaration in the changed.leanfiles it decides whether the statement was preserved and only the proof/body changed. It also renders the Markdown report and upserts it as a PR comment (POST first, PATCH the marked comment afterwards)..github/workflows/check-golf.yml— triggers on anissue_commentcontaining/check-golfon a PR, resolves the merge-base and head, runs the script, and comments.scripts/README.md— documents the tool and how to run it locally.How it works
The Lean sources are parsed textually (no build required, so the check is fast):
byblock closed by indentation);:=/where/ equation|arm, so:=in default binders andbyblocks inside a type (⟨x, by omega⟩) do not confuse the split;byproof terms embedded inside a type are treated as proof-irrelevant, so golfing them counts as a proof change, not a statement change.Anonymous instances and
examples are not tracked (they have no stable name).Testing
Run locally against two revisions:
Validated against a large real golf PR: the checker reports 0 statement changes across 312 changed files, and a name-level cross-check confirms no named declaration is dropped by the parser. The post→edit comment logic is covered by a mocked-API test.