feat: keep the previous Lean declarations diff visible while a new build runs#56
feat: keep the previous Lean declarations diff visible while a new build runs#56adomani wants to merge 3 commits into
Conversation
…ild runs The `### PR summary` comment carries a Lean-aware declarations-diff region, spliced in post-build by `updateDeclsDiffSection.py`. On every push, mathlib4's pre-build `PR_summary.yml` rewrites the whole comment and resets that region to the `(Lean -- pending)` placeholder, so a previously-computed diff disappears until the next build finishes. Add a `carry_forward(region, new_heading)` helper plus two ways to use it: * a new non-patching `MODE=emit`, called by the pre-build to print the region content: it carries an existing real diff forward under `NEW_HEADING` (relabelled stale) instead of blanking it, else prints the pending placeholder; * `MODE=warning` now carries a real diff forward under `NEW_HEADING` (surfacing the cache miss) rather than always replacing it with the unavailable block. A "real diff" is recognised by its body stamp (`✅ **Lean-aware diff**`), not its heading, so a once-shown diff survives repeated relabels without reverting to pending. The success path is unchanged. Adds 6 tests (51 pass). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Companion mathlib4 PR: leanprover-community/mathlib4#40486 |
ReferenceInformation-oriented. The API surface, no rationale.
Module constants
Modes
Tests — |
ExplanationUnderstanding-oriented. The design decisions. The comment is split across two repos: mathlib4's workflows generate it, this script patches it post-build. Any fix to "what the comment shows across pushes" therefore touches both — that split is pre-existing. A real diff is detected by its body stamp (
|
How-to: verify locallyProblem-oriented. Reproduce the behaviour before merging.
|
…r-coupled test Addresses review feedback on the declarations-diff carry-forward: * find_summary_comment now requires the comment author to be github-actions[bot]. Under pull_request_target this script reads a '### PR summary' comment's Lean region and carries it forward; since anyone can post such a comment, requiring the bot author keeps attacker-authored region content (markers + forged stamp) out of that loop. * carry_forward substitutes NEW_HEADING literally (via a lambda) instead of as a regex replacement template, so a heading containing '\' or '\g' cannot corrupt the output; it also warns on stderr when the diff stamp is present but no '(Lean…)' heading matched, surfacing NEW_HEADING / _HEADING_RE drift instead of silently no-op'ing. * tests: assert a section from the real producer (render_override) satisfies carry_forward — guarding against stamp drift that the hand-written fixture cannot catch — plus literal-heading, non-bot-impostor and missing-user cases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the "Mathlib cache ... isn't on the server" jargon from `build_warning` (it describes a missing built-master snapshot at the merge-base, not an olean cache) and update the test heading constant to match the reworded `(Lean -- stale; merge master and push to refresh)` used in mathlib4's decls-diff.yml. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
LGTM. Feel free to merge in a coordinated way with the downstream PR. |
Add
carry_forward+ a non-patchingMODE=emitso the PR-summary comment keeps a previously-shown Lean diff (relabelled) instead of reverting to pending / unavailable.Companion: leanprover-community/mathlib4#40486 · details in the Reference / Explanation / How-to comments below.