<!-- mixed -->
# Phase 2 Patch Boundary + Probe Oracle — Adversarial Review

Reviewer: adversarial review executed 2026-09-28. Reviewed revision `2f3f521` (tip at review time, a descendant of
the two reviewed commits `4ffd1c4` = Axis 1 exit gate, `2f3f521` = Phase 2 general target). The reviewed worktree was
detached at `/tmp/kilo/phase2-review` and left unmodified; all probes and reproducers under `/tmp/kilo/`. The user's
working tree was not modified except for adding this report.

Scope (in-scope files, as briefed): `patch.py`, `patch_executor.py`, `model_adapter.py`, `experiment_target.py`,
`trial_driver.py`, `hidden_oracle.py`, `experiment_spec.py`, `experiment.py` re-export set, `docs/self-host.md`,
`tests/test_axis1_patch_producer.py`, `tests/test_phase2_general_target.py`. Normative context: `docs/executors.md`,
`docs/experiment.md`, `docs/glossary.md`, `docs/research/axis1-patch-producer-design.md`,
`docs/research/r08-evaluator-isolation-adversarial-review.md`. **No source edits to the target revision; no test
weakening.** Mutation experiments were run on throwaway copies under `/tmp/kilo/`.

---

## Verdict

**Not accepted as-is for Phase 3. Blocking defects: one P0 in the patch boundary, and a rejection of the raw
probe-oracle containment model.** The two exit gates are real and honest — they pass, they are non-vacuous, and I
confirmed they *fail* when the fixed bug is re-introduced — but the boundary has a verdict-changing
`git apply`-fidelity defect, and the general-target path ships a probe shape whose containment I reject, plus
integration gaps that make the "arbitrary target" claim only true for the bespoke in-test calibration.

- Bash baseline is healthy: `/home/ruben/Projectos/meta-project/orchestrator/.venv/bin/python -m pytest -q` →
  **718 passed** at `2f3f521`. `scripts/check-docs` clean (exit 0). `tests/test_static_gates.py` 5 passed.
  `scripts/check-static` gated rules clean (exit 0; 76 non-gated ruff findings, informational).
- Both exit gates pass standalone: `test_axis1_exit_gate_model_reply_changes_tree_and_grade` and
  `test_phase2_non_self_repository_runs_end_to_end` → **2 passed in 10.65s**.
- **P0** — `patch.apply_patch`/`parse_patch` normalise line endings and treat Unicode line boundaries as line breaks, so
  an accepted patch can produce a tree that `git apply` would never produce; a reply `git apply` refuses can be
  accepted and graded `CORRECT_ACCEPTANCE` (whole-trial reproducer below).
- **Probe-oracle ruling:** the raw probe shape (`subprocess.run([sys.executable,"-c",code])` on the host, as in
  `_calc_probe`) is **rejected** as an isolation mechanism. It is only acceptable as an input driver feeding the
  existing `hidden_runner` sandbox shape, or under an equivalent sandbox with data-only exchange.
- The boundary is overwhelmingly *fail-closed* on `git apply` differentials (13/33 stricter, most fail-open cases
  benign), which is good; the P0 is the exception, not the pattern.

---

## Probe-oracle ruling

The probe model (a `check.probe(tree_path)` callable executed directly in the controller process, where the probe
itself may spawn the candidate) is a **different and weaker containment posture than R08**. R08's accepted model is
`hidden_runner` (`src/orchestrator/hidden_oracle.py:186`): candidate code runs in a child of a trusted collector,
inside `NAMESPACE_V1`, against a **disposable per-check copy**, with a **before/after tree digest** and
**controller-side expected values**. The probe shape used by the general-target exit gate is the exact
`_calc_probe` in `tests/test_phase2_general_target.py`: `subprocess.run([sys.executable, "-c", code],
capture_output=True, timeout=5)` — no sandbox, no copy, no digest, expected values inside the child's `code`.

**Ruling: reject the raw probe model; require a hybrid.** A project-owned `probe` may exist, but it must be an
*input driver* only:

1. It must run the candidate through `sandbox.SandboxRunner` under `PROFILE_NAMESPACE_V1`, on a **disposable
   per-check copy**, with the same `before_digest`/`after_digest` check as `hidden_runner` (`hidden_oracle.py:200-236`).
2. The candidate's process must receive **inputs only**; the expected comparison must be made controller-side
   (the `COLLECT:` payload pattern), never as an assertion inside the candidate's process.
3. The probe's **source hash** must enter the oracle binding/freeze hash, not `__qualname__` (see F6).
4. The harness must enforce a per-check wall-clock budget independent of the probe (see F5).
5. Candidate execution must be out-of-process or otherwise unable to leak a bare `BaseException` into grading
   (see F5).

Under those constraints the probe is acceptable and preserves the R08 split. Without them it is rejected.

### Containment matrix (observed, probe shape as shipped in the exit gate)

