Skip to content

Run the Path Which Found and Hold the Report's Deadline on Windows - #3855

Merged
ptr727 merged 4 commits into
developfrom
fix/1754-claude-cmd-shim
Nov 4, 2026
Merged

ptr727 merged 4 commits into
developfrom
fix/1754-claude-cmd-shim

Conversation

@ptr727

@ptr727 ptr727 commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refs #1754. Both candidates the issue names reproduce on native Windows 11, and this fixes both.

  • Every claude child runs the path shutil.which returned. CreateProcess searches for a bare name with .exe alone, so it misses the claude.cmd an npm install puts on PATH.
  • A report child's deadline holds on Windows. subprocess.run kills only the direct child there, then waits with no bound for the pipes to close. run_with_deadline kills the tree with taskkill /T and bounds the final collection.
  • Undecodable output now reaches the caller on Windows. Text mode decodes on a reader thread there, so a decode failure printed a traceback and the caller got stdout=None. git_in re-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.cmd and System32 alone on PATH, or the real Git for Windows launcher with a stalling alias.

Case Before After
Listing through claude.cmd None, read as unknown []
live_channel registered: None registered: False
register_claude_marketplace False True
install_claude_plugin raises FileNotFoundError True
3-second deadline, stalled git behind the launcher 20.1 seconds, the length of the stall 3.2 seconds

A resolved .cmd path also runs without shell=True where the shim's directory and an argument hold a space.

Tests

  • ClaudeCmdShimCase drives a real stub shim, and skips off Windows.
  • RunWithDeadlineCase drives a real process tree whose grandchild inherits the pipes.
  • Against the old subprocess.run form, the timing test fails at 30 seconds.
  • With the tree kill reduced to a direct kill, the tree test fails.
  • The full suite passes natively from Git Bash on this head: 3377 tests, 354 skipped.

Left as they are

A .cmd shim runs through cmd.exe, so two checkout path shapes behave differently there, measured with a stub. Both are declined under GOVERNANCE.md "Trust Boundaries and Hardening Effort", since the path is trusted input and the shape is rare.

  • An & in a path with no spaces cuts the argument there. The child exits non-zero, and registration prints that and returns False.
  • A %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

  • Other Captured subprocess.run Timeouts Can Outlast Their Deadline on Windows #3854 (scripts/pr_review.py, scripts/pr_cleanup.py, scripts/local_review.py, scripts/host_gate.py, scripts/docker_lint.py, class pre-existing). These run the same captured subprocess.run with 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

`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.
Copilot AI lite review requested due to automatic review settings November 4, 2026 00:53
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • 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

@ptr727

ptr727 commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 112f44976568b96028655972de3066bf951def2d, the content this pull request carries at that commit against develop, and it recorded 0 findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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 .cmd shims.
  • 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

@ptr727

ptr727 commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

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 Windows unit test job passed on 112f449, and ClaudeCmdShimCase and RunWithDeadlineCase run there, since only the first skips off Windows and the second's tree test runs on Windows alone. The full suite also passed from Git Bash on native Windows 11 on this head, 3377 tests with 354 skipped, and the before and after measurements are in the body. Against the old subprocess.run form the timing test fails at 30 seconds, and with the tree kill reduced to a direct kill the tree test fails.

@ptr727
ptr727 merged commit 36947ab into develop Nov 4, 2026
12 checks passed
@ptr727
ptr727 deleted the fix/1754-claude-cmd-shim branch November 4, 2026 01:06
@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.31%. Comparing base (b38e084) to head (112f449).
⚠️ Report is 92 commits behind head on develop.

Files with missing lines Patch % Lines
scripts/skills_install.py 90.47% 2 Missing ⚠️
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     
Flag Coverage Δ
python-3.13 83.31% <90.47%> (+1.70%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ptr727 added a commit that referenced this pull request Nov 4, 2026
…#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)
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.

2 participants