Introducing a PageIdentity interface and a PageIdentityValue class would allow a lot of code to stop depending on the Title class, removing spurious dependencies dragged in by that. It also allows us to move towards using immutable, serializable value objects, instead of global-state-aware smart records.
PageIdentity should be defined in a way that allows Title to implement it directly. It should be similar to LinkTarget (and could perhaps extend it), with the distinction that it also exposes a page ID. This (annoyingly) means that a PageIdentity does not always identify an entry in the page table - it may instead also refer to a non-existing page, a special page, or a foreign (interwiki) page.
Proposed signature for PageIdentity
Open questions:
* Should PageIdentity //be// a LinkTarget, or //have// a LinkTarget? Having a LinkTarget seems cleaner, but inconvenient, and potentially confusing because Title will be implementing both, LinkTarget and PageIdentity.
* What should the relationship between PageIdentity and PageRecord (see T195069) be? PageRecord should probably //have// a PageIdentity, not //be// a PageIdentity, so that the contract of PageRecord can guarantee that PageRecords always refer to entries in the page table (and perhaps also the archive table).
* getArticleID is an akward method name to have in PageIdentity. It should have a getId() method instead. Should Title::getArticleID() be deprecated in favor of getId(), when Title implements PageIdentity? Is getId() a clear enough name in the context of Title?
* How can the idea of a page "existing" be clarified in the contract if PageIdentity, while maintaining compatibility with the way exists(), canExist(), isSpecialPage() and isAlwaysKnown() work on Title?
* What terminology should be used to represent the idea that a PageIdentity refers to a "real" page, rather than a "special" page or foreign link target? "article" is ambiguous...
* What terminology should be used to identify PageIdentities that identify pages that belong to a different wiki, but one to which we still have direct database access via PageStore and RevisionStore, know the namespaces, etc? Perhaps they should not be "foreign", and differ from local pages only in their wiki ID?