Echo notification expiration should be time-based, not a hardcoded limit of 2000 notifications.
This would be better because:
* The hardcoded limit is vulnerable to data loss caused by notification spam. Even if the spammy events are later hidden (e.g. by revision-deleting relevant revisions), older notifications are still lost. (T367754)
* The hardcoded limit reveals how many events were hidden that way. For example, on enwiki I currently have 1,993 notifications, which let me know that there are 7 notifications I am no longer allowed to view (due to deleted revisions, deleted pages, or something else). This is a very minor, but probably unwanted information leak.
* It would let us remove compatibility code for very old notifications. Currently we have to be able to display every notification ever sent, which requires maintaining backwards-compatibility if the data format is ever changed (which means we never change the format, and just leave mistakes in forever, [[ https://gerrit.wikimedia.org/g/mediawiki/extensions/DiscussionTools/+/c3bf635b4541351378e5a0c6770fd57f820dbd88/includes/Notifications/EventDispatcher.php#260 | e.g. this ]]), compatibility with corrupted data caused by bugs (e.g. T323236, T367638, T286192), or running maintenance scripts to convert them (to my knowledge this never happened, but would be necessary for e.g. T325703). For example, on plwiki I have notifications going all the way back to 2013, when the extension was deployed.
Echo code should be able to cope with more than 2000 notifs, it uses key-based pagination and has good indexes.
The only downside would be that notifs of sentimental value would all be eventually lost. If we make this change, we should announce it first.
See also {T227853}.