The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): a crash cell counts the kill when taskkill reports the update itself terminated (CI5)
Teknium8c4571f8b491
diff --git a/tests/ci/test_windows_update_crash_oracles.py b/tests/ci/test_windows_update_crash_oracles.pyindex e349ef7de34..bb2ad35d7eb 100644--- a/tests/ci/test_windows_update_crash_oracles.py+++ b/tests/ci/test_windows_update_crash_oracles.py@@ -75,15 +75,23 @@ class _Proc: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+_ROOT_KILLED = b"SUCCESS: The process with PID 4242 (child process of PID 77) has been terminated.\r\n"+_CHILD_GONE = b'ERROR: The process with PID 5151 (child process of PID 4242) could not be terminated.\r\n'+_ROOT_GONE = b'ERROR: The process "4242" not found.\r\n'++[email protected]("exit_rc,taskkill_rc,stdout,point_seen,killed_there", [+ (None, 0, _ROOT_KILLED, True, True), # running at its kill point: the crash the cell asserts on+ (0, 0, b"", True, False), # already exited 0 with HEAD at the target: never interrupted+ (None, 128, _ROOT_GONE, True, False), # taskkill found no process: it exited between poll and kill+ # The update's job (kill-on-close) took git down with it mid-walk: the root WAS killed there.+ (None, 128, _CHILD_GONE + _ROOT_KILLED, True, True),+ (0, 0, b"", 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))+ tmp_path, monkeypatch, exit_rc, taskkill_rc, stdout, point_seen, killed_there):+ monkeypatch.setattr(crash, "taskkill_tree",+ lambda pid: subprocess.CompletedProcess([], taskkill_rc, stdout, b""))proc = _Proc(exit_rc)def point(*_):diff --git a/tests/e2e/core/windows_update/_machine.py b/tests/e2e/core/windows_update/_machine.pyindex b2d59cf8b4c..8f089d899d2 100644--- a/tests/e2e/core/windows_update/_machine.py+++ b/tests/e2e/core/windows_update/_machine.py@@ -647,5 +647,6 @@ def descendants(proc: subprocess.Popen) -> list[Any]: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."""+ rc 0 means every process in the tree was terminated. rc 128 can still mean ``pid`` itself was+ killed (a job member died with it mid-walk): read stdout, see ``_kill_delivered``."""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 bb67bf50c5b..76c09a294bc 100644--- a/tests/e2e/core/windows_update/test_crash_cells.py+++ b/tests/e2e/core/windows_update/test_crash_cells.py@@ -58,6 +58,7 @@ from __future__ import annotationsimport contextlibimport json+import reimport shleximport shutilimport subprocess@@ -271,6 +272,19 @@ def _tree_matches(tree: dict, commit: str, target: str) -> bool:and tree["target_file"] == (commit == target))+def _kill_delivered(killed, pid: int) -> bool:+ """True when ``taskkill /T /F`` terminated the update's root *pid* itself.++ rc 128 does not mean the update was gone: its git runs in the update's kill-on-close job, so+ killing the update can take a job member down while taskkill is still walking the tree, and+ that member reports "could not be terminated". Only the root's own SUCCESS line ("with PID+ <pid> (child process of …") proves the kill landed; a child's line names <pid> as its parent.+ """+ if killed is None:+ return False+ return killed.returncode == 0 or re.search(rb"with PID %d \(" % pid, killed.stdout or b"") is not None++def _kill_when(machine, proc, label: str, point, target: str) -> str:"""Poll ``point(proc, machine, target)`` until it names the moment, then taskkill the whole tree.@@ -289,7 +303,7 @@ def _kill_when(machine, proc, label: str, point, target: str) -> str: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:+ if not _kill_delivered(killed, proc.pid):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 "