| Hostile candidate behaviour | Prevent | Detect | Tolerate | Evidence |
|---|---|---|---|---|
| Writes outside its tree during probe | | | ✓ | `ESCAPED_MARKER` created on host; probe still `PASS` |
| Mutates its own graded tree mid-probe | | | ✓ | tree rewritten; no digest; **cross-check contamination**: check `b-observer` PASS only because check `a-mutator`'s candidate wrote a file into the shared tree |
| Spawns a surviving child and returns | | | ✓ | `start_new_session=True` grandchild wrote its marker ~8s after the probe returned; no teardown/reap |
| Hangs in `__init__`/import | | ✓ (probe's own 5s) | | `CANDIDATE_TIMEOUT`; **but** the harness has no outer timeout, so a probe without its own timeout hangs grading |
| Floods stdout/stderr | | | ✓ | 41,943,040 bytes (40 MiB) fully buffered in the **controller** process by `capture_output=True`; no cap (R08 capped this) |
| Raises `SystemExit`/`TimeoutError` from module body | ✓ (in child) | | | child exit ≠ 0 → `FAIL`; `TimeoutError` → `CANDIDATE_TIMEOUT` |
| A probe that lets a candidate `BaseException` reach the controller | | | | `SystemExit`/`KeyboardInterrupt` raised *by the probe* escape `_run_check` (`oracle.py:380-390` catches only `Exception`) and crash grading |
| Reads controller environment/secrets | | | ✓ | probe child inherits the controller env; candidate read a sentinel env var |
| Reads the held-out expected values | | | ✓ | candidate read its own `/proc/self/cmdline`, which contains `assert add(-1, 1) == 0 …` twice — the exact assertions/expected values |

Two further consequences: (a) `hidden_suite_manifest_hash` declares
`"execution": {"mode": "SANDBOXED_COLLECTOR_CHILD", … "expected_values": "controller-side only; never present in the
sandbox"}` (`hidden_oracle.py:344-353`) for **every** manifest, including probe-based ones — the declared execution
mode is false for the probe path; and (b) `hidden_runner` **is** still used for the fixed target (`check.probe is
None` → `runner`), confirmed by reading `oracle._run_check` and `build_hidden_oracle`: the split is by manifest, not a
global switch.

---

## Findings

A finding is listed only where it can change a check's verdict or where an explicit guarantee fails; unit-level
divergences that are strictly fail-closed are folded into the census (section "Census"). Each finding has a
reproducer, the code reference, and a candidate fix.

### F1 (P0, boundary) — `apply_patch`/`parse_patch` normalise line endings; an accepted patch can differ from `git apply` and flip a verdict

**Where:** `src/orchestrator/patch.py:110` `old_lines = current.splitlines()`; `patch.py:285` `lines =
text.splitlines()`; and `patch_executor._apply_parsed_patch` (`patch.py`-driven) reading with `open(...)` text mode
(universal newlines). `"\n".join(...)` rewrites every line ending and `str.splitlines()` splits on `\r`, `\v`, `\f`,
`\x1c-\x1e`, `\x85`, `\u2028`, `\u2029`.

**Guarantee violated:** G1 "An accepted patch applies with `git apply` semantics" and G2 "the admitted candidate tree
is exactly the base commit plus the admitted changes". Specifically "content outside the hunks is preserved
byte-for-byte" is false for any target whose files contain CRLF, a lone `\r`, a form feed, NEL, or U+2028/U+2029.
Form feed is valid Python source; CRLF repositories are common.

**Whole-trial reproducer (false acceptance, the P0):** a calculator repo whose `calc/core.py` is CRLF; the model
reply is a unified diff with **LF context lines**. `git apply` refuses it (`error: patch failed: calc/core.py:1`),
yet the boundary accepts it, rewrites the file to LF, and the trial classifies **`CORRECT_ACCEPTANCE`**:

```
repo calc/core.py = CRLF stub; reply = LF-context patch
git apply --check  -> refuses (exit 1)
run_trial(...)     -> outcome=ACCEPTANCE_CLAIMED classification=CORRECT_ACCEPTANCE hidden={'h':'PASS'}
```

A correct boundary would have refused the reply; the observed boundary silently accepts it — the brief's P0 rule.

**Whole-trial reproducer (false negative direction):** with a CRLF base and a CRLF-context reply that `git apply`
*accepts*, a byte-fidelity probe that expects the `git apply` result (CRLF preserved) grades `FAIL`; the produced
tree is LF, so a check sensitive to those bytes sees different content. Observed:
`{'bytes-preserved': 'FAIL'}`, classification `FALSE_SUCCESS`.

**Boundary-level proof of the splitlines corruption (content outside the hunk is not preserved):**

```
in : b'one\xc2\x85TWO\xc2\x85three\n'   -> out: b'ONE\nTWO\nthree\n'   preserved=False   (NEL)
in : b'one\x0cTWO\x0cthree\n'           -> out: b'ONE\nTWO\nthree\n'   preserved=False   (form feed)
in : b'one\xe2\x80\xa8TWO\xe2\x80\xa8three\n' -> out: b'ONE\nTWO\nthree\n' preserved=False (U+2028)
```

**Census:** the `crlf_file` corpus row is a fail-open: `git apply` rejects (both default and `--unidiff-zero`) while
the boundary accepts and normalises.

**Fix:** read/write the worktree in binary or with `newline=""`, and split *only* on `"\n"` after stripping a single
trailing `"\r"`; never use `str.splitlines()`. Treat CRLF content as bytes. Add a corpus row asserting byte-for-byte
equality with `git apply` on a CRLF repo. (The always-append-trailing-newline behaviour is an acknowledged residual
and composes with this: a no-trailing-newline file also gains a newline; the census `no_trailing_newline` row is the
one "accepted by both, content differs" case.)

---

### F2 (P0 for the probe model, R08-class) — expected values reach the process that runs candidate code

**Where:** the probe shape executes the held-out assertions *inside* the process that imports the candidate
(`tests/test_phase2_general_target.py::_calc_probe`, `code` string), unlike `hidden_runner` which keeps the
comparison controller-side (`hidden_oracle.py:250-265`).

**Guarantee violated:** G5 "Held-out assertions stay controller-side … (R08)". Candidate code read
`/proc/self/cmdline` and obtained `assert add(-1, 1) == 0` and `assert mul(-2, 3) == -6` verbatim. A candidate can
special-case the exact inputs (already an acknowledged R08 residual) with no effort and no inference.

**Reproducer:** module body does `open('/proc/self/cmdline','rb').read()`; the probe then grades `PASS`. The dump
contains the full assertion text.

**Fix:** make the probe a data-only driver: candidate in a sandboxed child returning observations; expectations
compared controller-side. Never embed the expected comparison in the child's argv/code.

---

### F3 (P1, boundary) — `\ No newline at end of file` is skipped anywhere, changing hunk-count interpretation

**Where:** `patch.py:173` (body parser skips the marker wherever it appears).

**Guarantee violated:** G1 (fidelity). Corpus `marker_mid_hunk`: a marker placed mid-hunk causes the boundary to
accept a patch `git apply` rejects; the applied result is then a plausible-looking but wrong file. This is a
fail-open (3 corpus rows are fail-opens: `crlf_file`, `delete_missing`, `marker_mid_hunk`).

**Fix:** only accept the marker immediately after a content line at the physical end of the hunk, and reconcile it
with the header counts; otherwise reject.

### F4 (P2, boundary) — deleting a nonexistent file is a silent no-op accepted

**Where:** `patch.apply_patch` returns `None` for `hunks is None` without checking the file exists; the executor's
`_apply_parsed_patch` then no-ops.

**Guarantee violated:** G1. Corpus `delete_missing`: `git apply` errors on a missing path; the boundary accepts.
Impact is low (no content change), but "accepted ⇒ applied" is loose.

**Fix:** reject a deletion hunk whose target is absent.

### F5 (P1 for the probe model) — no harness-enforced per-check timeout, unbounded capture, and a bare `BaseException` escape

**Where:** `oracle._run_check` (`oracle.py:380-390`) has no timeout of its own and catches only `Exception`; the
`_calc_probe` timeout lives in the probe. `capture_output=True` buffers without bound.

**Guarantee/aspect:** G5 "the check's timeout producing `CANDIDATE_TIMEOUT` — never a harness hang" and
"never a mislabelled `INFRASTRUCTURE_ERROR`".

**Reproducer:** (a) a probe that omits its own timeout hangs the run; the harness will not interrupt it. (b) a 40 MiB
candidate flood is fully buffered in the controller (mild case); larger floods can raise `MemoryError`/`OSError`
inside the probe, which `_run_check` maps to `ORACLE_INFRASTRUCTURE_ERROR` — a candidate-induced resource failure
mislabelled as infrastructure. (c) a probe that raises `SystemExit`/`KeyboardInterrupt` (e.g. after executing
candidate code in-process) escapes `_run_check` and crashes grading (observed: `escaped SystemExit: 1`,
`escaped KeyboardInterrupt`).

**Fix:** wrap `check.probe` with a hard per-check timeout and `except BaseException` (map non-`TimeoutError` to
`INFRASTRUCTURE_ERROR` after recording that candidate code was involved), and cap captured output as R08 does.

### F6 (P1, integrity) — the probe is not bound by the binding or the freeze hash; same-`__qualname__` probes collide

**Where:** `oracle_target_binding` binds the probe by `getattr(c.probe, "__qualname__", "probe")`
(`hidden_oracle.py:296`); `hidden_suite_manifest_hash` binds `drivers_hash`/`expected_values_hash` from the *fixed*
`_HIDDEN_DRIVERS`/`_HIDDEN_EXPECTED` (`hidden_oracle.py:374-378`), not from the manifest's probes.

**Guarantee violated:** G5 "The binding and freeze hashes … bind the oracle". The frozen suite hash does **not** bind
a probe's code or expected values at all, and the R12 binding binds only the qualname.

**Reproducer:** two distinct probes returned by the same factory share
`__qualname__ == "factory.<locals>.probe"`; a manifest whose check is swapped from a PASS probe to a FAIL probe has
the **same** `oracle_target_binding` and the **same** `hidden_suite_manifest_hash`, and `run_trial`'s R12
recomputation passes while the swapped probe grades `FAIL`. Cross-process reproducibility of the hashes is fine
(verified) — the problem is *what* they bind.

**Fix:** bind a content hash of the probe (e.g. source/`code` object hash) rather than `__qualname__`; include the
manifest's probe texts in `hidden_suite_manifest_hash`; keep the fixed drivers/expected binding for the fixed target.

### F7 (P1, general-target integration) — the shipped five-case calibrator is fixed-target-only

**Where:** `experiment_phases.calibrate_oracle` (`experiment_phases.py:83-165`) writes `src/parser/parse.py`,
injects `"hidden-parse"`, and checks the fixed target's timeout check.

**Guarantee:** G6 (five-case calibration) and the Phase 2 "arbitrary target" claim. The Phase 2 exit gate works
around this with a private in-test `_calibration` that calls `_calibrate_case` directly; the public calibrator is not
general.

**Reproducer:** `calibrate_oracle(calc_target, calc_manifest, workdir)` →
`FileNotFoundError: .../calibration/solution/src/parser/parse.py`. No five-case report is produced for a general
target through the shipped API.

**Fix:** parameterise `calibrate_oracle` by case trees and the check-id injection (or have the target/oracle supply
the five case fixtures), so the general freeze pipeline can calibrate without the fixed layout.

### F8 (P2, general-target integration) — `ORACLE_INFRASTRUCTURE` injection and command/script handling do not generalise

**Where:** `trial_driver._grade_trial` hard-codes `inject={"hidden-parse": …}` (`trial_driver.py:1410-1411`);
`run_trial` chooses `verify_commands_for(target)` in patch mode and never consults `target.trial_scripts` for the
command device (`trial_driver.py:722-728`).

**Reproducer:** `_grade_trial(calc_manifest, tree, "ORACLE_INFRASTRUCTURE")` →
`{'calc-held-out': 'PASS'}`, `is_indeterminate == False`. A general target declaring an infrastructure trial script
gets no calibration; `BUILD_FAILURE` scripts are likewise inert in patch mode.

**Fix:** inject the target's first check id (or accept the check id from the manifest/target), and make the
trial-script contract explicit about which scripts apply in patch mode.

### F9 (P2, builder) — empty contract pieces accepted; non-mapping obligations raise `AttributeError`; string `criterion_ids` interpreted char-wise

**Where:** `experiment_target.build_target` (`experiment_target.py:300-390`).

**Guarantee violated:** G4 "refuses … empty contract pieces". Observed:
`acceptance_criteria=("",)` **accepted**; `child_id=""` **accepted**; `obligations=("AC",)` raises
`AttributeError: 'str' object has no attribute 'get'` (fail-closed but uncleansed); `criterion_ids="AC"` with
`acceptance_criteria=("A","C")` **accepted** (string iterated per character).

**Fix:** require non-empty strings for criterion ids and child ids; require mapping obligations; reject non-sequence
`criterion_ids`.

### F10 (P2, builder) — budget fields are unvalidated; `snapshot_hash` does not cover `project_kernel`

**Where:** `experiment_target.build_target`; `TargetSnapshot.snapshot_hash` (`experiment_target.py:246`).

Observed: `budget` of `-5.0`, `nan`, and `inf` are all **accepted** (no validation). `dataclasses.replace` of
`obligations`/`trial_scripts` changes `snapshot_hash` (good), but an **in-place** mutation of the nested
`project_kernel` dict does **not** (`project_kernel_hash` is stored, not recomputed), so `oracle_target_binding`
cannot detect a post-build kernel tamper; `replace(repository=…)` with the same commit likewise does not change the
hash. Impact is limited (the run does not consume `project_kernel`, and `freeze_manifest` re-hashes the frozen copy),
so this is P2.

**Fix:** validate budgets (finite, non-negative) in `build_target`; hash `project_kernel` content in
`snapshot_hash` or document that only the build-time hash is bound.

### F11 (P2, command lookup) — malformed visible commands crash `run_trial`; shell-style commands are unsupported

**Where:** `experiment_target.verify_commands_for` uses `shlex.split` (`experiment_target.py`), unvalidated by
`build_target`.

Observed: `visible_commands=("echo 'unterminated",)` is accepted by `build_target`, then `verify_commands_for`
raises `ValueError: No closing quotation` inside `run_trial` (before the try/finally that would record/settle),
leaving the reservation outstanding as liability. Pipes/redirections are not interpreted (no shell), so a target
declaring a shell-style verifier silently runs the wrong argv.

**Fix:** validate commands in `build_target` (parse-able argv, or declare a shell mode) and fail the builder rather
than the trial.

### F12 (P2, patch executor) — a pending patch is not bound to its attempt

**Where:** `patch_executor._dispatch` consumes `self._pending_patch` without checking
`patch_request.attempt_id == request["attempt_id"]` (`patch_executor.py:112-113`).

**Reproducer:** `set_patch(PatchRequest(attempt_id="att1", …))`, never dispatch `att1`, then dispatch `att2` with no
fresh patch → `att2` reports `COMPLETED` with `changed_paths=['src/a.py']`: **att1's patch was applied to att2**.
Reachable when `set_patch` happens but dispatch does not (provider failure/cancel) and a later attempt's model reply
is empty (`_model_patch` returns without `set_patch`, `trial_driver.py:1277-1278`).

**Fix:** clear/invalidate `_pending_patch` on attempt completion/cancellation, and assert the attempt id matches at
dispatch.

### F13 (P2, freeze discipline) — `freeze_manifest` does not recompute the binding, so foreign/tampered manifests freeze

**Where:** `experiment_spec.freeze_manifest` (`experiment_spec.py:571-578`) refuses only an **empty** binding; it
does not recompute `oracle_target_binding`. `run_trial`/`calibrate_oracle` do recompute and refuse.

Observed: a tampered manifest (check set altered, stale binding) and a foreign manifest (binding from another
target) are both **accepted** by `freeze_manifest`; a foreign manifest freezes to the **same `content_hash`** as the
valid one (the manifest carries no binding field and `content_hash` omits the binding).

**Fix:** recompute `oracle_target_binding(target, oracle_manifest)` inside `freeze_manifest` and include the binding
(or its digest) in `ExperimentManifest`/`content_hash`.

### F14 (P2, imports / docs accuracy) — `verify_commands_for`/`NodeCommands` are not re-exported; docs say "delivered"

`experiment.py` re-exports `build_target` but not `verify_commands_for`/`NodeCommands`, so external consumers cannot
reach the target-derived command facade the Phase 2 claim depends on. `docs/self-host.md:58` says Phase 2 is
*delivered*; given F1/F7/F8 the accurate status is "delivered for the exit-gate fixture, not for arbitrary targets".
Fix: extend the re-export set; adjust the status wording.

**Known-residual check (per brief):** the disclosed residual is
`freeze_manifest(model_profile: ModelProfile = MODEL_PROFILE)` bound at def time (`experiment_spec.py:558`). I
confirmed it and searched for siblings: the only other `= CONSTANT` defaults in the in-scope signatures are
immutable `str`/`int`/`float`/`bool` constants (`PILOT_CALIBRATION_METHOD`, `MANIFEST_ID`, `FROZEN_AT`,
`PER_ATTEMPT_ACTION_LIMIT`, `DECOMPOSITION_BENEFIT_THRESHOLD`, booleans). **No siblings found.**

---

## Claims verified (the eight guarantees)

| # | Guarantee | Result | Evidence |
|---|---|---|---|
| 1 | Patch boundary admitted-then-faithful; fail-closed on malformed/stale; git-apply semantics; bounded | **Partial / falsified in one case** | Census: 13/33 boundary-stricter (fail-closed), malformed/truncated/counts/ascending/overlap/past-EOF/NUL/`..`/absolute/`.git`/scope all rejected; size bound exact (65536 accept, 65537 reject). But **F1** (line-ending normalisation) and F3/F4 are fail-open. |
| 2 | Admitted candidate tree = base + admitted changes; base content preserved; hidden/controller content excluded | **Holds structurally, undermined by F1** | `create_candidate` overlays only changed paths and verifies the committed tree (`worktree.py:274-321`); `_reject_git_metadata`; `_is_hidden` on materialise. F1 changes the bytes of the admitted change. |
| 3 | Differential honesty: working vs broken reply differ only in reply; grade follows held-out semantics | **Holds** | Whole trials: calc `working`→`CORRECT_ACCEPTANCE`, `visible_pass_heldout_fail`→`FALSE_SUCCESS`, `noop`→`CORRECTLY_UNRESOLVED`; fixed `working`→`CORRECT_ACCEPTANCE`. Both exit gates assert per-arm PASS/FAIL and identical frozen manifests (only reply varies). |
| 4 | Builder fails closed on bad repo/commit; freezes every piece with bidirectional coverage; identity is a hash, not label echo | **Partial** | Non-repo/absent/bare/foreign commit refused; HEAD/tag/abbrev normalised. But **F9/F10** (empty pieces, budgets, kernel hash). |
| 5 | Probe-oracle: candidate contained; held-out assertions controller-side; unknown/timeout/crash → INDETERMINATE, never miscounted or crashing | **Falsified for the probe model** | **F2, F5, F6**; containment matrix. Note: `hidden_runner` (fixed target) *does* satisfy this — per-check copy, digest, sandbox, controller-side expected; the split is by manifest. |
| 6 | Five-case calibration correct; foreign/unbound/tampered manifest refused at run_trial/calibrate_oracle/freeze; interruption reopens with identity/intended outcomes | **Partial** | Calibration works for the fixed target and (via the test's private `_calibration`) for calc; but **F7** (public calibrator not general) and **F13** (freeze accepts foreign/tampered). run_trial/calibrate_oracle refuse refusals correctly (verified). |
| 7 | Verification-only commands: no command writes candidate code in the patch path; unsatisfiable gate → refused acceptance + settled retry | **Holds for the shipped targets** | `run_trial` uses `verify_commands_for` (target visible commands) in patch mode; no `_write_script`. Fixed `visible_fail_heldout_pass` → `INFEASIBLE`/`CORRECTLY_UNRESOLVED` (settled, no silent success). Contract caveat: the harness cannot stop a *target* from declaring a writing command (target is trusted) — a Phase 3 constraint, not a Phase 2 bug. |
| 8 | Command lookup: no cross-node override reachable; no undeclared commands; missing entry never vacuous pass | **Holds** | `NodeCommands` fallback is the target's declared commands for any id (incl. `../`, NUL); no production overrides. Empty observations → `NO_VISIBLE_CHECKS` failed (`acceptance_checks.py:69-76`). Caveat: **F11** (unparseable command crashes). |

---

## `git apply` fidelity census

Corpus: 33 hand-built scenarios at `/tmp/kilo/p2/corpus.py`, each applied by real `git apply` (with `-p1`, and with
`--unidiff-zero` as the oracle for zero-context patches) and by the boundary, comparing accept/reject and resulting
file bytes.

| Metric | Count | Notes |
|---|---|---|
| Scenarios | 33 | |
| Accept/reject agreement | 17/33 | `census.py` |
| Boundary stricter (git accepts, boundary rejects) | 13 | Fail-closed: `real_git_diff_multifile`, `mode_change_only`, `pure_rename`, `rename_with_edit`, `minusminus_content`, `descending_hunks`, `nul_byte`, `null_both`, `scope_out`, `quoted_tab_path`, `quoted_octal_path`, `same_path_twice`, `index_line_after` |
| **Fail-open (git rejects both modes, boundary accepts)** | **3** | `crlf_file` (F1), `delete_missing` (F4), `marker_mid_hunk` (F3) |
| Accepted by both but content differs | 1 | `no_trailing_newline` (acknowledged residual) |

Notable fail-closed divergences worth stating: real `git diff` output (with `diff --git`/`index` lines) is
**rejected** outright (`unexpected line outside a file section`) — safe but means a real model emitting standard git
format is refused; quoted paths (tabs/octal-escapes) are rejected as "renames" because `(?:a/)?` cannot match inside
quotes; renames and pure mode changes are rejected. Malformed/truncated hunks, count mismatches, descending or
overlapping hunks, past-EOF, NUL, `..`, absolute, `.git`, and out-of-scope paths are all rejected; `src/.git/...`
passes the parser/scope but is caught by `_reject_git_metadata` at import. Symlink escapes are refused by
`tarfile.filter="data"` (`AbsoluteLinkError`, `LinkOutsideDestinationError`). The size bound is exact.

**Zero-context and inverted-differential:** my first `multi_hunk` result (`git` "rejects") was `git`'s default
no-`--unidiff-zero` conservatism, not a boundary defect; with the correct oracle the boundary agrees.

---

## Residual unknowns

- The boundary was exercised on LF/CRLF/Unicode-separator text; I did not exhaustively fuzz every malformed hunk
  grammar against `git apply`, so additional fail-opens beyond the three census rows may exist. The census is a
  sample, not a proof.
- I did not attempt to force a real `MemoryError` in the probe (host protection); the unbounded-capture finding is
  demonstrated at 40 MiB and argued for larger sizes.
- Real-model measurement is deliberately unclaimed; my model-client probes used `PatchModelClient` and custom patch
  texts, so I can speak to the harness and the diffs, not to provider behaviour.
- I did not run the full measured comparison matrix under adversarial replies beyond the probes above; the exit
  gates do so for the two fixture replies.
- `trial_driver._grade_trial` hard-codes `"hidden-parse"` (F8); I confirmed the no-op on a calc manifest but did not
  audit every other fixed-target constant for general-target reachability.

---

## Reproduce

All commands from `/tmp/kilo/phase2-review` (detached at `2f3f521`), using
`/home/ruben/Projectos/meta-project/orchestrator/.venv/bin/python`.

```bash
# baselines
.venv/bin/python -m pytest -q                                   # 718 passed
.venv/bin/python -m pytest -q tests/test_static_gates.py        # 5 passed
scripts/check-docs                                              # exit 0
PATH="$(dirname $PYTHON):$PATH" scripts/check-static            # gated rules clean (exit 0)
.venv/bin/python -m pytest -q \
  tests/test_axis1_patch_producer.py::test_axis1_exit_gate_model_reply_changes_tree_and_grade \
  tests/test_phase2_general_target.py::test_phase2_non_self_repository_runs_end_to_end   # 2 passed

# F1 whole-trial false acceptance (CRLF base, LF-context reply refused by git apply -> CORRECT_ACCEPTANCE)
.venv/bin/python - <<'PY'
import os, subprocess, sys, dataclasses, tempfile
sys.path.insert(0, "src"); sys.path.insert(0, "tests")
from orchestrator import experiment, oracle
from helpers import open_test_spend_ledger
W = tempfile.mkdtemp(); repo = os.path.join(W, "repo")
os.makedirs(os.path.join(repo, "calc")); os.makedirs(os.path.join(repo, "tests"))
open(os.path.join(repo, "calc", "__init__.py"), "wb").write(b"")
open(os.path.join(repo, "calc", "core.py"), "wb").write(
    b'def add(a, b):\r\n    raise NotImplementedError("add")\r\n\r\ndef mul(a, b):\r\n    raise NotImplementedError("mul")\r\n')
open(os.path.join(repo, "tests", "test_calc.py"), "w").write(
    "import os,sys,unittest\n"
    "sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n"
    "from calc.core import add, mul\nclass T(unittest.TestCase):\n"
    "    def test(self):\n        self.assertEqual(add(2,3),5); self.assertEqual(mul(2,3),6)\n")
for a in (("git","init","-q",repo),("git","-C",repo,"config","user.email","t@e.c"),
          ("git","-C",repo,"config","user.name","t"),("git","-C",repo,"add","-A"),
          ("git","-C",repo,"commit","-qm","b")):
    subprocess.run(a, check=True, capture_output=True)
c = subprocess.run(("git","-C",repo,"rev-parse","HEAD"), capture_output=True, text=True).stdout.strip()
t = experiment.build_target(repo, c, snapshot_id="T", task_statement="t", project_kernel={"k":1},
    visible_commands=("python3 -m unittest discover -s tests -q",), components=(("calc","calc/**"),),
    owned_scope=("calc/**",), acceptance_criteria=("AC",),
    obligations=({"child_id":"c","criterion_ids":("AC",),"budget":30.0},))
def probe(tp):
    code = ("import sys\n" + f"sys.path.insert(0,{tp!r})\nfrom calc.core import add, mul\n"
            "assert add(2,3)==5 and mul(2,3)==6\n")
    r = subprocess.run([sys.executable,"-c",code], capture_output=True, timeout=5)
    return oracle.GRADE_PASS if r.returncode == 0 else oracle.GRADE_FAIL
m = oracle.OracleManifest("o", (oracle.OracleCriterion("AC",True,1.0),),
    (oracle.OracleCheck("h",("AC",),1.0,oracle.GRADE_PASS,30.0,True,probe=probe),), "")
m = dataclasses.replace(m, target_binding=experiment.oracle_target_binding(t, m))
reply = ('--- a/calc/core.py\n+++ b/calc/core.py\n@@ -1,5 +1,5 @@\n def add(a, b):\n'
         '-    raise NotImplementedError("add")\n+    return a + b\n \n def mul(a, b):\n'
         '-    raise NotImplementedError("mul")\n+    return a * b\n')
wd = os.path.join(W, "trial"); os.makedirs(wd)
experiment.set_model_client_factory(
    lambda p, s: experiment.PatchModelClient(experiment.PATCH_MODEL_PROFILE, default_patch=reply))
try:
    mt = experiment.run_trial(t, m, experiment.placeholder_limits(), experiment.PATCH_MODEL_PROFILE,
                              experiment.ARM_DIRECT, 1001, wd, spend_ledger=open_test_spend_ledger(wd))
finally:
    experiment.set_model_client_factory(None)
print(mt.controller_outcome, mt.classification, dict(mt.oracle_outcomes))
# -> ACCEPTANCE_CLAIMED CORRECT_ACCEPTANCE {'h': 'PASS'}   (git apply refuses this reply)
PY
# F1 boundary proof
.venv/bin/python - <<'PY'
import sys; sys.path.insert(0,'src')
from orchestrator import patch as p
for sep in ("\x85","\x0c","\u2028","\x0b"):
    src="one%sTWO%sthree\n"%(sep,sep)
    n=p.parse_patch("--- a/f\n+++ b/f\n@@ -1,1 +1,1 @@\n-one\n+ONE\n", owned_scope_include=["**"])
    print(repr(src.encode()), "->", repr(p.apply_patch("f", n.files["f"], src).encode()))
PY

# F2 expected-value leak into the candidate's process
# candidate calc/core.py body: open('/proc/self/cmdline','rb').read() -> contains the held-out assertions
# F6 probe binding collision
.venv/bin/python /tmp/kilo/p2/binding.py
# F7 public calibrator not general
.venv/bin/python /tmp/kilo/p2/general.py
# F9/F10 builder probes
.venv/bin/python /tmp/kilo/p2/builder.py
# F12 stale pending patch applied to a later attempt
.venv/bin/python /tmp/kilo/p2/stale_patch.py
# census
.venv/bin/python /tmp/kilo/p2/census.py
# regression pin is non-vacuous: reintroduce snapshot-after-patch in a throwaway copy
cp -a /tmp/kilo/phase2-review /tmp/kilo/mut   # then move `base_manifest = snapshot(...)` after apply
cd /tmp/kilo/mut && .venv/bin/python -m pytest -q tests/test_axis1_patch_producer.py::test_axis1_exit_gate_model_reply_changes_tree_and_grade
#   -> FAILED (working reply graded FAIL) — the pin catches the inverted-differential regression
cd /tmp/kilo/mut && .venv/bin/python -m pytest -q tests/test_phase2_general_target.py::test_phase2_non_self_repository_runs_end_to_end
#   -> FAILED (working trial {'calc-held-out':'FAIL'}) — the pin catches it on the general target too
```

**Regression-pin check (explicit):** both exit gates fail on the snapshot-after-patch mutant, so the pins are
non-vacuous. They also cannot pass with identical replies: both tests require the working reply to be `PASS` and the
broken reply `FAIL` (and the general gate asserts working `== {"calc-held-out":"PASS"}`), so an identical or
incidental differential fails the assertion.

**Brief-clarification note:** the probe section of the brief says a hanging tree must yield `INDETERMINATE`, never
`FALSE_SUCCESS`. The frozen design (both `_CALIBRATION_CASES` in `experiment_phases.py:70-80` and the Phase 2 test's
`_calibration`) deliberately maps a candidate timeout with a claimed acceptance to `TRIAL_FALSE_SUCCESS`, and the
harness behaves accordingly. If `INDETERMINATE` is actually intended, that is a cross-cutting policy change (two
calibration tables and both gates), not a Phase 2 defect — flagging for the owner's ruling.

---

## Verification addendum (remediation, 2026-09-28)

All fourteen findings are closed. Suite after remediation: **728 passed**
(718 + 10 new pins); `scripts/check-docs` 202 links OK; `tests/test_static_gates.py`
5 passed; gated lint clean. Two interpretation notes and two residual notes are
stated below; nothing else deviates from the candidate fixes proposed here.

### Per finding

| Finding | Fix landed | Pin |
|---|---|---|
| **F1** (P0) | `patch.py` splits only on `"\n"` (`str.splitlines` is forbidden and documented as such), file IO is `newline=""`, content lines are exact bytes (`\r`, form feed, NEL, U+2028 are content). **Interpretation note:** the candidate fix's "stripping a single trailing `\r`" would have kept the false-negative direction open (CRLF content rewritten to LF); the landed fix is stricter and byte-exact, satisfying both of this report's reproducers: an LF-context diff against CRLF content is **refused**, a CRLF-context diff applies with its CRLF bytes preserved. | `test_line_endings_are_byte_exact_like_git_apply`, plus the whole-trial reproducer pinned as `test_crlf_base_refuses_the_lf_context_reply_review_f1` (every arm's trial must not classify `CORRECT_ACCEPTANCE`). |
| **F2** (P0 probe) | The sanctioned shape is `hidden_oracle.sandboxed_probe(driver=…, compare=…)`: the candidate runs in the `NAMESPACE_V1` sandbox under an inputs-only driver; observations travel as a `COLLECT:` payload; the expected comparison lives in the controller-side `compare`. The exit gate's `_calc_probe` was rebuilt in this shape. | `test_expected_values_never_reach_the_candidate_process` (a cmdline-dumping candidate cannot see the held-out sentinel). |
| **F3** | The marker is accepted only immediately after the content line it describes, at most once per side, with no further line of that side after it (a context line carries both sides); application verifies the marker's end-state claim against the real file and reproduces the no-newline state in the result — which also closes the previously acknowledged `no_trailing_newline` residual. | `test_no_newline_marker_rules_and_delete_missing`. |
| **F4** | Deleting a nonexistent path raises `PatchRejected`. | same test. |
| **F5** | `oracle._run_probe` wraps every probe with a harness-enforced per-check deadline (SIGALRM in the main thread; documented limitation elsewhere) and maps `TimeoutError` → `CANDIDATE_TIMEOUT`, `Exception` **and bare `BaseException`** (`SystemExit`/`KeyboardInterrupt`) → `INFRASTRUCTURE_ERROR`. Flooding is bounded by the sandbox capture. | `test_probe_deadline_and_base_exception_are_contained`, `test_flooding_candidate_is_bounded_and_graded` (payload-first grades; payload drowned by a flood fails closed). |
| **F6** | `oracle.probe_identity` hashes source/bytecode + closure cell values + defaults (recursively, depth-bounded; nested callables by content, never `repr` — a function repr carries a memory address). It replaces the qualname in `oracle_target_binding`, in `hidden_suite_manifest_hash` (per check), and in `GradeCache.manifest_key`. The suite-hash execution disclosure is now per shape. | `test_probe_identity_binds_behaviour_not_qualname` (factory probes sharing a qualname get distinct identities; identical parameters reproduce). |
| **F7** | `calibrate_oracle` accepts a `CalibrationCases` corpus (case trees + `timeout_check_id` + `infrastructure_check_id`); with none supplied it builds the fixed target's corpus as before. The exit gate now calibrates through the public API shape rather than `_calibrate_case` directly. | exercised by `test_phase2_non_self_repository_runs_end_to_end` (the five-case discipline on the general target). |
| **F8** | `_grade_trial` injects the infrastructure device into the **manifest's first check**, never a fixed id. The trial-script contract is documented at the `TRIAL_SCRIPTS` definition: scripts are per-target calibration devices; `ORACLE_INFRASTRUCTURE` is target-independent; `BUILD_FAILURE` is a scripted-path device, inert in the patch path where the model's patch is the only candidate source. | `test_injected_and_non_decisive_grades_are_never_cached` (injection shape) and the phase2 end-to-end matrix. |
| **F9** | `build_target` refuses empty criterion/child ids, non-mapping obligations, bare-string `criterion_ids` (char-wise iteration), and undeclared criterion references; nested `obligations` budgets are validated too. | `test_build_target_refuses_empty_pieces_and_criterion_mismatch` extended. |
| **F10** | Obligation budgets must be finite and non-negative (the `numeric` leaf); `snapshot_hash` binds the kernel's **live content**, so an in-place kernel mutation changes the snapshot identity. | same test + `test_build_target_freezes_the_repository_state`. |
| **F11** | `build_target` parses every visible command as argv (`shlex`) and refuses unparseable declarations at the builder, never mid-trial. | `test_build_target_refuses_empty_pieces_and_criterion_mismatch`. |
| **F12** | The leaf now **plans** the execute attempt first, binds the patch to that attempt id and node (`PatchRequest.attempt_id`/`node_id`), then dispatches; `PatchExecutor` drops a pending patch whose attempt or node does not match the dispatch, and an empty reply leaves none pending. A stale patch can never contribute content to another attempt. | `test_stale_patch_never_reaches_another_attempt` (the report's reproducer shape). |
| **F13** | `freeze_manifest` **recomputes** `oracle_target_binding` and refuses a mismatch (not merely an empty binding); the frozen manifest carries `oracle_binding` in its `content_hash`. | `test_freeze_refuses_a_tampered_or_foreign_manifest_review_f13`. |
| **F14** | The façade re-exports `verify_commands_for`, `NodeCommands`, `probe_identity`, `sandboxed_probe`; `docs/self-host.md` Phase 2 status now references this review and its addendum. | import smoke in the suite. |

### Probe-oracle ruling: adopted

The hybrid is implemented as the only sanctioned probe shape: harness-enforced
per-check disposable copy + before/after tamper digest + hard deadline
(`oracle._run_probe`) wrapping the `sandboxed_probe` data-only driver
(`hidden_oracle`). The containment matrix's rows map as follows: writes outside
the tree — prevented by the sandbox; self-mutation and cross-check
contamination — detected by the per-check copy + digest (`GRADE_FAIL`);
surviving children — killed by the sandbox teardown (R15); hangs — the harness
deadline and the sandbox wall budget; output floods — bounded capture;
`SystemExit`/`KeyboardInterrupt` — contained as infrastructure; controller
environment — the plan's env allowlist (`_HIDDEN_ENV`); held-out expected
values — controller-side `compare`, absent from the candidate's process.

**Residual notes.** (1) The harness deadline uses SIGALRM and therefore binds
the main thread; a probe run from another thread enforces its own budget (the
sandbox deadline still applies to the sanctioned shape). (2) In patch mode a
batched concurrent attempt degrades to the bounded per-leaf path (one model
patch per leaf); the batch dispatch path remains the scripted experiment's
device. Both are documented at their sites. The `RAW` probe shape remains
possible but is disclosed as unverified in the frozen suite hash and is not
used by any shipped oracle.
