REVIEW BRIEF — phase6-supervisor-fixes-2 (Phase 6: the sweep-to-quiescence fix — F9)
REV: 2da5a5a9a67336c1b8c9bb1d0f49e703eb32f806
FINAL: 0459c5b5577117a4116890ee0cc356edcf9214ca
REVIEW ACCEPTANCE: scripts/check-scope 2da5a5a9a67336c1b8c9bb1d0f49e703eb32f806 0459c5b5577117a4116890ee0cc356edcf9214ca docs/research/phase6-supervisor-fixes-2-brief.md
FOCUS: the sweep-to-quiescence fix above all — does the freeze-and-sweep loop leave no racing-fork PID alive after the exit, is the reparented-orphan boundary named in `SHAPES` rather than hidden, is F10's one-reading claim the one consistent reading, is the `IN SCOPE` line plain with scope green, are the docs figures the gate's own printed lines (rule 14), and does the step touch only the IN SCOPE files with every committed battery green and no committed test edit outside them.
SEVERITY SCALE: P0 blocks the step; P1 is serious; P2 is minor.
QUESTIONS TO ATTACK:

  F10 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: fixed
  The brief's fix description is incomplete as written. It says the loop alone ("capture the descendant chain, kill the group with the one `killpg`, SIGKILL each surviving captured descendant individually, then re-capture") makes "the second pass's capture see" the racing tail. Measured by driving three structures against the review's q1d shape: the loop with the group kill in the first pass leaves 6 of 296 tail forks alive, and the loop that keeps the child alive with the group kill last leaves 3 of 362 — because in both the captured tail's parent is killed and the tail is reparented to init, so a re-capture from the child pid is empty. The only structure that both catches the tail and preserves the brief's `Reparented-orphan boundary shape` (the orphan already adopted out-of-tree before the first capture) is to freeze the in-group forker (SIGSTOP) so the capture is stable before the group kill; the subreaper alternative catches the tail but also catches the boundary orphan (measured: it kills the q1e orphan), which would contradict the brief's named boundary.
  FIXED: no regression test — a committed brief's prose has none. The reading taken is the one consistent with the brief's GOAL (the racing forker dies with the deadline) and its named boundary (the init-adopted orphan survives), it is committed at FINAL (0459c5b), and the racing-fork pin at tests/test_phase6_supervisor.py:491 exercises it. Named per the brief's own instruction ("If exactly one reading is consistent, take it and file a FINDING with ORIGIN: BRIEF that names the reading you took").

  1. The sweep to quiescence live at FINAL — the one question. Re-drive the expiry kill through the supervisor as a subprocess: (a) the racing-fork shape — a fixture child forking session-escaped sleepers every ~5ms across a short deadline — leaves no forked PID alive after the supervisor exits; (b) the earlier faces still hold — the session-escaped grandchild dead after the exit, the in-group grandchild dead at the fixed point, the child-head observation green; (c) the reparented-orphan boundary — a sleeper already adopted by init before the deadline — survives the sweep still adopted out-of-tree (3/3 in the report; re-drive it). Report each guarantee as falsified-with-reproducer or attacked-and-not-falsified with the method. Then the structural question the brief's loop answers: is freeze-then-loop one seam over the whole surface, or does a surface remain the sweep cannot reach — a forker that ignores SIGSTOP, a fork storm that outruns the bounded pass budget, a descendant that double-forks out of the tree between passes? Attack the window, not only the faces. File a finding per falsified class.

  2. F10's one-reading claim. The implementer's F10 says the brief's loop-alone description cannot catch the tail (both loop structures leave tail forks alive: 6 of 296, 3 of 362) and the freeze is the one structure consistent with the GOAL plus the named boundary (the subreaper kills the q1e orphan the brief promises survives). Verify against the delivered code: does the freeze (SIGSTOP before the first capture, group kill after) plus the bounded loop make the racing-fork pin pass where the loop alone fails — re-drive the loop-without-freeze structure on a scratch worktree diffed against FINAL and name the pin that goes red, and on which member? Is there a second consistent reading (a structure that catches the tail and preserves the boundary without the freeze), or is F10's the one? If a second reading exists, the finding is not one-reading and the step returns to planning.

  3. F8's lottery and the oracle line. The implementer's F8 stays carried (fixture owner named, both files outside scope, green run at FINAL after four F8-signature reds — including one with this step's module reverted, so the lottery is not this step's). Adjudicate: is the lottery real and outside this step, and does `carried` name an owner that can act — or does the oracle line's flakiness block this step? Also adjudicate the `NOT VERIFIED` full-suite gap the same way: does the pre-commit hook's double coverage plus the `--fast` battery close it, or does the slow battery need its own run?

  4. The report's forms and counts (J-class). `FINAL` is the work commit `0459c5b5577117a4116890ee0cc356edcf9214ca`, never the report commit `bb1b4dd` — verify rather than taking the report's word. Re-run the brief's ACCEPTANCE lines at FINAL (fast suite 976/106, the 13-passed supervisor-plus-review line, the 17-passed axis2 non-slow battery, the oracle module, static gated `BLE001,S110` clean with advisory `Found 104 errors.` unchanged, docs printed line with 0 errors — every figure the gate's own printed line, rule 14, never the REV line quoted in CONTEXT); `TRIPPED: none` matches check-scope's `tripped:` line and REVIEW ACCEPTANCE is green run first. `git diff 2da5a5a9a67336c1b8c9bb1d0f49e703eb32f806 0459c5b5577117a4116890ee0cc356edcf9214ca --stat` touches only the IN SCOPE files plus the brief (no committed test edit outside them — verify). `SHAPES`' reparented-orphan boundary read against rule 7: the boundary is probed live 3/3 at FINAL and named, not hidden — adjudicate whether the unbuilt shape is properly measured rather than buried. `INHERITED`'s F9 fixed-close and F8 carry against the received set (the fixes-2 brief's carried F9/F8). Every field of the report present and filled, nothing outside the template added. Standing battery: `scripts/check-tests` (your full run — record it in `VERIFIED`).

