<!-- informative -->
# Phase 3 Project Oracle — Adversarial Review

Scope: commits `d4d6267` and `6be581d` (worktree checkout at `/tmp/kilo/phase3-review`,
revision `6be581d`). Normative docs consulted: `docs/experiment.md`, `docs/sandbox.md`,
`docs/control-plane.md`, `docs/executors.md`, `docs/self-host.md` (Phase 3),
`docs/research/phase3-project-oracle-design.md`, `AGENTS.md`.

Method: no source edits. Every mutation is a copy of the frozen repository under
`/tmp/kilo/p3/`; every probe is a boundary invocation of the public/seam surface
(`build_project_oracle`, `grade_manifest`, `_run_probe`, `sandbox.SandboxRunner`,
`run_sandboxed_probe`, `calibrate_oracle`, `freeze_manifest`, `_calibrate_case`).
Reproducers are listed with each finding.

Baseline on this host (informative, not a verdict):

- `scripts/check-tests --fast` → `712 passed, 26 deselected`.
- `scripts/check-static` → rc 0 (gated rules clean).
- `tests/test_static_gates.py` → `5 passed`.
- `scripts/check-docs` → `204 OK`.
- `tests/test_phase3_project_oracle.py` (exit gate) → **times out under the default
  `pytest -q`**; passes only with `--timeout=0` (see P2-1).

## Verdict

**Reject, revert, or narrow the phase's central claim before it is treated as delivered.**

The machinery's primitives are sound: script-level gate tampering is refused, binding is
content-sensitive and reproducible, foreign/stale bindings are refused at every entry
point, the corpus is non-vacuous and specific, and the sandbox containment rows hold.
However, the phase's core promise — that the target's own gates, frozen and bound, are a
trustworthy acceptance oracle — does not survive the seams:

- **P0-1** shows the command gates can be neutralized to PASS through candidate-controlled
  *configuration* (`ruff.toml`, `pytest.ini`, `conftest.py`, test markers) without touching
  a gate script and without a re-freeze. A tree with genuine `BLE001/S110` violations, or a
  genuine failing test, is graded `CORRECT_ACCEPTANCE`.
- **P1-2** shows the registry floors compare *counts*, not identities, so a covered-finding
  demotion (and a `test_bug_*` pin deletion) can be compensated while every repository
  meta-test stays green.
- **P1-3** shows `_run_probe`'s pre-deadline tree copy follows candidate symlinks, so a
  symlink to `/dev/zero` produces an unbounded grader-side write/hang outside any deadline.

These falsify guarantees 1 (spirit), 2, 4, 5, and 8 as stated.

---

## Findings

### P0-1 — The command gates are neutralizable through candidate-controlled tool configuration

