← Back to Pull requests

Guidance on breaking changes #912

Open
unknown opened this pull request with 394 lines diff across 4 files
View on GitHub
unknown unknown commented on Sep 09, 2026 12:35 UTC
Author

The motivation here is that:
1. Users bumping their mathlib versions by a small amount (eg less than one month) should not have to deal with errors in their code
2. But if this is necessary, then mathlib should endeavour to make them as easy to fix as possible
3. We already follow these principles with the deprecation policy and deprecation of modules policy
4. Ecosystems of programming languages are often very strict with breaking changes, and the guidance I add here is relatively very mild to the contributor and harsh on the downstream user. I don't like that it's this way round, but hopefully the change here is a step in the right direction and uncontroversially so. (see eg Rust's policy on breaking changes https://rustc-dev-guide.rust-lang.org/bug-fix-procedure.html, or SemVer's rule on backwards-incompatible changes https://semver.org/#spec-item-8)
5. Lean core sets an expectation that breaking changes will be discussed in the release notes: https://github.com/leanprover/lean4/blob/master/RELEASES.md
6. A number of PRs already discuss breaking changes in their description
7. Hopscotch and its existing CI workflows create issues/PRs giving the mathlib commit and PR description which breaks project code, so requiring it to be mentioned in the description is especially useful for users of hopscotch.

The spirit of this policy already exists in mathlib writings in various guises:

  • We discourage non-terminal simps because they make it more likely that a new [simp] can produce a breaking change (and more generally the flexible linter)

  • We have a deprecation policy for names and modules

  • The "Growing Mathlib" paper says

  • Many large formalisation projects are carried out in a repository depending on Mathlib. If keeping

    up with the latest Mathlib changes is too onerous, contributing results back to Mathlib may become impossible.

    Previous discussion on related points:

  • https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Deprecation.20.26.20recycling.20lemma.20names

  • #mathlib4 > notes for adaptations each release cycle @ 💬

  • #mathlib maintainers > Deleting #align statements @ 💬 in particular the comment
  • Imagine that refactor PRs have to pass a check that every unique id is accounted for by mentioning which are added and which are deleted in the PR description. Then as a reviewer you can know if every declaration has been preserved (modulo judgment calls for whether to preserve an id for a transformed statement).

    Adding what you just said, it could also check that the id refers to the same statement, and if not, the PR description must mention the breaking change.

  • #lean4 > Deprecation without explanations @ 💬

  • The general discussion around deprecated modules
  • Diff: 394 lines (+295 / -99) across 4 files Reviewer: b-mehta Review duration: 119902m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.50) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 394 lines diff across 4 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    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.358
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #912"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% 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: 50.2% (MEDIUM) · Higher = larger blast radius
    50.2%
    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: 44.7% · Lower = rushed or shallow review
    44.7%
    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: 27.7% · Safe to merge
    27.7%