Summary

This PR fixes ZStream#buffer over-prefetch behavior where upstream effects could be evaluated more than one element ahead when buffer(1) is used.

Root cause: runIntoQueueElementsScoped used queue.offerAll for each incoming chunk, which allowed chunk-level eager evaluation before per-element backpressure kicked in.

Changes

  • Replace chunk offerAll with element-by-element queue.offer in runIntoQueueElementsScoped
  • Add regression test in ZStreamSpec:
    • buffer(1) should not evaluate more than one element ahead

Why this works

With per-element offer, producer must respect queue capacity at element granularity, so with buffer(1) it can only be one element ahead of the consumer.

Notes

  • The change is narrow and isolated to queue writing semantics for element buffering.

/claim #9810

Claim

Total prize pool $250
Total paid $0
Status Pending
Submitted March 03, 2026
Last updated March 03, 2026

Contributors

JU

Jujubee's code

@Jujubee-LLM

100%

Sponsors

ZI

ZIO

@ZIO

$250