**Guarantees attacked:** 1 ("no accepted path lets a modified gate produce PASS without a
deliberate re-freeze"), 5 (residual acceptance surface "exactly what the brief declares").

The frozen gate identity binds only the *gate script bytes* (`scripts/check-static`,
`scripts/check-tests`). The gates' effective policy lives in candidate-controlled files that
are neither hashed nor frozen: `ruff.toml` for `gate-check-static`, and
`pytest.ini`/`conftest.py` for `gate-check-tests`. Both the frozen gate and the repository's
own meta-tests read the same candidate-controlled config, so both can be neutralized together.

Reproducers (trees under `/tmp/kilo/p3/`; grade with
`probe.py <tree> --only gate-check-<gate>`):

1. **`gate-check-static` fail-open.** `t-ruffdodge/` adds a genuine
   `try/except Exception: pass` to `src/orchestrator/review_violation.py` and appends
   `[lint.per-file-ignores] "src/orchestrator/*" = ["BLE001", "S110"]` to `ruff.toml`.
   - `ruff check --isolated --select BLE001,S110 src/orchestrator` → `Found 2 errors`.
   - `ruff check --select BLE001,S110 src/orchestrator` (reads candidate `ruff.toml`) →
     `All checks passed!`.
   - `tests/test_static_gates.py::test_no_blind_or_swallowed_exceptions` (also reads the
     candidate `ruff.toml`) → passes.
   - Frozen oracle: `gate-check-static: PASS`.
   The gate script hash is unchanged; nothing detects that the gate's policy was rewritten.

2. **`gate-check-tests` fail-open.** Append a genuinely failing test to
   `tests/test_executor.py`, then any of:
   - `t-break-conftest/`: add a `conftest.py` `pytest_collection_modifyitems` that deselects
     the failing node → `gate-check-tests: PASS` (full grade: all six checks PASS).
   - `t-break-addopts/`: `pytest.ini` `addopts = --co -q` (collect-only) → `gate-check-tests: PASS`.
   - `t-krename/`: rename the failing test to contain the excluded `-k` substring
     `test_frozen_corpus_branch_coverage_meets_the_floor` → `gate-check-tests: PASS`
     (the disclosed dodge, now empirically confirmed).
   - `@pytest.mark.slow` on the failing test (the gate runs `-m "not slow"`), and
     `@pytest.mark.skip` / `@pytest.mark.xfail` are mechanically equivalent siblings
     (slow-marker deselect confirmed host-side).

Because the registry checks inspect only registry bookkeeping, a full grade of
`t-break-conftest` is six PASSes; `classify_trial` with a controller acceptance claim is
`CORRECT_ACCEPTANCE`. The oracle therefore certifies a tree whose own gates are effectively
disabled. This is a much larger residual than the brief's declared "excluded modules'
behavioural regressions", so guarantee 5 fails.

Direction: a gate identity must bind the gate's *effective configuration inputs*
(hash `ruff.toml`, `pytest.ini`, root `conftest.py`, and the test corpus, or run the gate with
an injected trusted config and `--override-ini` / `--config`), or the in-manifest gate must be
acknowledged as advisory and the acceptance claim moved to a trusted, frozen test corpus the
candidate cannot rewrite.

### P1-2 — Registry floors compare counts, not identities; demotions and pin deletions can be compensated

**Guarantee attacked:** 2 ("a candidate that … demotes a covered finding, deletes a mapped
pin, … is graded FAIL … even when every repository meta-test passes its edits").

The counterexample compare checks `covered >= floor`, `min_covered >= floor`, and per-node
name existence; the open-defect compare checks `fixed/open` counts, `unregistered`, and
vacuity. None compares the *set* of covered finding ids, mapped node ids, or deviation
declarations against freeze time.

Reproducers:

1. **Covered-finding demotion compensated by a filler finding** (`t-compensate/`): demote
   `R23` to pending (drop its regression pin, keep `prefix_revision` + add
   `remediation_batch`), add a new `R24` covered by an existing collecting test to
   `tests/counterexamples.yaml`, and add an `R24` row to
   `docs/report-milestone8-readiness.md`.
   - `tests/test_counterexample_registry.py` → `5 passed` (all meta-tests green).
   - Frozen oracle full grade → **all six PASS**. The demotion is invisible because the
     frozen floor is a count.

2. **`test_bug_*` pin deletion** (`t-pindelete/`): delete the
   `test_bug_schema_version_accepts_boolean` function and its registry node, leaving the
   defect entry `status: fixed` with no `tests`.
   - `tests/test_open_defect_registry.py` → `4 passed` (green; `unregistered`, floors, and
     vacuity all consistent).
   - Frozen oracle full grade → **all six PASS**, while a permanent regression pin for a
     fixed defect has been deleted.

3. **Uncompared surfaces.** `registry-fidelity-floors` compares only `len(fakes)`; a fake's
   `deviations` are never compared, so "removes a declared deviation trips the floor" is not
   implemented. At freeze there is exactly one deviation (`scripted-executor`/
   `no-protocol-validation`) and the repository meta-test guards it, so this is latent rather
   than exploitable today.

The `unchanged` corpus case is a valid headline for the *exact* mutation (lower a floor:
`t-cc-lower` with all duplicate keys lowered → `registry-counterexample-floors: FAIL`, all
meta-tests green), but guarantee 2's broader claims are falsifiable by compensation.

Direction: freeze the identity sets (covered finding ids, mapped node ids, per-fake deviation
names), not just counts; bind them into `hidden_suite_manifest_hash`.

### P1-3 — `_run_probe`'s pre-deadline tree copy follows candidate symlinks (unbounded write / hang)

**Guarantees attacked:** 4 ("a … flooding … candidate is contained"), 8 ("never an unbounded
run").

`oracle._run_probe` calls `shutil.copytree(tree_path, copy)` (default `symlinks=False`,
i.e. follow) **before** arming the harness deadline (`signal.alarm` is set after the digest,
which is computed after the copy). A candidate file that is a symlink to an infinite stream
makes the controller copy without bound.

Reproducers:

- `t-static-devzero/`: `scripts/check-static -> /dev/zero`. Direct `shutil.copytree`
  follows the symlink (verified: a link to `/etc/hostname` copies the target's bytes). Under
  `RLIMIT_FSIZE=64MiB`, `oracle._run_probe` wrote 64 MiB in <0.4 s before failing as
  `ORACLE_INFRASTRUCTURE_ERROR`; without the cap this writes until the grader's filesystem is
  full, and no deadline bounds it.
- `t-static-fifo/`: a FIFO makes `copytree` raise `SpecialFileError`, surfaced as
  `ORACLE_INFRASTRUCTURE_ERROR` (fail-closed, but the check is lost).
- The same applies to any candidate-controlled path, not only gate scripts.

Direction: `copytree(..., symlinks=True)` (and reject special files), or arm a setup deadline
around the copy and cap bytes copied.

### P2-1 — The exit gate cannot pass under the repository's default test configuration

`docs/research/phase3-project-oracle-design.md` states the corpus is "`slow`-marked with an
explicit generous timeout". There is no per-test timeout override; `pytest.ini` sets a global
`timeout = 120`, which applies.

- `pytest tests/test_phase3_project_oracle.py -q` → `Timeout` (pytest-timeout) after 120 s
  while grading a corpus case; rc 1.
- `pytest tests/test_phase3_project_oracle.py -q --timeout=0` → `1 passed in 149.75s`.
- `conformance.run_full_suite()` itself is ~1 s, so the cost is the five case grades,
  dominated by the 60 s `known-timeout` case plus four ~15–20 s grades.

So the documented full-suite baseline ("738 passed") is not reproducible under the repo's own
defaults on this host: the phase's headline exit gate times out. Direction: add
`@pytest.mark.timeout(...)` sized for the corpus (the "explicit generous timeout" the brief
already claims), or shrink the timeout case's gate budget.

### P2-2 — Design brief and commit message diverge from the implementation

- The brief's check table lists `gate-check-docs` (`AC-DOCS`); the implementation builds no
  such check. `CRITERIA` is `('AC-TESTS', 'AC-STATIC', 'AC-REGISTRIES')` and all six checks
  map onto those three. The brief also says "these five criteria" (there are three/four).
- The brief and commit say "16 runner-spawning modules"; `RUNNER_SPAWNING_MODULES` has **17**.
- The brief says the registry drivers only read bytes and "the compare — controller-side —
  parses the YAML and the test ASTs"; the drivers actually parse and compute the metrics
  (facts-only; no expectations, so not a security issue, but the split is misdescribed).
- The commit claims "a candidate that … deletes a declared deviation trips the floor"; the
  fidelity compare never inspects deviations.
- `frozen_floors(REPO).gate_hashes` hashes `scripts/check-docs`, but no check consumes it
  (dead floor entry), reinforcing the `AC-DOCS` gap.

### P2-3 — `run_trusted_gates=False` silently bypasses the trusted-side gates

`build_project_oracle(run_trusted_gates=True)` refuses the build when
`conformance.run_full_suite()` fails or the external-link half of `scripts/check-docs` fails
(both verified by injection). With `run_trusted_gates=False` neither is invoked and the value
is not recorded in the manifest or the R12 binding. There is no production caller today
(only the exit-gate test, which uses the default `True`), so this is prospective; when a
Phase 4/5 production entry point adopts `build_project_oracle`, `False` must be refused or
recorded as a hash-bound deviation.

### P2-4 — Registry hygiene notes (no current fail-open)

- `tests/counterexamples.yaml` declares `min_covered` twice (top-level line 17 and trailing
  line 159). PyYAML last-wins, so the first is decorative; all readers agree, so this is a
  review hazard, not a bypass. `frozen_floors` and the frozen compare both read the trailing
  value, which is why the corpus's `_demote_a_finding` (replace-all) works.
- The open-defect driver computes `unregistered` as a bare-name set difference; a
  *parameterised* `test_bug_*` pin (`test_fn[case]`) would be reported as unregistered and
  fail a good tree. No such pin exists at freeze; the failure mode is fail-closed.
- `_run_probe` creates an empty `.venv` mount-point inside the graded copy before the
  before-digest. This mutates the tree the checks see but is honest under the before/after
  digest and benign for all current checks.
- `sandbox_launcher._setup_filesystem` bind-mounts each `/dev/<device>` twice (the
  `host_device` path and `f"/dev/{device}"` are the same string). Cosmetic.

---

## Required censuses

### Gate-tampering census (in-manifest gates)

`check-static` and `check-tests` tested by copying the tree and tampering the gate script;
graded with `probe.py <tree> --only gate-check-<gate>`.

| Tamper | check-static | check-tests | Binding delta |
|---|---|---|---|
| rewrite to `exit 0` | FAIL | FAIL | none (tree change only) |
| wrap original + `exit 0` | FAIL | FAIL | none |
| truncate | FAIL | FAIL | none |
| flip one byte (valid script) | FAIL | FAIL | none |
| replace with directory | FAIL | FAIL | none |
| symlink to byte-identical script | PASS | PASS | none |
| symlink to different passing script | FAIL | FAIL | none |
| FIFO | ORACLE_INFRASTRUCTURE_ERROR | (same class) | none |
| symlink to `/dev/zero` or `/dev/urandom` | **unbounded copy before deadline (P1-3)** | (same class) | none |
| candidate `ruff.toml` `per-file-ignores` (no script change) | **PASS with genuine violations (P0-1)** | n/a | none |
| candidate `pytest.ini` / `conftest.py` / marker / `-k` rename | n/a | **PASS with genuine failure (P0-1)** | none |

Only the byte-identical symlink passes; the binding is unaffected by tree content because it
is computed from the manifest, and the frozen hash lives controller-side in the compare.

### Registry-floor census

| Mutation | Frozen check | Outcome | Repo meta-tests |
|---|---|---|---|
| lower `min_covered` (all occurrences) | counterexample | FAIL | pass (internally consistent) |
| demote `R23` + lower floor (`unchanged`) | counterexample | FAIL (only this check) | pass |
| demote `R23`, keep floor, no compensation | counterexample | FAIL (`covered 22 < 23`) | pass |
| demote `R23` + filler `R24` | counterexample | **PASS (P1-2)** | pass |
| delete mapped test name | counterexample | FAIL + `gate-check-tests` FAIL | fail |
| remove `prefix_revision` | counterexample | FAIL (`missing_prefix`) | invalid (handled) |
| delete `test_bug_*` fn + mapping | open-defect | **PASS (P1-2)** | pass |
| strip a pin's `tests:` (function kept) | open-defect | FAIL (`unregistered`) | fail |
| lower `min_fixed` | open-defect | FAIL (floor echo) | pass |
| symlink counterexamples.yaml → `/dev/null` | counterexample | FAIL | fail |
| symlink → `/proc/self/environ` | counterexample | FAIL | fail |
| invalid UTF-8 | counterexample | FAIL | fail |
| YAML alias bomb | counterexample | FAIL | fail |
| remove a fidelity `fakes` row | fidelity | FAIL | fail |
| lower `min_parameters` | guard | FAIL | pass |

### Binding / identity attacks (guarantee 3)

- Rebuild in-process and cross-process → identical binding and suite hash.
- Change `oracle_version` → binding and suite hash change.
- Two factory probes with equal `__qualname__` but different closure values → different
  `probe_identity`; swapping them changes the binding.
- Change the frozen gate-ignore argv → binding and suite hash change.
- Stale/foreign `target_binding` → refused by `freeze_manifest`, `calibrate_oracle`, and
  `run_trial` (`ExperimentError`); a RAW probe is refused unless `allow_unverified_probes`.
- All six checks are `SANDBOXED_DATA_DRIVER`.

### Containment matrix (new sandbox shape; guarantee 4/7)

Run via `sandbox_probe.py` in the project-oracle probe shape (same `_HIDDEN_ENV`, rw `/work`,
ro `/work/.venv`, toolchain ro mounts, `/tmp` tmpfs, `/dev` tmpfs).

| Probe | Result |
|---|---|
| write 2 GiB through `/dev/null` | discarded; `/dev/null` size 0; `/dev` has exactly 4 char nodes |
| write `/usr/bin/evil` (ro toolchain) | `OSError` |
| write `/work/.venv/SHADOW` (ro mount) | `OSError` |
| write `/work/newfile` (rw) | allowed (by design) |
| candidate `.venv/SHADOW` planted in tree | invisible; `/work/.venv` is the host venv |
| read `/proc/self/cmdline`, `/proc/self/environ` | only the driver source and `_HIDDEN_ENV`; no floors/hashes |
| gate `echo hi >/dev/null` | rc 0 (grant works) |
| mutating probe (`_run_probe`) | `GRADE_FAIL` |
| hung probe (2 s budget) | `GRADE_CANDIDATE_TIMEOUT` at 2 s |
| `BaseException` probe | `GRADE_INFRASTRUCTURE_ERROR` |
| 100 MiB stdout flood | `GRADE_FAIL`, controller healthy |
| fork bomb (256-process limit) | `GRADE_FAIL` in ~1 s, host healthy |
| symlink gate → `/dev/zero` | **P1-3** |

### Resource bounds (guarantee 8)

| Probe | Result |
|---|---|
| 50 000-line mapped test file | PASS (~1 s) |
| YAML alias bomb | FAIL (~0 s), no OOM |
| deeply nested Python expression in mapped file | FAIL (~1 s) |
| 100 MiB output flood | FAIL, host memory stable |

Residual: without a delegated cgroup the 8 GiB limit is per-process address space and not
tree-aggregate (up to 256 allowed processes). This is the sandbox's documented trade, not
new to these commits.

### Corpus non-vacuity and specificity (guarantee 6)

- known-good → all PASS; unchanged → only counterexample FAIL; known-broken → gate + registry
  FAIL; timeout tree → only `gate-check-tests` `CANDIDATE_TIMEOUT`.
- `_calibrate_case` specificity: timeout tree with `expect_candidate_timeout="gate-check-tests"`
  → `FALSE_SUCCESS`; with `"gate-check-static"` → raises (`PASS` where timeout expected).
- Slot swaps raise: good tree in the unchanged slot → `MISSED_SUCCESS`; unchanged tree in the
  known-good slot with an acceptance claim → `FALSE_SUCCESS`.

### Trusted-side split (guarantee 5)

- All in-manifest probes are the verified data-only driver shape; RAW probes refused.
- `conformance.run_full_suite()` failure and `check-docs` failure both refuse the build
  (injection-verified); `run_trusted_gates=False` bypasses silently (P2-3).
- Fail-closed drift confirmed: a new sandbox-dependent test module (`t-newrunner/`) is green
  host-side and makes `gate-check-tests` FAIL under the frozen ignore list.
- **The split is not honest as declared**: P0-1 shows the "in-manifest gates" can be
  neutralized through candidate config, so the true residual acceptance surface is far larger
  than "excluded modules' behavioural regressions".

### Exit gate (required)

- `tests/test_phase3_project_oracle.py` passes end-to-end only with the global timeout
  disabled (`--timeout=0`, 149.75 s). Under `pytest -q` it times out at 120 s (P2-1).

---

## Artifacts

All mutation trees, reproducers, and drivers are under `/tmp/kilo/p3/`:

- `probe.py` — grade a tree with the frozen project-oracle manifest (`--only`, `--gate-timeout`,
  `--registry-timeout`, `--inject`).
- `bind.py`, `make_tamper.py`, `sandbox_probe.py`, `drivers/` — binding, gate-tamper, and
  containment harnesses.
- Trees: `t-static-*`, `t-tests-*`, `t-unchanged`, `t-compensate`, `t-pindelete`, `t-krename`,
  `t-break-conftest`, `t-break-addopts`, `t-ruffdodge`, `t-newrunner`, `t-timeout`, `t-broken`,
  `t-hugefile`, `t-bombyaml`, `t-deepast`, `t-cc-*`, `t-od-*`, `t-fid-*`, `t-guard-*`,
  `t-venvshadow`, `t-static-devzero`, `t-static-fifo`.

Repository host state: only this new review document was added; no existing source, test, or
documentation file was modified.

---

## Verification addendum (Phase 3 review remediation, 2026-09-29)

All reported findings are closed. Final verification: **749 passed** (full
suite, including the slow five-case Phase 3 corpus); `scripts/check-docs` 204
links OK; `tests/test_static_gates.py` 5 passed; gated lint clean.

### P0-1 — gate/config/test-corpus neutralization

`FrozenFloors` now snapshots hashes and path sets for every test-control file
(ruff/pytest configuration, all conftests, startup hooks), every baseline
`tests/**/*.py` file, and the gate scripts. Gate drivers report their observed
hashes/path sets; the controller-side compare requires exact identity before
considering the gate exit code. The check-tests argv runs only the frozen
baseline test modules (the existing runner-spawning/nested-environment
exclusions remain); changing, adding, or deleting a test/config requires a
trusted re-freeze. The freeze also verifies every gate/config/test/registry
blob against `TargetSnapshot.commit`, refusing a dirty-worktree/target
provenance mismatch.

Regression pin: `test_gate_config_and_baseline_test_corpus_neutralization_is_rejected`
reproduces (a) a ruff per-file ignore plus a genuine gated-rule violation
(the local ruff invocation passes, the frozen gate grades FAIL), (b)
`pytest.ini` collect-only plus a failing test and a conftest deselector (the
local check-tests invocation passes, the frozen gate grades FAIL), (c) the
`-k` rename dodge (pytest deselects the renamed failure, the frozen test-file
identity grades FAIL), and (d) an additive test-file path (requires re-freeze).

### P1-2 — identity floors

Registry comparisons now freeze and require baseline identities, not just
counts: covered finding ids + their mapped node ids and `prefix_revision`;
open-defect pin ids + mapped nodes (a fixed pin cannot be demoted); guard
parameter names/sites/test nodes; and fixture-fake names/kinds/modules/
qualnames/deviation names. Additions can be proposed, but cannot compensate
for removal/replacement of a freeze-time identity.

Regression pin: `test_registry_identity_floors_reject_compensated_replacements`
reproduces the review's R23-demotion + R24-filler tree and a removed fixed
`test_bug_*` pin; each mutated tree passes its repository meta-test, but the
corresponding frozen identity check grades FAIL.

### P1-3 — bounded no-follow probe copy

`oracle._run_probe` arms the deadline before copy/digest and uses a chunked,
size-capped copier. It never follows symlinks; relative links are preserved
only when they resolve inside the tree to a regular file/directory; escaping,
dangling, special-file, and over-limit inputs fail closed. The no-follow copy
cannot read `/dev/zero` during setup, and copy time is within the harness
deadline.

Regression pins: `test_probe_copy_refuses_symlink_and_special_file_before_execution`,
`test_probe_copy_refuses_symlink_to_infinite_stream_before_copy_review_p1_3`,
`test_probe_copy_refuses_internal_symlink_to_special_file`, and
`test_probe_copy_budget_and_deadline_cover_pre_run_copy`.

### P2 closures

- **P2-1:** the five-case corpus has an explicit `@pytest.mark.timeout(2400)`;
  it passes without disabling the global timeout.
- **P2-2:** `phase3-project-oracle-design.md` and `self-host.md` now agree with
  the implementation: three in-manifest criteria; conformance and external
  link checking are trusted-side; the frozen test/control corpus and re-freeze
  policy are explicit.
- **P2-3:** the public `build_project_oracle` has no
  `run_trusted_gates=False` bypass; the builder always executes both
  trusted-side preconditions. Pinned by
  `test_project_oracle_has_no_trusted_gate_bypass_flag`.
- **P2-4:** the duplicate trailing `min_covered` YAML key was removed; the
  open-defect driver normalizes parametrized ids, pinned by
  `test_open_defect_identity_normalizes_parameterized_node_ids`; the registry
  meta-test requires `min_covered` be declared once.

Residual policy: adding or editing a baseline test/control file requires a
trusted re-freeze. Candidate source is **not** part of that policy — see the
gate-execution model in
[phase3-project-oracle-design.md](phase3-project-oracle-design.md#the-gate-execution-model).

---

## Independent re-verification (round 2, adversarial review, 2026-09-30)

The working tree carries an uncommitted remediation. I re-ran the exit gate and the whole
attack suite against it, independently of the addendum above.

Reproduced and **closed**:

- Full suite `749 passed` in 594 s; `scripts/check-static` rc 0; `scripts/check-docs`
  rc 0 (204 OK). The Phase 3 + `test_probe_oracle` modules pass from a cleared stage cache
  (20 passed in 297 s). **P2-1 is closed** by the explicit `@pytest.mark.timeout(2400)`.
- **P0-1 (root config / baseline tests)** closed: `ruff.toml` per-file-ignore,
  `pytest.ini addopts`, root and `tests/conftest.py` deselectors, the `-k` rename, and an
  additive test module all grade `FAIL` (identity and closed-set corpus), while the local
  gates exit 0.
- **P1-2** closed: demote-R23 + add-R24-filler → `registry-counterexample-floors FAIL`;
  fixed-`test_bug_*` pin deletion → `registry-open-defect-floors FAIL`, with the repository
  meta-tests green.
- **P1-3** closed: a gate symlinked to `/dev/zero` and a >1 GiB tree both grade `FAIL`
  immediately, with no unbounded copy.
- **P2-3** closed (no `run_trusted_gates` parameter); **P2-4** closed (duplicate
  `min_covered` removed, parametrized-pin normalization added).

New blocker:

### N-1 (blocking, fail-shut) — the oracle freezes and overlays the entire source tree, so it cannot grade a candidate's source

`_inventory_gate_inputs` classifies any path under `_BASELINE_ROOTS = ("src/", "tests/",
"scripts/")` as a frozen baseline input, so all 42 `src/orchestrator/*.py` files enter
`test_hashes`. `_gate_check` builds `frozen_overlay_paths` from
`gate_hashes | control_hashes | test_hashes`, which therefore binds the **frozen** source
read-only over `/work/src/**`; and `_frozen_surface_intact` requires the candidate's source
to hash exactly equal to the freeze.

Consequences: (a) any candidate change to an existing source file fails both command gates;
(b) the gate executes the frozen source, so it does not "grade the candidate's source" — the
claim made in `phase3-project-oracle-design.md`'s gate-execution-model section and in the
remediation summary. New source files are *not* in the frozen path set, so a candidate may
add files but may never fix an existing one: the oracle only accepts a tree byte-identical
to the freeze, which makes the acceptance gate vacuous in the fail-shut direction.

Reproducer (`/tmp/kilo/p3/probe2.py`, snapshot of the current tree):

| candidate tree | gate-check-static | gate-check-tests |
|---|---|---|
| unchanged | PASS | PASS |
| `src_comment` — append a comment to `reducer.py` | **FAIL** | **FAIL** |
| `src_behavior` — append a helper to a source module | **FAIL** | **FAIL** |
| `new_src_module` — add a new `src/orchestrator/*.py` | PASS | PASS |

`frozen_floors(snapshot).test_hashes` has 136 entries: 42 under `src/`, 82 under `tests/`,
12 under `scripts/`; the overlay set contains all 42 `src/` files.

Fix: `_BASELINE_ROOTS = ("tests/",)` (gate scripts are already controls), so only the test
corpus and gate/config files are frozen and overlaid; or exclude `src/**` from both
`frozen_overlay_paths` and `_frozen_inputs`. Re-run the exit gate with a benign source edit
in the `known-good` tree to prove the candidate's source is actually graded.

### N-2 (latent; masked only by N-1) — candidate-added *nested* gate config is not frozen

The control inventory records only files that exist at freeze, and the closed-set corpus
counts only `tests/*.py` and `scripts/*.py`. A candidate-added `src/orchestrator/ruff.toml`
(nested ruff config) currently grades **all six PASS** (`nested_ruff`); host-side,
`ruff check --select BLE001,S110 src/orchestrator` passes with it while `--isolated` finds
2 errors. Once N-1 is fixed so the candidate's source is graded, this becomes a real
static-gate bypass. (`tests/pytest.ini`, by contrast, currently grades
`gate-check-tests FAIL` — fail-closed, but the same class of surface.)

Fix: treat `ruff.toml`, `.ruff.toml`, `pytest.ini`, `pyproject.toml`, `setup.cfg`, `tox.ini`,
and `conftest.py` as forbidden *new* basenames anywhere in the tree, and add them to the
closed-set membership comparison rather than only the freeze-existing control hash map.

### N-3 (minor) — duplicate `_verify_frozen_inputs_match_commit`

Defined at `project_oracle.py:261` and again at `project_oracle.py:858`; the second shadows
the first, which is dead and omits the blob map. Consolidate to one definition.

### N-4 (minor) — frozen stage directories leak

`_stage_frozen_inputs` uses `tempfile.mkdtemp` under `~/.cache/orchestrator/frozen-gates` and
never removes it; one directory per manifest build (5 had accumulated; a single module run
added another). Reuse a content-addressed stage or clean up at manifest teardown.

### N-5 (minor) — document state

The addendum above ends mid-sentence ("New fixture rows and registry edits remain checked
against") and declares "All reported findings are closed"; the closure is accurate for
root-level gate config and baseline test edits but not for nested configs (N-2), and it does
not mention that the fix freezes the candidate's source (N-1). The body sections still
describe the original findings, so the document now reads as both open and closed; a
reconciliation pass is needed.

Net: the security findings in this review are genuinely fixed, but the remediation introduced
a blocking functional regression (N-1) and left one latent configuration surface (N-2). The
Phase 3 exit gate should not be considered delivered until N-1 is fixed and the corpus
includes a `known-good` case that actually edits source.

## Round-2 remediation (2026-09-30)

All five round-2 findings are closed. Verification after the fixes: full suite **749 passed**
(397 s); `scripts/check` rc 0; `scripts/check-static` rc 0; `scripts/check-docs` rc 0 (204 OK);
`tests/test_phase3_project_oracle.py` 5 passed (205 s).

**N-1 closed.** `_BASELINE_ROOTS` is now `("tests/",)`. `scripts/**` was already a control
surface, and `src/**` is deliberately neither frozen nor overlaid, so the frozen suite grades
the candidate's own source. `floors.test_hashes` drops from 136 entries to 82, with **0** under
`src/`. Reproducer on the fixed tree:

| candidate tree | gate-check-static | gate-check-tests |
|---|---|---|
| unchanged | PASS | PASS |
| `src_comment` — append a comment to `reducer.py` | PASS | PASS |
| `src_behavior` — break `reducer.py`'s node table | PASS | **FAIL** |
| `new_src_module` — add a new `src/orchestrator/*.py` | PASS | PASS |

The fourth row is the important one: a behaviour-changing edit to an existing source file is
now caught, which is only observable because the gate executes the candidate's source.

**N-2 closed.** `_frozen_name_policy` (name policy over control basenames) rejects any file
whose basename is a frozen control basename (`ruff.toml`, `.ruff.toml`, `pyproject.toml`,
`pytest.ini`, `tox.ini`, `setup.cfg`, `conftest.py`, …) unless it sits at a frozen control
path. A candidate-added `src/orchestrator/ruff.toml` now grades `gate-check-static FAIL` and
`gate-check-tests FAIL`, where it previously graded all six PASS while genuinely neutering
ruff host-side.

**N-3 closed.** `_verify_frozen_inputs_match_commit` is a single definition. It keeps the
worktree-versus-commit check and additionally verifies the freeze-time inventory digests
against the committed blobs, so a `floors` object built from anything other than the target
commit is refused even when the worktree happens to agree.

**N-4 closed.** `_stage_frozen_inputs` is content-addressed by the digests it holds: rebuilding
a manifest for the same target reuses one directory (verified: two builds → one stage entry).
It stages into a sibling and renames, so a concurrent build never observes a partial overlay
tree.

**N-5 closed.** The truncated sentence in the verification addendum above is completed, the
residual re-freeze policy now states that candidate source is outside it, and this section
closes the round-2 findings. The document's body sections remain the original findings; the
addendum and the two remediation sections above are the authoritative status.

**Corpus.** The `known-good` case now carries a benign source edit, so the accepted tree is not
a byte-identical replay of the freeze. `N-1` and `N-2` are pinned in
`test_gate_config_and_test_corpus_neutralization_is_rejected`, which asserts a benign source
edit is accepted by both command gates, a behaviour-changing edit is rejected by
`gate-check-tests`, and a nested gate config is rejected by `gate-check-static`.

---

## Independent re-verification (round 3, adversarial review, 2026-09-30)

The round-3 remediation is committed as `ad58f98` ("Close the Phase 3 oracle review findings,
round 1 and round 2"); the worktree is clean. The report's statement "I have not committed
anything" is inaccurate — the fixes are committed, and I verified that committed state.

Exit criteria, independently reproduced:

- Full suite `749 passed` in 363.75 s; `scripts/check-static` rc 0; `scripts/check-docs`
  rc 0 (205 OK); `tests/test_phase3_project_oracle.py` + `tests/test_probe_oracle.py`
  `20 passed` from a cleared stage cache.
- Recovery integrity (the ~580-line deletion and `/tmp` recovery incident): exactly one
  `_verify_frozen_inputs_match_commit`; no duplicate top-level definitions; all five registry/
  gate drivers present; `build_project_oracle` and all six checks functional.

Attack campaign (`/tmp/kilo/p3/probe2.py` over a committed snapshot of the committed tree):

| candidate tree | gate-check-static | gate-check-tests | registry |
|---|---|---|---|
| unchanged | PASS | PASS | all PASS |
| benign comment in `reducer.py` | PASS | PASS | all PASS |
| break `model.py` (import-time raise) | PASS | **FAIL** | all PASS |
| add new `src/orchestrator/*.py` | PASS | PASS | all PASS |
| nested `src/orchestrator/ruff.toml` | **FAIL** | **FAIL** | all PASS |
| root `ruff.toml` per-file-ignore | FAIL | FAIL | all PASS |
| root `conftest.py` deselector | FAIL | FAIL | all PASS |
| `pytest.ini addopts` | FAIL | FAIL | all PASS |
| additive test module | FAIL | FAIL | all PASS |
| delete fixed `test_bug_*` pin | FAIL | FAIL | open-defect **FAIL** |
| demote `R23` + `R24` filler | PASS | PASS | counterexample **FAIL** |
| gate symlink → `/dev/zero` | FAIL | FAIL | all FAIL |
| >1 GiB tree | FAIL | FAIL | all FAIL |

This closes **N-1** (candidate source is graded: a benign edit is accepted, a
behaviour-changing edit is rejected only by actually running the candidate source) and **N-2**
(a candidate-added nested gate config is now rejected where it previously graded all PASS),
and re-confirms the round-1 closures P0-1, P1-2, P1-3.

- **N-3** closed: single definition with the committed-blob inventory-digest comparison.
- **N-4** closed: two consecutive builds on one snapshot produced exactly one stage directory
  (content-addressed, stage-and-rename).
- **N-5** closed: the truncated sentence is completed and the residual re-freeze policy states
  candidate source is outside it.

Residual: no open security or blocking functional finding. Minor only — a missing blank line
before a decorator in `tests/test_phase3_project_oracle.py` (not linted), and the document's
body still presents the round-1 findings as open with remediation recorded in later sections.

Verdict: the round-2 recommendation (withhold the phase until N-1 is fixed) is satisfied. I
accept the Phase 3 project-owned oracle at `ad58f98`.
