Repository navigation
feat(task): route resumable single-connection tasks and discard partials - #206
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 11, 2026
greenhat616
force-pushed
the
feat/hardening-42-resume-routing
branch
from
November 13, 2026 07:44
6a2fd5a to
8c30a0c
Compare
greenhat616
marked this pull request as draft
November 13, 2026 08:55
A task with resume on that prefers one connection now runs on the concurrent engine with a single connection, so it can keep a state file. This happens only when it could resume: a usable validator, a known non-zero size, no content coding, and range support. Otherwise it stays a single-connection download, exactly as with resume off. discard_partial, crate-internal until resume is public, takes the destination lock and runs the discard order: invalidate the state, and keep the partial file if that fails; remove the partial file, then the state file. A failed removal of the partial file is reported with the new IoOp::Remove. Later failures, such as a state file that cannot be removed or a failed directory sync, are only logged. A runner now drops its connection or stream when it begins to stop, before the stop is published, not only while still connecting. So by the time its slot is free, the stream the engine owned is gone, and a retry never overlaps it. Nothing reads the stream after the stop, and the slot accounting is unchanged. The ureq2 adapter's blocking reads can still outlive a dropped stream and hold a second connection for a while. That predates this change and needs an adapter teardown signal; it is documented as a known limitation.
greenhat616
force-pushed
the
feat/hardening-42-resume-routing
branch
from
November 13, 2026 22:25
8c30a0c to
ff090e6
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.
C33c (T21), the last part of C33 and the fifth commit of PR-9d (resume) in the download strategy hardening stack. It is stacked on #205 (C33b), which is its base branch. Together with #204 and #205 it completes C33. The design notes are in §11.5.8, §11.5.5 (discard order) and §14.29.3.
What
Routing (§11.5.8)
A task with
Resume::Onandprefer_mode(Singleton)is routed to the concurrent engine withmax_connections = 1when all of these hold:A routed task then follows the full resumable path from C33b, and
TaskInfo::modereports Concurrent. Otherwise the task stays single-connection and is not resumable. The other cases in which the engine picks one connection already fail §11.5.3, so they never route.discard_partial(crate-internal until C20, a lead decision)The order:
Unsupported::Fail. Failure givesInUseorIo { Lock }.The failures:
Io { Lock }on the state file.Io { Remove }on the partial file.IoOp::Removeis new and additive; the enum is#[non_exhaustive].Ok.Runner change: release the input before the stop
begin_stopinrunner/run_loop.rsnow always drops the runner's input before Draining and beforeStoppedis published. Before, it did so only while connecting. The manager frees the slot onStopped, so the previous stream owned by the engine is gone before a retry can take the slot.begin_stop, and the slot accounting (C28, C29, T8) is unchanged.Known limitation: ureq2
The ureq2 adapter runs
unblock(request)and the body reads (CrossRuntimeStream/blocking::Unblock) on the blocking pool. A call that is already running keeps its response and socket until it returns, even after the stream is dropped. So a retry after an idle timeout or a cancel can briefly hold a second connection. ureq sets no timeouts by default.AgentBuilder::timeout_read, which bounds a stalled socket read, andAgentBuilder::timeout, a deadline for the whole request, together with ureq's DNS caveat.Not breaking
Resumeanddiscard_partialstay crate-internal.Offtask chooses its mode exactly as before.IoOp::Remove.Tests
transfer_optionschecks one connection.test_a_retry_waits_for_the_old_stream:discard_partial.InUse, which touches nothing.Review
Reviewed with
/ccg:review, using the codex backend only (a single-model review).timeout_readreally bounds) and its suggestion (a precise wording of the guarantee) are applied.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, 899 passed, 1 ignored (the benchmark).cargo test --workspace --locked: 28 suites, 828 passed, 1 ignored.RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features -p bolt-load: the same 18 errors as its base. It was last run in round 1; later rounds changed only tests,design.mdand the adapter README.