<!-- informative -->

# Phase 4 option (e) review: evidence-typed obligation source and the declared-structure gate

Independent falsification review of `d78862d`, executed against the
[review brief](phase4-option-e-review-brief.md). Scope: `derive_obligations.py` (new),
`experiment_target.py` (delta), `data/fixed-target-obligations.yaml` (new), and the four
migrated test files; `experiment_spec.py` and `trial_driver.py` read for call-site context
only. Probes drove real entry points (`build_target`, `build_fixed_target`,
`load_fixed_target_obligations`, `derive_obligations`, `measure_divergent_axes`,
`is_admissible`, `plan_decomposition`) over throwaway git repositories; no source edits.

- Revision under review: `d78862dd147914cc5c973dec7602af8b9f64bc8b`
  (`git worktree add --detach /tmp/kilo/phase4-review d78862d`).
- Baselines: `pytest -q` 770 passed; `check-tests --fast` 740 passed / 30 deselected;
  `check-docs` 229 links OK; `check-static` rc 0 (gated rules clean; B/SIM advisory only).
  Touched tests at `d78862d`: 33 passed. (Three Phase 3 failures first seen in the
  worktree were environmental: those tests exec `<worktree>/.venv/bin/ruff` and the
  detached worktree has no `.venv`; after symlinking it, all green.)
- Pre-images: `git show d78862d^:src/orchestrator/experiment_target.py`,
  `…:tests/test_phase2_general_target.py`, `…:tests/test_phase3_project_oracle.py`,
  `…:src/orchestrator/experiment.py`, `…:src/orchestrator/trial_driver.py`.
- Probes: `/tmp/kilo/probes/` (`probe_a.py`, `probe_ab.py`, `probe_ce.py`, `probe_fix.py`,
  `probe_f.py`, `probe_g.py`, `common.py`). Monkeypatch sites (runtime-only, restored in
  `finally`): `experiment_target._BASE_FILES`, `derive_obligations.derive_obligations`,
  `derive_obligations.derive_dependencies`, `experiment_target.load_fixed_target_obligations`.

## Verdict: NO-GO for the bounded recursive-planning pilot on this base

