Repository navigation
feat(core): carry the If-Range validator in adapter meta - #202
Draft
greenhat616 wants to merge 1 commit into
Draft
greenhat616 wants to merge 1 commit into
greenhat616 wants to merge 1 commit into
Conversation
greenhat616
force-pushed
the
feat/hardening-38-meta-validator
branch
from
November 13, 2026 07:44
2f255ee to
f324941
Compare
greenhat616
marked this pull request as draft
November 13, 2026 08:55
BoltLoadAdapterMeta gains `validator`: the validator an adapter sends in If-Range, a strong ETag or a Last-Modified, or None when ranges are unconditional. The resume work will store it in the state file and compare it with a fresh probe. Validator moves from bolt-load-http to bolt_load_core::adapter, and bolt-load-http re-exports it, so the old path still works. It gains `matches`: the same kind, a strong ETag byte for byte, and a Last-Modified compared as a date, so its format may differ. Core now depends on httpdate, which was already in the lock. Both adapters drop their separate cached If-Range value. They store the validator once in the probed meta, and every range request takes its If-Range, and the value its response is checked against, from that field. So the meta always reports what the ranges send.
greenhat616
force-pushed
the
feat/hardening-38-meta-validator
branch
from
November 13, 2026 22:26
f324941 to
3cdeb7b
Compare
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.
C34 (T21), the first commit of PR-9d (resume) in the download strategy hardening stack. It is stacked on #201 (the destination lock), which is its base branch. The design notes are in §11.5.7, §11.5.13 (item 2.1) and §14.27.
Why
A resumed download must check that the resource is still the version it started on. The state file will store the validator the adapter used, and C20 will compare it with a fresh probe (§11.5.7). The engine cannot see that validator today: each adapter keeps its
If-Rangevalue privately. This PR puts it in the adapter meta.What
Core (
bolt-load-core)Validatormoves frombolt-load-httptobolt_load_core::adapter::Validator(adapter/validator.rs). The variants, derives andas_strare unchanged.bolt-load-httpre-exports it, sobolt_load_http::Validatorstill works.Validator::matches, for C20:Nothing calls it yet.
BoltLoadAdapterMeta::validator: Option<Validator>andwith_validator. It holds the validator the adapter sends inIf-Range;Nonemeans ranges are unconditional.httpdatebecomes a dependency of core. It has no dependencies of its own and was already in the lock.The parsing and selection helpers stay in
bolt-load-http, since core does not need them.Adapters (reqwest, ureq2)
if_rangevalue is gone. The probe builds the meta withetag,last_modifiedandvalidator, and the validator comes from thebytes=0-0GET, as in C19. Every range request takes itsIf-Rangefrom the cachedmeta.validator, and so does the check of its response. So the meta always reports what the ranges send.validatorasNone, and noIf-Rangeis sent.before_requesthooks and the adapter README now say that a hook, a ureqcallhook or reqwest default headers must not replace the adapter'sIf-Range, or add one when the meta has none. Response checking always uses the cached value. The behaviour is unchanged since C19.Not breaking
The only items removed are private:
Context::if_range;Probed::if_range;with_validators.The new field is on a struct that is already
#[non_exhaustive], and the old type path is re-exported. So the commit isfeat(core)without!.Known limitations
TaskBuilder::metacarries whatever validator the caller gives it, and the adapter still sendsIf-Rangefrom its own probed meta. C20 must compare against the adapter's fresh meta. Noted in §14.27.UreqAdapterdoes not implementClone, because itsbefore_requestis aBox, so it is shared through anArc. Only reqwest has the clone test.Tests
matches:as_stris the value sent;bolt-load-adapter/tests/if_range.rs, both adapters.the_meta_names_the_validator_sentchecks the exactmeta.validator, then that two ranges each send exactly that value, or none. The cases:a_cloned_adapter_shares_the_validator(reqwest): one probe, and the clone and the original send the sameIf-Range.a_failed_range_request_keeps_the_validator: a hook sends one range to a port that closes every connection. The range fails as retryable,meta.validatoris unchanged, and the retried range sends the sameIf-Rangeand succeeds.meta.validatorwere added to two existing tests.matches.Review
Reviewed with
/ccg:review, using the codex backend only (a single-model review).Round 1: PASS (94/100). It found no Critical or Major issue, and its Minor and both suggestions are applied:
If-Rangealone;Checks
All on
+nightly-2026-11-06, with--no-fail-fast. Clippy allowsunnecessary_lazy_evaluationsuntil #183 merges.cargo fmt --all -- --check.-D warnings.cargo test --workspace --all-features --locked: 28 suites, 819 passed.cargo test --workspace --locked: 28 suites, 748 passed.if_range.rsneeds both adapter features.RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features -p bolt-load: the same 18 errors as its base.bolt-load-adapter,bolt-load-coreandbolt-load-http: no errors.