This series modifies our database representation of messages that have been referenced by other messages, but for which we don't have the message itself. Currently, we store this information as Xapian metadata, but this has several downsides for performance and complexity and results in hard-to-fix thread linking bugs. This patch series implements "ghost messages", which replace this Xapian metadata with Xapian documents that look and act very much like regular message documents, but simply have no content. This simplifies and speeds up our thread linking algorithm and fixes the currently broken thread linking test.
Ghost messages also open up interesting future possibilities, such as "pre-seeding" tags for messages that are not yet indexed. This could be used to make notmuch insert simpler and more robust, as part of tag synchronization, and to improve nmbug's behavior when tags arrive before messages.