--- BEGIN BRIEF UNDER REVIEW (copy of docs/research/phase6-supervisor-fixes-2-brief.md; the committed file is authoritative) ---
IMPLEMENTER BRIEF — phase6-supervisor-fixes-2 (Phase 6: the sweep-to-quiescence fix — F9)

GOAL: F9 is disposed and the supervisor's "kills the whole process tree" sentence holds over the capture window, not only the captured snapshot. The expiry kill re-walks-and-sweeps to quiescence — capture the descendant chain, kill the group, SIGKILL each surviving descendant, then re-capture and sweep again until the chain is empty or a bounded retry budget expires — so a process forked between the first capture and the group kill (the review's racing forker: 3 of 331 tail forks surviving) dies with the deadline instead of outliving it. The doubly-escaped orphan (reparented to init before the deadline) is closed the same way the review leaves it closable: the re-walk finds it while it is still a descendant, and whatever is already adopted out-of-tree at the first capture is named in `SHAPES` as the sweep's documented boundary, not hidden. F8 stays carried (the oracle fixture's hypothesis-seed lottery names an owner outside this brief's scope).

CONTEXT: The fixes review (`docs/research/phase6-supervisor-fixes-review.md`) re-drove every kill face live at FINAL `5ce423e97f45688d6808af40fdee8a506c816a98` and confirmed F4–F6 fixed on their faces (session-escaped fixture shape dead at the exit and 15s after; in-group grandchild dead at the fixed point; real-head `--budget 8` with five peak descendants all dead at the exit; all four named mutants red on the right members). Its two capture-window probes are hand-driven scratch fixtures, not committed pins: `/tmp/kilo/q1d_window2.py` (a racing fixture child forking session-escaped `sleep 60` grandchildren every ~5ms across a 2s deadline — 3 of 331 forked PIDs alive after the exit, always the final three forks, born after `_descendants` walked /proc) and `/tmp/kilo/q1e_rerun.py` (a doubly-escaped orphan adopted by init before the deadline, surviving `state=S ppid=3174`). The delivered sweep is capture-then-signal over numeric PIDs with no re-walk and no container boundary, so anything born-or-reparented after the snapshot is outside the surface by construction. Per rule 13 the next brief makes the claim structurally true over the whole surface (this brief: the sweep loops to quiescence) — the PID-reuse corner needs no action (capture-to-kill adjacent statements, pid_max 4194304, no I/O between). Red at this brief's `REV`: the suite is green — red evidence is written first (see the Red evidence section). `REV` names the step's base — the parent of this brief commit — and is not claimed to be `FINAL`'s parent (F4's lesson).

