<!-- informative -->

# Reviewer Brief: Bounded Recursive-Planning Pilot — the Model Producer

## Mandate

Independently falsify the pilot's producer. The **guard** has cleared three
adversarial reviews and is accepted
([re-review 3](phase4-recursive-planning-pilot-re-review-3.md)); do not re-litigate
it except where the producer's use of it is wrong. The producer is new surface and
has cleared nothing.

Two commits are under review:

1. **`30b1527` — The pilot's model producer: propose, never trust.** P6, P7, the
   P8 wiring, and the producer's shape.
2. **`853d2a2` — Never lose a proposal record.** A P8 violation the implementer
   found while writing this brief, and fixed before sending it.

**The claim to attack.** A model may propose the child structure for an admitted
parent; it may not decide that structure. Concretely:

> Every path from a provider's output to a `DECOMPOSITION_ADMITTED` payload passes
> `admit_proposal`; a refusal produces no partial payload and no partial state; and
> every proposal — admitted or refused — produces exactly one instrumentation
> record naming the stage that actually refused it.

The two structural properties that matter are **the seam cannot be bypassed** and
**the record cannot be lost**. A pilot that records nothing on the paths that fail
is unmeasurable, and P8 exists because a pilot that cannot be measured cannot be
bounded in practice.

**Independence:** you must not be the author of these two commits,
`planning_pilot.py`'s producer, or `tests/test_planning_pilot.py`. The pilot spec
both *directs* and *describes* the implementation, so a spec bug and an
implementation bug are indistinguishable unless you read the pre-images.
`git show 431e87f:…` is the pre-image for every function this change touched.
Treat every test, comment, and docstring as a claim to verify.

## Target

- Repo: `/home/ruben/Projectos/meta-project/orchestrator`
- Revision reviewed: **`853d2a2`** (tip). Local, not pushed.
  `git worktree add --detach /tmp/kilo/pilot-producer 853d2a2`.
- Normative documents: `docs/research/phase4-recursive-planning-pilot-spec.md`
  (the directive; P2, P6, P7, P7a, P8, and the Tests section), the pilot's earlier
  reviews (read for accepted decisions, not to re-adjudicate),
  `docs/work-graph.md` (decomposition proposal admission), `docs/control-plane.md`,
  `docs/budgets.md`, `docs/glossary.md`, `docs/tables/limits.yaml`.
- Baseline (none of these is a verdict): `.venv/bin/python -m pytest -q` (expect
  **859 passed**); `scripts/check-tests --fast` (**829 passed, 30 deselected**);
  `scripts/check-docs` (**251** links OK); `scripts/check` and
  `scripts/check-static` rc 0.
- **No model calls, no network, no credentials.** The harness has no model call for
  recursive planning, so the provider is an injected callable and every test uses a
  deterministic double. If you find yourself wanting a model, that is a finding
  about the seam's usability, not a reason to call one.

## The guarantees under review

1. **The seam cannot be bypassed.** No path from provider output to a payload
   skips `admit_proposal`. Try: a provider that mutates the child list it returned
   after the fact; a provider that returns a generator; a provider that raises
   mid-iteration; children that are mappings with surprising types; and whether
   `propose_decomposition` is the only constructor of a pilot payload or whether
   one can be assembled and admitted without the guard.
2. **Refusal is total through the producer.** A good child beside a bad one yields
   nothing, not the good one. No partial payload, no partial state mutation, and
   the provider's own objects are untouched.
3. **Coverage is derived, not supplied.** The provider cannot inject its own
   `criterion_coverage`, and a child omitting `criterion_ids` yields empty coverage
   that the **reducer** refuses. Confirm the division of labour is real: the guard
   admits, the reducer decides sufficiency, and neither can be skipped.
4. **P6: the pilot cannot mark a target `DECLARED`.** No obligation-source field,
   no axis name, no `TargetSnapshot` in anything the producer returns. A
   pilot-admitted structure is the derived path's structure.
5. **P7: the kernel's stated bounds are the enforced bounds.** The non-goal
   amendment names depth 2, `maximum_children_per_node`, and the 32-per-trial
   ceiling. **The existing test only greps for those substrings** — see concern 1;
   testing whether that is sufficient is the point of attack A5.
