Skip to content

test(claude-cli): scope the async stdout-pipe probes to POSIX and pin the Windows outcome - #8666

Merged
lidge-jun merged 2 commits into
devfrom
fix/dev-red2-stdout-flush-windows-scope
Nov 13, 2026
Merged

lidge-jun merged 2 commits into
devfrom
fix/dev-red2-stdout-flush-windows-scope

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

windows 5/14 of dev batch run 43369456647 failed four cases of tests/providers/claude-cli-fixture-stdout-flush.test.ts, the regression for the fixture flush fix in #8484:

  • "the fixture's replay write is still pending while stdout has no reader": 60 s timeout; the child exited with marks=[].
  • "releasing the reader delivers the whole replay frame and the callback orders the exit": 60 s timeout.
  • "exiting before the replay write drains drops the frame, which the reader reports as malformed": no CodingAgentProtocolError.
  • "a child that never reads stdin fails the parent's write with EPIPE…": the parent's 3 MB stdin write returned true.

These cases measure a stdout pipe write that the runtime is still holding when the process exits, which is the defect #8484 fixed. That state exists only where pipe writes are asynchronous. Node documents process.stdout pipe writes as asynchronous on POSIX and synchronous on Windows, and the Windows log shows Bun doing the same: the observe child never returned from its multi-megabyte write while nothing read stdout. So on Windows the guarded defect cannot occur, and these assertions encode POSIX pipe semantics. The production default-path case passed on Windows.

  • The two cases that need an unread stdout write to return while still pending ("still pending", "exiting before the replay write drains") run where stdout pipes are asynchronous (ASYNC_STDOUT_PIPES).
  • The reader-release case runs everywhere. It deadlocked on Windows only because it waited for replay-returned before starting the reader. On Windows it now starts the reader first; the accepted === false check stays limited to asynchronous pipes, and the callback, frames and exit-order assertions are unchanged.
  • The no-read case is about the parent's stdin write, not stdout, so it has its own gate, PARENT_STDIN_WRITE_HELD. On Windows the 3 MB write returned true at once and the effect of a later kill was not observed, so no Windows expectation is invented. The early-exit EPIPE case still runs everywhere and passed on Windows.
  • A new Windows-only case asserts that the pre-fix early exit still delivers all three frames and the whole replayed text with exit 0. CI showed only that this path raised no protocol error; the full expectation rests on synchronous pipe writes and is confirmed only by the next Windows batch.
  • The default-path, small-payload, malformed-hang and early-exit EPIPE cases run everywhere, unchanged.

The task brief said "no skip". This restricts cases whose premise doesn't exist on one platform and adds a positive assertion for that platform instead, so I'm calling it out for an explicit decision.