INHERITED:

From `docs/research/phase6-supervisor-fixes-implementer.md`, its `INHERITED` block verbatim:

  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).

From `docs/research/phase6-supervisor-fixes-review.md` — its `INHERITED` block, then each carried finding's block from its `FINDINGS` section, moved verbatim (rule 2 governs the planner's copy of this block; the review's received set is the fixes brief's carried F4/F5/F6, all three fixed at FINAL, F7 fixed as recorded):

  Nothing in the received set is still open: the fixes brief carried F4, F5 and F6 (each `carried`), and all three are fixed at FINAL — F4 fixed by the descendant-chasing kill over the captured surface (session-escaped grandchild dead after the exit, pinned at tests/test_phase6_supervisor.py:432; real-head `--budget 8` leaves no descendant at the exit or 15s after), F5 fixed by the absorbed discriminating member (fixed-time assertion at :416, red under the lone-child-kill mutant), F6 fixed by the absorbed child-head observation (tests/test_phase6_supervisor.py:450, red under the double-launch, dropped-secret, and added-variable mutants) — and F7 stays `fixed` as recorded in the review that filed it, unchanged. Added by this review, each carried finding with its ID:
    F9 (P1, ORIGIN: CODE, carried) — the descendant sweep cannot reach what is born or reparented after the chain capture: tail forks of a racing forker (3 of 331) and a doubly-escaped orphan adopted by init survive the deadline kill by construction. Next action is the planner's per rule 13: re-walk-and-sweep to quiescence or an OWNER ruling narrowing the whole-tree sentence to the captured-at-deadline surface.
    F8 (P2, ORIGIN: CODE, carried) — the phase3 oracle fixture's gate-check grade is a hypothesis-seed lottery (60.0s fixture deadline vs unseeded in-sandbox draws, green at FINAL). Next action is the fixture's owner: raise `gate_timeout_seconds` toward the 300.0 default or pin the in-sandbox gate's hypothesis seed/profile.

  F9 | SEVERITY: P1 | ORIGIN: CODE | STATE: carried
  The descendant sweep cannot reach a process forked between the chain capture and the group kill, nor one already reparented out of the chain: a racing fixture child that forks session-escaped `sleep 60` grandchildren every ~5ms across the 2s deadline leaves 3 of 331 forked PIDs alive after the exit — always the final three forks (2495117, 2495118, 2495119 of 331), i.e. born after `_descendants` walked /proc; and a doubly-escaped orphan (a session-escaped middleman that spawns a session-escaped sleeper then exits, so the sleeper is adopted by PID 3174/systemd before the deadline) survives the kill still adopted out-of-tree (`state=S ppid=3174` after exit 1). The delivered sweep is capture-then-signal over numeric PIDs with no re-walk and no container boundary, so anything born-or-reparented after the snapshot is outside the surface by construction.
  FIXED: no regression test — both reds are this review's hand-driven probes on scratch fixture children (`/tmp/kilo/q1d_window2.py`, `/tmp/kilo/q1e_rerun.py`), not committed pins; no committed module was edited by this review. Next action is the planner's per rule 13: re-walk-and-sweep to quiescence (capture, kill, re-capture until the chain is empty or a bounded retry budget expires), or an OWNER ruling narrowing the whole-tree sentence to the captured-at-deadline surface; the PID-reuse corner needs no action (capture-to-kill is adjacent statements, pid_max 4194304, no I/O between — recycle inside the window is not a live shape).

