Repository navigation
fix(gateway,client): size a verified raw blob, and adopt the size open's pull - #2646
Merged
Merged
Conversation
…n's pull - #2616 (part): a raw blob that a whole pull on the gateway verified answers with Content-Length, Accept-Ranges, HEAD and one Range (206/416), and is refused with 402 before its pull when it does not fit the allowance; its pull is capped at that size. The size comes from the fetch host's SizeHints through a new worker request (Request::Size, no pull slot); the empty root is empty with no pull. A node's size claim never gives a length: the server stops reading a body at its Content-Length, so an understated claim would end a short pull as a whole response. The first request still streams unsized (#2645). - HEAD /_decdn/<hash> on a site answers as the bare host does instead of 404, and HEAD of a bundle or entry under /_decdn/ redirects to its site. - #2633: LaneSources lanes are PrimedSource-wrapped, and the whole-blob open that learns the first size claim primes its pull on the lane, so a download's first leg adopts it instead of the holder writing the bytes twice. Streamed fetches still drop it (#2644). - Tests: gateway raw-blob length/range/402/HEAD/empty-root tests, a worker size-lookup test, a downloader adoption test, gateway_public checks an unsized first response then HEAD and a range of the verified blob, and peer_store_probeless checks a fast-path download probes nothing and the holders write its wire bytes once. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
An incompatible primed pull retains unpaid credit reservations that can block an otherwise affordable replacement leg.
1 open issue
What changed in this PR
This PR adds size-aware raw-blob responses to the gateway after a whole pull verifies the blob’s size, and reuses the client’s size-discovery pull for matching downloads.
Changes:
- Adds verified-size lookup, raw-blob length and range support, and corrected site
HEADrouting. - Primes whole-blob pulls for adoption by a download’s first matching leg.
- Adds regression coverage and documents the remaining first-request and streamed-fetch limitations.
| File | Description |
|---|---|
| crates/e2e/tests/peer_store_probeless.rs | Checks probe-free downloads and avoids duplicate served bytes. |
| crates/e2e/tests/gateway_public.rs | Tests verified raw-blob length and range responses. |
| crates/client/src/lane_sources.rs | Primes size-discovery pulls for download reuse. |
| crates/client/src/downloader/tests.rs | Tests adoption of a primed whole-blob pull. |
| crates/client/src/bundle/engine.rs | Clarifies size-discovery comments. |
| crates/cli/src/commands/gateway/worker/tests.rs | Tests size lookup without a pull slot. |
| crates/cli/src/commands/gateway/worker.rs | Exposes verified sizes through worker requests. |
| crates/cli/src/commands/gateway/tests.rs | Covers sized blobs, allowance rejection, site HEAD, and empty blobs. |
| crates/cli/src/commands/gateway/allowance.rs | Documents admission using verified blob sizes. |
| crates/cli/src/commands/gateway.rs | Adds size-aware blob handling and site HEAD routing. |
| crates/cli/src/commands/fetch.rs | Exposes verified sizes and clarifies size-discovery docs. |
| CHANGELOG.md | Records gateway and client fixes and limitations. |
| adr/appendix-gateway.md | Documents verified-size responses and range behavior. |
| adr/039-multi-source-parallel-fetch.md | Documents size-pull retention and adoption. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 6 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
…ange The pull LaneSources keeps from the whole-blob size open held its floor reservation on the node while a first leg of another range (a streamed window, a resumed gap) opened beside it, so a pool or signer with room for one floor could refuse that leg. PrimedSource::prime_next parks a pull for the next open alone: an open of exactly its range adopts it, any other open closes it before the wrapped source opens. The node's prime is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
9 tasks done
Open
7 of 11 tasks
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
Two gateway follow-ups from #2593.
Part of #2616
Closes #2633
#2616 (part): a raw blob the gateway verified answers with its length,
HEADandRangeGET /<hash>on the bare host,/_decdn/<hash>on a site) getsContent-LengthandAccept-Rangesonce a whole pull on the gateway has verified its size. The size comes from the fetch host'sSizeHints, read through a new worker request,Request::Size/PullWorker::size, which takes no pull slot.Range(206, or 416 past the end), is refused with 402 before its pull when it does not fit the allowance, and its pull is capped at that size, as a sized entry's is.HEADon a raw blob answers from the verified size with no pull.HEAD /_decdn/<hash>on a site used to be read as an entry of the site's own bundle and answered 404. It now answers as the bare host does, andHEADof a bundle or an entry under/_decdn/redirects to its site.Content-Length. A claim below the real size would cap the pull there, and the verified prefix would end as a whole 200 or 206. The client keeps a cut file and sees no error.#2633: a download adopts the pull it opened for the size
LaneSourceslanes are wrapped inPrimedSource. With no size hint (the peer-store fast path, or a pinned node whose probe gave no size), the whole-blob open that reads the signed size primes its pull on the lane instead of dropping it after the node has written up to a credit window.align_range(0, 0, total), so the drive adopts the pull and the holder writes the blob's wire bytes once.PrimedSource::prime_next). Any other first leg (a streamed window, a resumed gap) closes it before opening its own pull, so the node never holds the floor it reserved for the pull beside the replacement leg (review: Copilot). The node'sprimekeeps its semantics.WindowPacer) do not adopt it yet: client: a streamed fetch with no size hint still drops the pull it opened for the size #2644.Docs:
adr/appendix-gateway.md(§ Payment and allowance, § Ranges), ADR 039 (first size claim), the gateway, worker, allowance,fetch.rsandlane_sources.rsdocs, and the CHANGELOG.Reviewer notes
Gateway::blob/blob_size/head_blobincrates/cli/src/commands/gateway.rs, thenopen_for_headerincrates/client/src/lane_sources.rs.ProbeOpts::sizedflag. A multi-agent review found the truncation hole above, and an unbounded probe round per anonymousHEAD, so that cut was dropped.crates/client/src/targets.rsis unchanged.Verification
pre-commit run --all-files: passed. The cargo-deny advisories it prints come from the existing lockfile and only warn.cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo fmt -- --check,CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items, andmake -C adr check-refs: all exit 0.cargo nextest run --workspace: 5939 passed.gateway_public,gateway_pointer,gateway_concurrent_pullsandpeer_store_probelesspassed.gateway_publicnow checks that a raw blob's first response has no length, then aHEADwith the length and aRangewindow of the verified blob, and adds that window's wire bytes to the node's served-bytes check.peer_store_probelessnow checks that its fast-path download probes nothing and that the three holders write the blob's wire bytes once, within 16 KiB.gateway_sdk) at the pinned.github/sdk-typescript.sha: passed on both the public and the loopback gateway.driver::tests::a_pull_primed_for_the_next_open_closes_before_another_range_opens: a primed pull is closed before a leg of another range opens.peer_store_probelessfails: "the holders wrote 397220 bytes for a 198610-byte pull".prime_nextclose removed, the driver test above fails.🤖 Generated with Claude Code