fix(windows): terminate native proxy process tree (#3313)

## Description

PR #3311 included the Windows proxy cleanup fix, but its squash title
was `test(copilot): ...`. Release Please therefore treated the merge as
test-only and omitted the fix from release PR #3228. This follow-up
preserves the fix under a release-eligible Conventional Commit title and
strengthens its regression test to pin the complete non-interactive
`taskkill /T` invocation.

Closes #3311

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

- assert Windows cleanup terminates the complete native proxy process
tree
- assert cleanup captures `taskkill` output, uses a bounded timeout, and
does not fail solely on its exit code
- restore the already-merged fix to Release Please's changelog input via
this PR's `fix(windows)` title

## Testing

- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check .`)
- [x] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [ ] Manual testing performed

### Test Output

```text
2 passed, 58 deselected in 0.50s
All checks passed!
1 file already formatted
pre-commit: Ruff, Ruff format, and mypy passed
```

## Real Behavior Proof

- Environment: Windows, Python 3.12.13
- Exact command / steps: `uv run --no-sync pytest
tests/test_cli/test_wrap_helpers.py -k
"kill_proxy_uses_taskkill_tree_on_windows or
cleanup_uses_pre_shutdown_pid_when_health_probe_races"`
- Observed result: both targeted Windows cleanup regression tests passed
- Not tested: live proxy shutdown was already validated in #3311

## Runtime Rollout Safety

- Rollout-managed feature(s): none
- Minimum rollout channel: none
- Stable/default behavior changed: no additional runtime change; the
implementation landed in #3311
- Kill switch / disable path: not applicable
- Unsafe override required: no
- Qualification impact: restores the Windows cleanup fix to the
generated release notes
- Rollback path: revert this test-only commit

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] I did **not** edit `CHANGELOG.md` — it is generated by
release-please from my Conventional Commit PR title (a CI guard enforces
this)

## Screenshots (if applicable)

Not applicable.

## Additional Notes

The production change and live Windows validation are in #3311. This PR
is intentionally focused on correcting release metadata without
duplicating or perturbing that implementation.
This commit is contained in:
JD Davis
2026-08-27 13:28:36 -07:00
committed by GitHub
parent 91af73fc04
commit 91d4fc8bbd
+8 -3
View File
@@ -598,7 +598,7 @@ class TestProxyClientRefCounting:
self, monkeypatch: pytest.MonkeyPatch
) -> None:
"""Windows cleanup must terminate the native launcher's whole tree."""
calls: list[list[str]] = []
calls: list[tuple[list[str], dict[str, object]]] = []
checks = iter([True, False])
monkeypatch.setattr(wrap_mod.sys, "platform", "win32")
monkeypatch.setattr(wrap_mod.time, "sleep", lambda _seconds: None)
@@ -606,11 +606,16 @@ class TestProxyClientRefCounting:
monkeypatch.setattr(
wrap_mod.subprocess,
"run",
lambda command, **_kwargs: calls.append(command),
lambda command, **kwargs: calls.append((command, kwargs)),
)
assert wrap_mod._kill_proxy_by_pid(456, self.PORT)
assert calls == [["taskkill", "/F", "/T", "/PID", "456"]]
assert calls == [
(
["taskkill", "/F", "/T", "/PID", "456"],
{"capture_output": True, "timeout": 10, "check": False},
)
]
def test_cleanup_uses_pre_shutdown_pid_when_health_probe_races(
self, clients_dir: Path, monkeypatch: pytest.MonkeyPatch