Repository navigation
feat(streaming): asynchronous byte source driven by its host - #255
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks done
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2e92c9cb2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
DrunkOnJava
enabled auto-merge (squash)
October 26, 2026 10:31
AsyncSource is the adapter for a transport that answers later: a worker thread, a browser worker, an HTTP range fetcher or an event loop. It owns no thread, runtime or connection. A poll with nothing in flight posts one request of at most one chunk and returns Pending; the host takes it, fetches it however it likes and answers with complete, complete_eof or fail, then polls again. An answer for another offset, an empty one or one longer than the request is rejected and the request stays in flight; bytes the caller's next scratch cannot take are held, at most one chunk, so nothing is fetched twice. stream_walk --url drives the R13-R2000 walk through AsyncSource and an HTTP/1.1 range worker thread kept in the examples (plain http, one keep-alive connection; no client or TLS dependency in the library). verify_source.py serves the canonical R2000 fixture and the pinned line_R14 and line_2000 from a local range server: the output equals the file-backed run under a fixed and a mixed chunk schedule, all 9,206 fetches are answered on a later poll after a Pending, the bytes served equal the bytes delivered (in order, once), and with the fixed schedule every fetch is exactly the grammar's demand. Fresh-process resume over HTTP fetches no range twice; a 416 past a short file ends in the walk's typed Truncated, and a Content-Range for another offset and a body cut short are source errors, each leaving only a valid output prefix. It runs in the required Streaming E2E job. Refs #206
…TP bodies Two findings from the review on #255. AsyncSource holds bytes it fetched but the caller's scratch has not taken yet. A checkpoint saved only the walker and the caller's digest, so a resumed process built a fresh adapter and fetched those bytes again (--chunks 256,1 --stop-after 1 on the canonical fixture fetched bytes 1-5 twice). AsyncSource now exposes held() and with_held(); stream_walk saves them beside the checkpoint in <path>.source and restores them on --resume, and refuses to checkpoint with a fetch in flight. complete() also rejects an answer whose end would pass u64::MAX. The example HTTP worker allocated and read a response body before checking it: a server that ignores Range (200, the whole file) or a 206 claiming more than was asked for was buffered first. It now decides from the status and Content-Length before allocating; a 416 body is drained only up to 1 KiB. verify_source.py resumes over HTTP at fifteen stops under a three-size chunk schedule, five of them with held bytes, and requires the fetched and delivered byte sequences of the two processes to concatenate to the uninterrupted run's; discarding the saved bytes makes that check fail. It adds the ignored-Range and oversized-206 faults.
DrunkOnJava
force-pushed
the
feat/streaming-async-source
branch
from
October 26, 2026 10:48
c0c66a4 to
4fcf37c
Compare
3 tasks done
This was referenced Oct 27, 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.
Summary
byte_source::AsyncSourceis the asynchronous adapter #206 asks for: a transport that answers later (a worker thread, a browser worker, an HTTP range fetcher, an event loop) satisfies the sameByteSourcecontract without the library owning a thread, runtime, connection or dependency. Advances #206; the browser worker is #209.Design
A poll with nothing in flight posts one request of at most one chunk and returns
Pending; the host takes it (take_request), fetches it however it likes and answers withcomplete,complete_eoforfail, then polls again. An answer for another offset, an empty one or one longer than the request is rejected and leaves the request in flight. Bytes the caller's next scratch cannot take are held (at most one chunk) and delivered on the following polls, so nothing is fetched twice. A different request while one is in flight is an error, never a second fetch.The HTTP/1.1 range worker that drives it in the E2E lives in
examples/support/http_range.rs(plainhttp, one keep-alive connection, std only). Shipping an HTTP or TLS client in the library is a dependency and product decision this PR does not make. The "forward-only transport needs a spool/cache" acceptance item is already documented indocs/streaming/README.md;AsyncSourceposts absolute offsets, so its transport must be range-capable.Test plan
python3 tools/streaming/verify_source.py target/debug/examples/stream_walkagainst an in-process Python range server (206 +Content-Range, 416 past the end), on the canonical R2000 fixture and the pinnedline_R14.dwgandline_2000.dwg:Pending(real asynchrony, not the injected flag);Truncated; aContent-Rangefor another offset and a body cut short are source errors; each leaves only a valid output prefix.workflow_dispatchon a stacked head containing this commit (run 40299178744): the step takes 3 s. An earlier run hung because thousands of small keep-alive request/response pairs met Nagle's algorithm and delayed ACKs on Linux loopback; the worker and the test server both setTCP_NODELAY, and the resume runs use 256-byte chunks.verify_walk.pystill passes with the modifiedstream_walk; fmt, clippy (-D warnings, all targets),cargo doc -D warnings.Not measured: TLS, a remote host, latency or throughput, a browser worker.
Source-provenance declaration
Clean-room declaration. All code in this PR was written from scratch. The only sources consulted were this repository and the ODA's public Open Design Specification for .dwg files v5.4.1. No Autodesk SDK, ODA SDK (Drawings / Teigha), LibreDWG or other copyleft DWG implementation source, and no decompilation, was consulted. Spec citations are in the diff.