Skip to content

Add bounded controlled-session PTY draining - #24

Open
omry wants to merge 1 commit into
pr23from
pr24
Open

Add bounded controlled-session PTY draining#24
omry wants to merge 1 commit into
pr23from
pr24

Conversation

@omry
omry changed the base branch from main to pr23 August 8, 2026 11:24
@omry
omry marked this pull request as ready for review August 8, 2026 11:25
Copilot AI lite review requested due to automatic review settings August 8, 2026 11:25
@omry

omry commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

@codex review

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

Adds a controlled-session PTY output pump that drains workload PTY output in bounded chunks and produces a stable drained/failed finalization result suitable for the lifecycle output-finalization barrier.

Changes:

  • Introduce PTYOutputPumpV1 to read PTY output in fixed-size chunks, emit via a flow-controlled callback, and latch an immutable finalization status.
  • Add unit tests covering ordering, bounded chunking, timeout cancellation, error handling, and lifecycle barrier integration.
  • Update the controlled-session design doc to reflect the new bounded draining/finalization behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
internal/controlledsession/output.go Implements bounded PTY output pumping with deadline-based finalization and immutable results.
internal/controlledsession/output_test.go Adds coverage for delivery ordering, backpressure timeout behavior, and error/EOF handling.
docs/CONTROLLED_SESSION_DESIGN.md Documents the new PTY output pump behavior and its interaction with the lifecycle barrier.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

}()
<-emitterEntered

result, err := pump.Finalize(time.Now().Add(20 * time.Millisecond))
Comment thread docs/CONTROLLED_SESSION_DESIGN.md Outdated
barrier and timeout outcome, are implemented; bounded output draining,
controlled-session networking, and Docker orchestration remain later slices
barrier and timeout outcome, are implemented. The synthetic PTY output pump
now preserves byte order with one bounded flow-control chunk, charges time
Comment thread docs/CONTROLLED_SESSION_DESIGN.md Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 457c7b5fe4

ℹ️ 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".

@omry

omry commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a23958e1c

ℹ️ 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".

Comment thread internal/controlledsession/output.go Outdated
Comment on lines +175 to +176
if closed, closeErr := pump.closeSource(); closed && closeErr != nil {
pump.appendResultError(fmt.Errorf("close timed-out controlled-session PTY output: %w", closeErr))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve errors from concurrent source closure

When the EOF path is already executing Close as the deadline expires and that close fails, this call returns closed == false with the shared non-nil closeErr, so the condition drops the error. The EOF path also cannot record it because the timeout result has already won the result latch, leaving PTYOutputFinalizationV1.Err with only context.DeadlineExceeded and hiding the underlying PTY adapter failure; append any non-nil close error even when another goroutine performed the close.

Useful? React with 👍 / 👎.

@omry

omry commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 4a1baa8322

ℹ️ 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".

@omry omry added the approved PR reviewed and approved label Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved PR reviewed and approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants