Repository navigation
feat(core)!: carry validators in adapter meta and send If-Range - #197
Draft
greenhat616 wants to merge 1 commit into
Draft
greenhat616 wants to merge 1 commit into
greenhat616 wants to merge 1 commit into
Conversation
This was referenced Nov 9, 2026
greenhat616
force-pushed
the
feat/hardening-33-if-range
branch
from
November 13, 2026 07:44
9101ca9 to
a1afe09
Compare
greenhat616
marked this pull request as draft
November 13, 2026 08:55
The adapter meta now carries the resource's strong ETag and its Last-Modified, and both adapters send If-Range on every range request when the probe gave a usable validator: a strong ETag, or else a Last-Modified at least a second older than Date, and nothing when the ETag is weak. The validators come from the unconditional bytes=0-0 GET, never from a HEAD, which some servers answer with other validators. A 200 to a conditional range request that carries another validator or none, and a 206 whose validator conflicts with the one sent, are ResourceChanged. A 200 with the same validator is still RangeIgnored and falls back to one connection. A changed resource ends the task with DownloadError::ResourceChanged after the usual teardown, without the fallback. Restarting it belongs above the engine (#195). BREAKING CHANGE: range requests now carry If-Range, and a resource that changes during a download fails the task with the new DownloadError::ResourceChanged (UnretryableError::ResourceChanged from adapters) instead of falling back or completing. To get the new version, download again with a fresh adapter: an adapter probes once and keeps its validator, and its clones share it.
greenhat616
force-pushed
the
feat/hardening-33-if-range
branch
from
November 13, 2026 22:25
a1afe09 to
a074c82
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.
C19 (T20), the second commit of PR-9 (resume) in the download strategy hardening stack. It is stacked on #194, which is its base branch. The design notes are in §3 (D12–D14), §11.2 and §14.23.
Why
A download must not mix two versions of a resource. Before this PR, the only check was the total in
Content-Range, so a same-size replacement between two range requests went unnoticed. T20 adds HTTP validators andIf-Range, so the server itself reports a change (RFC 9110 §13.1.5).Scope: the maintainer's decision
The first version of this PR handled the change inside the engine:
BoltLoadAdapter::refresh()(D13);The first review showed that this does not belong in the engine:
On 2026-11-09 the maintainer moved restart handling above the engine, into a client or job layer. It is tracked in #195, with the full constraints and acceptance criteria. This PR now only detects a change and fails. The engine marks the place with
TODO(#195).What
Core (
bolt-load-core)BoltLoadAdapterMeta.etagkeeps only a strong ETag, andlast_modifiedkeeps the raw value. Both havewith_*setters.UnretryableError::ResourceChangedis new.Validators (
bolt-load-http/src/validator.rs)ETag,Last-ModifiedorDatecounts as missing.If-Rangevalue:Last-Modifiedat least 1 s older thanDate;Classification (
range.rs)ResourceChanged, checked beforeContent-RangeResourceChangedRangeIgnored(the fallback, as before)If-RangeRangeIgnoredAdapters
bytes=0-0GET.Content-Range, otherwise from the HEAD'sContent-Length.If-Rangeon every range request when they have a validator.Engine
ResourceChanged, from a plain failure or from a hedge side, ends the task withDownloadError::ResourceChanged:Test server
New
RangeFault::VALIDATEDfaults, 18 in all:Date,ETagandLast-Modifiedcome from one fixed snapshot;If-Rangeis evaluated per RFC 9110;ReplacedAfterShortRangekeeps no validators, so the fallback stays covered.Breaking change
If-Range. A resource that changes during a download fails the task withDownloadError::ResourceChanged, where it used to fall back or complete.a_later_task_on_the_same_adapter_keeps_the_old_validatorrecords this behaviour, which Restart a download whose resource changed, above the task engine #195 must change.Known limitations
bytes=0-0probe fails or is rejected, or there is no usable validator, ranges carry noIf-Rangefor the adapter's lifetime.If-Range, or with custom adapters that send none.Tests
Unit:
validator.rs: the grammar, repeated fields, the date rules (equal, exactly 1 s, future, missing Date, three HTTP-date formats), and the weak ETag;range.rs: the classification;runner.rs: a changed resource ends the mode without a fallback.bolt-load-adapter/tests/if_range.rs, both adapters. It covers:bolt-load/tests/resource_changed.rs, all three clients. It covers:ResourceChanged, with no file and no temp file left;ResourceChanged, with no fallback;ResourceChanged, while parts without validators complete;Every data range's
If-Rangeis asserted.Mutations, all 11 caught:
ResourceChangedtaking the fallback;Moved to #195
refresh(D13);Review
Reviewed with
/ccg:review, using the codex backend only (a single-model review).refreshchanged other tasks' baselines;If-Rangeasserted;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: 27 suites, 782 passed.cargo test --workspace --locked: 27 suites, 714 passed.RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features -p bolt-load: the same 18 errors as its base.The test server's existing port race (it picks a port, then binds it, giving os error 10048) failed some earlier runs, but not the final ones. It will be fixed in a separate test-infrastructure PR.