Skip to content

[BUG]: macOS cancellation cleanup test races with process exit #221

Closed

Description

@mavericksea-ai

What happened?

While fixing and validating the error-recovery changes in #217, we found a small, intermittent macOS process-exit timing issue in the local-mode cancellation test. Filing it separately because it affects process cleanup/test synchronization rather than error-recovery scoring.

The observed impact is flaky test validation. We did not observe a persistent child process or ongoing work after cancellation: every captured failing child disappeared without another signal within approximately 1.6 ms of the assertion. This appears to be a low-severity timing issue based on the evidence below.

The failing case is:

tests/test_harbor_local_mode.py::test_streamed_exec_escalates_after_launcher_exits_with_term_ignoring_descendant[cancel]

tests/test_harbor_local_mode.py:3349:
    with pytest.raises(ProcessLookupError):
E   Failed: DID NOT RAISE ProcessLookupError

The test expects the child PID to have disappeared immediately when cancellation cleanup returns. Occasionally os.kill(child_pid, 0) still succeeds while macOS is finishing the child's exit.

Reproduction steps

On macOS, use a disposable checkout of either commit listed below with the project's test and Harbor dependencies installed. A single run often passes. This wrapper invokes the existing test unchanged 100 times with distinct test IDs, allowing four workers to exercise the race:

cat > tests/_process_reap_comparison_test.py <<'PY'
from pathlib import Path
import runpy
import pytest

original = runpy.run_path(str(Path(__file__).with_name("test_harbor_local_mode.py")))[
    "test_streamed_exec_escalates_after_launcher_exits_with_term_ignoring_descendant"
]

@pytest.mark.parametrize("attempt", range(100))
def test_cancel_repeat(tmp_path, attempt):
    original(tmp_path=tmp_path, lifecycle="cancel")
PY

PYTHONPATH="$PWD/src" .venv/bin/python -m pytest -n 4 -q tests/_process_reap_comparison_test.py
rm tests/_process_reap_comparison_test.py

Observed results in isolated source copies using the same Python environment:

Commit Ten individual runs 100 runs across four workers
5349e9b 10 passed 98 passed, 2 failed
22d82c7 10 passed 98 passed, 2 failed

The failing test and src/skillevaluator/tier3/harbor/local_environment.py are byte-for-byte identical between these commits. The failure therefore predates the Harbor-marker follow-up in 22d82c7.

Process-state evidence

A separate diagnostic run on 5349e9b invoked the original test 200 times across four workers, recording os.kill/os.killpg outcomes and reading macOS KERN_PROC_PID state immediately after the assertion's successful PID probe. The observation occurred before the test's finally block could send another signal. That run produced 193 passes and 7 failures.

In all seven captured failures:

  1. Cleanup successfully sent SIGKILL to the process group.
  2. The subsequent os.killpg(group, 0) raised PermissionError (EPERM). The existing group-wait helper returns on that exception.
  3. The test's immediate os.kill(child, 0) still succeeded.
  4. The child PID disappeared naturally, without another signal, within about 1.6 ms of the assertion.

Four kernel-state captures showed:

parent PID:       1
process state:    SRUN
process flags:    0x2004, including P_WEXIT ("Working on exiting")
exit status:      9 (SIGKILL)
next observation: ESRCH (PID no longer present)

In the other three cases, the PID had already disappeared before the first kernel-state read completed. The reader was validated against a deliberately unreaped child, which correctly reported SZOMB, and then ESRCH after waitpid.

These observations support a short exit-teardown race. They do not establish that the captured children were in a stable zombie state: the observed states were exiting (P_WEXIT) or already gone. No persistent child was observed in these runs.

Relevant code at the baseline revision:

Expected outcome: make the cleanup/test synchronization tolerate bounded exit completion on macOS while retaining a meaningful failure when a child actually survives cancellation. The appropriate change to the wait helper or assertion still needs review; no fix for this issue is included in #217.

SkillEvaluator version or commit

  • Baseline: 5349e9b0c2c83dcb6d331b3800a3ec98085592ae
  • Follow-up: 22d82c7c0b998d048d28a5429653d22d377f5f11
  • Branch: fix/error-recovery-149 in mavericksea-ai/SkillEvaluator

