Repository navigation
feat(prebuilt): verified fetch ladder with Range resume (#1882) - #2172
Merged
Merged
Conversation
Turn a `Resolution::Hit` asset into a file on disk without trusting any single URL: - exact `size_bytes` and SHA-256 are enforced while the body streams: an over-long body is refused before it writes past the declared size, and a short body is kept as a resumable partial instead of being committed; - a partial resumes with `Range` + `If-Range` against the validator (ETag, else Last-Modified) that the writing attempt recorded in a sidecar, and restarts from byte 0 when the server answers 200 instead of 206; a 416 discards the partial so the fresh attempt can run; - the URL ladder is tried in order, each URL twice (resume, then from scratch), because a poisoned partial can only be cured by starting over; - concurrent fetches of one digest in this process collapse to a single download (process-local single-flight); - the destination name is derived from the digest plus a sanitized basename, so a bucket filename can never escape the staging directory. Tests are local axum fixtures (resume headers asserted on the wire, refused range, 416, corrupt source fall-through, over-long and short bodies, single-flight, invalid assets, size limit, traversal filename). 12 new tests; `prebuilt` 18/18 and the crate lib suite 335 passed. Two RED proofs by mutation: dropping the If-Range header fails the resume test, disabling the exact-size check fails the short-body test. #1882 stays open (remaining cells: streaming extraction, staging/partial GC, disk-cache LRU, BuildRequest field, bucket key, daemon-wide single-flight).
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Clippy (`-D warnings`) refused the first cut: `Fetcher::attempt` was 130 lines (cap 100) and the fixture's `(Range, If-Range)` log tripped `type_complexity`. Split the attempt into `open` (request, status/Content-Range decision, sidecar write) and `stream` (hash + exact-size enforcement), share the sidecar reader, and give the fixture log a `Wire` alias. Behaviour is unchanged except that an over-long body now also drops the sidecar, which the corrupt-source test already required of a poisoned partial. Proven locally: `soldr cargo clippy -p fbuild-packages-fetch --lib --tests -- -D warnings` exit 0; prebuilt 18/18; crate lib 335 passed.
`Dylint Full` on the previous head failed `ban_poison_panic`:
`self.gates.lock().expect("gate map poisoned")` cascades the original
panic across every other digest's lock holder.
The map only hands out `Arc`s and a poisoned map still holds valid gates,
so recover the guard with `.unwrap_or_else(|error| error.into_inner())`
instead of panicking, per the lint's documented cure.
Verified: `soldr cargo clippy -p fbuild-packages-fetch --lib --tests -- -D
warnings` exit 0; crate lib suite 335 passed / 0 failed / 2 ignored.
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 24, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 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.
Implements the next cell of #1882: the verified fetch ladder that turns a
Catalog hit into a file on disk.
What it does
Fetcher::fetch(&Asset)→Artifact { path, size_bytes, sha256 }:size_bytesand SHA-256 areenforced as the body arrives: a body that exceeds the declared size is
refused before it writes past it, a short body is kept as a resumable
partial, and nothing is renamed into place unless the digest matches.
asset digest plus the response ETag (else Last-Modified) in a sidecar; the
next attempt asks for
bytes=<len>-guarded byIf-Range, restarts at 0 whenthe server answers
200, and discards the partial on416.scratch — because a poisoned partial can only be cured by starting over.
one download; the second caller re-verifies the committed file.
fp-digits + sanitized basename, soa bucket filename (
../../evil) cannot escape the staging directory.Tests (real output)
prebuiltmodule: 18 passed, 0 failed (12 new). Crate lib suite:335 passed, 0 failed, 2 ignored in 4.68 s.
Fixtures are local axum servers that assert on the wire: the resume test
requires
Range: bytes=3000-and the matchingIf-Range; a refused rangemust rewrite the body rather than append; a
416must lead to a clean restart;a corrupt source must fall through to the next URL and, alone, exhaust without
leaving a partial.
Two RED proofs by mutation: removing the
If-Rangeheader fails the resumetest; disabling the exact-size check fails the short-body test.
cargo fmt --checkexit 0;ci/enforce_platform_boundary.py --print-totalsexit 0 and
ci.test_enforce_platform_boundary14 tests OK.soldr cargo clippy -p fbuild-packages-fetch --lib --tests -- -D warnings→ exit 0 (the first push did fail CI Clippy:
attemptwas 130 lines and thefixture log tripped
type_complexity; the second commit splitsattemptintoopen+streamand adds aWirealias, no behaviour change).#1882 stays open (remaining cells: streaming extraction, staging/partial GC,
disk-cache LRU, the
BuildRequestfield, the bucket key, and a daemon-widesingle-flight).
Authored by the fbuild steward agent; ~/dev/fbuild untouched.