Skip to content

Promote Develop: Read winget's Own Log and Hold the Report's Deadline - #3856

Merged
ptr727 merged 3 commits into
mainfrom
develop
Nov 4, 2026
Merged

ptr727 merged 3 commits into
mainfrom
develop

Conversation

@ptr727

@ptr727 ptr727 commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Promotes the changes merged into develop since promotion #3849 to main.

  • #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 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 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

ptr727 and others added 2 commits November 3, 2026 08:54
…es Its Holders (#3851)

## Summary

A failed winget install or upgrade in
`host-setup/windows/install-tools.ps1` names the processes holding the
tool's files only where something says files were in use. Before this
change the only signals were the package's own installer log
(`<id>.*.log`) and a short list of exit codes. A portable or zip
package, `astral-sh.uv` among them, has no installer, so it writes no
such log. winget's refusal to delete a running executable is reported
under the generic `0x8A150052`, so such an upgrade failed with no hint
of what held the file.

- `Get-InstallerFailureReason` now also reads winget's own
`WinGet-<timestamp>.log` for the failed call. That is the latest one
created at or after the attempt that names the package id, which winget
logs among its arguments, and only its `<E>` lines are kept. The `list`
and `show` probes that run before the attempt are passed over.
- In winget's own log, an access denial naming a file (`Access is
denied.: "<path>"`) counts as files in use, as does Windows' "used by
another process". A denial naming no file does not. The installer-log
wording is unchanged, since an installer's "Access is denied" can be a
permission failure no running process causes.
- `Select-FailureEntry` is the old in-function "last few entries, keep
the in-use one" logic pulled out, so both logs share it.
- `Write-InstallFailure` prints a `winget's own log says:` block and the
log's path beside the installer-log block.

This applies to every winget package rather than to uv alone. A package
with an installer still reports through its installer log as before.

The `comments` label is on this pull request because the change corrects
the header comments of both functions, which the new behavior would
otherwise leave false.

## Verification

- `uv run --no-project --with pytest python -m pytest
tests/test_install_tools.py -q`: 23 passed, 18 skipped. The new cases
cover a portable package's reason read from winget's log, a longer id
that only starts with the package id not being read as its log, an
installer log's denial alone and a winget denial naming no file not
counting as in use, and the report naming holders from winget's log.
- The new `Get-InstallerFailureReason` run on a Windows 11 host against
a real failed portable upgrade's DiagOutputDir selected the upgrade's
own session log over the probes before it, set `InUse` to true, and
returned the `remove: Access is denied.` entry.
- Ruff, mypy, and PSScriptAnalyzer with the repository settings are
clean.

## Findings from the local strict review

Five recorded passes ran, the last over `10a272ba` with no findings. The
two `introduced` findings this body listed after the opening push are
both fixed in `8e5a0b6b`:

- `host-setup/windows/install-tools.ps1:601` (`introduced`): the
`Write-InstallFailure` header said a Git upgrade that failed on a
download "leaves no log", which winget's own session log made false.
**Fixed in `8e5a0b6b`.**
- `host-setup/windows/install-tools.ps1:507` (`introduced`): the
winget-log in-use pattern accepted "access is denied" on any `<E>` line.
**Fixed in `8e5a0b6b`**, which counts only a denial naming a file.

The fourth pass also raised a dead empty-entry guard in
`Select-FailureEntry`, fixed in `10a272ba`. It raised one more, a denial
naming a file outside the tool's install tree, such as winget's temp
download folder under an antivirus lock, counting as in use. That one is
declined under `GOVERNANCE.md` "Trust Boundaries and Hardening Effort".
Its only effect is a printed suggestion naming processes running from
the tool's own install tree, which is neither silent nor destructive nor
one an outsider can trigger. winget logging such a denial is also
unverified.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…3855)

## 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

- #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](https://claude.com/claude-code)
Copilot AI lite review requested due to automatic review settings November 4, 2026 01:06
@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

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.

🟡 Changes recommended

An active review finding remains because the comment in host-setup/windows/install-tools.ps1 has a grammatical error that should be corrected.

1 open issue
What changed in this PR

Promotes the latest develop changes to main, improving Windows winget failure diagnostics and making the skills installer more reliable with Claude CLI shims and stalled subprocesses.

Changes:

  • Reads winget session logs and reports relevant failure details and file-holder processes.
  • Resolves the Claude executable through shutil.which, including Windows .cmd shims.
  • Adds deadline handling and process-tree cleanup for report subprocesses.
  • Expands coverage for winget diagnostics, subprocess deadlines, decoding failures, and Windows shims.
File Summary Findings
tests/​test_skills_install.py Tests process deadlines, decoding failures, and Windows Claude shims. No findings.
tests/​test_install_tools.py Tests winget-log selection, failure classification, and report output. No findings.
scripts/​skills_install.py Adds Claude path resolution and bounded subprocess execution. P1: Catch UnicodeDecodeError when Claude output cannot be decoded. P1: Terminate the POSIX process group and reap descendants before returning from a deadline.
host-setup/​windows/​install-tools.ps1 Reads winget logs and reports portable-package failure details and file holders. P2: Treat hyphens as part of package IDs to avoid matching another package’s log. P2: Continue failure reporting when a winget log is unreadable. P3: Fix the grammar in the related comment.

This pull request requires changes.

Review effort: Lite

