Function read_result_is_stable_under_concurrent_append
pub async fn read_result_is_stable_under_concurrent_append<F: Fixture>(
open: impl AsyncFn() -> F,
) -> RuleOutcomeExpand description
One read is one sample: an append made after the stream has been polled
does not appear in it.
ES-11. The store is read once to fix the expected answer, a stream is opened over the same query, polled once, an event is appended, and the stream is then drained. What comes out must be exactly what was visible before the append.
§The leading poll is the whole reason this rule is portable
It reads as an incidental detail and it is not. The contract fixes the
sample no later than the first poll, and deliberately does not say
whether it is taken at call time or deferred: MemoryEventStore filters,
orders and truncates under the read lock when read is called, and
happenstance-sqlite cannot — spawn_blocking panics with no runtime in
scope and read is not async, so its work has to move into poll_next.
Both are conformant. A rule that appended before the first poll would
therefore fail the deferring adapter at random while passing the buffering
one, and the failure would read as a flake rather than as a rule asking
the wrong question. One poll first, and both shapes answer the same.
A stream that answers Poll::Pending on that first poll has still been
polled, and nothing in the specification says a read stream is ready
immediately — PagedStreamStore is the conformant control for exactly
that. So the leading poll’s result is kept where there is one and
ignored where there is not.
§What it rejects
RefetchingPagedStore: a store with no cursor issuing an independent
statement per page against whatever it holds now. That is the natural
shape for a one-shot-HTTP adapter, and it is what ES-11’s ceiling — capture
a position ceiling H no later than the first poll and bound every later
statement by position <= H — exists to require. It also rejects
BorrowHoldingStore, whose stream holds the store open so the append in
the middle of this rule cannot happen at all.
§What it deliberately does not assert
Nothing about laziness. Whether the adapter did its work at call time or at the first poll is unobservable through the port and is the adapter’s business; a MUST no rule can check is the decorative-rule failure with the arrow reversed.