Skip to main content

batch_is_not_evaluated_against_its_own_condition

Function batch_is_not_evaluated_against_its_own_condition 

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

A condition is evaluated only against events the store already held.

ES-21 [FROZEN]. A batch can never conflict with itself, and the sentence has to be written down because the reference store answers it correctly only by accident of ordering — MemoryEventStore checks stored before it extends, and nothing said it had to.

What it rejects is the per-row conditional INSERT … SELECT … WHERE NOT EXISTS, which the decision ledger carries as a live candidate for the append-condition SQL strategy. Carried per row, the guard travels with every statement, so the second row of a batch is checked against a store that already holds the first — and on the canonical DCB uniqueness shape, where the condition names the very type being written, it self-rejects. An adapter built that way refuses every conditional append of more than one matching event and passes every other rule in this suite. PerRowConditionStore is the compiled version, and it rolls back on rejection precisely so that it fails this rule and not append_is_atomic. WriteThenCheckStore fails it from the other side: writing before deciding puts the batch into the set its own probe reads.

§The reissue at the end is the anchor, and it is doing real work

Without it the rule’s whole content is is_ok(), which a store whose probe answers None to everything satisfies for free — and an inert probe is exactly what this suite exists to catch. The identical batch under the identical condition must now be refused, which is evidence that the condition’s query really does match these events and that the admission above was a verdict rather than an absence.

is_err, deliberately, and not ConditionViolated: which error a rejection is reported as is ES-25’s MUST and condition_rejection_is_reported_as_condition_violated owns it.