pub async fn convergent_projection_cannot_observe_local_position<F>(
open: impl AsyncFn() -> F,
) -> Result<RuleOutcome, Violation>Expand description
SY-21. A declared projection cannot observe the local position: the same arrivals, numbered twice, commit byte-identical read models.
The fixture’s projection is run twice, fresh each time and one event
per commit, over one arrival order, origin one’s events first. The
first replica numbers the events densely from the first position; the
second numbers them from far past it, with gaps between. Delivered
already withholds the position from the fold (SY-21’s compile-fail
fences). The rule compares read models, so any channel that lets the
local numbering reach them fails it; the one the port a fold is given
offers is its store’s checkpoint.
That is a reading of SY-21, not its letter. The clause forbids handing the arrival position “in the value it folds over”, and its reopening condition grants a fold the store’s own checkpoint. This rule takes the clause to mean that a fold may read its checkpoint but must not let it reach the read model: SY-20’s property, applied to positions.
Rejects a projection that writes its checkpoint into its read model,
which SY-20’s rule passes, since both of its interleavings number the
same count of events densely. tests/wrong_projections.rs holds it
against both rules.
§Errors
A Violation of SY-21 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_cannot_observe_local_position(async || {
StockOnHandFixture::new()
}),
)?;
assert_eq!(outcome, RuleOutcome::Ran);