Skip to content

Document stream ownership and v2 early-close behavior#57

Open
znull wants to merge 9 commits into
znull/stage-v2-cleanfrom
znull/v2-early-close-regression-tests
Open

Document stream ownership and v2 early-close behavior#57
znull wants to merge 9 commits into
znull/stage-v2-cleanfrom
znull/v2-early-close-regression-tests

Conversation

@znull

@znull znull commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This branch builds on znull/stage-v2-clean by introducing explicit endpoint stream ownership types and documenting the behavior changes that fall out of the v2 pipeline wiring.

It replaces boolean stdin/stdout close flags in the Stage startup contract with InputStream and OutputStream types, so ownership is visible in the value passed to each stage. The stream ownership docs now spell out when stages must close closing streams, including Start() error paths, and the startup cleanup code has been aligned so the pipeline only closes streams it still owns. WithStdoutCloser is still closed when startup fails before the final stage receives it.

It also documents v2 early-close producer behavior. A downstream stage can stop reading before all input is consumed, causing upstream writes to surface EPIPE, SIGPIPE, or io.ErrClosedPipe; README and public godoc now point callers at IgnoreError(stage, IsPipeError) for stateless producers and call out the extra consistency work required for stateful producers.

@znull znull self-assigned this Jun 11, 2026
@znull znull marked this pull request as ready for review June 11, 2026 11:10
@znull znull requested a review from a team as a code owner June 11, 2026 11:10
Copilot AI review requested due to automatic review settings June 11, 2026 11:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR documents a behavioral difference between go-pipe v1 and v2 around early-consumer exit and producer-side pipe write errors, and adds/adjusts tests to validate the v2 behavior (including how IgnoreError(..., IsPipeError) can be used to safely ignore these errors for stateless producers).

Changes:

  • Document v2’s more direct surfacing of producer-side pipe errors when downstream stages stop reading early, with guidance/patterns for stateful producers.
  • Remove Windows-specific skips from several pipeline tests that shell out to Unix utilities, and drop the runtime import.
  • Add new tests asserting (a) Go producers can observe pipe errors when a command exits without reading stdin and (b) IgnoreError(IsPipeError) allows stateful producers to finish processing.
Show a summary per file
File Description
README.md Adds v1→v2 migration note explaining early-close pipe errors and how to handle them.
pipe/pipeline_test.go Updates pipeline tests (removes Windows skips) and adds new coverage for producer-side pipe errors + IgnoreError(IsPipeError) behavior.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 9

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread pipe/pipeline_test.go
Comment thread pipe/pipeline_test.go
Comment thread pipe/pipeline_test.go
Comment thread pipe/pipeline_test.go
Comment thread pipe/pipeline_test.go
Comment thread pipe/pipeline_test.go
Comment thread pipe/pipeline_test.go
znull and others added 5 commits June 12, 2026 21:59
Replace Stage.Start close flags with InputStream and OutputStream
types. The endpoint constructors encode whether a stream is
closing while preserving the underlying reader/writer type.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add regression coverage for the go-pipe v2 behavior where a Go producer
can see a pipe error directly when a downstream command exits without
fully reading stdin.

This documents the visible semantic change from v1 to v2. Also, we add
an example that demonstrates correctly handling downstream early exit in
a stateful producer.
@znull znull force-pushed the znull/v2-early-close-regression-tests branch from 8a9f705 to 0ca3ba9 Compare June 12, 2026 20:57
@znull znull changed the title document changed v2 early-close behavior Document v2 early-close behavior after endpoint streams Jun 12, 2026
@znull znull changed the title Document v2 early-close behavior after endpoint streams Document endpoint-stream ownership and v2 early-close behavior Jun 12, 2026
@znull znull changed the title Document endpoint-stream ownership and v2 early-close behavior Document stream ownership and v2 early-close behavior Jun 12, 2026
znull and others added 4 commits June 12, 2026 23:07
Explain that go-pipe v1 could hide producer-side pipe write errors as an
implementation detail of the command stdin-copy path, while v2 exposes
those errors more directly.

Document the migration patterns for stateless and stateful producers.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@znull znull force-pushed the znull/v2-early-close-regression-tests branch from 0ca3ba9 to 433e104 Compare June 12, 2026 21:07
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.

2 participants