REPORT — phase6-sandbox-sweep-review
STEP: phase6-sandbox-sweep (F20)
REV: d9c660e   FINAL: 36cd049b37029295d114142d82127dcc04be2111
CHANGED: tests/test_review_phase6_sandbox_sweep.py — one review probe (`test_the_probe_pid_scan_counts_an_unrelated_argv_carrier`, the carried-F24 over-match reproduction, `pytestmark = pytest.mark.slow` and a host-only cgroup2-visibility guard); no delivery file touched
VERIFIED: REVIEW ACCEPTANCE run first (the method's gated check): `scripts/check-scope d9c660e06ac530394dd6f072461b99ff6edc59fe 36cd049b37029295d114142d82127dcc04be2111 docs/research/phase6-sandbox-sweep-brief.md` — exit 0, `claimed: src/orchestrator/sandbox.py tests/test_batch3_execution.py`, `tripped: none`, `scope: ok (3 path(s) in d9c660e06ac530394dd6f072461b99ff6edc59fe..36cd049b37029295d114142d82127dcc04be2111)` (the third path is the brief file itself). The tree under review is clean; `git diff d9c660e06ac530394dd6f072461b99ff6edc59fe 36cd049b37029295d114142d82127dcc04be2111 --stat` names the two IN SCOPE files plus the brief only (255 insertions, 14 deletions) — no committed test edit outside IN SCOPE. The review brief's embedded copy of the implementer brief is byte-identical to `git show 36cd049:docs/research/phase6-sandbox-sweep-brief.md` (only the BEGIN/END marker lines differ), so no ORIGIN: BRIEF divergence rides.
VERIFIED: Q1(a) — the sweep's guarantees, on the delivered code: the diff REV→FINAL touches only `import contextlib`, the module constants (`SWEEP_PASSES = 5`, `SWEEP_SETTLE = 0.1`), and `_kill`'s body/docstring. `_kill` is capture, kill, re-capture inside one loop over the descendant tree: per pass `_descendants(process.pid)`, `killpg` on the launcher's group (the `process.kill()` fallback on its failure), a per-pid SIGKILL over the fresh capture, a union merge into the returned list, `break` on an empty capture, and a `SWEEP_SETTLE` settle — bounded by `SWEEP_PASSES`; the signature `_kill(process, cgroup) -> list` stands and the returned list is the union of the passes' captures; `if cgroup: cgroup.kill()` stands before the loop (the cgroup arm first where a cgroup exists, composing with the walk on the same call — this host holds a delegated cgroup v2 subtree, probed `(True, ('cpu', 'memory', 'pids'), '/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service')`, and the cgroup path holds no orphaned sandbox leaves after every drive this review ran); `_teardown` is untouched (its `_await_dead` over `killed + killed_now` and the `processes survived teardown` error stand — the same error the mutant re-drive below produced live). One seam over the whole descendant surface — a single recapture loop, not an enumerated case list (rule 13 met). Live answer, instrumented scratch: pass 0 captures 128 pids including the namespace init and its per-pid SIGKILL begins the reap; pass 1's capture is empty and the loop breaks — the sweep converges in 2 of the 5 budgeted passes on the live shape.
VERIFIED: Q1(b) — the delivered pin on the byte-verified REV scratch (`git archive d9c660e` with the workspace `.venv` symlinked in; the scratch's `src/orchestrator/sandbox.py` and `pytest.ini` cmp-verified against `git show d9c660e:…`; `tests/test_batch3_execution.py` replaced by the delivered pin's content, cmp-verified against `git show 36cd049:…` — the scratch carries REV's single-capture `_kill` under the delivered pin): `.venv/bin/python -m pytest tests/test_batch3_execution.py::test_racing_forker_and_double_forked_sleeper_die_at_teardown -q --durations=0` — `1 passed in 1.27s`, `1 passed in 1.29s`, `1 passed in 1.31s` (three re-drives). GREEN — F23's re-drive claim reproduces; the brief's named red does not exist at REV on this host.
VERIFIED: Q1(c) — the namespace-init mechanism, re-driven live on an instrumented scratch (FINAL content plus a per-pass stderr log and a `MECH_WEAK` switch; the instrument diff adds only the helper/flag/log lines and re-indents the per-pid loop under the flag): the delivered kill on the live racing shape — `MECH pass=0 captured=128 nspid1=[2531710]`, `MECH pass=1 captured=0` — pass 0 always captures the PID-namespace init (the workload process; its `NSpid` last field is 1) and kills it per-pid; the members die by the kernel's namespace reap, not by later sweep passes; after the drive the argv scan counts 0 survivors. The weak-kill re-drive (killpg only, the per-pid walk skipped): `AFTER weak kill, survivors: 122`, `AFTER killing init(s) [2532013], survivors: 0` — the implementer's measured 124→0 class reproduces (fork-timing variance, 122 here vs 124 there); and on the same scratch the unchanged runner-side verification fired `SandboxSetupError: sandbox teardown could not be verified: processes survived teardown: […]`. So the sweep is not what does the reaping: the init's SIGKILL — always inside the pass-0 capture — reaps the namespace, and the sweep is the budgeted recapture over that mechanism, the defense-in-depth the brief itself ordered (the sweep still closes the kill-surface class the mutants name: F23's classification confirmed).
VERIFIED: the delivered red class, re-driven — two kill-surface mutants on their own diff-verified FINAL scratches: mut1 (`_descendants` stubbed to `[]`, FINAL plus one appended line): the racing pin `1 failed in 1.35s` on the named assertion `assert survivors == [], f"racing forkers survived teardown: {survivors}"` at tests/test_batch3_execution.py:306, ~124 surviving pids (matches the implementer's mutant red); mut2 (the per-pid SIGKILL loop removed — the killpg arm only): the drive fails on the runner's own verification, `SandboxSetupError: sandbox teardown could not be verified: processes survived teardown: […]` — the pin reddens on the same kill-surface class through `_teardown`, an error form rather than the pin-assertion form, recorded as such.
VERIFIED: Q3(a) — F24 reproduced airtight: a `bash -c 'sleep …; true # …'` carrier whose argv was pid-verified to retain the probe-path literal (`retains literal in argv: True`) reddens the F1 escape pin: `AssertionError: escaped workload survived teardown: [2533729]` at tests/test_batch3_execution.py:231, `1 failed in 0.85s` — the survivor pid is the carrier's own. Controls: no carrier → `1 passed in 0.84s`; an exec-dropping carrier (`bash -c '<single command> # …'` execs in place and discards the comment) → the pin stays green — the class needs a live process retaining the literal in argv, exactly the invoking-command-line class F24 filed. Sharpening for the carry: the failing pin's `finally` SIGKILLs everything the scan found, so the over-match also kills innocent host processes carrying the string, not only misstates the evidence; and a table-scan review probe can itself be failed by the same pipeline inside a fresh root (this review's own probe, before its guard, read an empty zombie cmdline inside the R08 grading sandbox — see FINDINGS F25).
VERIFIED: Q1's determinism interlude (the review's own misstep, worked to a verdict and filed as F25): the full standing battery first went `1 failed, 1088 passed in 1108.27s (0:18:28)` with the sole red `tests/test_phase3_project_oracle.py::test_grading_gate_grades_one_candidate_identically_across_consecutive_runs` (the seeded-determinism pin, verdict-equality at `:621`), and two isolated re-drives of the same node at FINAL went `1 failed in 191.04s` and `1 failed in 235.26s` (verdict sequences `['FAIL','PASS','FAIL','FAIL','FAIL']`, `['PASS','PASS','FAIL','FAIL','PASS']` — per-drive `exit=0, timed_out=False, violation=None`, so the FAIL arm is the inner gate's own exit). The same node on the byte-verified REV scratch — GREEN `1 passed in 258.15s` — and on the clean FINAL tree — GREEN `1 passed in 193.13s`. Attribution: the oracle's floor snapshot (`_snapshot_repo`) grades the dirty working tree by design (the fixture docstring: "HEAD plus a dirty working-tree copy would bind different inputs (R12)"), this review's own probe file rode in its first form unmarked, joined the inner deterministic suite (`RUNNER_SPAWNING_MODULES` excludes the runner-spawning modules only), and failed inside every graded drive — all three reds are the review's own artifact, at REV-green/FINAL-clean-green they are not a delivery defect. The committed probe now carries `pytestmark = pytest.mark.slow` plus the cgroup2-visibility guard.
 VERIFIED: Q4 — counts at the FINAL tree (this review's own printed lines, rule 14): `scripts/check-tests --fast` — `981 passed, 109 deselected in 118.67s (0:01:58)` (the clean delivery's own 981/108 count plus this review's one marked probe module as the added deselected member); the byte-identical count on the pristine REV scratch — `980 passed, 108 deselected in 96.88s (0:01:36)` — and the delta is exact by ID, not by count arithmetic: the collect-only ID diff across the two clean trees names exactly `tests/test_batch3_execution.py::test_racing_forker_and_double_forked_sleeper_die_at_teardown` (1088→1089 collected, 108 deselected in both) before this review's own file rides. `.venv/bin/python -m pytest tests/test_batch3_execution.py --durations=5` — `13 passed in 4.87s`, slowest five `1.10s` racing pin, `0.88s` cancellation pin, `0.59s` F1 escape pin, `0.58s` deadline pin, `0.23s` limits pin (matches the report's own figures). `scripts/check-static` — exit 0, gated `All checks passed!`, advisory `Found 104 errors.` — identical count on the REV scratch, and the review's probe adds none (ruff-clean under B,SIM). `scripts/check-docs` — `395 Total (in 213ms) 🔗 180 Unique ✅ 395 OK 🚫 0 Errors` (this review's report adds no markdown links, so the gate's printed figures are unchanged from the implementer's own 0-error line). `scripts/check-tests` (no arguments, the full standing battery, slow modules included): `1090 passed in 962.93s (0:16:02)` — the counted whole (981 fast pins + this review's 1 marked probe + 108 slow), all green, with the review probe running through (the carrier survived the full-battery context; no skip needed). One battery attempt mid-review died ENOSPC instead — `2 failed, 1058 passed, 30 errors in 1068.81s` on `OSError: could not create numbered dir … in /tmp/pytest-of-ruben/pytest-168` at `/tmp` 1-inode-free (F15's carried leaked-tree class, measured again the hard way); the stale tmpfs tree (8000 dirs ≥1h old) and the old `pytest-of-ruben` numbering were pruned (~104k+117k inodes back) and the battery re-driven green above; F15's next action is unchanged.
VERIFIED: Q4 — the report's forms: FINAL names the work commit 36cd049 (never the report commit 4de85bc — verified from the two shas and their `Actor: IMPLEMENTER` trailers); every template field present and filled (`CHANGED` lines, `NOT VERIFIED: none`, `TRIPPED: none` matching check-scope's tripped line, `PROPOSED ROWS: none`, `METHOD FRICTION` filled), nothing outside the template added; the VERIFIED figures match this review's own re-runs to the decimal where the same command is re-driven; `record.md` holds the chain's cited rows (ba9e25e, c6d2d7a at docs/record.md:278-279) and this step's status edit rides a later step per the brief's OUT OF SCOPE; the implementer's disjoint INHERITED accounting matches the received set (F13–F17 carried, F21/F22 carried, F19 fixed as recorded, F20 fixed by this step under the F23 repoint, F23/F24 added carried).
VERIFIED: Q2 and Q3(b,c) adjudications — Q2: F23 stands as filed and F20 is fixed by this step as classified: the delivered red the pin holds is the kill-surface mutant class (mut1's assertion red, re-driven by this review; mut2's runner-side red on the same class), the sweep lands as the brief's own ordered defense-in-depth, and the brief's named REV red is chimeric. The second reading (the red exists on a shape this environment draws differently — no NAMESPACE_V1, no cgroup) is refuted as a shape, not merely undemonstrated: the runner has exactly one profile and fails closed (`SandboxUnavailable`) without the namespaces (the module docstring and the pin's `_caps` fail-closed gate); there is no other shape to draw the named red on. Whether the load-borne nested-grading/oracle stack F20 originally sighted (the boundary review's own red-then-green re-drives) can recur post-sweep is not re-verified here — that stack rode the nested-grading teardown tier, not a `_kill` pass race, and no line in this review's drives re-draws it; it stays the load-borne half the F14/F16 dispositions govern, and the planner may prefer to soften F20's "fixed" wording to "fixed as the kill-surface mutant class" when the next brief corrects F23's text (cycle step 5 owns that wording; this review only reports). Q3(b): the reuse is the brief-instructed move (verbatim `_probe_pids`) and its bound is real but not closed: SERIAL_MODULES isolates the scan-bearing modules from sibling workers, this review's probe's carrier is dead before any serial phase starts, and the module's own passes stay green — yet nothing bounds a foreign same-host process whose argv carries the literal (the commit-message measurements and this review's carrier both leak the bound). The assertion is a global-table property held as evidence exactly where no host process names the path. Q3(c): honest — F24's FIXED form states the red "reproduced only when the invoking command line names the probe path", which matches the mechanism this review measured; it was never a red at REV on the clean host, and F24 does not claim it was.
NOT VERIFIED: the load-borne nested-grading/oracle stack of the original F20 sighting (no clean re-drive exists for a load-borne sighting; the class is carried to the planner's F14/F16 dispositions and the wording above).
FINDINGS:
  F25 | SEVERITY: P2 | ORIGIN: CODE | STATE: fixed
  The oracle's floor snapshot grades the dirty working tree by R12 design (`_snapshot_repo`, "an exact snapshot of the tree the exit gate will grade"; the fixture docstring binds grading-not-HEAD), and the inner suite's only content exclusions are the frozen runner-spawning-module list plus `-m "not slow"` — so any unmarked tests/ module created by an in-flight session silently joins the graded corpus of the seeded-determinism pin and reddens the standing battery on a good tree. Measured: three red determinism re-drives (the full battery `1 failed, 1088 passed in 1108.27s`; isolated `1 failed in 191.04s`; isolated `1 failed in 235.26s`) whose failing inner member is this review's own first-form probe file, each clean again once the file is marked slow or absent (REV scratch green, clean-FINAL green, all on the delivery's own code). The defect's owner is the probe-shipping discipline this review violated, not the delivered step: the brief's own new-module rule ("a new module under tests/ that runs trials or sandboxed suites carries pytestmark = pytest.mark.slow") is the correct guard, and a module whose runner is none of those still rides the same floor surface.
  FIXED: tests/test_review_phase6_sandbox_sweep.py::test_the_probe_pid_scan_counts_an_unrelated_argv_carrier — committed with `pytestmark = pytest.mark.slow`, the cgroup2-visibility skip (`no cgroup2 visible here (an R08-type fresh root): the whole-table measure is host-side only`), and a spawn that never reds on a hostile context (it waits for a nonempty cmdline, retries the spawn once, and skips if the carrier still cannot hold the literal); green host-side (`1 passed in 0.24s`), deselected wherever `-m "not slow"` applies, ruff-clean, green by run-through in the full standing battery (`1090 passed in 962.93s`; no skip needed), and the clean-FINAL determinism re-drive is green with the file in the tree. The planner's residual: a doc line (a research-session's dirty tree is a graded corpus member) or a widening of the brief's new-module rule, at cycle step 5's discretion.
SHAPES: the shapes this review probed that the suite does not build:
  - The weak-kill drive shape (the killpg-only arm, per-pid walk skipped): a live drive whose 122+ union of captures stays alive until the namespace init's SIGKILL — probed on an instrumented scratch, not built by the suite; the runner-side `_teardown` verification holds the shape already, so no pin is owed.
  - The exec-dropping carrier control (`bash -c '<single command> # …'` retains nothing in argv after exec): probed as the F24 defect's boundary, not built as a stable test — the negative control greens both sides of any fix.
  - The empty-cmdline zombie carrier inside a minimal-toolchain fresh root (this review's probe inside the R08 grading sandbox): the shape that breaks an unmarked table-scan module; absorbed by the same guard (cgroup2-visibility skip) rather than a pin of its own.
  - The literal-retaining carrier itself: this review's committed probe builds it (`test_the_probe_pid_scan_counts_an_unrelated_argv_carrier`), so it stops being an unbuilt shape at the probe's own commit (slow-marked).
TRIPPED: none
PROPOSED ROWS: none
METHOD FRICTION: two places, both the reviewer's own. (1) The brief's new-module rule was misread as scoping to "trials or sandboxed suites" only; the probe file shipped unmarked and silently joined the oracle's graded dirty-tree corpus, reddening the standing determinism pin three times before the cause was isolated (FINDINGS F25) — the method's silence about the floor's dirty-tree snapshot coupling for non-runner-spawning modules is the concrete gap the friction names. (2) The first REV scratch construction reused the delivered pin's content across two snapshots in one shell line and one of the three scratch builds failed silently (an empty target directory); the byte-verification step caught it before any result was trusted, and each later scratch was built and verified one tree per step.
INHERITED:
  From the brief under review, the still-open items copied verbatim (the chain through the cleanup review's carried set), then the step's own carried findings:

  F13 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: carried
  The brief names the pin's red as "N consecutive grades of the known-good tree produce non-identical verdicts (PASS on one run, CANDIDATE_TIMEOUT on the next)". In this environment the known-good tree's `gate-check-tests` grade is stable well under the fixture's 60.0s deadline (ten pin runs, 50 grades, ~37–46s each, every grade PASS), so the pin passes at REV. The lottery's grade-flip needs a candidate whose suite fails — a failing tree's hypothesis tests shrink, and the shrinking varies the suite's wall — and the near-deadline flip is the neutralisation test's broken-source candidate (FAIL→CANDIDATE_TIMEOUT, 3/3 at REV). The pin's assertion and the seeded determinism are correct; the brief's stated candidate is simply not the one that flips here.
  FIXED: no regression test — an ORIGIN: BRIEF finding is fixed once a later committed brief corrects the text; the pin and the seed land as delivered.

  F14 (P2, ORIGIN: DOCUMENT, carried) — the F8 red evidence is load-borne and the implementer report does not say so; a later actor re-driving the red on an idle host sees green and may conclude the red is chimeric. Next action is the planner's: carry the load condition into the carried F8 block (or a later committed brief's correction), the seed and the pins stand as delivered.

  F15 (P2, ORIGIN: CODE, carried) — killed runs leak intermediate probe trees and no janitor reaps them; the shared tmpfs inode table filled to 3 free and the standing battery's first run died ENOSPC until 81 leaked trees were pruned by hand. Next action is the harness owner's (a tombstone/janitor keyed by the run identity) or a planner ruling that scratch hygiene is each session's duty.

  F16 (P2, ORIGIN: CODE, carried) — the seeded determinism is wall-bounded: at the fixture's 60.0s deadline the near-deadline candidate's seeded grade flips FAIL→CANDIDATE_TIMEOUT under host load (measured once mid-run and once at a 62.44s wall), so the pin's green determinism is stable-half evidence only. Next action is the fixture owner's: raise the grading deadline for near-deadline candidates (the 300.0 default gives a >=5x margin here) or an OWNER ruling that the deadline's load envelope is governed, not deterministic.

  F17 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: carried
  The brief's boundary-fix instruction is internally inconsistent (FINDINGS, F17): the double-fork pin must leave no descendant alive after the exit while the F10 q1e boundary shape must survive the fix, and the two name one live shape (a session-escaped middleman spawning a session-escaped sleeper then exiting before the deadline, the sleeper adopted by init) that no container boundary can kill and spare at once. The GOAL reading was taken (F11/F12 fixed by the container boundary, both pins green at FINAL, no committed discriminating member changed verdict); the boundary this step retires is the named init-adopted orphan, and the new boundary is what the child never forked. Next action is the planner's: a later committed brief's text correction — the q1e-survival sentence, F12's "without also catching the documented boundary" clause, and the boundary sentence in the module docstring this step corrected in code.
  FIXED: no regression test — the reading is delivered in the work commit and its evidence is the two reds above and the FINAL battery above; the correction itself is a committed brief's prose, which has none.

  F21 | SEVERITY: P2 | ORIGIN: DOCUMENT | STATE: carried
  The implementer report's module-battery line records the module battery widened by the review module (`.venv/bin/python -m pytest tests/test_phase6_supervisor.py tests/test_review_phase6_supervisor.py --durations=5` — `15 passed in 17.72s`) and never the brief's documented form (`.venv/bin/python -m pytest tests/test_phase6_supervisor.py --durations=5`) with the documented form's own printed line. The wide form is a strict superset (the module's 13 pins plus the review module's 2 probes), green, and every figure it carries is its own printed line — nothing is evaded; but the brief's acceptance names the documented command, and the report's own template requires each claimed figure to name the command that actually ran while this acceptance line names both the documented form it did not run and the wide form it did. This review ran the documented form at FINAL — `13 passed in 12.46s` — so the figures stand; what carries is the report-text deviation from the brief's named battery.
  FIXED: no regression test — a document deviation in a committed report, which only a later step (or the planner's correction of the carried note) absorbs; the documented form's gate line is in this review's VERIFIED.

  F22 (P2, ORIGIN: BRIEF) — the brief's review-block copy of the carried F17 finding is truncated mid-sentence (the literal `(line truncated to 2000 chars)` marker), which rides as a carried text-correction to the planner.

  F23 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: carried
  The brief's named red at REV is not reproducible — "at REV, with the delivered single-capture _kill, the racing forker's final tail forks plus the double-forked sleeper survive teardown adopted out-of-tree". In a NAMESPACE_V1 drive the workload is the PID-namespace init, _descendants always captures it (descendants=128 namespace_inits=[…]), and its SIGKILL makes the kernel reap the whole namespace (init death kills the namespace; measured: 124 live descendants after a weakened kill, 0 after the init dies), so the delivered _kill already leaves no descendant alive and the pin passes at REV. The sweep lands as the brief's requested defense-in-depth port and the pin as a regression pin; the named red is chimeric for the sandbox, and the load-borne leak F20 measured rode the nested-grading/oracle path, not a standing sandbox-drive race.
  FIXED: no regression test — an ORIGIN: BRIEF finding is fixed once a later committed brief corrects the text; the sweep and the pin land as delivered, and the pin's red class is the kill-surface mutant above.

  F24 | SEVERITY: P2 | ORIGIN: CODE | STATE: carried
  The module's `_probe_pids` (`tests/test_batch3_execution.py`) scans the whole process table for any cmdline containing the literal probe path, so an unrelated process that merely carries that string in argv is counted a survivor. Measured: three `git commit` hook runs failed the F1 pin with exactly two survivors — the `bash -c '<commit>'` wrapper and the `git commit` process — whose command lines carried the path because this step's commit message quoted it; rewording the message cleared it. `scripts/check-tests`' `SERIAL_MODULES` isolation protects against sibling workers but not against the invoking command line.
  FIXED: no regression test — `_probe_pids` is reused verbatim as the brief instructs and is not edited; the named failing assertion at REV is the F1 pin's `assert survivors == [], f"escaped workload survived teardown: {survivors}"`, reproduced only when the invoking command line names the probe path.