Environment

  • macOS 27.0.1, arm64
  • Python 3.13.12 in the repository virtual environment
  • Harbor 0.24.0
  • pytest 9.1.1; pytest-xdist 3.8.0
  • Four workers (-n 4); the existing test initializes local mode with sandboxing disabled

Before submitting

  • I agree to follow this project's Code of Conduct.
  • I searched existing issues and found no duplicate of this report.

Activity

  1. mavericksea-ai commented on Oct 23, 2026

    @mavericksea-ai
    ContributorAuthor

    Adding the diagnostic sources and raw failure records so the process-state evidence can be reproduced independently. This adds evidence only; it does not propose or apply a code fix.

    The diagnostic calls the existing test_streamed_exec_escalates_after_launcher_exits_with_term_ignoring_descendant test with lifecycle="cancel", unchanged. It wraps os.kill/os.killpg to record the group signals and, if the assertion's PID probe succeeds, samples KERN_PROC_PID before the test's finally block can send another signal. It uses the macOS SDK's struct kinfo_proc through a small C helper rather than hard-coded ctypes structure offsets.

    Run Revision Result Longest observed interval until PID disappearance
    Original diagnostic run, 2026-10-21 5349e9b 193 passed, 7 failed 1.503458 ms
    Recheck, 2026-10-23 5349e9b 195 passed, 5 failed 1.477958 ms
    Portable diagnostic validation, 2026-10-23 22d82c7 193 passed, 7 failed 1.420458 ms

    Across all 19 captured failures, SIGKILL to the group returned successfully, the following group existence check raised EPERM, and the child's immediate PID probe still succeeded. Every observed child then disappeared without another signal. In 12 captures the state reader saw SRUN, P_WEXIT (0x2000) set, and exit status 9; in the other seven, the child was already gone before the first state read. The reader's separate self-check reports SZOMB for a deliberately unreaped child and ESRCH after waitpid.

    The uninstrumented 100-repetition wrapper in the issue also reproduced the same assertion: originally 98 passed / 2 failed on each of 5349e9b and 22d82c7, and another 98 passed / 2 failed on 5349e9b during today's recheck. Instrumentation can affect timing; these counts are observations, not an estimate of a universal failure rate. The sampling loop sleeps approximately 1 ms between reads, so the reported durations are observation intervals, not precise kernel exit latency or a guaranteed upper bound for other runs. This supports a brief exit-completion race in this scenario, not a claim that every cancellation path is safe.

    Run the diagnostic

    Requires macOS, Xcode Command Line Tools (xcrun clang), and the checkout's installed Python test dependencies including Harbor and pytest-xdist. Save the following block as /tmp/issue221-diagnostics.sh, then run it from the checkout root:

    bash /tmp/issue221-diagnostics.sh

    The runner prints a new temporary directory containing the sources, compiled reader, all 200 per-attempt JSON records, results.xml, and pytest.log. It creates no tracked repository files. If the interpreter is elsewhere, set ISSUE221_PYTHON=/absolute/path/to/python when invoking it. Use a checkout of 5349e9b or 22d82c7 to match the recorded revisions; the runner records the actual checkout HEAD and verifies that the cleanup module imports from that checkout's src directory. A nonzero pytest exit is expected when the reported assertion reproduces; a clean run does not disprove an intermittent race.

    Complete diagnostic runner (shell, C state reader, and Python test wrapper)
    #!/usr/bin/env bash
    set -euo pipefail
    # Run from a SkillEvaluator checkout with its test/Harbor dependencies installed.
    export ISSUE221_REPO="${ISSUE221_REPO:-$PWD}"
    ISSUE221_PYTHON="${ISSUE221_PYTHON:-$ISSUE221_REPO/.venv/bin/python}"
    export ISSUE221_DIAG
    ISSUE221_DIAG="$(mktemp -d "${TMPDIR:-/tmp}/issue221-diag.XXXXXX")"
    export PYTHONPATH="$ISSUE221_REPO/src:$ISSUE221_DIAG"
    printf 'Diagnostic files and results: %s\n' "$ISSUE221_DIAG"
    
    cat > "$ISSUE221_DIAG/process_state.c" <<'ISSUE221_C_SOURCE'
    #include <sys/types.h>
    #include <sys/sysctl.h>
    #include <sys/proc.h>
    #include <errno.h>
    #include <stdio.h>
    #include <string.h>
    
    int read_process_state(int pid, int *status, int *ppid, int *pgid,
                           int *flags, int *exit_status, char *command) {
        struct kinfo_proc info;
        memset(&info, 0, sizeof(info));
        size_t size = sizeof(info);
        int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
        if (sysctl(mib, 4, &info, &size, NULL, 0) != 0) {
            return errno;
        }
        if (size == 0) {
            return ESRCH;
        }
        *status = info.kp_proc.p_stat;
        *ppid = info.kp_eproc.e_ppid;
        *pgid = info.kp_eproc.e_pgid;
        *flags = info.kp_proc.p_flag;
        *exit_status = info.kp_proc.p_xstat;
        snprintf(command, MAXCOMLEN + 1, "%s", info.kp_proc.p_comm);
        return 0;
    }
    ISSUE221_C_SOURCE
    
    cat > "$ISSUE221_DIAG/process_state.py" <<'ISSUE221_READER'
    """Read-only macOS state via KERN_PROC_PID, which includes zombie processes."""
    
    import ctypes
    import os
    import time
    from pathlib import Path
    
    
    probe = ctypes.CDLL(str(Path(__file__).with_suffix('.dylib')))
    probe.read_process_state.argtypes = [ctypes.c_int, *([ctypes.POINTER(ctypes.c_int)] * 5), ctypes.c_char_p]
    probe.read_process_state.restype = ctypes.c_int
    STATUS = {1: 'SIDL', 2: 'SRUN', 3: 'SSLEEP', 4: 'SSTOP', 5: 'SZOMB'}
    
    
    def process_state(pid):
        status, ppid, pgid, flags, exit_status = (ctypes.c_int() for _ in range(5))
        command = ctypes.create_string_buffer(17)
        timestamp = time.monotonic_ns()
        error = probe.read_process_state(pid, ctypes.byref(status), ctypes.byref(ppid), ctypes.byref(pgid), ctypes.byref(flags), ctypes.byref(exit_status), command)
        if error:
            return {'time_ns': timestamp, 'pid': pid, 'errno': error}
        return {
            'time_ns': timestamp, 'pid': pid, 'ppid': ppid.value, 'pgid': pgid.value,
            'status': status.value, 'status_name': STATUS.get(status.value, 'UNKNOWN'),
            'comm': command.value.decode(errors='replace'), 'flags': flags.value, 'exit_status': exit_status.value,
        }
    
    ISSUE221_READER
    
    cat > "$ISSUE221_DIAG/test_issue221_diagnostic.py" <<'ISSUE221_TEST'
    """Diagnostic wrapper only; the original test and implementation are unchanged."""
    
    import json
    import os
    from pathlib import Path
    import runpy
    import sys
    import subprocess
    import time
    
    import pytest
    
    diagnostic_root = Path(__file__).resolve().parent
    repo = Path(os.environ["ISSUE221_REPO"]).resolve()
    sys.path.insert(0, str(diagnostic_root))
    sys.path.insert(0, str(repo / "src"))
    from process_state import process_state
    from skillevaluator.tier3.harbor import local_environment
    
    assert Path(local_environment.__file__).resolve().is_relative_to(repo / "src")
    revision = subprocess.check_output(
        ["git", "-C", str(repo), "rev-parse", "HEAD"], text=True
    ).strip()
    original = runpy.run_path(str(repo / "tests/test_harbor_local_mode.py"))[
        "test_streamed_exec_escalates_after_launcher_exits_with_term_ignoring_descendant"
    ]
    records = diagnostic_root / "records"
    records.mkdir(exist_ok=True)
    
    
    @pytest.mark.parametrize('attempt', range(200))
    def test_cancel_state(tmp_path, monkeypatch, attempt):
        raw_kill, raw_killpg = os.kill, os.killpg
        events = []
        checked = False
        evidence = {'attempt': attempt, 'revision': revision, 'events': events}
    
        def traced_killpg(pgid, sig):
            event = {'time_ns': time.monotonic_ns(), 'operation': 'killpg', 'pgid': pgid, 'signal': int(sig)}
            events.append(event)
            try:
                result = raw_killpg(pgid, sig)
            except OSError as exc:
                event['errno'] = exc.errno
                raise
            event['errno'] = 0
            return result
    
        def traced_kill(pid, sig):
            nonlocal checked
            caller = sys._getframe(1)
            assertion = not checked and sig == 0 and caller.f_code.co_name == original.__name__
            if not assertion:
                return raw_kill(pid, sig)
            checked = True
            evidence['child_pid'] = pid
            started = time.monotonic_ns()
            evidence['assertion_time_ns'] = started
            try:
                result = raw_kill(pid, sig)
            except OSError as exc:
                evidence['assertion_kill_errno'] = exc.errno
                raise
            evidence['assertion_kill_errno'] = 0
            # Capture state before pytest raises and before the test's finally block
            # can send any further signal. Observe disappearance for up to 1 sec.
            samples = [process_state(pid)]
            evidence['samples'] = samples
            while samples[-1].get('errno') != 3 and time.monotonic_ns() - started < 1_000_000_000:
                time.sleep(0.001)
                samples.append(process_state(pid))
            evidence['observation_ms'] = (time.monotonic_ns() - started) / 1_000_000
            return result
    
        monkeypatch.setattr(os, 'kill', traced_kill)
        monkeypatch.setattr(os, 'killpg', traced_killpg)
        try:
            original(tmp_path=tmp_path, lifecycle='cancel')
            evidence['outcome'] = 'passed'
        except BaseException as exc:
            evidence['outcome'] = type(exc).__name__
            evidence['message'] = str(exc)
            raise
        finally:
            (records / f'{attempt:03}.json').write_text(json.dumps(evidence, indent=2) + '\n')
    ISSUE221_TEST
    
    xcrun clang -dynamiclib -O2 "$ISSUE221_DIAG/process_state.c" -o "$ISSUE221_DIAG/process_state.dylib"
    
    # Check that the reader distinguishes an unreaped child from a reaped one.
    "$ISSUE221_PYTHON" - <<'ISSUE221_VALIDATE'
    import errno, os, time
    from process_state import process_state
    pid = os.fork()
    if pid == 0:
        os._exit(0)
    try:
        deadline = time.monotonic() + 2
        while True:
            state = process_state(pid)
            if state.get("status_name") == "SZOMB" or time.monotonic() >= deadline:
                break
            time.sleep(0.005)
        print("unreaped:", state)
        assert state.get("status_name") == "SZOMB", state
    finally:
        os.waitpid(pid, 0)
    state = process_state(pid)
    print("reaped:", state)
    assert state.get("errno") == errno.ESRCH, state
    ISSUE221_VALIDATE
    
    # Failing assertions are the reproducer's expected signal, not suppressed.
    # The script returns pytest's nonzero status if the race reproduces.
    "$ISSUE221_PYTHON" -m pytest -n 4 -q --tb=short \
        -c "$ISSUE221_REPO/pyproject.toml" -o addopts= \
        "$ISSUE221_DIAG/test_issue221_diagnostic.py" \
        --junitxml="$ISSUE221_DIAG/results.xml" \
        2>&1 | tee "$ISSUE221_DIAG/pytest.log"

    Raw evidence

    Below are all failure records from the three diagnostic runs, including the original seven cited in the issue. Numeric values, timestamps, PID samples, and signal outcomes are preserved from the saved per-attempt JSON; they are grouped here with counts derived from all 200 records in each run. Passing per-attempt records are omitted from this comment for size; the runner writes both passing and failing records when reproduced. time_ns is a monotonic timestamp, not wall-clock time. On the recorded macOS environment, errno 1 is EPERM and errno 3 is ESRCH.

    Raw JSON: all 19 captured failures across three runs
    [
      {
        "run": "Original diagnostic run, 2026-10-21",
        "trials": 200,
        "passed": 193,
        "failed": 7,
        "maximum_observation_ms": 1.503458,
        "failure_records": [
          {
            "attempt": 18,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 118733855521791,
                "operation": "killpg",
                "pgid": 62573,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 118733856032416,
                "operation": "killpg",
                "pgid": 62573,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 118733856058541,
                "operation": "killpg",
                "pgid": 62573,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 62580,
            "assertion_time_ns": 118733856490500,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 118733856531958,
                "pid": 62580,
                "errno": 3
              }
            ],
            "observation_ms": 0.370625,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 54,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 118734383246333,
                "operation": "killpg",
                "pgid": 62740,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 118734383919166,
                "operation": "killpg",
                "pgid": 62740,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 118734383941625,
                "operation": "killpg",
                "pgid": 62740,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 62745,
            "assertion_time_ns": 118734384343375,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 118734384378041,
                "pid": 62745,
                "ppid": 1,
                "pgid": 62740,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 118734385699583,
                "pid": 62745,
                "errno": 3
              }
            ],
            "observation_ms": 1.369875,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 57,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 118734526953541,
                "operation": "killpg",
                "pgid": 62776,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 118734535966916,
                "operation": "killpg",
                "pgid": 62776,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 118734535998416,
                "operation": "killpg",
                "pgid": 62776,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 62783,
            "assertion_time_ns": 118734536730125,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 118734536810500,
                "pid": 62783,
                "ppid": 1,
                "pgid": 62776,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 118734538170791,
                "pid": 62783,
                "errno": 3
              }
            ],
            "observation_ms": 1.503458,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 58,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 118734624043291,
                "operation": "killpg",
                "pgid": 62804,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 118734624608125,
                "operation": "killpg",
                "pgid": 62804,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 118734624633041,
                "operation": "killpg",
                "pgid": 62804,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 62811,
            "assertion_time_ns": 118734625048666,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 118734625083875,
                "pid": 62811,
                "errno": 3
              }
            ],
            "observation_ms": 0.087625,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 66,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 118734355248041,
                "operation": "killpg",
                "pgid": 62729,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 118734355942000,
                "operation": "killpg",
                "pgid": 62729,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 118734355969583,
                "operation": "killpg",
                "pgid": 62729,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 62738,
            "assertion_time_ns": 118734356378458,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 118734356417750,
                "pid": 62738,
                "ppid": 1,
                "pgid": 62729,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 118734357752750,
                "pid": 62738,
                "errno": 3
              }
            ],
            "observation_ms": 1.389375,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 67,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 118734479777583,
                "operation": "killpg",
                "pgid": 62760,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 118734480315208,
                "operation": "killpg",
                "pgid": 62760,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 118734480337958,
                "operation": "killpg",
                "pgid": 62760,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 62765,
            "assertion_time_ns": 118734480731125,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 118734480765708,
                "pid": 62765,
                "errno": 3
              }
            ],
            "observation_ms": 0.082458,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 115,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 118734855056375,
                "operation": "killpg",
                "pgid": 62884,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 118734855603041,
                "operation": "killpg",
                "pgid": 62884,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 118734855627833,
                "operation": "killpg",
                "pgid": 62884,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 62891,
            "assertion_time_ns": 118734856003333,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 118734856037208,
                "pid": 62891,
                "ppid": 1,
                "pgid": 62884,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 118734857355166,
                "pid": 62891,
                "errno": 3
              }
            ],
            "observation_ms": 1.368583,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          }
        ]
      },
      {
        "run": "Independent recheck, 2026-10-23",
        "trials": 200,
        "passed": 195,
        "failed": 5,
        "maximum_observation_ms": 1.477958,
        "failure_records": [
          {
            "attempt": 22,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 170790591581416,
                "operation": "killpg",
                "pgid": 98409,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 170790592132750,
                "operation": "killpg",
                "pgid": 98409,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 170790592155833,
                "operation": "killpg",
                "pgid": 98409,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 98416,
            "assertion_time_ns": 170790592592958,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 170790592636875,
                "pid": 98416,
                "ppid": 1,
                "pgid": 98409,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 170790593973083,
                "pid": 98416,
                "errno": 3
              }
            ],
            "observation_ms": 1.391708,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 30,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 170790384490458,
                "operation": "killpg",
                "pgid": 98348,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 170790388488375,
                "operation": "killpg",
                "pgid": 98348,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 170790388515958,
                "operation": "killpg",
                "pgid": 98348,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 98353,
            "assertion_time_ns": 170790388924375,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 170790388967833,
                "pid": 98353,
                "errno": 3
              }
            ],
            "observation_ms": 0.375458,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 53,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 170790762005208,
                "operation": "killpg",
                "pgid": 98459,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 170790762567125,
                "operation": "killpg",
                "pgid": 98459,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 170790762589875,
                "operation": "killpg",
                "pgid": 98459,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 98467,
            "assertion_time_ns": 170790762996625,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 170790763037458,
                "pid": 98467,
                "ppid": 1,
                "pgid": 98459,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 170790764406166,
                "pid": 98467,
                "errno": 3
              }
            ],
            "observation_ms": 1.477958,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 153,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 170791551271791,
                "operation": "killpg",
                "pgid": 98721,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 170791551838666,
                "operation": "killpg",
                "pgid": 98721,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 170791551861250,
                "operation": "killpg",
                "pgid": 98721,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 98727,
            "assertion_time_ns": 170791552274916,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 170791552306458,
                "pid": 98727,
                "ppid": 1,
                "pgid": 98721,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 170791553624083,
                "pid": 98727,
                "errno": 3
              }
            ],
            "observation_ms": 1.367959,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 156,
            "revision": "5349e9b",
            "events": [
              {
                "time_ns": 170791706490083,
                "operation": "killpg",
                "pgid": 98773,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 170791707522500,
                "operation": "killpg",
                "pgid": 98773,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 170791707546541,
                "operation": "killpg",
                "pgid": 98773,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 98779,
            "assertion_time_ns": 170791707946041,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 170791707979125,
                "pid": 98779,
                "ppid": 1,
                "pgid": 98773,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 170791709289291,
                "pid": 98779,
                "errno": 3
              }
            ],
            "observation_ms": 1.355667,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          }
        ]
      },
      {
        "run": "Portable diagnostic validation, 2026-10-23",
        "trials": 200,
        "passed": 193,
        "failed": 7,
        "maximum_observation_ms": 1.420458,
        "failure_records": [
          {
            "attempt": 22,
            "revision": "22d82c7c0b998d048d28a5429653d22d377f5f11",
            "events": [
              {
                "time_ns": 171674080227375,
                "operation": "killpg",
                "pgid": 99883,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 171674080891333,
                "operation": "killpg",
                "pgid": 99883,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 171674080921791,
                "operation": "killpg",
                "pgid": 99883,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 99888,
            "assertion_time_ns": 171674081347875,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 171674081390916,
                "pid": 99888,
                "ppid": 1,
                "pgid": 99883,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 171674082732125,
                "pid": 99888,
                "errno": 3
              }
            ],
            "observation_ms": 1.402541,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 43,
            "revision": "22d82c7c0b998d048d28a5429653d22d377f5f11",
            "events": [
              {
                "time_ns": 171673971840875,
                "operation": "killpg",
                "pgid": 99853,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 171673972372416,
                "operation": "killpg",
                "pgid": 99853,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 171673972413541,
                "operation": "killpg",
                "pgid": 99853,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 99860,
            "assertion_time_ns": 171673972850375,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 171673972895833,
                "pid": 99860,
                "errno": 3
              }
            ],
            "observation_ms": 0.688541,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 46,
            "revision": "22d82c7c0b998d048d28a5429653d22d377f5f11",
            "events": [
              {
                "time_ns": 171674187198458,
                "operation": "killpg",
                "pgid": 99910,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 171674187708583,
                "operation": "killpg",
                "pgid": 99910,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 171674187733750,
                "operation": "killpg",
                "pgid": 99910,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 99915,
            "assertion_time_ns": 171674188170458,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 171674188207625,
                "pid": 99915,
                "ppid": 1,
                "pgid": 99910,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 171674189556166,
                "pid": 99915,
                "errno": 3
              }
            ],
            "observation_ms": 1.420458,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 113,
            "revision": "22d82c7c0b998d048d28a5429653d22d377f5f11",
            "events": [
              {
                "time_ns": 171674746598541,
                "operation": "killpg",
                "pgid": 192,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 171674747256666,
                "operation": "killpg",
                "pgid": 192,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 171674747279916,
                "operation": "killpg",
                "pgid": 192,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 199,
            "assertion_time_ns": 171674747668875,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 171674747707250,
                "pid": 199,
                "errno": 3
              }
            ],
            "observation_ms": 0.100416,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 131,
            "revision": "22d82c7c0b998d048d28a5429653d22d377f5f11",
            "events": [
              {
                "time_ns": 171674920844166,
                "operation": "killpg",
                "pgid": 251,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 171674921448416,
                "operation": "killpg",
                "pgid": 251,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 171674921471166,
                "operation": "killpg",
                "pgid": 251,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 257,
            "assertion_time_ns": 171674921889208,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 171674921924791,
                "pid": 257,
                "ppid": 1,
                "pgid": 251,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 171674923231083,
                "pid": 257,
                "errno": 3
              }
            ],
            "observation_ms": 1.365667,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 178,
            "revision": "22d82c7c0b998d048d28a5429653d22d377f5f11",
            "events": [
              {
                "time_ns": 171675368919708,
                "operation": "killpg",
                "pgid": 439,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 171675369793500,
                "operation": "killpg",
                "pgid": 439,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 171675369824250,
                "operation": "killpg",
                "pgid": 439,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 445,
            "assertion_time_ns": 171675370371500,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 171675370414791,
                "pid": 445,
                "errno": 3
              }
            ],
            "observation_ms": 0.1055,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          },
          {
            "attempt": 180,
            "revision": "22d82c7c0b998d048d28a5429653d22d377f5f11",
            "events": [
              {
                "time_ns": 171675389210666,
                "operation": "killpg",
                "pgid": 444,
                "signal": 15,
                "errno": 0
              },
              {
                "time_ns": 171675389826458,
                "operation": "killpg",
                "pgid": 444,
                "signal": 9,
                "errno": 0
              },
              {
                "time_ns": 171675389850333,
                "operation": "killpg",
                "pgid": 444,
                "signal": 0,
                "errno": 1
              }
            ],
            "child_pid": 452,
            "assertion_time_ns": 171675390282125,
            "assertion_kill_errno": 0,
            "samples": [
              {
                "time_ns": 171675390321125,
                "pid": 452,
                "ppid": 1,
                "pgid": 444,
                "status": 2,
                "status_name": "SRUN",
                "comm": "bash",
                "flags": 8196,
                "exit_status": 9
              },
              {
                "time_ns": 171675391641416,
                "pid": 452,
                "errno": 3
              }
            ],
            "observation_ms": 1.383083,
            "outcome": "Failed",
            "message": "DID NOT RAISE ProcessLookupError"
          }
        ]
      }
    ]

    The test file and src/skillevaluator/tier3/harbor/local_environment.py have identical Git blob IDs at upstream 2085a03, 5349e9b, 22d82c7, and main as checked on 2026-10-23:

    tests/test_harbor_local_mode.py
    17a0dbbed4dd3217ee244fecba86e7f9b496ebd8
    src/skillevaluator/tier3/harbor/local_environment.py
    54ce8b03ae676cb68d20062c122c18af72581869
    

    The open implementation question remains how to handle the group wait's PermissionError and the test's immediate PID assertion while still detecting a child that actually survives cancellation. No fix or PR is included here.

  2. added a commit that references this issue on Oct 29, 2026
    a95f36e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions