On-demand ordered windows publish an intermediate window during repair or refill #2131
Problem#
For an ordered, limited live query over an on-demand source, a repair or a refill can publish an intermediate window before the window is complete. The settled window is right.
Two forms, both reproduced by the ordered-work oracle's on-demand path:
- Repair: a visible row is deleted from an unindexed source-filter window. The window publishes empty, then publishes the refilled row.
- Refill: a row leaves a join-filtered window only through the join. The window first publishes a live row after the loaded prefix in the place of an earlier row that the query has not loaded. The proving page then publishes the right row.
The second form shows a wrong row, not only a short window. #2122 made the settled result right and recorded this transient as an on-demand limit.
Cause#
- For the repair,
OrderedSourceLoaderholds publication only when the adapter returns a Promise (settlesAsync). An on-demand repair continues after the graph turn even when the adapter returnstrue, so the delete publishes first. - For the refill, an ordinary page request does not hold publication. A chain of page and tie requests can reach the graph turn's flush between requests.
Tried#
- Without the
settlesAsynccondition, an asynchronous repair always holds publication. The repair form then does not occur. It fails 8 tests in the pagination oracle, which expect those windows at their checkpoints. - A flush gate holds publication while a window holds a row after the loader's settled boundary, with a full-source fallback. The refill form then does not occur. It fails 2 more pagination-oracle tests.
Decision needed#
Define what an on-demand window may publish while an asynchronous repair or refill is in flight, and reconcile it with the pagination oracle's checkpoints. Options include:
- holding the last complete public snapshot, as initial loads and window moves do
- allowing a short window but never a row that the loaded prefix does not prove
Oracle#
The ordered-work oracle's on-demand path checks the settled window after each step. Its one-publication-per-commit check does not apply to on-demand sources until this is decided.
This issue was written by Isaac.
KyleAMathews closed this
Sign in to join this conversation.
Decision and new evidence#
Policy decision: while a repair, refill or window move is in flight, an on-demand ordered window keeps publishing its last complete snapshot. This matches ARCHITECTURE.md: "Both paths keep the last complete public snapshot until they settle."
The ordered-work oracle in #2132 has a strict barrier law for this policy. It is not committed, because production fails it. Two traces fail:
offset 1,limit 2. A visible delete with a held refill publishes[1002, 1003]. The last complete window was[1001, 1002].offset 1,limit 1. AsetWindow({ offset: 0, limit: 1 })publishes the moved window before its promise settles. The last complete window was[]. The issue text above assumed that moves already hold their publication.I keep the strict law and both traces as JSON for the PR that closes this issue. I also keep the definition of a barrier that the harness can observe. That definition is a pending move, or a held request from the query's own subscription without a cursor. That PR will add them. The intermediate-window law from my earlier work also goes into that PR.
This comment was written by Isaac.