Repository navigation
fix(hook): keep hook protocol stderr silent; make stream tests portable to Windows - #3582
Open
twaugh-godaddy wants to merge 1 commit into
Open
twaugh-godaddy wants to merge 1 commit into
twaugh-godaddy wants to merge 1 commit into
Conversation
…le to Windows Running the test suite on Windows surfaced two issues: 1. Product bug: rtk hook <agent> invocations ran the daily missing/outdated-hook check, which prints a warning to stderr in the middle of hook protocol execution — exactly what copilot_selfheal_test's 'stderr must stay silent (protocol safety)' asserts against. Unix CI never sees it because the test sandbox sets HOME and the check resolves ~/.claude through it; on Windows dirs::home_dir() ignores HOME, so the real ~/.claude leaks in and the warning fires (10 of 12 tests failed). Fix: skip maybe_warn() for Commands::Hook, like Gain already does — a warning has no business on a protocol stream regardless of platform. 2. Test bug: src/core/stream.rs unit tests spawned unix coreutils (echo, sh, true, false, cat, dd|tr|fold) that don't exist on stock Windows, failing 16 tests with 'Failed to spawn process'. Fix: a small shell() helper runs each script through sh -c / cmd /C, the 10 MiB cap tests stream a Rust-generated temp file via cat/type, and the two previously cfg(not(windows))-gated filter tests now run on Windows too. Verified on Windows (PowerShell, no unix tools on PATH): full suite 2580 unit + 12 copilot_selfheal + 12 guard_integration passed, 0 failed (before: 16 + 10 failures). cargo clippy --all-targets clean. Co-Authored-By: Claude Code <[email protected]>
This was referenced Sep 13, 2026
Collaborator
|
Hey @twaugh-godaddy, thanks for this and for the detailed write-up, and sorry it sat this long. The hook-warning half has since landed on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! We're heavy rtk users at GoDaddy, and while running an internal code-quality-gate pilot against rtk on a Windows machine we hit two sets of test failures. Both are reproduced and fixed here, verified on Windows (rustc 1.97.1, PowerShell, no unix tools on PATH).
1.
tests/copilot_selfheal_test.rs— 10/12 failing (real product bug, all platforms)Every failing test tripped the same assertion:
stderr must stay silent (protocol safety), with stderr containing:Root cause:
run_cli()(src/main.rs) callshook_check::maybe_warn()for every command exceptGain— includingrtk hook <agent>. So the daily missing/outdated-hook warning can land on stderr in the middle of hook protocol execution. Unix CI never sees it because the test sandbox setsHOMEandresolve_claude_dir()resolves~/.claudethrough it; on Windowsdirs::home_dir()ignoresHOME, so the hook reads the real~/.claudeand the warning fires. Any real user (any OS) with Claude Code installed but no rtk hook registered would get the same protocol-breaking stderr once a day fromrtk hook copilot.Fix: skip
maybe_warn()forCommands::Hook { .. }, exactly likeGainis already skipped — a nag has no business on a protocol stream. This also makes the test suite deterministic on Windows.2.
src/core/stream.rsunit tests — 16 failing (test-harness bug)test_run_streaming_passthrough_echoand 15 siblings spawn unix coreutils directly (echo,sh -c,true,false,cat,dd | tr | fold), which don't exist on stock Windows →Failed to spawn process.Fix: a small
shell()test helper runs each script throughsh -c/cmd /C(same pattern asbuild_shell_commandinsrc/cmds/rust/runner.rs), using scripts valid in both shells. The 10 MiB cap tests now stream a Rust-generated temp file viacat/typeinstead ofdd | tr | fold. Bonus: the two filter tests that were#[cfg(not(windows))]-gated (test_run_streaming_streaming_filter_drops_lines,test_run_streaming_buffered_filter) now genuinely run and pass on Windows.test_exit_code_signal_killstayscfg(unix)since signals are inherently unix.Verification (Windows)
--bin rtk)copilot_selfheal_testcargo testcargo clippy --all-targetsandcargo fmtare clean on the touched files. No behavior change for the warning outside hook invocations.🤖 Generated with Claude Code