SnapshotRebuildStore
The snapshot rebuild control plane of a SnapshotStore, its own port: a store offers it through SnapshotStore.rebuilds. The snapshot subscriptions never use it; the node's snapshot maintenance does.
Rebuilds work per aggregate type, its table: the store records the state revision the table is claimed at (claim, table), and the snapshots of another revision or marked stale (markStale) are pending until a rebuild rewrites them from the log, in place, whatever their revision. The TCK's SnapshotStoreSpec checks it for a store that has it.
A table removed under its record: the store creates a table's structure (its index, table or collection) before the first claim records it, and never again after that. So a structure missing while its record is kept was removed (an operator deleted the index, dropped the table or the collection): it holds nothing the log committed before. The store records it SnapshotTable.removed when it finds it so, at its first use of the table, or later on a path it already takes (a statement that misses the structure, its maintenance round), never by the structure's identity, and writes it on the record it checked alone, while that record is at the same SnapshotTable.generation and not removed: a renew between the check and the write made the structure and reset the record, which stays served. It serves a removed table no more: a save, a batch's snapshots and a rewrite of it write nothing and answer not written, markStale answers false, pending lists none and a load answers null, so a load reads the log. The record keeps removed through every claim and mark. A store whose structures it does not manage (ddl: none) cannot tell, and a structure emptied in place is not missing.
Functions
Claims type's table at state revision and returns its record after the claim. The first claim records the table, not yet backfilled, filled by fill, and rebuilding unless revision is 1 (a snapshot written before revisions is of revision 1). A later claim raises a lower revision; it lowers a higher one only when lower says so (a rollback, once no node of the higher revision is left); either change starts a rebuild. A later claim never changes the SnapshotTable.fill the first one recorded, whatever its own fill. Claims are atomic: concurrent claims leave one revision and one fill.
Sets rebuilding and backfilled, each when given, on type's table while it is claimed at revision; returns the record after, or null when the table is claimed at another revision or not at all.
Marks type's table SnapshotTable.backfilled while it is claimed at revision and at generation, the one whose backfill the caller checked; returns the record after, or null when it is claimed at another revision or generation, or not at all. A renewal between the check and the mark so leaves the renewed table unmarked.
Fills type's table again from the log's beginning at generation, the operator's step for a table removed under its record (or emptied in place): a claim whose configured generation is above its record's renews it. While the record's SnapshotTable.generation is lower, the store makes the table's structure (its index, table or collection) when it is missing, the one moment beside a first claim that the store creates it, and then resets the record, in that order: not SnapshotTable.backfilled, filled by SnapshotFill.BACKFILL, not SnapshotTable.removed, at generation; its revision and SnapshotTable.rebuilding stay as they are, so the reset needs no revision. A record at generation or above is left as it is (a lowered generation is the record's to keep, and renewals of one generation by several nodes are one). It returns the record after, or null when the table has no record (a first claim comes first) or the store cannot renew.
Stores snapshot, rebuilt from the log, in place of the stored one: when the store holds none for its ref, or holds the same or a lower version, whatever its state revision; returns whether it was written. A stored version above snapshot's, written meanwhile, stays. Writing clears a stale mark of a version up to snapshot's.