Expected dispositions (rule 8 forms): F9 fixed with red evidence (named below — the racing-fork tail pinned dead, the sweep looping to quiescence under a bounded budget). F8 stays carried (the lottery is real, outside this brief's scope, its owner named; the oracle line rides green at FINAL).

IN SCOPE: scripts/supervise_run.py, tests/test_phase6_supervisor.py

RESIDUALS:

none — rule 3 selection for this brief's `IN SCOPE`: no `docs/residuals.md` trigger glob matches `scripts/supervise_run.py` or `tests/test_phase6_supervisor.py` (the `PILOT-R*` triggers name `planning_pilot.py`, `controller.py`, `reducer.py`, `decomposition.py`, `model.py`, and `derive_obligations.py`; the store is byte-verified against `docs/residuals.md` before this brief's commit, rule 2). No residual row rides, so the residual half of `scripts/check-scope` has nothing to carry here and it prints `tripped: none` — the line your report's `TRIPPED` field copies.

OUT OF SCOPE:
- Editing this brief file (`docs/research/phase6-supervisor-fixes-2-brief.md`). A committed brief is never modified; a re-cut is a new file.
- `scripts/smoke_run.py` in full: the run and `--resume` recovery it drives are delivered and pinned; the supervisor calls them as subprocesses and edits neither. If recovery needs a code change, stop and report `IN SCOPE` as insufficient.
- `scripts/stress_run.py` in full: its child discipline is the pattern the supervisor follows, not a seam the supervisor edits. If the discipline needs a change, stop and report `IN SCOPE` as insufficient.
- `src/orchestrator/sandbox.py` in full: the descendant-chasing technique is the pattern the supervisor follows, not a seam this brief edits. Read it, do not touch it; if the technique needs a change, stop and report `IN SCOPE` as insufficient.
- `src/orchestrator/controller.py`, the store, the experiment harness, `src/orchestrator/secrets.py`, `src/orchestrator/spend.py`: no controller, store, credential, or ledger change rides here. No new event type, no `docs/tables/*` change and no table regeneration, no `docs/event-catalogue.md` change.
- `docs/self-host.md`, `docs/residuals.md`, `docs/record.md`, `docs/method.md`, `docs/templates/`: the status edit, if any is owed, rides a later step; this step delivers the sweep-to-quiescence fix.
- Every committed test module except the IN SCOPE pin module — `tests/test_run_entry.py`, `tests/test_axis2_robustness.py`, `tests/test_smoke_run_client.py`, `tests/test_review_phase6_supervisor.py`, and every other committed module are read-only here. No committed test file outside IN SCOPE is edited. If a pin would have to change for acceptance to pass, stop and report `IN SCOPE` as insufficient.
- `tests/open_defects.yaml` and the registry's meta-tests: no registration rides (F9 is the open finding whose next brief is this one; no `test_bug_*` name — the open-defect registry would then own it).
- The controller stack, `experiment_target.build_target`, `schemas.py`.
- Registry and control files: `tests/counterexamples.yaml`, `tests/guard_mutation_matrix.yaml`, `tests/fixture_fidelity.yaml`, `tests/verifier_registry.yaml`, `tests/spend_paths.yaml`, `tests/invariants.py`, `tests/helpers.py`, `pytest.ini`, tool configuration.
- No new dependencies, no tooling configuration, no reformatting. No new exception class and no `*Executor`/`*ModelClient` class or provider-registry registration.

ACCEPTANCE: Commands (run every one and paste what each prints into `VERIFIED`; expected result is green, exit 0, for each):

    scripts/check-tests --fast
    .venv/bin/python -m pytest tests/test_phase6_supervisor.py tests/test_review_phase6_supervisor.py
    .venv/bin/python -m pytest tests/test_axis2_robustness.py -m "not slow"
    .venv/bin/python -m pytest tests/test_phase3_project_oracle.py
    scripts/check-static
    scripts/check-docs
    scripts/check-scope 2da5a5a9a67336c1b8c9bb1d0f49e703eb32f806 <FINAL> docs/research/phase6-supervisor-fixes-2-brief.md

