pub async fn convergent_projection_is_interleaving_independent<F>(
open: impl AsyncFn() -> F,
) -> Result<RuleOutcome, Violation>Expand description
SY-20. A declared projection commits byte-identical read models under two interleavings that agree on each origin’s order and disagree everywhere else.
The fixture’s projection is run twice, fresh each time, over the two
origins’ events: origin one’s first, then origin two’s first. Its read
models are compared byte for byte. A fixture whose projection has not
declared ConvergentProjection cannot be handed to this rule; that
is SY-22’s exclusion, and
non_convergent_projections_are_excluded_not_failed holds it.
Rejects unit-ledger, a per-serial state machine that keeps whatever
arrived last, and with it the class: any fold whose answer depends on
arrival — a count of arrivals kept as an order, a first or last
writer by arrival, a queue consumed in arrival order.
tests/wrong_projections.rs holds each against this rule.
§Errors
A Violation of SY-20 if the two read models differ, if either
origin authored nothing, if a run applied fewer events than it was
handed or failed, or if the fixture could not open or read a store.
§Examples
use happenstance_sync_testkit::{StockOnHandFixture, convergence_rules};
use happenstance_testkit::{RuleOutcome, block_on};
let outcome = block_on(
convergence_rules::convergent_projection_is_interleaving_independent(async || {
StockOnHandFixture::new()
}),
)?;
assert_eq!(outcome, RuleOutcome::Ran);