Repository navigation
Run the Path Which Found and Hold the Report's Deadline on Windows - #3855
Conversation
`CreateProcess` searches for a bare name with `.exe` alone, so every `claude` child missed the `claude.cmd` an npm install puts on `PATH`. Measured with a stub shim: the listings read as unknown, and the plugin install raised `FileNotFoundError`. Each child now runs the path `shutil.which` returned. A report child's deadline did not hold either. `subprocess.run` on Windows kills only the direct child and then waits with no bound for the pipes to close, so a 3-second deadline over a stalled git behind the launcher took 20 seconds, the length of the stall. The report's children now run under a helper that kills the tree and bounds the final collection. The same case takes 3.2 seconds. That helper decodes stdout on the calling thread. Text mode decodes on a reader thread on Windows, where undecodable output printed a traceback and handed the caller `None`, which `git_in` then failed on.
A default Windows launch inherits no handle, so the stub's grandchild never held the pipes and the timing test passed against the old `subprocess.run` form. The child now launches with `close_fds=False`. Against the old form the test fails at 30 seconds, and with the tree kill reduced to a direct kill the tree test fails. The patched one-second grace also bounded `taskkill`, and three seconds had to cover two interpreter starts, so a slow runner could fail with no defect. The tests keep the real grace and allow five seconds, and a grandchild that never started says so.
`git_in` strips its output and reads it as one token or by truthiness, and `json.loads` treats a carriage return as whitespace. So nothing reads the translated form, and no test pins it.
The repository's encoding gate refuses a text-mode spawn with no named encoding. `tasklist` prints in the OEM code page, so naming UTF-8 would be false, and the test only looks for ASCII digits.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
A recorded local strict-review pass covers head |
There was a problem hiding this comment.
🔵 Needs a closer look
Native Windows execution was unavailable to independently validate process-tree cleanup, .cmd launch semantics, and deadline behavior, so the reported measurements still require human confirmation.
No open issues 🎉
What changed in this PR
This pull request improves Windows reliability in skills_install.py by executing resolved Claude launcher paths, enforcing bounded subprocess cleanup, and preserving decode errors. It adds coverage for Windows shims, process trees, deadlines, and undecodable output.
Changes:
- Executes the exact path returned by
shutil.which(), including.cmdshims. - Adds bounded subprocess execution with Windows process-tree termination and caller-thread decoding.
- Expands tests for launcher resolution, process deadlines, descendant cleanup, and decoding behavior.
- Follow-up changes are needed to terminate POSIX descendants and tighten the deadline assertion.
| File | Description |
|---|---|
tests/test_skills_install.py |
Updates subprocess mocks and adds coverage for process trees, deadlines, Windows shims, and decoding behavior. |
scripts/skills_install.py |
Adds resolved Claude executable paths and bounded subprocess handling. |
This pull request requires changes.
Review effort: Lite
|
Answering the round at #3855 (review), (1) item, its headline: "Native Windows execution was unavailable to independently validate process-tree cleanup, .cmd launch semantics, and deadline behavior, so the reported measurements still require human confirmation." No change needed. The reviewer's own environment had no Windows, and the behavior it names has been executed on Windows twice. The required |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3855 +/- ##
===========================================
+ Coverage 81.60% 83.31% +1.70%
===========================================
Files 26 29 +3
Lines 9070 9956 +886
===========================================
+ Hits 7402 8295 +893
+ Misses 1668 1661 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…#3856) Promotes the changes merged into `develop` since promotion #3849 to `main`. - [#3851](#3851) reads winget's own log for a failed install or upgrade in `host-setup/windows/install-tools.ps1`, so a portable package whose files are in use names the processes holding them. - [#3855](#3855) runs each `claude` child in `scripts/skills_install.py` through the path `shutil.which` returned, so an npm `claude.cmd` shim is reached. It also makes a report child's deadline hold on Windows, where a 3-second deadline over a stalled git took 20.1 seconds and now takes 3.2. Measured on native Windows 11, with the full suite passing there. - [#3857](#3857) answers this promotion's first review round. A locked winget log no longer aborts the failure report, a package id in winget's own log matches whole, and an undecodable `claude` listing reads as unknown. Fixes #1754 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
Refs #1754. Both candidates the issue names reproduce on native Windows 11, and this fixes both.
claudechild runs the pathshutil.whichreturned.CreateProcesssearches for a bare name with.exealone, so it misses theclaude.cmdan npm install puts onPATH.subprocess.runkills only the direct child there, then waits with no bound for the pipes to close.run_with_deadlinekills the tree withtaskkill /Tand bounds the final collection.stdout=None.git_inre-raises that error on purpose, and its mocked test could not show that the error never arrived. The helper decodes on the calling thread.Measured on native Windows
Each case used a stub, with
claude.cmdand System32 alone onPATH, or the real Git for Windows launcher with a stalling alias.claude.cmdNone, read as unknown[]live_channelregistered: Noneregistered: Falseregister_claude_marketplaceFalseTrueinstall_claude_pluginFileNotFoundErrorTrueA resolved
.cmdpath also runs withoutshell=Truewhere the shim's directory and an argument hold a space.Tests
ClaudeCmdShimCasedrives a real stub shim, and skips off Windows.RunWithDeadlineCasedrives a real process tree whose grandchild inherits the pipes.subprocess.runform, the timing test fails at 30 seconds.Left as they are
A
.cmdshim runs throughcmd.exe, so two checkout path shapes behave differently there, measured with a stub. Both are declined underGOVERNANCE.md"Trust Boundaries and Hardening Effort", since the path is trusted input and the shape is rare.&in a path with no spaces cuts the argument there. The child exits non-zero, and registration prints that and returnsFalse.%NAME%in a path expands to that variable's value. This one is not loud. A real directory name holding%around a defined variable name is what it takes to reach it. The maintainer confirmed this decline on this pull request.Pre-existing findings, filed
scripts/pr_review.py,scripts/pr_cleanup.py,scripts/local_review.py,scripts/host_gate.py,scripts/docker_lint.py, classpre-existing). These run the same capturedsubprocess.runwith a timeout, so they can outlast their deadline in the same way. They are unmeasured, and they move to one shared primitive in a change of their own.🤖 Generated with Claude Code