Zulip Chat Archive
Stream: batteries
Topic: batteries#887 breaking Mathlib
Kim Morrison (Sep 24 2024 at 23:07):
@Matthew Ballard, @Mario Carneiro, Mathlib needs adaptations for batteries#887. The automatic bump process is reporting failures: https://leanprover.zulipchat.com/#narrow/stream/345428-mathlib-reviewers/topic/Mathlib.20.60lake.20update.60.20failure/near/472580810
Kim Morrison (Sep 24 2024 at 23:10):
(Also noting that batteries changes that Mathlib needs adapation for also break Mathlib's nightly-testing
branch, and hence delay being able to test Lean PRs against Mathlib.)
Mario Carneiro (Sep 24 2024 at 23:12):
point me to what to do to avoid messing up your process
Kim Morrison (Sep 24 2024 at 23:17):
In some form, we need to have adaptations for Mathlib ready to go.
- We could do this manually: if a maintainer judges that it is likely that a change will break Mathlib, we ask if there is an adaptation ready before merging.
- We could automate this, like Lean automatically tests Batteries and Mathlib. That is, a CI process would continue after normal Batteries CI completes, creating a
batteries-pr-testing-NNNN
branch of Mathlib and updating the lakefile there to depend on the PR branch of Batteries. Then run normal CI on that branch, and report back via a labelbreaks-mathlib
orbuilds-mathlib
on the Batteries branch. - Or we could do this reactively -- the notifications are all already in place --- by having enough people watching the Mathlib update failures topic or the Mathlib status updates topic in #nightly-testing to notice when Batteries has introduced a Mathlib breakage, and fixing it promptly. (Here "enough" just means "not primarily me". :-)
Kim Morrison (Sep 24 2024 at 23:22):
Ideally, we can do all three. 1. will mostly stop things breaking, and 3. will backstop that when needed. If we can get started (either implementing or asking for help) on 2., that can gradually take the workload off maintainers.
Kim Morrison (Sep 24 2024 at 23:22):
But I think we need to do at least one!
Mario Carneiro (Sep 24 2024 at 23:23):
is there a way to make this fail in the merge queue?
Kim Morrison (Sep 24 2024 at 23:24):
So, variants of 2. would be possible, where rather than just reporting back with labels, we actually fail a CI check (that is either run all the time, or --- as you suggest --- only in the merge queue) if Mathlib doesn't cleanly adapt.
Mario Carneiro (Sep 24 2024 at 23:24):
How does lean core do it? Seems like breaking changes are merged all the time without adaptations ready to go
Kim Morrison (Sep 24 2024 at 23:25):
Yes, just judgement about whether testing is needed. If you want downstream testing, then you make sure your PR is based off nightly-with-mathlib
(which is a branch tracking the most recent nightly for which we know Mathlib succeeds).
Mario Carneiro (Sep 24 2024 at 23:26):
For this PR, I expect the adaptations to be very simple, since it's just a rename in some namespaces that will be used in a handful of tactics
Kim Morrison (Sep 24 2024 at 23:26):
If you don't want downstream testing (either because you're confident it isn't needed, because you know Mathlib is currently badly out of sync (thankfully this is rare recently), or because you know that I'm available to clean up), then you don't base off nightly-with-mathlib
, and instead the bot just reports that it isn't going to test Batteries+Mathlib.
Kim Morrison (Sep 24 2024 at 23:27):
Yes, for this PR option 3. above is perfectly fine. Just I'd like it to happen without me be the sole person to notice it needs to happen. :-)
Kim Morrison (Sep 24 2024 at 23:27):
(i.e. option 3 is only fine if the "enough" clause there holds!)
Kim Morrison (Sep 24 2024 at 23:29):
Note a virtuous cycle here: the more often Mathlib is compatible with lean's nightlies, the higher expectations Lean PR authors will have that testing against Mathlib will give useful signal, and the more likely they are to do the testing, and thus have adaptations (at either the Mathlib or Lean end!) ready before merging.
Kim Morrison (Sep 24 2024 at 23:45):
Okay, I am going to go fix this manually now.
Kim Morrison (Sep 24 2024 at 23:47):
Kim Morrison (Sep 24 2024 at 23:50):
and cherry-picked onto nightly-testing
.
Kim Morrison (Sep 24 2024 at 23:53):
Ooops, and my local build found another problem, which I've now deployed in both places.
Matthew Ballard (Sep 25 2024 at 09:13):
@Kim Morrison sorry messing up the process and thanks for fixing it.
I asked earlier about handling downstream breakage (of course not thinking it was in process) so it is good to get some answers and plans to make things smoother (hopefully).
Is there anyway to get that Zulip message from the bump automation to be more specific about what is being bumped?
Kim Morrison (Sep 26 2024 at 00:32):
I guess we could have the bot link to the diff on the lake-manifest.json
?
Kim Morrison (Sep 26 2024 at 00:32):
It is usually 75% batteries, 25% aesop, at least recently.
François G. Dorais (Sep 26 2024 at 02:29):
Is there a convenient way to trigger 2 on-demand? (The manual process is time consuming and prone to error.)
Kim Morrison (Sep 26 2024 at 02:46):
@François G. Dorais, option 2. for a Batteries PR doesn't exist at all at the moment. Are you talking about for a Lean PR? What would "on demand" look like?
François G. Dorais (Sep 26 2024 at 03:12):
Could be triggered by a maintainer or by the author on a case by case basis. For example, if I believe a PR might break Mathlib but I'm not sure how, then I could press the button to create a batteries-pr-testing-NNNN
branch to check it out. (But it might be easier to do it for all PRs.)
Kim Morrison (Sep 26 2024 at 03:12):
Yeah, seems easier to do it for everything than for some!
François G. Dorais (Sep 26 2024 at 03:13):
Agreed, I was mostly wondering if it already existed and I had been missing out.
Kim Morrison (Sep 26 2024 at 03:14):
No, this all exists for Lean, but no where else.
François G. Dorais (Sep 26 2024 at 03:16):
It would be great to have that for Batteries but I'm not sure about the implementation costs. It doesn't look like an easy task at all even though a working model already exists in Lean.
Kim Morrison (Sep 26 2024 at 03:23):
I think would just be a matter of copying .github/workflows/pr-release.yml
(from the lean4 repo), dropping everything before line 284, and adapting a bit.
Kim Morrison (Sep 26 2024 at 03:23):
We'd also need to update at the mathlib end to report back to Batteries for failures on batteries-pr-testing-NNNN
branches.
Kim Morrison (Sep 26 2024 at 03:24):
I think it would suffice to just always test Mathlib master, so it's actually a good bit simpler than the Lean case.
Kim Morrison (Sep 26 2024 at 03:34):
If someone could sanity check batteries#958, that is hopefully most of what is needed.
Kim Morrison (Sep 26 2024 at 03:50):
#17144 is the mathlib end of it.
Kim Morrison (Sep 26 2024 at 03:51):
Again, sanity check please, and then I'll set up the tokens and we can test in production.
François G. Dorais (Sep 26 2024 at 06:47):
That was really fast! LGTM
Johan Commelin (Sep 26 2024 at 07:10):
Kim Morrison said:
#17144 is the mathlib end of it.
LGTM
Kim Morrison (Sep 26 2024 at 07:18):
Okay, I will install tokens soon!
Kim Morrison (Sep 26 2024 at 10:21):
Hmm, we did it again, and batteries#956 breaks Mathlib and nightly-testing.
Kim Morrison (Sep 26 2024 at 10:21):
:-(
François G. Dorais (Sep 26 2024 at 10:48):
Looks like this is just about deleting the lemmas from Mathlib.Data.List.OfFn that were moved to Batteries as well as the obsolete _go
lemmas. So I just need to do that directly on nightly-testing. Is there some kind of signal so that we don't step on each other's toes?
François G. Dorais (Sep 26 2024 at 10:53):
Got it. I figured out the workflow.
Kim Morrison (Sep 26 2024 at 10:57):
Where did length_ofFn
go?
Kim Morrison (Sep 26 2024 at 10:57):
In this case we shouldn't be touching nightly-testing.
Kim Morrison (Sep 26 2024 at 10:58):
It's getting lake update
to work on master
that is the problem.
Kim Morrison (Sep 26 2024 at 10:58):
Fixing that and nightly-testing
will come good automatically.
François G. Dorais (Sep 26 2024 at 10:58):
It's on Batteries now.
Matthew Ballard (Sep 26 2024 at 10:58):
Protected? never mind
Kim Morrison (Sep 26 2024 at 10:58):
Unfortunately the bot that posts about lake update
breakages on master
is in a private stream that @François G. Dorais doesn't have access to.
Kim Morrison (Sep 26 2024 at 10:59):
I'll work out how to make that happen.
Kim Morrison (Sep 26 2024 at 10:59):
Oh, it's just imports that need fixing, in that case.
Kim Morrison (Sep 26 2024 at 10:59):
We need to import Batteries.Data.List.OfFn
at the right place in Mathlib.
François G. Dorais (Sep 26 2024 at 11:00):
Yes, I'm fixing that now.
Kim Morrison (Sep 26 2024 at 11:02):
And I'm getting you access to things. :-)
François G. Dorais (Sep 26 2024 at 11:02):
Got it. I just push on nightly-testing directly or is there an intermediate step?
Kim Morrison (Sep 26 2024 at 11:02):
Ah, as I was saying above, it's better to fix this on master
Kim Morrison (Sep 26 2024 at 11:03):
i.e. a PR in which we lake update
and then do this fix.
Kim Morrison (Sep 26 2024 at 11:03):
hopefully you could just take whatever change you've got and transplant it over
Kim Morrison (Sep 26 2024 at 11:03):
(If we fix it directly on master, a bot will merge the change to nightly-testing. If we just fix on nightly-testing, master will still need manual updating.)
Kim Morrison (Sep 26 2024 at 11:04):
(but besides that point yes, you are welcome to push direct to nightly-testing)
François G. Dorais (Sep 26 2024 at 11:04):
That makes sense!
François G. Dorais (Sep 26 2024 at 11:14):
Kim Morrison (Sep 26 2024 at 11:14):
Don't you also need a change in List.FinRange, since List.getElem_ofFn
is protected now?
Kim Morrison (Sep 26 2024 at 11:15):
but with that :peace_sign: :-)
François G. Dorais (Sep 26 2024 at 11:20):
OK. It will take a bit to internalize the workflow but I will definitely be able to help more going forward.
Kim Morrison (Sep 27 2024 at 01:25):
Just a heads up that I have installed all the requisite tokens and secrets, and merged batteries#958 and #17144.
Kim Morrison (Sep 27 2024 at 01:26):
In an ideal world, this will result in every PR to Batteries automatically generating a batteries-pr-testing-NNNN
branch on Mathlib which uses that PR, and then Mathlib CI reporting back with a label breaks-mathlib
or builds-mathlib
.
Kim Morrison (Sep 27 2024 at 01:26):
In the real world, where we have to test Github CI in production, none of this will work.
Kim Morrison (Sep 27 2024 at 01:26):
I don't have time right now to test this, but if no one else has in a few hours time I should be able to later today.
Kim Morrison (Sep 27 2024 at 11:43):
A fair number of fixes later, I think batteries#960 has demonstrated that it basically works!
François G. Dorais (Sep 27 2024 at 13:12):
batteries#966 was just labeled builds-mathlib
!
François G. Dorais (Sep 27 2024 at 21:04):
And batteries#854 was labeled builds-mathlib
after an update.
François G. Dorais (Sep 27 2024 at 21:05):
It's confirmed that batteries#960 works as intended in real life!
François G. Dorais (Sep 27 2024 at 21:21):
It already caught an unexpected error in batteries#948. (Not a major one, just a test that needs an update.)
Edward van de Meent (Sep 28 2024 at 13:44):
I'd like to mention that this change means https://leanprover-community.github.io/contribute/tags_and_branches.html may need an update about this feature, since it's not clear with whom the responsibilty for fixing the breaking change lies, and where/how this should be solved. i started a discussion of this in #mathlib4 > workflow for fixing breaking changes to Batteries , but feel free to move it here if that is more appropriate
Last updated: May 02 2025 at 03:31 UTC