Every `pytest` line names `.venv/bin/python -m pytest` deliberately (F17's carried correction: the bare `pytest` on PATH has no `pytest-timeout` and `pytest.ini`'s `strict_config = true` rejects it on this host — run these lines exactly as written and claim them under these names). The supervisor-plus-review line names the review file although it is OUT OF SCOPE here: its two probes stand unedited beside the delivered module and must stay green. The axis2 non-slow line is the supervisor's invariant battery (`17 passed, 4 deselected` at this brief's REV — the spend-settle and lock pins it must not regress). The oracle line rides because this brief's IN SCOPE touches files under `scripts/` and `tests/` (rule: a brief that adds a file under `tests/` or `scripts/` also names `pytest tests/test_phase3_project_oracle.py`; this brief edits under both). The docs gate is expected green with 0 errors — and every count figure you write in `VERIFIED` is the gate's own printed line, never the REV line quoted in this brief's CONTEXT and never recomputed from memory (rule 14, the F41 class). The scope line is expected green, exit 0, printing `tripped: none` (and the `claimed:` line the parser prints). `REV` below names the step's base — the parent of this brief commit — and is not claimed to be `FINAL`'s parent (F4's lesson).

The sweep-to-quiescence fix (`scripts/supervise_run.py`, in place): the expiry kill loops capture-kill-sweep to quiescence under a bounded retry budget — capture the descendant chain, kill the group with the one `killpg`, SIGKILL each surviving captured descendant individually, then re-capture: if the chain is empty the tree is dead; if it is not, sweep again, up to a small bounded number of passes (three is enough: the racing forker's tail is born inside one pass's window, and the second pass's capture sees it). A short settle (a tenth of a second) between passes lets forked children appear in /proc before the re-capture. The budget bounds the loop, not the kill: every pass still signals every captured descendant, and the loop never waits for the recovery — the recorded `--resume` still runs exactly once after the sweep, unchanged. The recovery path is otherwise unchanged: exactly one recorded `--resume` after a killed/lost/nonzero child, none after a clean child, same environment, same single-document stdout with narration on stderr, same exit rules, same fail-closed misuse.

The pins (`tests/test_phase6_supervisor.py`, in place): a racing-fork pin joins the merged tree pin's drive — a fixture child forking session-escaped sleepers every ~5ms across a short deadline, every forked PID recorded, none alive after the supervisor's exit (red at REV: the review's measured shape, 3 of 331 tail forks surviving). The doubly-escaped orphan is not pinned (already adopted by init at the first capture it is outside any descendant walk's surface — the sweep's documented boundary, named in `SHAPES`, not hidden). No committed test file outside IN SCOPE is edited.

Red evidence at `REV` `2da5a5a9a67336c1b8c9bb1d0f49e703eb32f806` (each unit must be replayable; the suite is green at REV, so each red is written by this step and demonstrated at REV against the unfixed code on a scratch copy diff-verified against `git show 2da5a5a:…` before use). `FIXED` names the pin's node id, the command, the named failing assertion, and the delivered file's line numbers or none (F22). Named reds to produce: F9's racing-fork red — the new pin at REV, with the review's forker shape (session-escaped sleepers every ~5ms across the deadline), leaves tail forks alive after the exit (a named failing assertion on forked-PID liveness after the supervisor's exit — an error or a hang is not red, the assertion must be the thing that failed).

Named shapes to build — the list of shapes, not the number of tests. One shape needs at least one test, and every named shape needs one:

- `Sweep-to-quiescence shape` (F9): a racing forker's every forked PID dead after the supervisor's exit — the sweep's second pass captures what the first pass's window missed.
- `Reparented-orphan boundary shape` (F9): the doubly-escaped orphan adopted by init before the first capture survives — named in `SHAPES` as the sweep's documented boundary (no descendant walk reaches what is already out-of-tree at capture time), not pinned and not hidden.

REV: 2da5a5a9a67336c1b8c9bb1d0f49e703eb32f806
CLOSE OUT: yes
DIVERGENCES: none
REVIEW: one session — the sweep-to-quiescence fix above all: does the sweep loop capture-kill-sweep under a bounded budget with a settle between passes, does the racing-fork pin leave no forked PID alive after the exit, is the reparented-orphan boundary named in `SHAPES` rather than hidden, is the `IN SCOPE` line plain with scope green, are the docs figures the gate's own printed lines (rule 14), and does the step touch only the IN SCOPE files with every committed battery green and no committed test edit outside them. Whether anything remains open after this step is the loop's exit input — report findings and let the planner decide (cycle step 5).

You implement one brief. You do not plan, re-scope, or decide what the work is. Read every file
in IN SCOPE before editing it; if what you find contradicts the brief, report that instead of
guessing. Modify only what IN SCOPE names. If you find uncommitted changes in the tree, stop and say
so. Stop and report rather than improvise when IN SCOPE is
insufficient, the brief contradicts the code, you have already failed twice at this goal, or the
requirement is ambiguous and no single reading is consistent with the rest of the brief. If exactly
one reading is consistent, take it and file a FINDING with ORIGIN: BRIEF that names the reading you
took. No new dependencies, no tooling configuration, no reformatting. Run every ACCEPTANCE command;
fix what is in scope and report what is not.

A defect in the brief is a FINDING, never METHOD FRICTION. METHOD FRICTION is only for the method and
its templates: any place you deviated from them, found them ambiguous, or found them silent. Report
friction you worked around — that is the section the method learns from.

Commit your own work. When ACCEPTANCE passes, commit the files you changed, and only those, in one
commit whose message ends with the trailer `Actor: IMPLEMENTER`. That commit's full sha is FINAL.
Then append docs/templates/report.txt verbatim, fill it in, write it to
docs/research/<phase>-<subject>-implementer.md, and commit it in a second commit with the same
trailer. Do not amend the first commit to add the report: FINAL must not change after the report
names it. If you cannot commit, stop and say so; do not leave work uncommitted for someone else to
commit.
--- END BRIEF UNDER REVIEW ---
You did not write this code and you will not fix it; a finding is output, not an action. The step's
decision is the planner's (cycle step 5): report findings, never decisions. The commits under review
carry the trailer `Actor: IMPLEMENTER`; if your session wrote any of them, stop and say so. Run
REVIEW ACCEPTANCE first: it is the method's only gated check. The ACCEPTANCE lines inside the brief
under review are the implementer's; re-run them to verify the delivery, and run `scripts/check-tests`
as your standing battery — the full suite is your falsification ground — recording both in `VERIFIED`.
The embedded brief is a convenience copy: if the
standalone file it names differs, file a FINDING with ORIGIN: BRIEF and review against the committed
file.

You may create new test files to prove a finding, and modify nothing else. If a failing test would
need registering in tests/open_defects.yaml, say so in the report and leave the registration to the
next implementer brief rather than editing that file; the registry owns test_bug_* pins only, and a
test_review_* probe rides red until absorbed. Read pre-images with git show <rev>:..., not
the implementation's account of them. Run every mutant on a scratch copy of the tree, and diff each
mutant against git show <rev>:... before trusting its result. Attempt to falsify the brief, not only
the code: a finding that the brief was wrong is a finding, and so is a defect the implementer filed
only as friction. Answer every item under QUESTIONS TO ATTACK. Answers live in the form's fields —
a finding in FINDINGS, a measurement in VERIFIED/SHAPES. An added review's QUESTIONS TO
ATTACK come only from the implementer's report — never from another review's findings. Enumerate
the shapes you probed that
the existing suite does not build, as a list; zero with a stated reason is legitimate. Report each
guarantee as falsified-with-reproducer or attacked-and-not-falsified with the method.

Commit your own work: your new test files and your report, together, in one commit whose message
ends with the trailer `Actor: REVIEWER`. Append docs/templates/report.txt verbatim, fill it in, and
write it to docs/research/<phase>-<subject>-review.md. If you cannot commit, stop and say so.
