Repository navigation
Bound Windows CLI output draining - #76576
Conversation
Co-authored-by: gh-aw-bot <[email protected]>
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ Matt Pocock Skills ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
There was a problem hiding this comment.
Found two blocking correctness issues: the polling drain loop artificially limits output throughput and can time out valid large output, and the new timeout regression test is timing-dependent on cold pwsh startup. Inline comments provide the requested fixes. Static review only; tests were not run per review instructions.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| $watch = [System.Diagnostics.Stopwatch]::StartNew() | ||
| $processTimeoutRejected = $false | ||
| try { | ||
| Invoke-CliProcess -FilePath $pwsh -ArgumentList @("-NoProfile", "-Command", "Write-Output 'process-timeout-marker'; Start-Sleep -Seconds 30") -TimeoutMs 500 | Out-Null |
There was a problem hiding this comment.
This regression depends on pwsh starting and emitting process-timeout-marker within the 500 ms process timeout. On a loaded Windows runner, the process can be killed before the marker is captured, making the test flaky independently of the timeout behavior. Synchronize on a readiness signal before applying the timeout, or avoid asserting output that is not guaranteed before 500 ms.
There was a problem hiding this comment.
Fixed in d0ad028: increased the startup-inclusive process timeout to 10 seconds and cleanup budget to 15 seconds. The marker must now appear immediately after Captured output:, so echoed arguments cannot satisfy the assertion. PowerShell regressions pass locally.
| if ($processExited -and $stdoutDone -and $stderrDone) { break } | ||
| if ($processExited -and $drainWatch.ElapsedMilliseconds -ge $PostExitDrainTimeoutMs) { break } | ||
| if ($processTimedOut -and -not $processExited -and $processCleanupWatch.ElapsedMilliseconds -ge 1000) { break } | ||
| Start-Sleep -Milliseconds 10 |
There was a problem hiding this comment.
This polling loop only consumes one 4096-character chunk per stream before sleeping 10 ms. That caps draining at roughly 400 KB/s, so the 2-second default can falsely report OUTPUT DRAIN TIMEOUT for legitimate large CLI output and also back-pressure live producers. Please continue consuming available data without the fixed sleep (or use dedicated reader tasks) so the timeout bounds descendants rather than normal output volume.
There was a problem hiding this comment.
Fixed in d0ad028: drain completed reads in bounded batches and skip sleeping while either stream has ready data, preserving fairness and timeout checks. Added an 8 MiB-per-stream regression; it passes with the fix and rejects the original throttled loop.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs, /tdd, and /codebase-design. Requesting changes because the new drain loop makes high-output processes about 15x slower.
📋 Key Themes & Highlights
Key Themes
- Throughput regression: each stream reads one 4 KB chunk per 10 ms tick. On 2 MB of output the helper takes 5.2 s, versus 0.36 s for the pre-PR helper. Draining completed reads in a
whileloop brings it to about 0.56 s. - Timing-sensitive assertion: the 500 ms process-timeout marker check assumes
pwshprints before the kill. This can flake on cold runners. - Coverage gaps: no checks for stderr-only drain timeout, nonzero exit combined with drain timeout, or
-AllowFailurewith the new drain code. - Structure: the helper is about 150 lines inside a YAML
run:block and is extracted by regex in the test script.
Positive Highlights
- ✅ The post-exit drain is bounded, and descendant cleanup runs in
finally. - ✅ Partial output is kept on process-timeout and drain-timeout paths, with explicit markers.
- ✅ Ordinary-exit, process-timeout, and drain-timeout regression scenarios pass on Linux
pwsh7.6.9. The Windows-only ConPTY section was not run here.
Correction
My inline comment on scripts/windows-cli-matrix.test.ps1 line 112 said the drain-timeout descendant holds only stdout. It inherits both stdout and stderr. The stderr-only gap in the coverage comment still stands.
@copilot please address the review comments above.
Comments that could not be inline-anchored
.github/workflows/windows-cli-integration.yml:199
**[/diagnosing-bugs]** The drain loop reads at most one 4 KB chunk per stream per tick, then sleeps 10 ms. Throughput is capped near 400 KB/s. On a 2 MB child output, this takes 5.2 s versus 0.36 s on the pre-PR helper (about 15x slower). <details> <summary>💡 Suggested fix</summary> Drain all completed reads per tick. Change the two guards at lines 162 and 171 from `if` to `while`, so each completed read is re-issued and consumed until it is not yet complete or reports EOF. With that change, ...
scripts/windows-cli-matrix.test.ps1:84
**[/tdd]** This assertion depends on `pwsh` printing `process-timeout-marker` within the 500 ms budget. On a cold Windows runner, process startup can take seconds, so the marker may never appear and the test becomes flaky. <details> <summary>💡 Suggested fix</summary> Keep the timeout test deterministic. Either start the child, wait for a sentinel file or a stdout line before the kill (for example, have the child write the marker to a file first), or use a longer budget and assert only on the ...
scripts/windows-cli-matrix.test.ps1:112
**[/tdd]** The drain-timeout case covers only a stdout-holding descendant. Other new branches have no regression check: stderr-only drain timeout, nonzero exit combined with a drain timeout, and `-AllowFailure` with the new drain code. <details> <summary>💡 Suggested tests</summary> Add focused cases that expect the `OUTPUT DRAIN TIMEOUT` error and the `<stderr drain timed out after process exit>` marker when only stderr is held open. Add one nonzero-exit case with a held pipe to confirm the e...
.github/workflows/windows-cli-integration.yml:83
**[/codebase-design]** `Invoke-CliProcess` has grown to about 150 lines of process-management logic inside an inline YAML `run:` block. The test script then extracts it by regex and AST parsing, so it is hard to navigate, and it cannot be unit-tested directly. <details> <summary>💡 Suggested refactor</summary> Move the helper into a standalone `.ps1` module, for example `scripts/windows-cli-process.psm1`, and `Import-Module` it from both the workflow and the regression script. The workflow and...
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
There was a problem hiding this comment.
🟡 Changes recommended
Timeout cleanup can leave pipe handles and pending I/O open indefinitely, while the regression test can pass without captured stdout and remains sensitive to slow PowerShell startup.
2 open issues
What changed in this PR
Introduces a post-exit drain deadline in gh-aw’s Windows CLI integration helper, targeting hangs caused by descendants that keep redirected output pipes open.
Changes:
- Captures stdout and stderr incrementally with a configurable drain timeout.
- Reports command details, elapsed time, exit status, and partial output on drain timeout.
- Adds regressions for ordinary exits, process timeouts, and descendant-held pipes.
| File | Description |
|---|---|
scripts/windows-cli-matrix.test.ps1 |
Extracts the workflow helper and adds subprocess timeout regressions. |
.github/workflows/windows-cli-integration.yml |
Adds bounded output draining, partial capture, and timeout diagnostics. |
Review effort: Max (auto)
| $stopwatch.Stop() | ||
| throw "TIMEOUT: '$FilePath $displayArgs' exceeded ${TimeoutMs}ms (elapsed $($stopwatch.ElapsedMilliseconds)ms)`nCaptured output:`n$stdout`n$stderr" | ||
| } finally { | ||
| if ($null -ne $proc) { $proc.Dispose() } |
| Invoke-CliProcess -FilePath $pwsh -ArgumentList @("-NoProfile", "-Command", "Write-Output 'process-timeout-marker'; Start-Sleep -Seconds 30") -TimeoutMs 500 | Out-Null | ||
| } catch { | ||
| $message = $_.Exception.ToString() | ||
| if ($message -notmatch "TIMEOUT:.*$([regex]::Escape($pwsh))" -or $message -notmatch "elapsed \d+ms" -or $message -notmatch "process-timeout-marker") { throw } | ||
| $processTimeoutRejected = $true | ||
| } | ||
| if (-not $processTimeoutRejected) { throw "CLI process timeout was swallowed" } | ||
| if ($watch.ElapsedMilliseconds -gt 5000) { throw "CLI process timeout cleanup exceeded its budget" } |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "9ff367d1d3280dad2c9340c946e67cc0323cf894",
"kind": "requested",
"schema_version": "1",
"state": "0035acbeed65e6a7a76bd163e9b8e7db5e2fbf32c3de9a20cb02469fee68fa4b",
"work": [
"91e5a67bd302526fc7b163d9ab4bd13e67b283ea06734adf214edbaf769243c3",
"eb192dfe551b2efd5ad142332cf1482ef6329d138039ce5b1dfb699fe549dfcc"
],
"workflow": "pr-sous-chef"
}
|
…bound-windows-cli-output-draining Co-authored-by: gh-aw-bot <[email protected]>
Co-authored-by: gh-aw-bot <[email protected]>
Merged latest main with |
|
🎉 This pull request is included in a new release. Release: |

After the CLI parent exits, a descendant can keep redirected stdout or stderr open and block the integration helper indefinitely. Bound post-exit draining and cleanup while preserving actionable diagnostics for drain and process timeouts.