6. **Every proposal produces exactly one record**, on every path including the
   malformed-`criterion_ids` path fixed in `853d2a2`, and the record's counts agree
   with the outcome. Try to find a path that returns or raises with no record.
7. **The refusing stage is the stage that fired.** A scope violation reports
   `SCOPE`, an over-budget child `BUDGET`, a fan-out or ceiling violation `BOUNDS`,
   a malformed `criterion_ids` `COVERAGE`. Confirm no stage is mislabelled or
   unreachable.
8. **The provider cannot mutate state through the result.** Mutating a returned
   child's nested `contract` or `budget_allocation` must not affect the provider's
   objects or anything already in state.

## In scope

- `planning_pilot.propose_decomposition` and `_criterion_coverage` in full.
- `PilotRefusal` and the stage-wrapping in `admit_proposal`, to the extent the
  producer depends on them.
- The `PROJECT_KERNEL` non-goal amendment and its test.
- The interaction with `admit_proposal` and with `decomposition.validate_decomposition`
  as the reducer's authority.
- Whether the producer is *reachable*: nothing in the harness calls it yet, which
  is disclosed below and is a finding about wiring, not about this code.

## Out of scope

- The guard's own bounds, cleared at re-review 3: depth derivation, the per-node
  fan-out, the per-trial ceiling, scope containment, budget authority, deep copy.
  Attack them only where the producer *misuses* them.
- The F1 single-layer containment decision, accepted with evidence and a pin.
- A model adapter. None exists. Do not review the safety of a model call; review
  whether the seam a model would plug into is sound.
- The `_nesting_shape` one-level residual (F10) and the unwired-ness of any
  remaining instrument.

## Known residuals and disclosed concerns — acknowledge, do not re-report as novel

1. **The kernel-bound test is a substring check, and that is probably not enough.**
   `test_the_kernel_records_the_pilot_lift_with_its_bounds` asserts the non-goal
   string contains `"depth 2"`, `"maximum_children_per_node"`, and
   `"32-proposed-children-per-trial"`. Those are literals in the string, not
   references to `MAX_PROPOSAL_DEPTH`, `maximum_children_per_node()`, or
   `MAX_PROPOSED_CHILDREN_PER_TRIAL`. If a bound were changed in code and not in
   the kernel text, the test would still pass. **The implementer believes this is a
   real weakness and has not fixed it**, because the honest fix — interpolating the
   constants into the kernel string — makes a frozen target's kernel text depend on
   module constants, which changes the fixture's contract inputs. Rule on it.
2. **Nothing calls `propose_decomposition`.** It is a library with no production
   call site and no wiring into the controller or the experiment arms. The pilot is
   therefore inert: no run can currently reach it. That is deliberate (the seam is
   reviewable without a model), but it means the producer has never been exercised
   end to end, and its integration is unproven rather than proven-good.
3. **No model adapter exists.** The provider callable's contract — what a real
   adapter must return, what shape its errors take, whether it may be async — is
   unspecified. The producer accepts whatever `provider` returns and normalises
   shallowly.
4. **A generator provider is untested.** `[dict(child) for child in (raw or ())]`
   consumes any iterable, but nothing pins the behaviour, and a provider that
   raises *during* iteration propagates out of `propose_decomposition` with no
   record — the same shape of gap `853d2a2` just fixed for coverage.
5. **The record describes the guard, not the run.** `admitted: True` means the
   guard admitted the structure; the reducer may still refuse the payload for
   insufficient coverage or a conflict. The field name does not say so.
6. **The producer was written after three reviews of the guard it calls.** Its own
   code has had no independent examination, and the style gate caught one
   per-character iteration bug in it on first run — the same class the option (e)
   chain hit twice, written a third time.

## Attacks to attempt (minimum)

**A1. Bypass the seam.** Find any way to obtain a pilot-admitted payload without
`admit_proposal` running: construct the payload dict directly, mutate a payload
after the guard returns, reuse a child admitted under one parent under another, or
call `admit_proposal` with a `state`/`parent_node_id` pair that does not correspond
to the payload's `node_id`. Success condition: a payload exists that the guard did
not admit.

**A2. Partial acceptance.** A provider returning [valid, invalid] in both orders,
and a provider returning three children where the second fails each of the three
checks. Confirm the payload is `None`, the record's `accepted_children` is 0, and
the provider's objects are unchanged.

