add stream.forward and future.forward builtins - #709
Draft
rvolosatovs wants to merge 2 commits into
Draft
Conversation
The Explainer specifies that a component may call `future.drop-readable` before reading a value to signal loss of interest, in which case a blocked `future.write` completes with `future-write-result.dropped`. But `SharedFutureImpl.drop` asserted that any pending buffer is a `WritableBuffer`, i.e. a pending *read*, while the only pending buffer actually possible at this point is the buffer of a pending *write*: a reader cannot drop its end while its own read is pending (`CopyEnd.drop` traps while copying) and a writer cannot drop its end before the write resolves (`WritableFutureEnd.drop` traps unless DONE). Exercising this spec-legal path failed the assert instead of notifying the writer with DROPPED. Flip the assert to expect a `ReadableBuffer` (the source buffer of the pending write), make `ReadableBufferGuestImpl` actually subclass `ReadableBuffer` (it previously only derived `BufferGuestImpl`, unlike `WritableBufferGuestImpl`, which does mix in `WritableBuffer`), and add a test reproducing the scenario. Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> Assisted-by: claude:claude-fable-5
rvolosatovs
force-pushed
the
stream-future-forward
branch
6 times, most recently
from
August 24, 2026 17:16
dc41cb5 to
5eaa8d2
Compare
Introduce the ⏩-gated `{stream,future}.forward` built-ins for zero-copy
forwarding: given the readable end of a source stream (resp., future) and
the writable end of a destination of the same type, both ends are
transferred out of the calling component and the destination is fused
with the source, delegating all subsequent reads, cancels and drops to
it. Elements rendezvous directly between the outer producer and consumer
with end-to-end backpressure and no read-ahead, and end-of-stream and
drops propagate in both directions, allowing hosts to remove the
calling component from the copy path entirely. Forwards may be chained;
a forward that would (transitively) make a stream or future its own
source traps.
In the binary format, `stream.forward` is assigned opcode 0x2e and
`future.forward` opcode 0x2f. The binary decode test is left to a
follow-up commit so that test/binary/binary.wast keeps passing against
engines that do not decode these opcodes yet.
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Assisted-by: claude:claude-fable-5
rvolosatovs
force-pushed
the
stream-future-forward
branch
from
August 24, 2026 17:46
5eaa8d2 to
17dffe0
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.
refs #658
tests blocked on #708