Skip to content

fix(dfir_lang): Add FusedStream requirement to source_stream#2552

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/fix-source-stream-fusedstream
Draft

fix(dfir_lang): Add FusedStream requirement to source_stream#2552
Copilot wants to merge 5 commits intomainfrom
copilot/fix-source-stream-fusedstream

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

source_stream converts Pending to Ready(None) when polling (line 76), effectively re-polling after termination. This violates the Stream contract unless the stream implements FusedStream, which guarantees Ready(None) is stable.

Changes

  • Added FusedStream trait bound to source_stream codegen in check_stream helper
  • Updated stream utilities to return Fuse<T> wrappers:
    • unbounded_channel(), unsync_channel()
    • iter_batches_stream()
    • TCP/UDP framing utilities (tcp_framed, udp_framed, etc.)
    • new_inbox() in simulation module
  • Updated dependent operators to fuse streams before passing to source_stream:
    • source_interval, source_stdin, source_file
  • Added compile-fail test surface_source_stream_not_fused.rs demonstrating the error when using non-fused streams

Example

Before this change, the following would compile but could panic at runtime:

// NotFusedStream panics if polled after returning None
let stream = NotFusedStream::new();
source_stream(stream) -> for_each(drop);  // Would compile, unsafe behavior

After this change, it correctly fails compilation with a clear error about the missing FusedStream bound.

Original prompt

This section details on the original issue you should resolve

<issue_title>bug(dfir_lang): source_stream should require FusedStream but doesn't</issue_title>
<issue_description>Since we re-poll after Ready(None)</issue_description>

<agent_instructions>You will simply need to update the trait bounds in the codegen in /home/ec2-user/hydro/dfir_lang/src/graph/ops/source_stream.rs

Please add one failing test into dfir_rs/tests/compile-fail (and symlink to file to dfir_rs/tests/compile-fail-stable to test on stable as well)</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: MingweiSamuel <6778341+MingweiSamuel@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 6, 2026

Deploying hydro with  Cloudflare Pages  Cloudflare Pages

Latest commit: 03889c7
Status:🚫  Build failed.

View logs

@MingweiSamuel MingweiSamuel changed the title [WIP] Fix source_stream to require FusedStream [WIP] fix(dfir_lang)!: source_stream to require FusedStream Feb 6, 2026
Copilot AI and others added 3 commits February 6, 2026 19:40
…tream>

Co-authored-by: MingweiSamuel <6778341+MingweiSamuel@users.noreply.github.com>
Co-authored-by: MingweiSamuel <6778341+MingweiSamuel@users.noreply.github.com>
Co-authored-by: MingweiSamuel <6778341+MingweiSamuel@users.noreply.github.com>
Copilot AI changed the title [WIP] fix(dfir_lang)!: source_stream to require FusedStream fix(dfir_lang): Add FusedStream requirement to source_stream Feb 6, 2026
Copilot AI requested a review from MingweiSamuel February 6, 2026 19:52
Comment on lines +58 to +59
fn check_stream<Stream: #root::futures::stream::Stream<Item = Item> + #root::futures::stream::FusedStream + ::std::marker::Unpin, Item>(stream: Stream)
-> impl #root::futures::stream::Stream<Item = Item> + #root::futures::stream::FusedStream + ::std::marker::Unpin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn check_stream<Stream: #root::futures::stream::Stream<Item = Item> + #root::futures::stream::FusedStream + ::std::marker::Unpin, Item>(stream: Stream)
-> impl #root::futures::stream::Stream<Item = Item> + #root::futures::stream::FusedStream + ::std::marker::Unpin
fn check_stream<Stream: #root::futures::stream::FusedStream<Item = Item> + ::std::marker::Unpin, Item>(stream: Stream)
-> impl #root::futures::stream::FusedStream<Item = Item> + ::std::marker::Unpin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(dfir_lang): source_stream should require FusedStream but doesn't

2 participants