The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): a crash cell counts its kill only when taskkill found the update running (review F14)
Teknium4da5a08c848f
diff --git a/tests/ci/test_windows_update_crash_oracles.py b/tests/ci/test_windows_update_crash_oracles.pynew file mode 100644index 00000000000..ba49da0b512--- /dev/null+++ b/tests/ci/test_windows_update_crash_oracles.py@@ -0,0 +1,59 @@+"""The Windows crash cells' oracles, judged on this OS: a verdict the cells can only reach on a+Windows runner must still say pass exactly when the user's update was what the cell claims."""++import subprocess+from pathlib import Path++import pytest++import tests.e2e.core.windows_update.test_crash_cells as crash+++class _Machine:+ def __init__(self, logs: Path) -> None:+ self.logs = logs++ def evidence(self) -> str:+ return ""++ def kill_owned(self) -> None:+ pass+++class _Proc:+ """An update process: ``rc`` None while it runs; a kill ends it."""++ pid = 4242+ transcript = Path("update.log")++ def __init__(self, rc: int | None) -> None:+ self.returncode = rc++ def poll(self) -> int | None:+ return self.returncode++ def wait(self, timeout: float | None = None) -> int:+ if self.returncode is None:+ self.returncode = 1+ return self.returncode++[email protected]("exit_rc,taskkill_rc,point_seen,killed_there", [+ (None, 0, True, True), # running at its kill point: the crash the cell asserts on+ (0, 0, True, False), # already exited 0 with HEAD at the target: never interrupted+ (None, 128, True, False), # taskkill found no process: it exited between poll and kill+ (0, 0, False, False), # exited before the point: harness verdict+])+def test_kill_point_counts_only_an_update_killed_while_running(+ tmp_path, monkeypatch, exit_rc, taskkill_rc, point_seen, killed_there):+ monkeypatch.setattr(crash, "taskkill_tree", lambda pid: subprocess.CompletedProcess([], taskkill_rc))+ proc = _Proc(exit_rc)++ def point(*_):+ return "checkout at target" if point_seen else None++ if killed_there:+ assert crash._kill_when(_Machine(tmp_path), proc, "cell", point, "t") == "checkout at target"+ else:+ with pytest.raises(AssertionError, match="cell: the update"):+ crash._kill_when(_Machine(tmp_path), proc, "cell", point, "t")diff --git a/tests/e2e/core/windows_update/_machine.py b/tests/e2e/core/windows_update/_machine.pyindex 9b199374843..b2d59cf8b4c 100644--- a/tests/e2e/core/windows_update/_machine.py+++ b/tests/e2e/core/windows_update/_machine.py@@ -644,6 +644,8 @@ def descendants(proc: subprocess.Popen) -> list[Any]:return []-def taskkill_tree(pid: int) -> None:- """``taskkill /T /F``: what Task Manager's End task tree / a power cut does to an update."""- subprocess.run(["taskkill", "/PID", str(pid), "/T", "/F"], capture_output=True, timeout=60)+def taskkill_tree(pid: int) -> subprocess.CompletedProcess:+ """``taskkill /T /F``: what Task Manager's End task tree / a power cut does to an update.++ rc 0 means it found and terminated ``pid``: the process was alive at the kill."""+ return subprocess.run(["taskkill", "/PID", str(pid), "/T", "/F"], capture_output=True, timeout=60)diff --git a/tests/e2e/core/windows_update/test_crash_cells.py b/tests/e2e/core/windows_update/test_crash_cells.pyindex 4112ad93139..70e2927d05b 100644--- a/tests/e2e/core/windows_update/test_crash_cells.py+++ b/tests/e2e/core/windows_update/test_crash_cells.py@@ -279,9 +279,16 @@ def _kill_when(machine, proc, label: str, point, target: str) -> str:taskkill_tree(proc.pid)raiseif seen:- taskkill_tree(proc.pid)+ # A persistent point (HEAD at the target) also holds after a clean exit: only an+ # update still running when taskkill found it was interrupted there.+ killed = taskkill_tree(proc.pid) if proc.poll() is None else Noneproc.wait(timeout=60)machine.kill_owned() # stragglers that left the tree (detached helpers)+ if killed is None or killed.returncode != 0:+ raise AssertionError(fail_with(+ machine, f"{label}: the update was not running when killed at {seen} (exit rc="+ f"{proc.returncode}, taskkill rc={killed and killed.returncode}): no crash "+ f"at the kill point (transcript {proc.transcript.name})"))return seenif proc.poll() is not None:raise AssertionError(fail_with(