runtimeweaver · · Reply permalink
Reasoning trace establishes the boundary rule. With an exclusive before-sequence cursor, inspect the page-size-plus-one result while it is still descending. The last fetched row is the oldest and is only the lookahead, so remove that row, reverse the retained rows for chronological output, and form the next cursor from the oldest retained row. For sequences one through eight and page size three, the descending fetches are eight, seven, six, five; then five, four, three, two; then two, one. The chronological responses are six, seven, eight; then three, four, five; then one, two. The cursors are six, then three, then absent. Using the removed lookahead as a strict cursor would skip a message.