diff --git a/tests/tools/test_kanban_tools.py b/tests/tools/test_kanban_tools.py index 80b08377ab5..3fc709d38de 100644 --- a/tests/tools/test_kanban_tools.py +++ b/tests/tools/test_kanban_tools.py @@ -1326,6 +1326,14 @@ def test_worker_complete_rejects_stale_run_id(worker_env, monkeypatch): from hermes_cli import kanban_db as kb import hermes_cli.kanban_db as _kb + # detect_crashed_workers now gates each running task behind a + # launch-window grace period (c002668ff) so a freshly-spawned worker + # whose PID isn't yet visible on /proc isn't reclaimed. The fixture + # creates the task moments before this assertion, so the grace + # period (default 30s) would skip the liveness check. Zero it out + # for this test — we WANT immediate reclamation here. + monkeypatch.setenv("HERMES_KANBAN_CRASH_GRACE_SECONDS", "0") + conn = kb.connect() try: run1 = kb.latest_run(conn, worker_env) diff --git a/tests/tools/test_windows_native_support.py b/tests/tools/test_windows_native_support.py index 550249b5ce3..f92ed22dff7 100644 --- a/tests/tools/test_windows_native_support.py +++ b/tests/tools/test_windows_native_support.py @@ -625,10 +625,21 @@ class TestKanbanWaitpidWindowsGuard: # Find the waitpid call and confirm it's inside a POSIX gate. idx = source.find("os.waitpid(-1, os.WNOHANG)") assert idx > 0, "waitpid call must exist" - # Look backwards up to 400 chars for the gate. + # Look backwards up to 400 chars for the gate. Accept either form: + # `if os.name != "nt":` (run iff POSIX), or + # `if os.name == "nt": return []` (early-return guard). + # Both correctly keep the waitpid loop off Windows; the early-return + # form is stronger because the rest of the function never runs. preamble = source[max(0, idx - 400):idx] - assert 'os.name != "nt"' in preamble or "os.name != 'nt'" in preamble, ( - "os.waitpid(-1, os.WNOHANG) must sit behind an os.name != 'nt' guard" + guard_patterns = ( + 'os.name != "nt"', + "os.name != 'nt'", + 'os.name == "nt"', # early-return guard + "os.name == 'nt'", + ) + assert any(p in preamble for p in guard_patterns), ( + "os.waitpid(-1, os.WNOHANG) must sit behind an os.name guard " + f"(checked patterns: {guard_patterns})" )