REPORT — phase6-supervisor-fixes-implementer
STEP: phase6-supervisor-fixes (Phase 6: the supervisor's kill-tree fix — F4–F6)
REV: 9b78d7a63ce69a4ed5db5a4f59c1edeaa3652bec   FINAL: 5ce423e97f45688d6808af40fdee8a506c816a98
CHANGED: scripts/supervise_run.py — the expiry kill reaches the whole process tree structurally, the descendant-chasing technique already in `SandboxRunner._kill` (`src/orchestrator/sandbox.py:1081`) copied into the supervisor: on `subprocess.TimeoutExpired` (`scripts/supervise_run.py:155`) it first captures the child's descendant chain with its own small `_descendants` walk (`scripts/supervise_run.py:79` — the /proc parent-chain walk from `SandboxRunner._descendants`, no import from the controller stack, so the supervisor's only heads stay the two recorded subprocesses), captured BEFORE the kill so a process that left the child's group — the sandbox's `sandbox_launcher.py`/workload pair, started in their own sessions (`start_new_session`/`setsid`) — is still identified after the group kill misses it; then kills the group with the one `killpg` (`scripts/supervise_run.py:168`, the fast path for the in-group shape and the only kill the delivered code had); then SIGKILLs every surviving captured descendant individually (`scripts/supervise_run.py:173`–`:175`, the structural half that reaches what left the group, silent on a descendant already reaped or not ours to signal); then reaps the child and drives the recorded recovery exactly once, exactly as before. The previous implementer report's CHANGED sentence ("`killpg` on expiry, so sandboxed grandchildren die with the child") was falsified by the review (F4) and is now true as written; `run_child`'s docstring states the two-half kill truthfully. No other behavior changes: the same two recorded subprocess heads, the same single JSON document, the same exit rule, the same misuse fail-closed set.
CHANGED: tests/test_phase6_supervisor.py — the tree pins are restructured into one merged pin (the brief's shapes are "a list of shapes, not the number of tests"), one drive (`tree-both`) carrying both discriminating surfaces: a fixture child spawns TWO grandchildren — an in-group one (holding the output pipes, the group-kill shape) and a session-escaped one (`start_new_session=True` out of the child's process group, output to the void as the sandbox's workloads write to files — the F4 whole-surface shape) — and `test_the_deadline_kill_reaches_the_tree_at_a_fixed_time_and_the_whole_surface_after_the_exit` (`tests/test_phase6_supervisor.py:373`) observes them at the two moments that discriminate: the in-group grandchild is dead at a fixed time after the 2s deadline (`:416`; never "after the supervisor exits", which a surviving in-group grandchild delays past its own sleep by holding the pipes — the review's F5 discriminating member), and the session-escaped grandchild is dead by the time the supervisor exits (`:432` — F4's whole-surface member). The former delivered pin `test_the_deadline_kill_reaches_the_whole_process_tree` is replaced by this merged pin: its grandchild-liveness-after-exit shape is preserved and strengthened (the in-group measurement moves strictly earlier), which is the review's prescribed fix for its F5 gap. The review's second probe lands too: the fixture's `--json` head now records every launch — argv and the whole `ORCHESTRATOR_*` environment — into `child-invocations.jsonl`, and `test_the_child_head_receives_the_whole_environment_and_runs_once` (`tests/test_phase6_supervisor.py:450`, absorbed, the review's own pin shape) observes on the clean face and the controller-death face: exactly one launch (`argv == ["--json"]`, `:466`–`:467`), the recorded environment equal to the supervisor's own `ORCHESTRATOR_*` set — none added, none redacted, the provider credential included (`:473`) — and the secret never touching the supervisor's output. The module goes from nine delivered pins to ten; `tests/test_review_phase6_supervisor.py` is untouched.
VERIFIED: scripts/check-tests --fast — `975 passed, 106 deselected in 115.51s (0:01:55)`, exit 0 (REV's 974 passed, 106 deselected plus the merged tree pin and the child-head pin, minus the replaced tree pin: ten pins where nine ran before).
VERIFIED: .venv/bin/python -m pytest tests/test_phase6_supervisor.py tests/test_review_phase6_supervisor.py — `12 passed in 14.42s`, exit 0 (ten pins in the delivered module; the review's two probes unedited and green beside them).
VERIFIED: .venv/bin/python -m pytest tests/test_axis2_robustness.py -m "not slow" — `17 passed, 4 deselected in 5.91s`, exit 0 (the same 17 passed, 4 deselected as REV: this step touches no committed module the spend-settle and lock pins read).
VERIFIED: .venv/bin/python -m pytest tests/test_phase3_project_oracle.py — `5 passed in 310.91s (0:05:10)`, exit 0.
VERIFIED: scripts/check-static — exit 0. The gated `ruff check --select BLE001,S110 src/orchestrator` prints "All checks passed!"; the advisory run prints "Found 104 errors." and "[*] 5 fixable with the `--fix` option (36 hidden fixes can be enabled with the `--unsafe-fixes` option)" (104 unchanged from REV's 104 — the edited pin module adds no advisory finding).
VERIFIED: scripts/check-docs — exit 0, prints "376 Total (in 192ms) 174 Unique 376 OK 0 Errors" (the counts are unchanged from REV's 376/174/376/0).
VERIFIED: scripts/check-scope 9b78d7a63ce69a4ed5db5a4f59c1edeaa3652bec 5ce423e97f45688d6808af40fdee8a506c816a98 docs/research/phase6-supervisor-fixes-brief.md — exit 0. Prints `claimed: scripts/supervise_run.py tests/test_phase6_supervisor.py tests/test_review_phase6_supervisor.py`, `tripped: none`, `scope: ok (3 path(s) in 9b78d7a63ce69a4ed5db5a4f59c1edeaa3652bec..5ce423e97f45688d6808af40fdee8a506c816a98)` (the third path is the brief, added under `docs/research/` at ee78aab and allowed implicitly).
VERIFIED: the red evidence at REV, on a scratch worktree at `9b78d7a63ce69a4ed5db5a4f59c1edeaa3652bec` (`/tmp/kilo/phase6-fixes/REV`, detached) with the pin module copied in uncommitted and the worktree's `scripts/supervise_run.py` byte-verified first (`git show 9b78d7a:scripts/supervise_run.py | diff - …` — empty):
  - F4's pin red at REV: .venv/bin/python -m pytest tests/test_phase6_supervisor.py — `1 failed, 9 passed in 7.57s`; the failing assertion is the named one: `AssertionError: grandchild 2184968 still survives the supervisor's kill: the expiry kill does not reach the whole process tree` at `tests/test_phase6_supervisor.py:432` (the pin's post-exit session-escaped-grandchild liveness line; the pin's fixed-time line above it passes at REV because the unfixed `killpg` does reach the in-group grandchild).
  - F4's real-head tree red at REV: the review's `--budget 8` scripted-environment drive (`sys.executable scripts/supervise_run.py --budget 8` from the REV worktree with `ORCHESTRATOR_WORKDIR=<tmp> ORCHESTRATOR_OWNER=phase6-fixes ORCHESTRATOR_CAP=500 ORCHESTRATOR_AUTHORIZED_AT=2026-01-01T00:00:00Z ORCHESTRATOR_AUTH_METHOD=phase6-fixes-probe ORCHESTRATOR_SEEDS=1001 ORCHESTRATOR_REQUIRE_CONFORMANCE=0`): exit 1, empty stdout (failed closed: `no trials directory to resume`), and the /proc parent-chain sampler found FOUR descendants alive at the supervisor's exit and still alive 15s after it — `sandbox_launcher.py` 1845987 and 1845989, a sandboxed workload 1845991 (`python3 -P -c …`), and its launcher's collector 1845990 — all dead by ~26.1s after the exit; the review's measured shape reproduced.
  - F5's red at REV: the lone-child-kill mutant (`process.kill()` in place of the group `killpg` — the single line, `git show 9b78d7a:scripts/supervise_run.py | diff - …` names it) with .venv/bin/python -m pytest "tests/test_phase6_supervisor.py::test_the_deadline_kill_reaches_the_tree_at_a_fixed_time_and_the_whole_surface_after_the_exit" — `1 failed in 4.04s`; the failing assertion is the named one: `AssertionError: grandchild 2185297 survives the deadline kill: the expiry kill does not reach the whole process group` at `tests/test_phase6_supervisor.py:416` (the pin's fixed-time line). The mutant leaves the committed pins green and only the absorbed member catches it — the discrimination the review required. The mutant was reverted after.
  - F6's reds at REV, each mutant diff-named against `git show 9b78d7a:scripts/supervise_run.py` before use and reverted after, run as .venv/bin/python -m pytest tests/test_phase6_supervisor.py::test_the_child_head_receives_the_whole_environment_and_runs_once: the double-launch mutant (a second `--json` Popen before the recovery) — the launch-count assertion fails, `assert 2 == 1` at `tests/test_phase6_supervisor.py:466`; the dropped-secret mutant (the child's env filters out `ORCHESTRATOR_PROVIDER_API_KEY`) — the environment-equality assertion fails at `tests/test_phase6_supervisor.py:473` ("the child's environment is not the supervisor's on the clean face: the run's ORCHESTRATOR_* set must reach the child unchanged"); the added-variable mutant (`env=dict(os.environ, ORCHESTRATOR_SUPERVISOR_ADDED="1")`) — the same environment-equality assertion fails with the added variable in the left set.
VERIFIED: the F4 green hand measurement at FINAL (the SHAPES entry's green face): the same real-head `--budget 8` scripted-environment drive, executed from the repository root against the fixed supervisor — exit 1, empty stdout (the recovery still fails closed; the kill is the only change), and the sampler found NO descendant alive at the supervisor's exit and none alive 15s after (alive_at_exit `[]`, alive_at_15s `[]`) — no survivor, against REV's four.
NOT VERIFIED: the full `scripts/check-tests` (no `--fast`): this brief's ACCEPTANCE names the `--fast` form, and `--fast` selects exactly the full non-slow suite (975 passed, 106 deselected — the 106 deselected are the slow-marked end-to-end experiment tests). The work commit's pre-commit hook additionally re-ran that same non-slow suite as its own gate before the commit landed (its parallel phase printed `944 passed in 22.57s` over 6 workers after ignoring the 3 serial modules, and its serial phase printed `31 passed in 11.44s`), so the full-suite shape is covered twice over; the `--slow` battery is not this step's acceptance. The oracle acceptance's repeatability is separately finding F8 below (a committed-fixture lottery, carried) — the line above is its green run at FINAL.
FINDINGS:
  F8 | SEVERITY: P2 | ORIGIN: CODE | STATE: carried
  The phase3 oracle fixture's gate-check grade is a hypothesis-seed lottery, not a load margin: `tests/test_phase3_project_oracle.py`'s `project_oracle_context` builds the manifest with `gate_timeout_seconds=60.0`, and `oracle._run_probe` covers the probe-tree copies, the identity digests, and the in-sandbox gate execution in that one 60.0s deadline (`src/orchestrator/oracle.py:632`, `:636`–`:637`, the probe call and its `GRADE_CANDIDATE_TIMEOUT` exception map at `:701`–`:705`) — while the frozen corpus's unseeded in-sandbox suite duration swings ~24–67s run-to-run (the fuzzer tests' hypothesis draws: shrinking/repro depth varies per seed against a fresh per-run hypothesis database on the sandbox's tmpfs), its seeded structural cost being ~30s. When a heavy draw lands past the deadline, correct grades flip instead of timing out loudly for a real reason: a graded FAIL becomes CANDIDATE_TIMEOUT (`AssertionError: assert 'CANDIDATE_TIMEOUT' == 'FAIL'`) and, in the five-case calibration, a `CORRECT_ACCEPTANCE` becomes `FALSE_SUCCESS` (`ExperimentError: calibration case 'known-good' classified 'FALSE_SUCCESS', expected 'CORRECT_ACCEPTANCE'` at `src/orchestrator/experiment_phases.py:265`).
  FIXED: tests/test_phase3_project_oracle.py::test_gate_config_and_test_corpus_neutralization_is_rejected and tests/test_phase3_project_oracle.py::test_project_oracle_classifies_the_five_case_corpus_on_a_real_repository, `.venv/bin/python -m pytest tests/test_phase3_project_oracle.py`, the two failing assertions quoted above — red at REV with no changes of this step in the tree (1 failed in 161.69s at load ~4.2 after passing in 159.95s at load ~3.3), so the lottery predates this brief. The discriminator that this step's pins are not the cause: the fixed-seed A/B inside the same sandbox shape, `--hypothesis-seed=424242` over the same 58-module selection — 30.27s / 30.81s with this step's pins and 25.14s / 23.42s without them (the pins' true in-sandbox cost ~+6s, twice, deterministic), and the full-corpus collection subprocess both grades depend on measures 2.0–2.3s with or without the pin module; the unseeded draws (24–67s across today's runs) are the seed's, not the corpus's. Next action: the fixture's owner raises `gate_timeout_seconds` toward `build_project_oracle`'s 300.0 default, or gives the in-sandbox gate a fixed hypothesis seed/profile so a red means a real regression; both files are outside this brief's scope and stayed untouched.
SHAPES: one shape the suite does not build, probed live on both faces of the fix (the pins drive fixture children by the brief's design — "without running a real trial" — so no committed pin launches the real `scripts/smoke_run.py` through the supervisor; the sandbox is available in this environment, so no fail-closed skip applies):
  1. The real-head whole-process-tree kill — `sys.executable scripts/supervise_run.py --budget 8` from the repository root (the REV face from the REV worktree) with the scripted environment (`ORCHESTRATOR_WORKDIR=<fresh tmp> ORCHESTRATOR_OWNER=phase6-fixes ORCHESTRATOR_CAP=500 ORCHESTRATOR_AUTHORIZED_AT=2026-01-01T00:00:00Z ORCHESTRATOR_AUTH_METHOD=phase6-fixes-probe ORCHESTRATOR_SEEDS=1001 ORCHESTRATOR_REQUIRE_CONFORMANCE=0`), the deadline landing mid oracle calibration, the descendant tree sampled by a /proc parent-chain walk every 150ms during the run and for 45s after the supervisor's exit. RED face at REV: exit 1, empty stdout, four descendants (two `sandbox_launcher.py` — 1845987, 1845989 — a sandboxed workload 1845991 and its collector 1845990) alive at the exit and still alive at 15s, all dead by ~26.1s after the exit. GREEN face at FINAL (the fix applied): exit 1, empty stdout, ZERO descendants alive at the exit and none at 15s — the tree dies with the deadline. The shape is otherwise pinned by the merged tree pin (the fixture session-escaped grandchild, no survivor after the exit).
TRIPPED: none
PROPOSED ROWS: none
METHOD FRICTION: none
INHERITED:
Nothing in the received set is still open: the brief's INHERITED carried F4, F5 and F6 (each `carried`), all three are fixed here — F4 fixed by the descendant-chasing kill over the supervisor's whole surface (its falsified absolute made structurally true, post-exit liveness of a session-escaped grandchild pinned at `tests/test_phase6_supervisor.py:432`), F5 fixed by absorbing the review's discriminating member into the merged tree pin (fixed-time assertion at `:416`), F6 fixed by absorbing the review's child-head observation as `tests/test_phase6_supervisor.py::test_the_child_head_receives_the_whole_environment_and_runs_once` (`:450`) — and F7 stays `fixed` as recorded in the review that filed it, unchanged. Added by this step, each carried finding with its ID:
  F8 (P2, ORIGIN: CODE, carried) — the phase3 oracle fixture's gate-check grade is a hypothesis-seed lottery: the frozen corpus's unseeded in-sandbox suite (24–67s per draw) exceeds the fixture's 60.0s per-check deadline on heavy draws and flips correct grades (FAIL→CANDIDATE_TIMEOUT; CORRECT_ACCEPTANCE→FALSE_SUCCESS). Next action is the fixture's owner: raise `gate_timeout_seconds` toward the 300.0 default or fix the in-sandbox gate's hypothesis seed/profile (both files are outside this brief's scope).
