ReservationStore
Reserved keys: uniqueness across aggregate instances, such as a user name unique within a tenant (documentation/designs/01-programming-model.md §7; 9.x PrepareKey).
A key is unique within its ReservationScope: one aggregate type, one tenant (or ReservationScope.SYSTEM_TENANT for keys unique across the type's tenants) and one namespace. It is held by at most one owner, an aggregate of that type (AggregateRef, compared field by field). The aggregate type is the unit of placement: its reservations live with its log, so two aggregate types that use the same namespace never conflict; a key that must be unique across aggregate types is modelled as an aggregate of its own that holds those keys. A decision reserves it pending with a short time to live, and confirms it once its events are appended: a process that crashes between reserving and appending leaves only a pending reservation that expires, never a key held for good. A confirmed reservation never expires; it ends only when its owner releases it.
Several attempts of one owner may reserve one key at once (a handover, a forward that timed out): a pending reservation records each attempt that reserved it, its holds, and an attempt whose events are surely not appended abandons only its own hold. The key stays reserved while another attempt still holds it, and a confirmed key is never abandoned.
A confirmed reservation records the version of its owner's fact that last confirmed it, and a release names the version of the fact that gave the key up: a release frees only a key no later fact confirmed, so a subscription replaying an old rename (A→B, then B→A) never frees the key a later fact of the owner confirmed again.
Every operation that changes a reservation names its owner and does nothing for anyone else. Expiry is judged by the implementation's clock, so the nodes sharing a store need clocks that agree within a small fraction of the time to live.
Functions
Confirms owner's reservation of key for its fact committed at version, making it permanent and clearing its holds. A pending reservation of owner is confirmed even if it expired; a key held by no one, or only by another owner's expired pending reservation, is taken confirmed: the fact committed, so it gets its key back. The reservation keeps the greater of its version and version, so confirming again, or a replay of an older fact, changes nothing. version is the fact's stream version, UNVERSIONED when there is none (a key imported from 9.x).
Releases owner's reservation of key, whatever its holds, for the owner's fact committed at version that gave the key up (a rename): a pending one, or one confirmed at version or below. A key a later fact confirmed is kept: the release is an old fact's, replayed. ANY_VERSION frees the key whichever fact confirmed it.
Reserves key in scope for owner's attempt hold, pending for ttl. A key held by no one, or only by an expired pending reservation (whoever's), is taken: pending, its only hold hold. When owner holds the key pending and live, hold joins its holds and the later expiry is kept; when owner holds it confirmed, it stays as it is.