**A3. The lost-record hunt.** Find any input where `propose_decomposition` returns
or raises without exactly one record. Start with: a provider that raises; a provider
that returns a generator that raises mid-iteration; a provider returning `None`; a
child that is not a mapping; a child whose `criterion_ids` is a mapping; a
`dependencies` entry that is malformed; a state mutated between the guard's
derivation and the payload's assembly. `853d2a2` fixed one instance of this class —
confirm it is now closed everywhere, not just for coverage.

**A4. Stage mislabelling.** For each refusal path, confirm the recorded stage is the
check that fired. Try to reach `PilotRefusal` with a stage that does not correspond
to the raised error, and try to reach a refusal that is *not* wrapped, so it escapes
as a bare `DecompositionError` with no stage.

**A5. Kernel drift.** Change `MAX_PROPOSAL_DEPTH`, `MAX_PROPOSED_CHILDREN_PER_TRIAL`,
or the fan-out table value **in a scratch copy only**, and see whether the kernel
test still passes. If it does, concern 1 is confirmed and you have a concrete
reproducer for the ruling you owe.

**A6. Coverage manipulation.** Can a provider get a criterion credited to a child
that does not own it, inflate `mandatory_cover`, or omit a mandatory criterion and
still have the *reducer* admit the payload? The guard does not check coverage, by
design; establish that the reducer's check is genuinely sufficient, and that nothing
in the producer's payload lets the reducer's own checks be skipped.

**A7. P6 by indirection.** Beyond the substring test: is there any way the producer's
output could be fed into `build_target` as a declared obligation set, or otherwise
cause a target to be marked `DECLARED`? Trace the producer's return value to every
consumer that exists (there is none in production — say so).

**A8. The deep copy under the seam.** Mutate a returned child's nested structures
and the provider's originals; then check whether the *already-admitted* children
list can be re-fed to the guard and admitted again with the mutation intact.

## Method

- Read the pre-images (`git show 431e87f:…`) of every changed function first and
  list the semantic deltas before testing any of them.
- Drive the real entry points — `propose_decomposition`, `admit_proposal`,
  `PilotRefusal`, `validate_decomposition`, `build_fixed_target` — with
  constructed `RunState`s and providers under `/tmp/kilo/`. No source edits.
- Prefer whole-path reproducers (a provider through `propose_decomposition`, then
  the resulting payload through `validate_decomposition`) over unit pokes.
- For a claim that depends on wiring ("nothing calls it"), establish it by search
  and say so plainly rather than inferring it from a passing test.
- For each attack: exact commands, the probe, observed vs expected, and the
  guarantee violated. Prefer a failing reproducer. Do not weaken or edit tests. If
  a guarantee holds, say "attacked, not falsified" and state the method.
- A **ruling** is required on concern 1 (the kernel-bound test) whatever your
  verdict: is the substring check acceptable, and if not, what is the fix that does
  not couple a frozen target's kernel text to module constants?

## Deliverable

1. **Verdict:** GO / NO-GO for wiring the producer into a run.
2. **A ruling on concern 1** (kernel-bound drift), with a reproducer.
3. **A ruling on concern 2** (inert producer): is "reviewable but unwired" an
   acceptable state for a safety-relevant path, and what is the minimum integration
   that would make it non-inert without a model?
4. **Findings** with severity (P0/P1/P2), the guarantee violated, a minimal
   reproducer, observed vs expected, and the proposed permanent regression test.
5. **Claims verified:** each of the eight guarantees with its attempt and outcome.
6. **An answer to A3 specifically:** the complete list of paths through
   `propose_decomposition` that produce no record, or confirmation there are none.
7. **Residual unknowns:** what you could not test and why.

## Exit criteria

- Every guarantee is either falsified with a reproducer or explicitly
  "attacked, not falsified" with the method.
- A3 is answered exhaustively, not by sampling.
- Concerns 1 and 2 are ruled on, not noted.
- A5 is answered with a concrete experiment on a scratch copy, and the scratch copy
  is discarded.
- The `853d2a2` fix is verified as closing the class rather than one instance.
- No source edits, no model calls, no network, no credentials; host state clean.
- Findings are reproducible from the report alone against `853d2a2`.
- The review states what it did not cover.

## Reproduce everything

List every probe command, constructed state, provider double, and scratch-copy
experiment here so the verdict can be re-run against a corrective revision.
