We now have a separate extracted library for handling 'Changes': See: https://github.com/wikimedia/wikibase-changes
This nicely encapsulates much of the business logic for working with changes on both client and repo.
What it does not do is encapsulate the reading and writing of the table that is shared between client and repo.
A number of places are making raw reads to this table (including maintenance scripts): e.g.
There already exists an store Class that could be used: extensions/Wikibase/lib/includes/Store/Sql/SqlChangeStore.php
- There should be one place that consolidates the code that reads or writes to the changes table (or perhaps two e.g. reading and writing split)
- This code should be available to both client and repo (e.g. it should be placed in a shared composer library)
- This could be the already extracted changes library (see: https://github.com/wikimedia/wikibase-changes) or a new data-access library should be created