Function read_to_composes_with_limit
pub async fn read_to_composes_with_limit<F: Fixture>(
open: impl AsyncFn() -> F,
) -> RuleOutcomeExpand description
A window and a budget on the same read, with the budget the smaller.
ES-16 and ES-14 together, and it is the last unread pair of read options:
until this rule the suite composed to with from, with backwards and
(since read_to_composes_with_multi_item_query) with a filtering query,
and issued to beside a limit at no call site at all.
It rejects WindowedPagingBudgetStore: the budget threaded into the
paging statement and not into the windowed one, because a closed window is
a different statement from a page and the paging clause was already on the
other one. That store is ForwardPagingBudgetStore one read option over,
and it passed all ninety-two rules that preceded this one — measured,
with an empty fails list, rather than argued. The caller it breaks is the
backfill worker ES-16 exists for, writing .limit(budget - fetched)
against the window it was given and being handed the whole window instead:
a batch nobody sized, and arithmetic about a number the store ignored.
§Why the budget is smaller than the window, and why there is one read
Because the other arrangement has no wrong implementation to name. With a
budget larger than the window the answer is the one to alone
determines, so ToBoundIgnoredStore and ToIsExclusiveStore would fail
here for read_to_is_inclusive’s reason and nothing else would fail at
all. With the budget smaller, both of those stores answer correctly —
the budget masks the bound — which is precisely why neither the bound’s
rules nor the budget’s can see the store this rule is for.
§to and limit commute, and that is why this rule is shaped as it is
read_from_composes_with_limit’s documentation used the commutation to
argue that no rule was owed here. The commutation is real: in read
order from cuts the front while to and limit both cut the back, and
two prefix operations compose to the shorter prefix whichever order they
run in. So the wrong implementation an adversarial review proposed — the
row budget applied before the upper bound,
.take(n).take_while(|e| e.position <= to) — answers every read exactly
as the reference implementation does, forwards and backwards alike. It is
not a defect, and it is deliberately not registered.
What the argument missed is that commuting is not the only way two options
interact. WindowedPagingBudgetStore does not reorder them; it drops
one because the other is present, which no amount of commutation reaches.
Order and applicability are different questions and only the first was
answered.
The read is forwards. The backwards composition stays with
read_to_under_backwards_bounds_the_older_end and
read_backwards_from_with_limit: the only wrong implementation that needs
backwards and a window and a budget is a store whose windowed
statement is written ascending with the LIMIT inside it and the
direction applied by an outer ORDER BY — a narrower hypothesis, needing
two statements and one specific SQL shape, and asserting it here would
make BackwardsToIsAnUpperBoundStore, BackwardsIgnoredStore and
FetchOneExtraStore fail this rule for reasons three other rules own. It
is recorded as an extension rather than taken.
Every event is tagged, carries one distinct tag, and the types ascend, for
limit_applies_across_items_not_per_item’s reasons: InnerJoinTagStore
needs a tag to join to, TagJoinFanOutStore needs a second tag to fan out
over, PayloadDedupStore needs two byte-identical events, and
SortByEventTypeStore’s sort has to be the identity here or
read_defaults_to_ascending_order loses its store.
The assertion names two positions the store itself assigned, so a store that returns nothing fails it and so does one that returns the window. That is the non-vacuity anchor.