Skip to main content

event_ids_are_unique_within_a_store

Function event_ids_are_unique_within_a_store 

pub async fn event_ids_are_unique_within_a_store<F: Fixture>(
    open: impl AsyncFn() -> F,
) -> RuleOutcome
Expand description

VT-5 and VT-8 — a store holds at most one event per EventId, and it is the store’s job to make that true rather than the caller’s.

The arrangement is a one-event append followed by a two-event one, which is the shape that separates the two ways this goes wrong. A store that binds one identity for a whole multi-row INSERT is wrong only within a batch (SharedBatchIdentityStore, and SharedBatchPositionStore arriving at the same place through the position column); a store that resets something between calls is wrong only across batches. One single-event append and one multi-event append reach both, and a single batch of three would reach only the first.

Uniqueness is checked by sorting and deduplicating rather than by pairwise comparison because EventId is Ord — deliberately, so that the convergent fold VT-5 argues for can sort merged events without a hash — and using that order here is free.