Verification

  • bun test tests/providers/claude-cli-fixture-stdout-flush.test.ts on Linux: 8 pass, 1 skip (the Windows-only case), 0 fail.
  • With process.platform reported as win32 on Linux, the selection flips: the stdout-pipe cases and the no-read case are skipped, the reader-release case passes with its reader started first, and the Windows case runs. It fails there only because Linux pipes really are asynchronous, so the Windows case itself is evidenced by the CI log, not run locally.
  • bun run typecheck: exit 0.
  • NOT RUN: a native Windows runner (the maintainer's next dev batch covers it), and the full suite.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • Tests
    • Improved cross-platform coverage for pipe behavior, including early process exits, buffered output, and unread input.
    • Added checks that synchronous pipes deliver complete output without reader errors.

… the Windows outcome

windows 5/14 of dev batch 43369456647 failed four cases of the #8484 stdout
flush regression. They measure a stdout pipe write the runtime still holds,
which only exists where pipe writes are asynchronous. Node documents
process.stdout pipe writes as synchronous on Windows, and the batch shows
Bun doing the same: the observe child never returned from its 3 MB write
with no reader (60 s timeouts, marks=[]), the pre-fix early exit delivered
the frames without a protocol error, and the parent's large stdin write was
accepted at once.

Those four cases now run where stdout pipes are asynchronous. Windows gets a
case that pins the opposite outcome: the pre-fix early exit still delivers
all three frames and the whole replay through the production reader. The
production default-path case and the remaining cases run everywhere,
unchanged.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 06:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T06:54:32.322155Z 9eefbf2 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Nov 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The stdout flush tests now distinguish synchronous and asynchronous pipe behavior by platform. They conditionally run pending-write and unread-stdin assertions, adjust when the reader starts draining, and verify that synchronous pipes deliver all expected frames and replay text after early exit.

Changes: Stdout pipe tests

Layer / File(s) Summary
Platform-specific stdout test behavior
tests/providers/claude-cli-fixture-stdout-flush.test.ts
Platform flags describe the observed pipe behavior. Tests skip pending-write and unread-stdin assertions when those conditions do not apply. The reader-release test uses platform-specific drain ordering. A synchronous-pipe test checks for no reader error, exit code 0, all three frames, and the complete replay text.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Possibly related PRs

  • lidge-jun/opencodex#8484: This PR changes the synthetic Claude CLI fixture’s stdout-write and exit behavior, which the tests in this PR exercise.
Merge Risk: Minimal · up to 95ae8

This change adjusts platform-specific test expectations for stdout pipe behavior and does not affect production behavior. No actionable merge-blocking risk is identified. Native Windows CI will confirm the new Windows-only case.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the test file scope (claude-cli), the async stdout-pipe probes being scoped to POSIX, and the Windows outcome being pinned. The raw summary and PR objectives confirm the change gates p…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the test file scope (claude-cli), the async stdout-pipe probes being scoped to POSIX, and the Windows outcome being pinned. The raw summary and PR objectives confirm the change gates pending-write cases to asynchronous pipes, adds a Windows-only synchronous-pipe test, and gates the stdin write assertion. The title is specific and accurate, though it uses some jargon and is long for a title.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9eefbf2 and 95ae8b4.

Files selected for processing: 1

  • tests/providers/claude-cli-fixture-stdout-flush.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

… stdin case on its own premise

Review of #8666. The reader-release case deadlocked on Windows only because
it waited for the replay-returned mark before starting the reader; on a
synchronous pipe the write returns only once read. It now runs everywhere,
starting the reader first where stdout pipes are synchronous, and keeps the
accepted===false check where they are asynchronous.

The no-read case is about the parent's stdin write, not stdout, so it gets
its own gate (PARENT_STDIN_WRITE_HELD) with the Windows evidence: the 3 MB
write returned true at once there, and the effect of a later kill was not
observed, so no Windows expectation is invented. The early-exit EPIPE case
still runs everywhere.
@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer judgment (dev integration, MAINTAINERS.md maintainer-integration exception): merging without a second maintainer approval, as part of the DEV-RED repair for dev batch run 43369456647 (windows 5/14).

  • Exact head: 95ae8b4cfd1643573bc83afc5491a53a2fd2317a. Every required PR check on this head passed.
  • Fresh independent review on this exact head (gpt-6.1-terra, high): VERDICT: PASS, one comment-wording nit (deferred and recorded; the PR body already states what CI did and did not prove). An earlier round's two findings were addressed: the reader-release case now runs on Windows, and the parent-stdin case has its own gate.
  • Classification: test-assumption bug from fix(advisor): enable Claude Messages replay consultation #8484. The cases needing an asynchronous stdout pipe are scoped to POSIX, and the stdin case is gated on its own observed premise, with Windows assertions added. Test-only.
  • The new Windows-only assertion rests on synchronous pipe semantics; the maintainer's next dev batch is its first native run.
  • No outstanding change requests.

@lidge-jun
lidge-jun merged commit 1471828 into dev Nov 13, 2026
32 of 35 checks passed
@lidge-jun
lidge-jun deleted the fix/dev-red2-stdout-flush-windows-scope branch November 13, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant