Function a_concurrent_reader_never_sees_a_partial_batch
pub async fn a_concurrent_reader_never_sees_a_partial_batch<F>(
open: impl AsyncFn() -> F,
) -> RuleOutcomeExpand description
A reader running against a live writer never sees part of a batch.
ES-18’s atomicity from the only side that can observe it. A sequential
rule can assert that a rejected batch left nothing behind
(append_is_atomic); it cannot assert
that an accepted batch was never visible half-written, because by the
time a sequential reader looks, the append has returned. The shape this
rejects is a row-at-a-time insert loop outside a transaction, which is
what an adapter writes when its driver has no multi-row insert and it
forgets the BEGIN.
§Two halves, and only one of them is deterministic
The post-hoc half is: once every writer has finished, every batch is present and complete. That holds on every run and rejects a store that permanently loses part of a batch.
The live half is a sampling test, and saying so is better than
implying otherwise. The reader loops until the writers signal completion
and checks every batch it can see; a store that is never caught
mid-batch passes. It cannot flake in the direction that matters — a
conformant store has no partial state to be caught in, so this half never
fails a correct adapter — and the loop is bounded by the writers rather
than by a count or a clock, so there is nothing here for CF-33 to object
to. What it can do is fail to catch a genuine defect on an unlucky run,
which is why the proof artefact’s RowAtATimeStore does not rely on luck:
it holds each partial batch open until the reader has completed a read
that started after the partial write, counted under a mutex the writers
wait on, so the rejection is a rendezvous rather than a
race.
That rendezvous needs the reader to exist before the first writer runs,
and a spawned thread is not a scheduled one. observe_while_writing
below therefore completes one read on the rule’s own thread before the
scope opens — spelled plainly rather than as an intra-doc link, because
it is private and linking to it from a public item is a rustdoc warning
the gate denies. The comment there records what its absence was measured
costing.