One P0 and the falsified half of the central negative claim must close first. After the
fixes in [Findings](#findings) the base is sound — the machinery is small, mostly
fail-closed, and the EDGES half of the gate is genuinely self-enforcing (demonstrated on a
real tree). But today a hand-authored obligation set can again reach a snapshot with no
justification (F1), and for two of the three catalogued axes the "declaration that stops
being necessary starts failing on its own" claim is false by construction (F2). Those are
exactly the properties the pilot's declarations will lean on.

Minimum to flip to GO: F1, F2, F3 (one-line and measurement fixes); F4–F6 should ride along.

> Superseded as a gate decision by [Re-review round 1](#re-review-round-1): the fixes in
> `cfdfbb4` were verified, two new findings (R1, R2) remain, and the round-1 verdict is
> **conditional GO**. The section below records round 0 as executed.

## Ruling on the predicate's permissiveness

**"Named axes must be measured, at least one, extras unnamed" is the wrong admission rule.
It does let a declaration carry unclaimed divergence, and the exploit is not marginal.**
Demonstrated: a declaration admitted naming only `ALLOCATION` while carrying a false
top-level edge *and* a nested subtree with a dependency on a non-existent sibling
(`/tmp/kilo/probes/probe_a.py`, "C-of-concern-1"). And a declaration whose top level is
identical to derivation is admitted on a vestigial nested child alone ("A-nesting.0"). A
declaration can rest almost entirely on undeclared divergence and be kept alive by a token
axis. The brief's question is answered: **yes, and it is a gate defect**, not the
acceptable cost of avoiding spurious claims.

**Substituted rule:** admissible iff `set(non_derivable_axes) == axes_present` (exact
equality), plus the existing non-empty-reason and catalogued-name checks.

Failure it closes: token-axis admission (the named set stops being a claim about *some*
divergence and becomes a complete account of *all* divergence, which is what "mechanically
justified" must mean for the field to be auditable). The cost the implementer names is real
but small: a declaration that incidentally diverges on an axis must say so in the rationale.
That is one clause of prose against an unbounded smuggling channel.

Rider no admission rule can fix: for `NESTING` and `ALLOCATION`, "measured" currently means
a structural property of the declaration, not a diff against derivation (F2). Even
`named == measured` would leave those axes tautological. Either measure all three axes
against `derive_obligations`' live output, or re-specify `NESTING`/`ALLOCATION` as
structural facts and rewrite the gate clause to say so honestly.

## Findings

### F1 — P0 — `obligations_source="DERIVED"` re-opens the hand-authored hole

**Guarantees violated:** 2 ("There is no `obligations=` bypass"), 1 ("Supplying
`obligations` implies `DECLARED`"). `_resolve_obligation_source` lets the explicit label
override the implication (`src/orchestrator/experiment_target.py:364-371`), and
`build_target` only derives when `obligations is None` (`:490`). The supplied structure is
never fed to `is_admissible` (that is gated on `obligations_source == "DECLARED"`), and
`derive_obligations` never produces the snapshot's structure.

Reproducer (`/tmp/kilo/probes/probe_ab.py`, B1):

```python
build_target(repo, commit, ..., obligations=handmade, obligations_source="DERIVED")
```

Observed: **built**, `target.obligations_source == "DERIVED"`, the hand-authored structure
(false edge, narrowed criteria) is the snapshot. Expected: `ExperimentError` — a
hand-authored set must be `DECLARED` and justified. This is precisely the pre-option-(e)
state: a declaration indistinguishable from a derivation, and the Phase 4 exit ("no
hand-authored obligations") satisfiable by assertion.

Regression test: the B1 call must raise `ExperimentError` mentioning the
source/obligations contradiction; `obligations=` with `obligations_source="DERIVED"` in any
combination (including empty tuples) must never build.

### F2 — P1 — the diff self-tracks only for `EDGES`; `NESTING`/`ALLOCATION` never outlive their justification

**Guarantees violated:** 4 ("measured against live policy, not a hard-coded checklist…
starts failing without any code or checklist change") and spec
[S5](phase4-option-e-implementation-spec.md#s5-predicate) /
[S8](phase4-option-e-implementation-spec.md#s8-admissibility-and-absorption-principle)
("the measured diff self-tracks when those become expressible").
`measure_divergent_axes` (`src/orchestrator/derive_obligations.py:460-494`) measures
`EDGES` as a real diff against `derive_dependencies`, but `NESTING` as *presence of a
nested key in the declaration* (`:482-483`) and `ALLOCATION` as *`criterion_ids !=
tuple(acceptance_criteria)`* (`:484-493`). Neither consults `derive_obligations`. When
derivation gains the capability, the axes stay "measured" and the declaration stays
admitted.

Reproducer (`probe_a.py`): monkeypatch `derive_obligations`/`derive_dependencies` so the
live policy produces exactly the declared nesting (resp. allocation), then rebuild with the
same declaration. Observed: **still built** both times. Expected: refused — the axis has
become derivable, so the declaration is no longer necessary. Control "A-edges.3": with
`derive_dependencies` matching the declared edges the build **is** refused — guarantee 4
holds for `EDGES` only (1/3).

Regression test: for each axis, patch the derivation policy to the declared structure and
assert the declaration starts failing; today this passes only for `EDGES`.

### F3 — P1 — a cosmetic permutation manufactures admissibility

**Guarantee violated:** 3 ("Admissibility requires measured divergence"). The `ALLOCATION`
comparison is an order-sensitive tuple compare. Reordering one obligation's `criterion_ids`
with no semantic difference measures `ALLOCATION` and admits the set.

Reproducer (`probe_ab.py`, H "criterion_ids order permutation only"): derived-identical
declaration except `criterion_ids=("AC-BETA", "AC-ALPHA")`, named `("ALLOCATION",)`.
Observed: **built**. Expected: refused (nothing to justify) —
[S4](phase4-option-e-implementation-spec.md#s4-projection) rule 4 excludes spelling-only
differences; order is spelling.

Regression test: permuted-criterion and permuted-`acceptance` declarations must both refuse
(the `acceptance` permutation already does — the asymmetry is accidental).

### F4 — P1 — `budgets=` is dead input on the `DECLARED` path; the fixture's `budgets:` map is decorative

**Guarantee violated:** 9 ("Budgets are declared input on both paths, keyed by component
name, with unknown keys refused"). `measure_divergent_axes` accepts `budgets`
(`src/orchestrator/derive_obligations.py:467`) and never reads it; `_resolve_budgets` is
reached only via `derive_obligations` (derived path). On the declared path an unknown key is
silently ignored. The fixture manifest's top-level `budgets:` block changes neither
`contract_hash` nor `snapshot_hash` when mutated.

Reproducer: `probe_ab.py` B9c (`obligations=…, budgets={"nope": 1.0}` → **built**, ignored)
and `probe_f.py` "mutate a top-level budgets map entry" →
`(contract_same=True, snapshot_same=True)`. Expected: refused ("budget names no declared
component"), and a budget mutation to move `snapshot_hash`.

Regression test: both paths must refuse unknown budget keys; mutating the manifest's
`budgets` map must change the snapshot identity, or the map must be deleted from the
manifest (it currently misleads: it is not the budgets channel).

### F5 — P1 — S6 step 1 "acceptance shape" is named in the spec and absent from the code

**Guarantee violated:** 6 (shape must fail at the boundary, not inside
`plan_decomposition`; [S6](phase4-option-e-implementation-spec.md#s6-validation-order)
normatively lists "acceptance shape"). `_validate_obligation_shape` never inspects
`acceptance`.

Reproducers (`probe_fix.py`): `acceptance="not-a-sequence"` → build accepts,
`plan_decomposition` raises `ValueError`; `acceptance=None` → accepts, plan raises
`TypeError: 'NoneType' object is not iterable`; `acceptance=({"mandatory": True},)` →
accepts, plan produces `[{"mandatory": True}]` — a criterion with no `id` inside the child
contract. Expected: `ExperimentError` at shape for all three.

Regression test: matrix over malformed `acceptance` (string, `None`, missing, non-mapping
entries, entries without `id`) asserting `ExperimentError` from `build_target`.

### F6 — P1/P2 — unvalidated dependency names are silently dropped

**Guarantees violated:** 5/6/7 (declared structure is validated; nested structure must not
reach `plan_decomposition` unvalidated). `_projected_edges` drops `depends_on` ids absent
from the top-level child map (`src/orchestrator/derive_obligations.py:452-455`) and
`plan_decomposition` drops any id not in its `id_map`
(`src/orchestrator/trial_driver.py:88-91`), with no check anywhere that a named dependency
exists.

Reproducer (`probe_ce.py` P4/P5): `depends_on=("ghost", "beta")` and a nested
`depends_on=("ghost",)`. Observed: **built**; `plan_decomposition` yields
`deps=("RUN-1-beta",)` / `deps=()` — the ghost is gone. Expected: refused at shape or
projection.

Regression test: a `depends_on` naming no sibling (top-level or nested) must raise
`ExperimentError`.

### F7 — P2 — a scope matching owned *and* unowned files is accepted

**Guarantee violated:** 5 / [S4](phase4-option-e-implementation-spec.md#s4-projection)
rule 1 ("every matched file must be owned by exactly one component").
`owners.discard(None)` (`src/orchestrator/derive_obligations.py:411`) removes unowned
matches before the singleton check.

Reproducer (`probe_fix.py` C1b): components
`(("alpha", "src/alpha/mod.py"), ("beta", "src/beta/mod.py"))`, files `src/alpha/mod.py` +
`src/alpha/extra.py`, scope `src/alpha/**`. Observed: **built** (`extra.py` silently dropped
from the accounting). Expected: refused. Reachable for file-exact component layouts — which
the greet target uses.

Regression test: a scope matching exactly one owned and one unowned file must raise
`DerivationError`/`ExperimentError`.

### F8 — P2 — duplicate top-level `child_id` is accepted

Two obligations with `child_id="twin"` on different components build; `plan_decomposition`'s
`id_map` collapses both onto one node id (`src/orchestrator/trial_driver.py:75`), emitting
two children with the same `node_id` (`probe_ce.py` C2). S7 defers nested *criteria*
uniqueness to the pilot, but nothing covers child-id identity at either level.

Regression test: duplicate `child_id` at top level and nested must raise.

### F9 — P2 — nested `obligations: <int>` escapes as `TypeError`

**Guarantee 7** (recursive validation, `ExperimentError` discipline).
`nested = obligation.get("obligations") or ()` then `for obligation in 5`
(`src/orchestrator/experiment_target.py:332`) raises `TypeError: 'int' object is not
iterable`. Fail-closed but wrong exception class (`probe_fix.py` E9b). A bare string is
refused (per-character iteration hits the mapping check) — the message is misleading but the
behaviour is closed.

Regression test: non-iterable nested `obligations` must raise `ExperimentError`.

### F10 — P2 — a nested scope escapes its parent's scope

[S7](phase4-option-e-implementation-spec.md#s7-nested-validation) non-vacuity covers
criteria and budgets only; a nested `scope: "src/beta/**"` under the `alpha` parent claims
the sibling's files and builds (`probe_fix.py` E15). Not a violation of guarantee 7 as
written — a gap in S7 itself that the pilot will inherit.

Regression test: nested scope not contained in the parent scope must raise (or S7 must
record the asymmetry as it does for greenfield scopes).

### F11 — P2 — S11 row "builder negatives" is half-done

`tests/test_phase2_general_target.py:266-311`: the base uses `components=(("c", "c/**"),)`
and `scope: "c/**"` against `_calc_repo`, which lays out `calc/core.py` — the scope matches
**no tracked file** ("a real scope" is false), and with `acceptance_criteria=("AC",)` the
named `ALLOCATION` axis is never measured (`("AC",) == full`) — the base is
**inadmissible** (`probe_ab.py` D1, with a `c/**`-bearing tree: `refused:inadmissible`). Each
negative reaches its named rule today only because every case raises before
projection/predicate. Any future case that reaches those stages will "pass" for the wrong
reason. Fix: use `calc/**` globs and a two-criterion base so `ALLOCATION` is actually
measured.

### F12 — P2 — S11 row "fixed-target declaration" pins the axes only as a subset

`tests/test_derive_obligations.py:348-349` asserts
`set(non_derivable_axes) <= {"EDGES", "NESTING", "ALLOCATION"}` and truthiness. Dropping
`EDGES` from the manifest while the ordering remains undeclarable would still pass the test
(the build would still admit: `named ⊆ measured`). Pin the equality set.

## Claims verified (ten guarantees)

| # | Claim | Falsification attempt | Outcome |
|---|---|---|---|
| 1 | Typed-field discipline | B1, B3–B8, B10: `DERIVED`+obligations+axes/reason, missing/empty/whitespace reason, uncatalogued/whitespace/bare-string axes, generator obligations, bad enum | **Falsified (F1)** for "supplying obligations implies `DECLARED`" (overridable label). Rest attacked, not falsified: `DERIVED` with axes/reason refused at the field boundary; `DECLARED` with empty/whitespace reason refused; uncatalogued/whitespace/bare-string axes refused at the predicate (`refused:inadmissible`, never a snapshot); generator refused before consumption |
| 2 | Derivation always recomputed; no `obligations=` bypass | B1, B9c, I1, I2, G3 | **Falsified (F1)**: `obligations=` + `obligations_source="DERIVED"` reaches a snapshot with hand-authored structure. Attacked, not falsified elsewhere: a raising derivation (overlap) is fatal with a supplied declaration (G3); `derive_obligations` cannot return a narrowed set (I1); the omitted-obligations path yields the full derived set (I2) |
| 3 | Admissibility requires measured divergence | B2b, H matrix (description/budget/spelling/acceptance-order/criterion-order) | **Falsified (F3)** via criterion-order permutation. Attacked, not falsified: identical-to-derived refused with "not admissible"; description, budget, and child-id spelling alone refused (`measured divergence []`) |
| 4 | Diff measured against live policy; self-enforcing | **A-edges.1/.2 real tree** (imports make `report → (parse, render)` real): `build_target` **and** `build_fixed_target` refuse — the gate self-enforces for `EDGES`. A-edges.3 control (patched `derive_dependencies`): refused. A-nesting.1 / A-alloc.1 (derivation learns nesting/allocation): still admitted | **Falsified (F2)** for `NESTING`/`ALLOCATION`. Holds for `EDGES` with the real-tree demonstration the brief demanded |
| 5 | Projection is a bijection onto components | C1b–C7: mixed owned/unowned scope, duplicate `child_id`, double claim, non-Python-only scope, superset scope, unclaimed component, greenfield scope | **Falsified (F7, F8)**. Attacked, not falsified: zero matched files, multi-component scope, double claim, unclaimed component all fail closed (`matches no tracked file` / `spans components` / `claimed by both` / `every component must be claimed`) |
| 6 | Validation order shape → coverage → projection → predicate | D2 (coverage + projection both bad → coverage error first), D3 (missing scope → shape error first), P1b/P2b/P2c (acceptance shapes) | **Falsified (F5)** on the boundary guarantee: the order itself attacked, not falsified (D2/D3 confirm the normative sequence), but S6's "acceptance shape" stage is unimplemented so malformed acceptance reaches `plan_decomposition` |
| 7 | Nested validation + non-vacuity | E1–E14, E2b, E9b/c, E15 | **Falsified (F9, F10)**. Attacked, not falsified: empty nested criteria, criterion outside the parent, undeclared criterion, negative/NaN/inf/bool budget, non-mapping entry, bare-string `child_id`/scope/criteria — all `ExperimentError` at shape; depth-3 nesting builds with the chain checked |
| 8 | Fixture contract byte-identical | F0a–F0e: pinned literal `sha256:157bbd15…f40848` matches `build_fixed_target` **and** `_target_contract_hash()`; `trial_scripts` keeps 1003/1004 kinds; `repository` absolute; `report → (parse, render)` + two-level nesting intact | **Attacked, not falsified.** Moving `_ROOT_OBLIGATIONS` into the YAML manifest preserves contract identity (canonical JSON: sorted keys, tuples ≡ lists) |
| 9 | Budgets declared input on both paths, unknown keys refused | B9a/b (derived path refuses unknown and near-miss keys — holds), B9c (declared path), F matrix on the manifest's `budgets` map | **Falsified (F4)** on the declared path. Holds on the derived path |
| 10 | Typed fields in `snapshot_hash`, out of `contract_hash` | F matrix (axes/reason mutations: contract same, snapshot changes), F10 post-build `dataclasses.replace`, F11 DERIVED vs DECLARED identity pair; S10 evidence audit: nothing under `evidence/` keys on either hash | **Attacked, not falsified** (the one F-matrix anomaly is F4: the dead `budgets` map moves neither hash, which is a guarantee-9 defect, not a hashing defect) |

## Every `DECLARED` target in the tree

| Declaration | Measured axes (probe) | Named axes | Minimal? |
|---|---|---|---|
| Fixture manifest `src/orchestrator/data/fixed-target-obligations.yaml` (`TARGET-EXPERIMENT-1`) | `EDGES`, `NESTING`, `ALLOCATION` (`probe_a.py` A-edges.0) | `EDGES`, `NESTING`, `ALLOCATION` | **Yes, minimal and necessary.** Each axis is load-bearing: `EDGES` carries the `report → (parse, render)` knowledge that no stub import expresses; `NESTING` the two-level recursion surface; `ALLOCATION` the per-component criterion split. Smaller *honest* claims do not exist (dropping any name leaves real divergence unnamed); smaller *admitted* claims do exist because of the permissive predicate — that is F3 and the ruling above, not a defect of this row. Not replaceable by derivation without loss (derivation drops ordering and nesting and stamps full criteria — the manifest's own rationale, verified against the stubs: the only cross-component importer, `tests/run_visible.py`, is unowned) |
| Greet target, `tests/test_phase2_general_target.py:566-630` (`TARGET-GREET-1`) | `ALLOCATION` only (measured on the greet tree: derived edges empty) | `ALLOCATION` | **Yes, minimal and necessary.** Derivation stamps both mandatory criteria on every child; the `core` leaf patches only `greet/core.py` and could never satisfy mandatory `AC-UTIL`. Not replaceable by derivation |
| Builder-negatives base, `tests/test_phase2_general_target.py:275-283` (test scaffold) | ∅ (base is inadmissible — F11) | `ALLOCATION` | **No.** The named axis is never measured and the scope matches nothing. A scaffold, not a real target, but it is exactly the "declaration that needs no declaration" the gate should refuse — and would refuse if it reached the predicate. Fix with F11 |

## S11 disposition table — row by row

| Row | Disposition | Verdict |
|---|---|---|
| `_ROOT_OBLIGATIONS` (`experiment_target.py:170-221`, uses `:307`, `:484`) → manifest; route through `build_target` | Deleted; `load_fixed_target_obligations()` added; `build_fixed_target` routes through `build_target` with `trial_scripts=TRIAL_SCRIPTS` | **Done.** F0b confirms the calibration devices survive |
| `trial_driver.py:65`, `experiment.py:72` dead imports → delete | Diff confirms the `_ROOT_OBLIGATIONS` import removed from both; "re-export the loader if the facade needs it" — condition not triggered (tests import `experiment_target` directly) | **Done** |
| `test_phase2…:116-127` calc → `obligations=None` | Derived; `:320` still asserts `child_id == "calc"`; derived-equivalent declarations refused (B2b) | **Done** |
| `test_phase2…:566-613` greet stays `DECLARED` on `ALLOCATION` | Present with reason; measured `ALLOCATION` only; minimal (see table above) | **Done** |
| `test_phase2…:268-311` builder negatives → real globs/scopes/axes | Cases reach their named rules today, but the scope matches nothing and the axis is unmeasured | **Half-done (F11)** |
| `test_phase3…:186-212` self target → `obligations=None` | Derived; the oracle manifest path is independent of `target.obligations` | **Done** |
| `test_derive_obligations…:222-249` override pin → admitted/refused pair | `test_a_divergent_override_is_admitted_and_an_equivalent_one_refused` — both halves present and meaningful | **Done** |
| `test_derive_obligations…:268-276` fixed-target declaration | Manifest path, ordering, nesting, contract pin asserted; axes pinned only as a subset | **Done with F12** |

No migrated call site silently kept a declaration that no longer needs one (the two real
declarations are minimal; the third is a scaffold — F11).

## Gate clause vs enforcement

[docs/self-host.md](../self-host.md#phase-4-general-decomposition) gate clause and its "is" claims:

| Clause text | Enforced? |
|---|---|
| "admitted only when it is **measurably divergent from what derivation produces**" | **Overclaims.** True for `EDGES`; `NESTING`/`ALLOCATION` are measured against the declaration's own shape and the full-set rule (F2) |
| "names only axes that were measured" | Yes (`is_admissible`, `src/orchestrator/derive_obligations.py:513`) — and the clause honestly says *only*, not *all* |
| "and carries a rationale" | Yes |
| "Necessity of a declared *edge* is not statically provable and is **not claimed**" | Honest non-claim; G5 confirms a spurious edge is indistinguishable from a necessary one (consistent) |
| "`_commands_for` and `_SOLUTION_FILES` are out of scope on two grounds…" | Honest non-claim; the exclusion hides no decomposition defect — the drift pin `test_commands_for_keys_track_the_manifest_child_ids` keeps the command map aligned with the manifest's child ids (top-level and nested) |
| Status: "`build_target` **recomputes derivation on every build**" | **Overclaims** in the strong sense: `derive_obligations` is not recomputed when obligations are supplied (only `derive_dependencies` + projection + axis measurement), and F1 shows a build with no derivation at all |

## Disclosed concerns — attack results

| Concern | Probe | Result |
|---|---|---|
| 1. Named axes ⊆ measured (permissiveness) | A-nesting.0, C-of-concern-1 | **Confirmed as a gate defect** — see the ruling above |
| 2. `EDGES` measured only where the projection can express it | G6 | Confirmed: a declared edge to a nested child id projects to nothing and reads as *no edge*, not as divergence (admitted naming only `NESTING`). Acknowledged, not novel |
| 3. Fixture's `report → (parse, render)` carries intended-solution knowledge | A-edges.0, F0d | Confirmed: verified against the stubs; kept as declared, and the gate self-enforces when the knowledge becomes real in the tree (A-edges.1/.2) |
| 4. `_module_candidates` prefers `pkg/sub.py` over `pkg/sub/__init__.py` | G8 | Confirmed: when the two candidates sit in different components the choice is the candidate order (`user → flat` observed) |
| 5. The scan reads the whole tracked tree, not `owned_scope` | G7 | Confirmed: a component glob outside `owned_scope` still produces edges (`helper → alpha`); `owned_scope` is never consulted by the scanner |
| 6. One `git ls-tree` per `_python_files` call (amplification) | inspection | Confirmed by call-graph: ≥3 `ls-tree` invocations per `build_target` (derived path: `derive_obligations` → `derive_dependencies`, plus `measure_divergent_axes`' own `derive_dependencies` and `project_declared_obligations`). Not timed |
| 7. Home-grown relative-import resolution | G9, G10 | Confirmed: `from pkg.a import *` yields an edge; a `try/except ImportError`-guarded import still reads as an edge; `from ...pkg import a` from depth 1 climbs out and is dropped; `from . import` resolves with no `__init__.py` |

## Residual unknowns

- Downstream of `plan_decomposition`, what a live run does with the unvalidated shapes F5/F6
  admit (e.g. `[{"mandatory": True}]` criteria) — the escape at the boundary is
  demonstrated; the run-level consequence is not.
- `decomposition._ensure_acyclic` end-to-end on a derived cycle (out of the reviewed
  surface; the derivation records both directions — G1).
- Concern 6 confirmed by inspection but not timed.
- The pilot's deferred validator (S7: nested criteria uniqueness/partition) is
  unimplemented — the handoff of F6/F8/F10 cannot be checked.
- Nondeterministic `Sequence` subclasses as `obligations` (pathological, not probed);
  duplicate axis tuple entries (`("EDGES", "EDGES")`) are stored un-normalized (cosmetic).
- Full `check-tests` (non-`--fast`) not run inside the detached worktree; the full suite was
  run at the tip workspace (770 passed) and the three touched files at `d78862d`
  (33 passed). The `d78862d`→tip delta is a dead alias and an unused import (verified in
  `278b1b1`).

## Reproduce everything

```bash
git worktree add --detach /tmp/kilo/phase4-review d78862d
ln -sfn /home/ruben/Projectos/meta-project/orchestrator/.venv /tmp/kilo/phase4-review/.venv
# baselines (main workspace, tip):
#   .venv/bin/python -m pytest -q; scripts/check-tests --fast;
#   scripts/check-docs; scripts/check-static
# touched tests at d78862d:
cd /tmp/kilo/phase4-review && PYTHONPATH=/tmp/kilo/phase4-review/src \
  /home/ruben/Projectos/meta-project/orchestrator/.venv/bin/python -m pytest -q \
  tests/test_derive_obligations.py tests/test_phase2_general_target.py \
  tests/test_phase3_project_oracle.py -p no:cacheprovider
# probes (read-only against the worktree; throwaway repos in /tmp):
cd /tmp/kilo/probes
/home/ruben/Projectos/meta-project/orchestrator/.venv/bin/python probe_ab.py    # B, D, H, I
/home/ruben/Projectos/meta-project/orchestrator/.venv/bin/python probe_a.py     # A + concern-1 exploit
/home/ruben/Projectos/meta-project/orchestrator/.venv/bin/python probe_ce.py    # C, E, plan_decomposition
/home/ruben/Projectos/meta-project/orchestrator/.venv/bin/python probe_fix.py   # C1b, E2b, E9b/c, P1-P3, E15, F11
/home/ruben/Projectos/meta-project/orchestrator/.venv/bin/python probe_f.py     # fixture identity matrix
/home/ruben/Projectos/meta-project/orchestrator/.venv/bin/python probe_g.py     # G + concerns 2/4/5/7
```

No source edits, no network, no credentials. Host left clean.

## Implementer's remediation (2026-09-30)

All twelve findings are closed and the review's substituted predicate is in
place. Verification after the fixes: full suite **780 passed**; `scripts/check`,
`scripts/check-static` and `scripts/check-docs` all rc 0 (239 links); the fixed
target's `contract_hash` is still byte-identical
(`sha256:157bbd15…f40848`) with its three axes unchanged.

**Predicate ruling adopted.** `is_admissible` now requires
`set(non_derivable_axes) == axes_present` — exact equality, not subset. The
named set becomes a complete account of the divergence. The fixture and the
greet target both name exactly what is measured, so neither needed a change.

**F1 (P0).** The source label can no longer override the implication:
`obligations_source` that contradicts the supplied obligations raises
`ExperimentError` naming the contradiction. `DECLARED` remains accepted, since
that is the consistent label the fixture manifest passes.

**F2.** All three axes are now diffs against `derive_obligations`' live output.
`NESTING` compares the declared nesting shape with the derived one;
`ALLOCATION` compares per-child criterion sets. Previously both were structural
properties of the declaration and could never self-track. Pinned by
`test_f2_nesting_and_allocation_self_track_against_live_derivation`, which
patches derivation to match the declaration and asserts the measured set
becomes empty.

**F3.** Criterion comparison is order-insensitive (`frozenset`), so a
permutation is spelling and no longer manufactures an `ALLOCATION` divergence.

**F4.** `budgets` reaches `_resolve_budgets` on the declared path too, because
`measure_divergent_axes` now calls `derive_obligations`. The manifest's
decorative top-level `budgets:` block is **deleted**: for a declared set the
per-obligation `budget` fields are the channel, and the block was misleading —
it read as the `budgets=` argument, which does not reach a declared set, and
mutating it moved neither hash.

**F5.** `_validate_acceptance` implements the acceptance shape S6 named: a
sequence of mappings, each with a non-empty string `id`.

**F6.** `_validate_depends_on` refuses a dependency naming no sibling, and
`_projected_edges` no longer drops unknown names. The projection is now strict
in both places rather than silent.

**F7.** A scope matching files no component owns is refused; the previous
`owners.discard(None)` let a scope reach past its component and drop files out
of the accounting.

**F8.** Duplicate top-level `child_id` is refused in the projection.

**F9.** A non-iterable nested `obligations` raises `ExperimentError` at shape
instead of escaping as `TypeError`.

**F10.** A nested scope must be contained in its direct parent's, compared on
glob-free prefixes. The first attempt compared in the wrong direction and
rejected the fixture's own legitimate `src/report/format.py` inside
`src/report/**`; the pin caught it.

**F11.** The builder-negatives scaffold is now a real two-component target
(`calc/core.py`, `calc/__init__.py`) with two criteria, so `ALLOCATION` is
genuinely measured and the base is admissible. The test asserts
`build_target(**base)` succeeds, so a future case that reaches the predicate
cannot pass for the wrong reason.

**F12.** The fixed-target test pins the axis set by **equality** against the
freshly measured set, not by subset.

**Gate clause.** `docs/self-host.md` no longer claims the loose form. The status
is now "partially done, under remediation" pending re-review, and the clause
states that the named axes must *equal* the measured divergence.

Not addressed, and stated rather than hidden: the review's disclosed concerns 2
(a declared edge to a nested child id projects to nothing), 4 (module-candidate
order), 5 (the scan reads the whole tracked tree, not `owned_scope`), 6 (three
`ls-tree` runs per build — now four, since the axis measurement derives), and 7
(home-grown relative-import resolution) all remain as disclosed. The greenfield
asymmetry (S4) is unchanged and accepted fail-closed. A re-review should say
whether the remaining P2s need closing before the pilot, or whether they are
correctly the pilot's inherited surface.

## Re-review round 1

Re-review of the fix commit `cfdfbb4` ("Close the option (e) adversarial review findings
F1-F12") against the round-0 findings above. Everything below was re-verified empirically
through the same real entry points, with the round-0 probes re-run at HEAD
(`/tmp/kilo/probes-rr/`).

Baselines at `ee85924`: `pytest -q` 780 passed; `check-tests --fast` 750 passed /
30 deselected; `check-docs` 239 links OK; `check-static` rc 0.

### Verdict: **conditional GO** — two findings to close first (R1, R2)

The P0 is genuinely closed, the central claim is now true for all three axes, and the
review's predicate ruling is in force in both directions. R1 and R2 are small (one
measurement-keying fix and a spec sync) and neither undermines the gate's shape.

### Round-0 findings re-verified

| Finding | Fix verified | Evidence |
|---|---|---|
| F1 (P0) DERIVED-label bypass | **Closed** | `obligations=handmade, obligations_source="DERIVED"` refused with a source/obligations contradiction; the reverse contradiction (`obligations` omitted + `"DECLARED"`) also refused; the consistent pairs still build |
| F2 non-self-tracking NESTING/ALLOCATION | **Closed** | With `derive_obligations` patched to produce the declared nesting (resp. allocation), the declaration now starts failing (`refused:inadmissible`); the EDGES control still refuses on a real tree (imports making `report → (parse, render)` real) |
| Ruling (exact equality) | **Adopted and enforced** | Under-named (token `ALLOCATION` + unclaimed `EDGES`/`NESTING`) refused; over-named refused; naming exactly the measured set admits. The concern-1 smuggle (false edge + nested subtree on a token axis) is refused |
| F3 cosmetic permutation | **Closed for order/wording; residual R1** | criterion-order, description-only, and budget-only differences all refuse; child-id spelling still manufactures `ALLOCATION` — see R1 |
| F4 budgets dead on DECLARED path | **Closed** | Unknown budget key refused on the declared path (via the measurement wrapper: `cannot measure obligation divergence … budget names no declared component`); the decorative manifest `budgets:` block is deleted (per-obligation fields are the channel) |
| F5 acceptance shape | **Closed** | String/`None`/id-less `acceptance` all refused at the builder (`acceptance must be a sequence of mappings`, `acceptance entry needs a non-empty string id`). Note: `acceptance` is now mandatory — a missing key is refused, which is stricter than S6's wording and fine |
| F6 ghost `depends_on` | **Closed** | Top-level and nested unknown dependency names both refused (`depends_on names no sibling obligation`). Concern 2's silent-drop form is gone; its other half (nested-internal edges never projected) is in the inherited surface |
| F7 unowned matched files | **Closed** | A scope matching one owned and one unowned file is refused on the ownership rule (`matches files no component owns`) |
| F8 duplicate `child_id` | **Closed** | Refused (`duplicate declared child_id … must be uniquely identifiable`). Nested-level duplicates remain deferred to the pilot's validator (S7) |
| F9 nested `obligations: <int>` | **Closed** | `ExperimentError` (`obligations must be a sequence, got int`), no `TypeError` escape |
| F10 nested scope escape | **Closed** | Escape refused (`nested obligation 'part' scope … escapes its parent …`); the fixture's own nesting still admits (the wrong-direction regression the implementer reported is guarded) |
| F11 builder-negatives scaffold | **Closed** | Base reworked to two real components (`calc/core.py`, `calc/__init__.py`) with per-leaf allocation, and the test now asserts `experiment.build_target(**base)` succeeds |
| F12 axis pin | **Closed** | `set(snapshot.non_derivable_axes) == set(measured) == {"EDGES", "NESTING", "ALLOCATION"}` |
| Guarantee 8 fixture identity | **Holds** | `contract_hash` still `sha256:157bbd15…f40848`; `trial_scripts` keeps 1003/1004; measured axes equal the named set |

### R1 — P1 — child-id spelling still manufactures `ALLOCATION` (F3-family residual)

`_allocation_shape` and `_nesting_shape` (`src/orchestrator/derive_obligations.py`) key the
comparison by raw `child_id`, while derived child ids are component names. S4 rule 4
excludes child-id spelling from the comparison, so a pure rename must not move any axis —
but it does: rename one child id, keep full criteria and no edges, name `ALLOCATION`, and
the set is admitted with zero semantic divergence.

Reproducer (`/tmp/kilo/probes-rr/probe_rr.py`, R1a; refined probe "R1a one renamed
child_id only"): derived-identical declaration with `child_id="alpha-x"` for one child,
`non_derivable_axes=("ALLOCATION",)`. Observed: **built**;
`measure_divergent_axes` reports `['ALLOCATION']` for the rename alone. Expected: refused —
nothing to justify.

Fix: key both shapes by projected component (via `project_declared_obligations`) rather
than by `child_id`, or normalise ids out of the shape keys. Regression test: a spelling-only
rename (top-level, and once nesting is derivable, nested) must measure `[]` and be refused.

### R2 — P1 — the normative spec still specifies the superseded predicate

`docs/research/phase4-option-e-implementation-spec.md` was not updated by the fix commit:
[S5](phase4-option-e-implementation-spec.md#s5-predicate) line 147 still says
`set(non_derivable_axes) <= axes_present` and line 157 still argues "Unnamed-but-divergent
axes stay permitted; requiring exact match would force spurious claims"; S6 step 4 still
says "axes subset and reason (S5)"; the [Tests](phase4-option-e-implementation-spec.md#tests-normative)
section item 2 still says "its axes are a subset of the measured axes_present". The
implementation now uses exact equality and diffs all three axes against
`derive_obligations`' live output. The spec is normative, so code and spec disagree on the
gate's central rule — the same class of defect the round-0 clause audit caught in prose.

Fix: update S5's pseudocode and rationale paragraph, S6 step 4, and Tests item 2 to the
substituted rule, and note under S4 rule 4 that the comparison is spelling-insensitive once
R1 lands. Docs-only; `check-docs` must stay rc 0.

### Ruling on the inherited surface (disclosed concerns 2/4/5/6/7)

**Accepted for the pilot as recorded**, with one condition (S7's validator ownership):

- **Concern 2 residual** (nested-internal edges are never projected or measured): bounded —
  nested edges are shape-validated and existence-checked (F6), but cannot diverge
  measurably. The pilot's validator owns nested uniqueness/partition per S7; record that
  nested edge honesty is not gate-enforced.
- **Concern 4** (module-candidate ordering) and **7** (home-grown relative imports): scanner
  accuracy only; they can distort which edges derivation *observes*, and S9 already
  disclaims edge necessity, so they cannot make a dishonest declaration pass.
- **Concern 5** (the scan ignores `owned_scope`): same reasoning; `owned_scope` is a
  delegation boundary, not an observation boundary, and the projection gate only reasons
  about component-owned files.
- **Concern 6** (git amplification): performance only. Note it grew slightly — the
  measurement now runs `derive_obligations` as well as `derive_dependencies` and the
  projection, so a declared build performs more `ls-tree` calls than round 0.

None of these can re-open the hand-authored hole or keep a dead declaration alive; each is
disclosed and bounded. If the pilot's declarations start depending on nested edge ordering,
concern 2 must be re-opened.

### Residual unknowns

- R1's nested-id variant could not be isolated while nesting itself diverges (the
  construction measures `NESTING` for both spellings); the manufacturing case is the
  top-level rename, confirmed. Once derivation can nest, re-probe the nested spelling case.
- Everything else from round 0's residual list stands (downstream behaviour of unvalidated
  shapes is now moot for acceptance — F5 closed it at the boundary; `_ensure_acyclic`
  end-to-end and the deferred validator remain unexercised).

### Reproduce round 1

```bash
# probes (round-0 suite re-run at HEAD, plus the residual-gap probes):
cd /tmp/kilo/probes-rr
/home/ruben/Projectos/meta-project/orchestrator/.venv/bin/python probe_rr.py
# baselines at HEAD:
.venv/bin/python -m pytest -q; scripts/check-tests --fast; scripts/check-docs; scripts/check-static
# the fix commit and this report:
git show cfdfbb4; git show ee85924
```

## Implementer's response to round 1 (2026-09-30)

Both findings are closed. **781 passed**; `scripts/check`, `scripts/check-static`
and `scripts/check-docs` all rc 0 (243 links). The fixed target's `contract_hash`
is still byte-identical with its three axes equal to the measured set.

**R1 closed.** `_nesting_shape` and `_allocation_shape` now take a
`child_to_component` map and key by **projected component**, not by raw child id.
A derived child id is always the component name, so keying the declared side by
`child_id` let a pure rename register as structural divergence: rename a child,
claim `ALLOCATION`, and be admitted with zero semantic difference. Nested child
ids are still compared verbatim, which is sound because the derived side produces
no nesting at all — any nesting is real divergence, and renaming a nested child
cannot change that. Pinned by `test_r1_a_pure_rename_does_not_manufacture_allocation`,
which asserts a derived-equivalent set under new names measures no axis and is
refused, and — so the pin is not vacuous — that a genuine allocation divergence
still measures under the same rename.

**R2 closed.** S5 of the implementation spec now specifies exact equality and
reproduces the shipped predicate. The original `named <= measured` text and its
"requiring exact match would force spurious claims" rationale are retained as a
labelled amendment with the review's falsification, rather than deleted, so the
reason the rule changed stays legible. S5's pseudocode also now expresses all
three axes as diffs against `derive_obligations` keyed by component, matching the
shipped code.

**Re-review condition recorded.** S7 now names the nested-edge asymmetry
explicitly: a nested obligation's own `depends_on` is shape-validated and checked
for naming a real sibling, but its *honesty* is not gate-enforced, because a
declared edge to a nested child id projects to nothing and reads as "no edge"
rather than as divergence. The asymmetry is distinct from S9's top-level edge
non-claim, and S7 carries the re-open trigger: if pilot declarations come to
depend on nested edge ordering, concern 2 must be re-opened and either
`derive_dependencies` must project nested structure or nested edges need their own
axis.

**Inherited surface accepted as recorded.** Concerns 2/4/5/6/7 stand unchanged
and bounded. S12 now notes that concern 6 grew slightly — axis measurement also
invokes `derive_obligations`, so a declared build runs the `ls-tree` scan
additional times — as a cost to revisit if per-target build time matters, not a
correctness defect.

## Re-review round 2 (closure)

Verification of `010e3dc` ("Close the option (e) re-review findings R1-R2"). Baselines:
`pytest -q` 781 passed; `check-tests --fast` 751 passed / 30 deselected; `check-docs`
243 links OK; `check-static` rc 0.

### Verdict: **GO** for the bounded recursive-planning pilot

| Finding | Fix verified | Evidence |
|---|---|---|
| R1 spelling manufactures `ALLOCATION` | **Closed** | Both shapes key by projected component (`child_to_component` in `measure_divergent_axes`). A derived-equivalent set under renamed child ids measures `frozenset()` and is refused; the renamed split set still measures `{'ALLOCATION'}` and builds — the pin asserts both directions and is not vacuous. Full rename of both children also measures nothing |
| R2 spec drift | **Closed** | S5's pseudocode now specifies exact equality and keys all three axis diffs by component; the original subset text is retained as a labelled **Amendment (re-review)** carrying the falsification. S7 records the nested-edge asymmetry (shape-validated, sibling-checked, honesty not gate-enforced) and the concern-2 re-open trigger; S12 records that concern 6 grew |

Nested child ids remain compared verbatim. That is sound **today** — derivation produces
no nesting, so any nesting is genuine divergence and a nested rename cannot manufacture an
axis that would not already be measured. Forward note for the S7 validator handoff: once
derivation can nest (the F2 self-tracking scenario), nested spelling must be excluded the
same way top-level spelling now is, or a nested rename will manufacture `NESTING` against a
derived nesting that differs only in nested ids. Not a defect on this base; recorded so the
pilot's re-baseline catches it.

The inherited surface stands as ruled in round 1: concerns 2/4/5/6/7 accepted and bounded,
with the nested-edge re-open trigger now in S7 rather than only in this report. Gate clause
and spec now say what the code does. **The next step is the pilot.**
