Skip to main content

append_stamps_identity_and_time

Function append_stamps_identity_and_time 

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

VT-4 — the four facts on a SequencedEvent are persisted, not produced by the read that returned them.

VT-4’s Rejects: line names the adapter that makes identity or time up at read time, and observes that it “passes every rule that reads back what it just wrote inside one process”. That is true of a rule that reads once, and it stops being true the moment one event is reached two different ways: an identity derived from the row’s ordinal in the result set, or a time taken from the connection’s clock in the row mapper, both answer differently when the result set is a different shape — while agreeing with themselves perfectly under any single query.

So this reads one event through Query::all() and again through a query that selects it alone, and compares the whole SequencedEvent. RowOrdinalIdentityStore and ReadTimeClockStore in tests/mutation_coverage/mutants.rs are the two compiled versions, and the first of them is right under Query::all() on a densely-allocated store, which is what makes it survivable and what makes the second read the whole rule.

The middle event, not the first, so that neither an ordinal-derived identity nor a first-row special case can coincide with the right answer. The types ascend on purpose: SortByEventTypeStore orders by (type, position) and would otherwise reorder the batch, which is read_defaults_to_ascending_order’s subject and not this one’s.

The local shape of the identity — that id.position() is the position this store assigned — belongs to append_stamps_a_local_event_id, and the time’s own claim to append_stamps_a_recorded_time. Asserting either here as well would be one rule wearing three names.