Comment thread host-setup/windows/install-tools.ps1 Resolved
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.31%. Comparing base (753c536) to head (c86ee86).
⚠️ Report is 463 commits behind head on main.

Files with missing lines Patch % Lines
scripts/skills_install.py 90.90% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3856      +/-   ##
==========================================
+ Coverage   83.30%   83.31%   +0.01%     
==========================================
  Files          29       29              
  Lines        9937     9956      +19     
==========================================
+ Hits         8278     8295      +17     
- Misses       1659     1661       +2     
Flag Coverage Δ
python-3.13 83.31% <90.90%> (+0.01%) ⬆️

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.

## Summary

Answers the findings on promotion #3856, whose head is `develop`, so a
code fix lands here first. Each test below failed before its fix,
measured on native Windows 11.

- **A locked winget log no longer aborts the failure report.**
`Select-String` was the one log read with no `-ErrorAction`, so under
the installer's `Stop` preference it threw. Measured under pwsh 7 and
Windows PowerShell 5.1. A throw there would also skip the Docker
maintenance exit that follows the report.
- **A package id in winget's own log matches whole.** A hyphen counts as
part of an id, so `Portable.Tool` does not take a log naming
`Portable.Tool-Extra` or `Vendor-Portable.Tool`.
- **An undecodable `claude` listing returns `None`**, as `claude_json`
documents, where it raised before. `git_in` keeps raising on purpose,
since `None` from it could read as a clean tree, and its docstring now
says so.

The full suite passes natively from Git Bash on this head.

## Findings from the local passes

A pass raised that the installer-log filter `<id>.*.log` also takes a
longer id, such as `OpenJS.NodeJS.LTS` for `OpenJS.NodeJS`. `c6a423be`
added a name filter for it, and the next pass raised two findings
against that filter. `87abc727` removes the filter, which answers both,
and these are their outcomes.

- `host-setup/windows/install-tools.ps1`, the longer-id match, class
`introduced`. Declined under `GOVERNANCE.md` "Trust Boundaries and
Hardening Effort". Packages install one at a time and the window opens
just before each call, so a sibling's log falls inside it only where a
second winget runs during the attempt.
- `host-setup/windows/install-tools.ps1`, the filter as over-hardening,
class `introduced`. Fixed in `87abc727`.
- `host-setup/windows/install-tools.ps1`, the filter dropping an
attempt's own log where its version starts with neither a digit nor `v`,
class `introduced`. Fixed in `87abc727`.

The hyphen boundary needs the same second winget to matter, and it stays
because it costs nothing. It cannot drop the attempt's own log, where
the name filter could.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@ptr727

ptr727 commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

Answering the round at #3856 (review), whose file table names these findings with no thread. The digest counted (3), and the table lists the four below, so each is answered.

  • scripts/skills_install.py, "Catch UnicodeDecodeError when Claude output cannot be decoded". Fixed in c86ee86. claude_json returns None for it, as its docstring states.
  • host-setup/windows/install-tools.ps1, "Treat hyphens as part of package IDs". Fixed in c86ee86.
  • host-setup/windows/install-tools.ps1, "Continue failure reporting when a winget log is unreadable". Fixed in c86ee86, reproduced first with a locked log under pwsh 7 and Windows PowerShell 5.1.
  • scripts/skills_install.py, "Terminate the POSIX process group and reap descendants before returning from a deadline". No change needed, per GOVERNANCE.md "Trust Boundaries and Hardening Effort". The deadline holds on POSIX through the bounded final collection, which RunWithDeadlineCase exercises with a real process tree. A surviving descendant is what subprocess.run left there before this change, so this is no regression, and its failure is neither silent nor destructive.

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

Approval should be deferred because the platform-specific PowerShell and Windows process-tree changes require native Windows execution that was not performed in this review.

No open issues 🎉

1 resolved since last review

Review effort: Lite

@ptr727

ptr727 commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

Answering the round at #3856 (review), (1) item, its headline: "Approval should be deferred because the platform-specific PowerShell and Windows process-tree changes require native Windows execution that was not performed in this review."

No change needed. That execution was performed outside the review. The required Windows unit test job passed on this head, c86ee86, with 3379 tests and 341 skipped. The full suite also passed from Git Bash on native Windows 11 on 87abc72, whose squash is this head, with 3379 tests and 354 skipped. The Select-String change was also run under Windows PowerShell 5.1, and each fix's test failed before its fix. #3855 and #3857 carry the measurements.

@ptr727
ptr727 merged commit df04ada into main Nov 4, 2026
14 checks passed
ptr727 added a commit that referenced this pull request Nov 4, 2026
…e Variables (#3861)

Promotes the change merged into `develop` since promotion #3856 to
`main`.

- [#3859](#3859) documents
a Windows devcontainer launch with `HOME` and `USERPROFILE` both set,
which `devcontainer.json` substitution cannot fix. It defines the
supported route as opening the repo from inside a WSL2 distribution, and
states a native launch's conditions and what Docker does with an absent
mount source. That pull request's body holds the measurements and what
was not measured.

Docs only. The defects those measurements found stay open: #3858 for
image tags that stop a snippet starting, and #3860 for read-only mounts
that are writable.

Closes #3852

🤖 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.

skills_install.py runs a bare claude argv, which may miss a Windows .cmd shim

2 participants