Skip to main content

batch_positions_follow_slice_order

Function batch_positions_follow_slice_order 

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

Positions within one batch are assigned in slice order, strictly ascending.

ES-19’s second sentence, which append_returns_last_written_position structurally cannot see: that rule infers the batch’s order from all.last(), so it asks only which position came back and never which event got it. On a quiescent store the highest position is the last row however the rows were ordered, so a store that writes the batch backwards and returns the maximum answers it correctly.

ReverseOrderBatchStore is the compiled version — a multi-row INSERT built from the batch reversed, which is what an adapter produces when it pushes rows onto a stack, or when it sorts a batch to group rows by an interned type id and forgets that grouping is also reordering. The consequence is not cosmetic: a decision replays its own batch in the order the store returns it, so Held then Released comes back as Released then Held and the projection is wrong with no error anywhere. SharedBatchPositionStore fails it too, one bind parameter over: one position bound for every row of a multi-row insert is not ascending, and “strictly” is the word that rejects it.

§Two things it deliberately does not assert

It does not re-assert the returned position. append_returns_last_written_position owns ES-19’s first sentence and ReturnsFirstOfBatchStore is its mutant; making the claim here would buy a second failure on that store and no new coverage.

And it compares positions found by type, never the order the read returned them in. Read ordering is read_defaults_to_ascending_order’s and SortByEventTypeStore is its mutant, so an order comparison here would fail every store whose defect is the read path — which is what keeps a mutant a scalpel rather than a shotgun.