Repository navigation
Add storage-enforced bounded page reads - #34
Merged
Merged
Conversation
Add load_stream_page to EventStreams: the stored records inside an inclusive position range, oldest first, at most limit of them, with the stream's observed position. The range is a consumer's replay boundary and the limit is its page size. The in-memory, SQLite and PostgreSQL backends implement it; both SQL backends apply the bounds and the LIMIT inside a bounded subquery joined to the head observation, so every empty page still reports the head and only the selected rows reach typed decoding. Zero limits, reversed ranges, past-head bounds and missing streams read empty pages, never errors. Shared conformance cases cover exact endpoints, truncation by count and by upper bound, unsigned bounds past i64::MAX, one-snapshot reads under a rival append, and a consumer paging a backlog to an endpoint captured from its first observation; SQL-local controls pin selection-before-decoding for both exclusion kinds. Card: E42
The consumer case's completion check ran after the next-start increment, so a final dense page starting at the largest sequence would panic on the checked add instead of completing catch-up, and the comment claimed the opposite order. Check completion on the page's own stretch - requested start through returned count minus one - which a page bounded by the endpoint cannot push past the largest sequence, and only then advance the next start. Card: E42
The selection-before-decoding control existed near-verbatim in the SQLite and PostgreSQL test modules. Lift it into the shared spec suite as a_page_selects_before_decoding, generic over the strict reader and the loose writer, with each backend wiring its own stores and its own decode-failure predicate. The consumer case also folds its first-page assertion into the endpoint it derives and builds the rival's batch in one block. Coverage is unchanged: every exclusion kind, the selected failure, and the zero-limit read still assert, now single-sourced. Card: E42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
EventStreams::load_stream_page: bounded, paged reads of one stream's history.limitof them, with the stream's observed position. The range is the replay boundary a consumer owns; the limit is its page size.at()is the observed head of the whole stream, never a page checkpoint. A consumer advances a page at its requested start plus its returned count, checks endpoint completion before incrementing, and lets an empty page end catch-up.usizelimit clamps instead of going negative.Existing callers are unaffected. External
EventStreamsimplementors must add the method - a breaking addition for implementors, stated as such.Conformance
i64::MAX, same-snapshot head and records under a rival append, and a consumer paging a dense backlog to an endpoint captured from its first observation - a rival append inside the originally requested range but beyond that endpoint never rides a page.Verification
Rust 1.88.0 (the declared floor):
An adversarial review round before this PR found and fixed one defect: the consumer case's completion arithmetic could overflow at the largest sequence; completion is now checked on the page's own stretch before any increment (
ec6b236).Note: strict Clippy on toolchains newer than the floor (1.95.0) flags three baseline lints in
src/test_helpers/repository.rsandtests/saga_outbox_postgres/windows.rs, files this PR does not touch. Left for a separate cleanup.Changelog entry included under [Unreleased].