Skip to content

feat(client): Streamer::open_range streams one verified byte window - #2607

Merged
thiras merged 4 commits into
mainfrom
feat/streamer-open-range
Oct 24, 2026
Merged

thiras merged 4 commits into
mainfrom
feat/streamer-open-range

Conversation

@thiras

@thiras thiras commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

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); the VerifiedReader hands out exactly the window, so an HTTP Range maps 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. open is now open_range(.., (0, 0), ..).

This is the client half of the HTTP Range the hosted public gateway answers. Part of #2593 (first of several PRs; the gateway side lands after #2590).

Reviewer notes

Read streamer.rs first: StreamState gains start/end, present_frontier finds the contiguous present run that holds start instead of the run from 0, next_verified stops at min(end, proven), and run_drive hands acquire the window as its one range (a tail keeps the zero-length "follow the bound" meaning AcquireTarget documents). Store sizing uses scheduler::claim_reach as the Downloader already does, so a deep window under max_blob_bytes is not clamped out of the store. Nothing below acquire changes: alignment and per-leg payment were already range-aware.

Unchanged on purpose: the whole-blob path (open) behaves as before; drained_stream_is_blake3_identical and the paused-consumer/spend-bound tests still pass unmodified.

Verification

Always:

  • pre-commit run on commit (all hooks passed; cargo deny findings are the known warn-only advisories)
  • CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features: clean
  • cargo nextest run -p decdn-client: 1090 passed (the 8 new streamer::tests::a_*window*/a_range_* tests fail to compile without the change)
  • PR title uses an allowed type and the subject does not start with an uppercase letter

Only if touched:

  • Public API of decdn-client: the .snap regenerated (one added signature)
  • User-visible change: CHANGELOG.md entry added by hand, one per PR

🤖 Generated with Claude Code

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]>
@thiras thiras added kind:feature New capability or a change to current behavior area:client decdn-client SDK: paid pull, lanes, buyer pool labels Oct 24, 2026
Copilot AI balanced review requested due to automatic review settings October 24, 2026 13:02
@thiras thiras self-assigned this Oct 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 open to (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

Comment thread crates/client/src/streamer.rs Resolved
Comment thread crates/client/src/streamer.rs Resolved
@github-code-quality

github-code-quality Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 0746c74 feat/streamer-open-r... 8e68081 +/-
77% 77% 0%
View coverage of the 5 most impacted files.
File main 0746c74 feat/streamer-open-r... 8e68081 +/-
crates/client/s...c/downloader.rs 83% 83% 0%
crates/client/src/scheduler.rs 94% 94% 0%
crates/node/src/dht/publish.rs 78% 80% +2%
crates/client/src/streamer.rs 84% 87% +3%
crates/client/src/sink.rs 95% 98% +3%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 24, 2026 14:54 UTC

thiras and others added 2 commits October 24, 2026 16:17
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]>
@thiras
thiras merged commit fba631e into main Oct 24, 2026
34 checks passed
@thiras
thiras deleted the feat/streamer-open-range branch October 24, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:client decdn-client SDK: paid pull, lanes, buyer pool kind:feature New capability or a change to current behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants