Skip to content

Move STDIO input reads off the cooperative executor#184

Merged
lynnswap merged 2 commits into
mainfrom
codex/fix-stdio-input-ci-hang
Jul 15, 2026
Merged

Move STDIO input reads off the cooperative executor#184
lynnswap merged 2 commits into
mainfrom
codex/fix-stdio-input-ci-hang

Conversation

@lynnswap

@lynnswap lynnswap commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Purpose

Fix the main-branch CI hang observed in run 29402610133.

The apparent progress-test stall was buffered output. Under a single cooperative worker, FileHandle.AsyncBytes performed a blocking stdin read and starved the task responsible for writing and closing the adapter pipe.

Changes

  • move STDIO input ownership to a dedicated DispatchIO channel
  • bound read-ahead to one 64 KiB operation while preserving input order and backpressure
  • close only the duplicated input descriptor and preserve the caller-owned FileHandle
  • preserve graceful EOF draining, immediate read-error aborts, cancellation, and descriptor-cleanup completion
  • add event-driven tests for bounded reads, exact-boundary EOF, active-read cancellation, read failures, deinitialization, and caller ownership
  • use an injected clock to prove read failures do not enter the EOF drain loop
  • bound the test event observation so regressions fail instead of hanging CI; elapsed time is not used to establish behavior

Testing

  • ./scripts/check.sh
    • 956 package tests passed
    • 24 process runtime tests passed
    • 13 STDIO adapter tests passed
  • strict single-worker reproduction passed with LIBDISPATCH_COOPERATIVE_POOL_STRICT=1 (14 focused tests)
  • branch-wide codex-review against pinned main@d2b7e76d: no findings

FileHandle.AsyncBytes can block the sole cooperative worker in low-capacity CI runners, starving the task that writes and closes adapter stdin. Route input through a bounded DispatchIO channel while preserving EOF drain, read-error abort, and deterministic shutdown contracts.
@lynnswap

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: 64ad7593f0

ℹ️ 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 Sources/XcodeMCPProxyKit/Stdio/StdioInputChannel.swift Outdated
Comment thread Tests/ProxyStdioAdapterTests/StdioAdapterIntegrationTests.swift Outdated
Close only the duplicated input descriptor during channel cleanup and verify that the caller-owned FileHandle remains open. Bound the failing-input test's send observation so regressions fail instead of hanging CI.

@lynnswap lynnswap left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 3b41ed25e9

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

@lynnswap
lynnswap merged commit 8bd7438 into main Jul 15, 2026
9 checks passed
@lynnswap
lynnswap deleted the codex/fix-stdio-input-ci-hang branch July 15, 2026 10:27
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.

1 participant