Repository navigation
feat(client): Streamer::open_range streams one verified byte window - #2607
Merged
Merged
Conversation
A caller that knows a blob's size can open a consumption-paced stream over `[offset, offset + len)` instead of the whole blob. The fetch opens, and pays for, only the chunk-group-aligned span around the window (ADR 038), the reader hands out exactly the window, a zero length is a tail to the proven size, a window is never teed to the cache, and a whole-blob cache hit serves the window from memory. `open` is the whole-blob window. This is the client half of the HTTP `Range` the public gateway answers (#2593). Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Finite windows can expand into tail fetches, and zero-size window validation permits a cached-slice panic.
2 open issues
What changed in this PR
Adds Streamer::open_range to the client SDK as groundwork for hosted gateway HTTP Range support in #2593.
Changes:
- Adds consumption-paced byte-window streaming and delegates whole-blob
opento(0, 0). - Adds window-aware reading, acquisition, store sizing, and cache handling.
- Adds eight range tests, updates the public API snapshot, and documents the feature.
| File | Description |
|---|---|
crates/client/tests/snapshots/public_api__public_api.snap |
Records the new public open_range signature. |
crates/client/src/streamer/tests.rs |
Tests window boundaries, aligned fetching, tails, and caching. |
crates/client/src/streamer.rs |
Implements window streaming and integrates acquisition and cache behavior. |
CHANGELOG.md |
Documents range streaming and its gateway role. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 5 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
A bounded window whose end reached a short claim was handed to the fetch as a tail while the reader stopped at the window's end, so the drive filled past a reader that never advanced and parked on the read-ahead window forever. Such a window now follows the proven size as the fetch does. A window past byte 0 needs a size claim, so a zero claim no longer fetches from byte 0 for a deep window. The cache is asked for exactly the window, as `BlobCache::get` is keyed, instead of the whole blob to slice. Docs for the cap, the scratch directory and an overstated claim say what the stream does. Co-Authored-By: Claude Fable 5.1 <[email protected]>
`AcquireTarget.bounded` marks exact ranges: `acquire` takes no range of a bounded target as a tail, even one that reaches the end of the blob as the caller knows it, so a window ending where the cap on held bytes puts the store's bound is fetched and stopped instead of followed past the cap into `BlobTooLarge`. A window past a short size claim is clipped to the claim and the stream ends with an error naming the shortfall; the fetch takes nothing past the claim. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This was referenced Oct 24, 2026
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
Streamer::open_range(hash, total_bytes, (offset, len), …)opens a consumption-paced stream over one byte window of a blob. The fetch opens, and pays for, only the chunk-group-aligned span around the window (ADR 038); theVerifiedReaderhands out exactly the window, so an HTTPRangemaps onto it with no trimming. A zero length is a tail to the proven size, a window past the proven size stops there, a window that starts at or past the size claim is refused at open, a window is never teed to the cache, and a whole-blob cache hit serves the window from memory.openis nowopen_range(.., (0, 0), ..).This is the client half of the HTTP
Rangethe hosted public gateway answers. Part of #2593 (first of several PRs; the gateway side lands after #2590).Reviewer notes
Read
streamer.rsfirst:StreamStategainsstart/end,present_frontierfinds the contiguous present run that holdsstartinstead of the run from 0,next_verifiedstops atmin(end, proven), andrun_drivehandsacquirethe window as its one range (a tail keeps the zero-length "follow the bound" meaningAcquireTargetdocuments). Store sizing usesscheduler::claim_reachas theDownloaderalready does, so a deep window undermax_blob_bytesis not clamped out of the store. Nothing belowacquirechanges: alignment and per-leg payment were already range-aware.Unchanged on purpose: the whole-blob path (
open) behaves as before;drained_stream_is_blake3_identicaland the paused-consumer/spend-bound tests still pass unmodified.Verification
Always:
pre-commit runon commit (all hooks passed;cargo denyfindings are the known warn-only advisories)CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features: cleancargo nextest run -p decdn-client: 1090 passed (the 8 newstreamer::tests::a_*window*/a_range_*tests fail to compile without the change)Only if touched:
decdn-client: the.snapregenerated (one added signature)CHANGELOG.mdentry added by hand, one per PR🤖 Generated with Claude Code