REPORT — phase4-recursive-planning-integration-provider-review
STEP: phase4-recursive-planning-integration-provider (the planning pilot's scripted provider at the driver seam)
REV: 2b269fc47184c67333087ff808c6df8d7744ae96   FINAL: afc5316b5d3b3111704830849efcd2257b3366fe
CHANGED:
  docs/research/phase4-recursive-planning-integration-provider-review.md — this report.
  tests/test_review_depth_walk.py — new reviewer probe module (RED BY DESIGN at FINAL; the finding's evidence, not a defect pin).
  No source file, no existing test module, and no docs file outside this report was modified. The unrelated probe copies used for mutants ran in /tmp/kilo/scratch* nothing-symlinked/copied trees and were diff-verified against `git show afc5316:...` before trusting any result.
VERIFIED:
- REVIEW ACCEPTANCE `scripts/check-scope 2b269fc afc5316 docs/research/phase4-recursive-planning-integration-provider-brief.md` — prints "scope: ok (2 path(s) in 2b269fc..afc5316)", exit 0; the two paths are exactly the IN SCOPE files. The work commit afc5316 carries the `Actor: IMPLEMENTER` trailer, touches only `src/orchestrator/trial_driver.py` and `tests/test_planning_pilot_routing.py`, and its parent is REV; none of these commits are mine.
- The review brief's embedded implementer brief is byte-identical to the committed `docs/research/phase4-recursive-planning-integration-provider-brief.md` (0 diff lines), and the file is unchanged from REV to FINAL.
- `scripts/check-tests --fast` — 950 passed, 42 deselected, 70.48s (delivery's own run); re-run with the probe module present: 950 passed, 45 deselected, 72.90s (the probe's three cases are slow-deselected).
- `pytest tests/test_planning_pilot_routing.py` — 12 passed, 7.18s (delivery's own run too).
- `pytest tests/test_phase3_project_oracle.py` — 5 passed, 227.74s without the probe; 5 passed, 229.11s with the slow-marked probe present. The friction-3 mechanism is thereby confirmed constructively: a slow-marked new module under tests/ does NOT break the oracle (pytest.ini registers `slow`; the oracle's internal gate runs `scripts/check-tests --fast` = `-m "not slow"` at src/orchestrator/project_oracle.py:731; the pre-commit hook `scripts/hooks/pre-commit` runs `check-tests --fast --parallel`, the pre-push hook the full suite).
- `scripts/check-static` — exit 0; 104 advisory B/SIM findings in the log (fail CLOSED only BLE001/S110: none) (delivery's own run too).
- `scripts/check-docs` — exit 0, 314 links OK (the report's VERIFIED cites "315 links OK"; both exit 0 — the count is environment-visible drift in the link checker, not a delivery divergence).
- `scripts/check-tests` (full, as the reviewer note directs) — 3 runs, all 3 runs RED at FINAL: 5 failed, 990 passed (437.77s / 436.35s / 449.33s). The five are F5's two (the delivery's own routing tests) and this review's three probe cases. Durations and counts recorded in full in F5/F1.
- Mutation checks that the delivered suite binds its shapes (scratch copies of afc5316, each mutant diff-verified first): wiring mutant editing the payload between guard and admission (`_admit_routed_decomposition` adding a `deps` key) → test_admitted_payload_is_forwarded_unmutated RED 2/2 (6.94s); refusal mutant falling back from the pilot refusal to the un-routed `_admit_decomposition` path → test_the_routing_seam_refuses_an_escaping_scope + test_a_refused_proposal_is_recorded_and_not_admitted + test_every_routed_proposal_leaves_its_instrument_in_order RED 3/3 (8.31s); provider-id mutant labelling RECURSIVE_LAZY "DERIVED" → test_every_arm_records_its_decomposition_provider_id RED (6.64s). The delivery binds the wiring, refusal, and provider-id guarantees.
NOT VERIFIED:
- The unmarked-module oracle counterfactual (whether an UNMARKED new test module breaks `pytest tests/test_phase3_project_oracle.py`): the nested-oracle test cannot be run on a scratch copy on this host — the control experiment (slow-marked probe present, nothing else changed) also fails on the scratch copy ("calibration case 'known-good' classified 'FALSE_SUCCESS'"), so scratch oracle runs are unfaithful here and were discarded rather than trusted. The mechanism claim stands on code reading (pytest.ini's registered `slow` marker + `check-tests --fast` = `-m "not slow"` + the oracle's internal gate invocation) and on the constructive half measured above.
FINDINGS:
  F1 | SEVERITY: P1 | ORIGIN: CODE | STATE: carried
  The implementer's F1 as carried is verified — falsified-with-reproducer by this review. `Controller._node_depth` (src/orchestrator/controller.py:178-193) walks CHILD_OF in the inverse direction of the production write: `Controller.propose_decomposition` records `from_node_id=child, to_node_id=parent` and the reducer's `children_of` (src/orchestrator/model.py:532-537) reads `to_node_id` as the parent, so the correct parent walk is "relations where `from_node_id == current`, step to `to_node_id`"; the shipped walk instead finds a node's CHILDREN and returns the subtree height. `planning_pilot._node_depth_from_state` (src/orchestrator/planning_pilot.py:343) and the two admission-time `maximum_depth` checks (controller.py:318, 733) sit on the same walk, so `MAX_PROPOSAL_DEPTH` (planning_pilot.py:39) and the run's `maximum_depth` limit (limits.yaml: `5`) never bind in production — at proposal time the proposing parent has no children yet, so every depth read is 0. Red at FINAL: tests/test_review_depth_walk.py, 3 failed, 0.20s, and the named failing assertions are exactly the three claims — `assert Controller.node_depth(state, root) == 0` (actual 2 = subtree height), `assert payload is None` for a proposal made at a true depth-2 node with the depth-unbounded provider (actual: full ADMITTED payload, no BOUNDS refusal), and `pytest.raises(RunLimitExhausted)` for admitting a second level under `maximum_depth: 1` (DID NOT RAISE). Green-not-error discipline holds: with only the walk direction corrected on a scratch copy (mutant diff-verified against `git show afc5316:src/orchestrator/controller.py`), all three pass, 0.19s. The implementer's own cross-evidence is confirmed: the pilot's own tests hand-build relations `from=parent, to=child` (tests/test_planning_pilot.py:183-184, 560-561, 573-574 — the inverse of production), which is why they cannot see the inversion; and their relation dump's direction matches this probe's clean measurement (a depth-2 leaf reads 0). The affected files are OUT OF SCOPE of this step and untouched by the work commit (0-line diff for src/orchestrator/controller.py and src/orchestrator/planning_pilot.py across REV..FINAL); carried, as the implementer did. TRIPPED: PILOT-R2's mechanism claim is thereby pinned too ("bounds admit exactly one recursive level" is not enforced).
  F2 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: carried  (re-assigned by this review; the implementer filed it `declined, not a defect`)
  The No-mutation shape as written is unsatisfiable, so it is a real defect in the brief and rule 8's own words govern: "a defect you will not fix now is carried, never declined". Evidence measured, not merely re-read: the delivery's own test pinpoints the divergence — `tests/test_planning_pilot_routing.py:321-322` asserts `"parent_proposal" not in produced["contract"]` (the guard's return is pristine) AND `logged["contract"]["parent_proposal"] == payload["proposal_id"]` (the payload the reducer admits in DECOMPOSITION_ADMITTED carries the added field); the addition is `Controller.propose_decomposition`'s own normalisation (controller.py:742, plus its `budget_id`/`budget_allocation` defaults), inside the method the brief itself forbids changing. The two clauses of the shape cannot both hold against the frozen controller: "the children, criterion coverage, and dependencies the reducer admits in DECOMPOSITION_ADMITTED are exactly the structures the guard returned" (literal per-dict equality over admitted children) fails, while the em-dash clause ("nothing edits an admitted payload between guard and event admission") is honoured. So the implementer's own closing words — "literally unsatisfiable" — describe a brief defect; its single-consistent-reading resolution is correct, is exactly the wiring constraint PILOT-R1 states, and is enforced by the delivered test. What is wrong is only the STATE: the shape's literal text stays in the frozen brief, cannot be fixed inside this step, and the "not a defect" label would log a demonstrably unsatisfiable acceptance shape as sound. Correct closeout treatment, as this review's brief demands: F2's STATE is `carried` on this report's INHERITED (with the adopted reading recorded), the PLANNER's CLOSEOUT for the step must enter it there and NOT under "DECLINED: F2 (not a defect)", and the shape's "exactly" wording awaits an OWNER/planner re-wording — the commit-holding brief text still stands as written.
  F3 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: carried  (misfiled as METHOD FRICTION by the implementer; here re-filed as the brief defect it is)
  The implementer's METHOD FRICTION entry about the acceptance note is substantively TRUE and belongs in FINDINGS: the implementer brief's note ("a new module under `tests/` breaks the oracle and both the fast suite and the commit hook deselect it") states the phenomenon but withholds the one convention on which its own named ACCEPTANCE command depends — the new module's cases must be slow-marked so the oracle's internal `check-tests --fast` deselects them (the implementer correctly inferred it from the other trial-running modules, and the oracle stayed green). A defect in the brief is a FINDING, never METHOD FRICTION — I file it here. Mechanism verified as measured in VERIFIED (both directions that were measurable on this host); the counterfactual half is NOT VERIFIED (nested-oracle scratch unfaithful — see above). The implementer's OTHER friction item (the CLOSEOUT stanza's ownership) is genuine method-fill: that silence lives in the report TEMPLATE (a method artifact), not in this brief — I confirm it as friction rather than a finding. It is nonetheless live: the committed precedent (detection-a review) has the REVIEWER fill the stanza in the review report, while this step's implementer left it to the planner; the two readings coexist unwritten. See the second METHOD FRICTION note.
  F4 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: carried
  The verdict on the rule-11 concern: the implementer brief's `REV:` field is the artifact the claim was copied from, and both are wrong. The brief's `REV: 1a4c0a72dd388ca1a2adb3f76b265529035331f8` names the pre-brief HEAD — a revision that cannot serve as this step's base, because the brief's own commit (2b269fc) is part of the step's change set (it consumes R2 in `docs/record.md`). Measured: `scripts/check-scope 1a4c0a7 afc5316 <brief>` fails with "scope: docs/record.md is in the diff and not in IN SCOPE"; `scripts/check-scope 2b269fc afc5316 <brief>` passes (2 paths). The committed practice that masked this: the detection-a episode used the same pre-brief-HEAD convention and passed only because its brief commit touched nothing besides the brief file itself (635f4b0 = adds the brief file; its parent is 1932f2d = that brief's REV). The implementer's report then claims `REV: 1a4c0a7...` — a copy of this brief's field, never declared against its source (git): the work's actual base is 2b269fc, the parent of afc5316. The claim STANDS as row-J class ("a claim not declared against its source"); the brief's `REV:` field is the origin of the false claim, and the review brief's own header (REV: 2b269fc) is the correct value the review scoping used. Neither will change retroactively, so this is a carried documentation defect: the next implementer brief's REV must name the revision the implementer builds on, and a report that copies a verbatim field must at least confirm it names an ancestor-parent of its FINAL before claiming it.
  F5 | SEVERITY: P1 | ORIGIN: CODE | STATE: carried
  As delivered to FINAL, the new routing module is red under the full suite the repo hooks sanction, 3 runs out of 3 (990 passed / 5 failed — the same two each time; the implementer's acceptance only ran it standalone, which is green 3/3). Cause, measured end to end: the routing fixture reads the session-level mutable binding `experiment.MODEL_PROFILE` at trial time (tests/test_planning_pilot_routing.py:160), and an earlier module leaves the binding mutated for the whole rest of the session: `test_phase2_general_target.py`'s `finally` restores with `experiment.set_model_profile(experiment.MODEL_PROFILE)` — which reads the DELEGATED binding that its own `set_model_profile(experiment.PATCH_MODEL_PROFILE)` just mutated, so it "restores" the patch profile (experiment_spec.py:203-206 `set_model_profile` is a bare global assignment; the facade `experiment.MODEL_PROFILE` reads the current `experiment_spec.MODEL_PROFILE`). A per-module binding history logged at REV ordering shows the onset exactly: patch profile from `test_phase3_project_oracle.py` onward, none before (log retained in /tmp/kilo/profile_history.log). A minimal pair repro on the working tree: `pytest tests/test_phase2_general_target.py tests/test_planning_pilot_routing.py` → 2 failed, 17 passed, 31.40s, the failure mode identical to the full suite: the poisoned profile (patch_production, but the patch table resolves the empty default) makes the review/patch model calls reply with empty patches — the observations carry `content_hash == sha256 of ""` and `changed_paths/artefacts: []`, the adapter refuses them with "ARTEFACT output rejected: path field 'path' must contain non-empty strings" (src/orchestrator/model_adapter.py:306), the parse leaf never gets past its review, the trial aborts with a single DECOMPOSITION_ADMITTED where the assertion expects the fixed target's two (failed-trial stores: /tmp/pytest-of-ruben/pytest-1306 and pytest-1307, pilot-routing0, RECURSIVE_LAZY-1001, 48 events). Counter-mutant proving the coupling and the remedy: pinning the profile at module import/fixture entry and resetting `MODEL_CLIENT_FACTORY` inside the delivered test file's OWN scope (the only file the finding needs to touch) turns the same pair green — 19 passed, 34.53s (scratch copy, mutant diff-verified). Root defect (a) sits in the delivered module's own IN SCOPE file and was fixable there; enabling defect (b) — the phase-2 restore-by-re-read leak — is pre-existing cleared work OUT OF SCOPE of this step. Carried: this review does not fix either.
SHAPES:
- Probed beyond the delivered suite (the delivered module builds all seven named shapes over real trials; this review re-ran them green and bound three of them by mutation, see VERIFIED):
  1. The pilot's DEPTH-bound refusal at the seam: a proposal made at a true depth-2 node with a valid provider must be refused at BOUNDS by `MAX_PROPOSAL_DEPTH`. Not built by the suite — the refusal shape is only probed with a scope escape, and the depth read is vacuous in the production direction — falsified-with-reproducer (RED, F1, tests/test_review_depth_walk.py).
  2. The controller's `maximum_depth` run-limit admission refusal at a true depth-2 proposal site. Not built by the suite — same vacuous read — falsified-with-reproducer (RED, F1, same module).
  3. The full-suite context as a runtime environment for the delivered trials: the delivered module's estimates of its own green-ness do not survive the sanctioned module ordering (pollution from the session-mutated `experiment.MODEL_PROFILE` global) — falsified-with-reproducer (RED 3/3, F5).
TRIPPED: none by this review's own diff (the probe touches no residual trigger glob: only a new slow-marked test module and this report). The implementer's TRIPPED: PILOT-R2 is confirmed by this review — the residual's "bounds admit exactly one recursive level" enrollment is not measured to be enforced, see F1.
PROPOSED ROWS: none (the ledger row for this step should not be completed as an unconditional green full-suite state while F5's red stand — conveyed to the planner through this report and each finding's carried state rather than a proposed row).
METHOD FRICTION:
- The scratch-copy environment for the nested-oracle counterfactual could not be made faithful on this host (the control experiment reproduces the calibration failure too), so the friction-3 counterfactual half was recorded as NOT VERIFIED rather than trusted; the mutant methodology (diff each mutant against `git show <rev>:...`, run only on faithful copies) covers everything it was applied to.
- This review followed the committed precedent of detection-a (the reviewer fills the CLOSEOUT stanza of the step's last report) despite the implementer's friction entry reading the template as silent; the two readings coexist in the committed record and should be settled by the owner (row 5): either only the planner produces CLOSEOUT (and the review's findings ride INHERITED to it), or the step's last report carries it, deterministically reaching the closure.
INHERITED:
F1 | SEVERITY: P1 | ORIGIN: CODE | STATE: carried
  From the implementer's report, verified here with additional reproducing evidence: depth of a node read from CHILD_OF walks the wrong direction (src/orchestrator/controller.py:178-193), never more deeply than one level; `MAX_PROPOSAL_DEPTH=2` and per-admission `maximum_depth` checks are vacuous at proposal time in production (the proposing parent always reads 0), so the pilot's depth guard and the controller's maximum_depth run limit never enforce; the pilot's own tests are blind (hand-built relations are written in the inverse direction; confirmed in tests/test_planning_pilot.py:183-184, 560-561). A depth-unbounded provider would be ADMITTED at any proposal seam (pinned RED: tests/test_review_depth_walk.py::test_the_pilot_depth_guard_never_refuses_a_node_at_depth_two; report's original reproducing evidence as a relation dump matches).
F2 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: carried  (state re-assigned by this review from the implementer's declined)
  The brief's No-mutation shape as written is unsatisfiable: the event's children carry `const parent_proposal` (and the controller's defaults), which the guard's return cannot (verified: tests/test_planning_pilot_routing.py:321-322 vs controller.py:742). The single consistent reading ("the driver forwards the producer payload without editing it; the dependency edges go through the dependencies argument") is implemented and pinned by the delivered test; the literal shape text stands as written in the frozen brief. Closeout: carried, not declined; the wording belongs to an OWNER/planner re-wording, and the next implementer brief at this seam inherits the pinning test and the divergence explanation.
F3 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: carried
  The implementer brief's acceptance note omits the slow-mark convention for new test modules under tests/, on which its own named oracle command's green depends (verified mechanically: pytest.ini's `slow` marker, `check-tests --fast` = `-m "not slow"`, the oracle's internal gate at src/orchestrator/project_oracle.py:731, the deselecting pre-commit hook, and measured-green constructive half on this host). Misfiled as METHOD FRICTION by the implementer; re-filed here as the brief defect it is. The counterfactual half (unmarked module breaks the oracle) is NOT VERIFIED — nested-oracle scratch unfaithful on this host.
F4 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: carried
  The implementer brief's `REV:` field names the pre-brief HEAD (1a4c0a7...) which cannot be this step's base (its brief commit consumes R2 in docs/record.md, so check-scope over that sha fails: "docs/record.md is in the diff and not in IN SCOPE"); the implementer's report propagated the field as its base claim — a claim not declared against its source, which stands (the work's actual base is 2b269fc, afc5316's parent). The next implementer brief's REV must name the revision the implementer builds on, and a copied verbatim field must at least be confirmed to name an ancestor-parent of the work's commit before it is claimed.
F5 | SEVERITY: P1 | ORIGIN: CODE | STATE: carried
  As delivered, the routing module's two parametrised routing-shape tests fail under the full suite on this host, deterministically, 3/3 runs (990 passed/5 failed each), because the fixture reads the session-mutated `experiment.MODEL_PROFILE` global that `test_phase2_general_target.py` leaks (its finally restores by re-reading the mutated delegated binding). Minimal pair repro: 2 failed / 17 passed in 31.40s; enabling path measured from the binding history log and the failed trial stores (empty-patch replies → "path field 'path' must contain non-empty strings" rejections at src/orchestrator/model_adapter.py:306 → trial abort with one instead of two DECOMPOSITION_ADMITTED). Counter-mutant with the profile pinned in the delivered file: 19 passed / 34.53s. Remedy surface: the delivered test file (pin at import/fixture entry, reset `MODEL_CLIENT_FACTORY`) and the pre-existing phase-2 leak; the next implementer brief inherits both.

Rule 2 governs the planner's copy of INHERITED above. Everything in it is still open at this step's close.

ANSWERS TO QUESTIONS TO ATTACK:
1. F1 stands as claimed, on its own red reproducer built through the REAL production write path: three failing assertions at FINAL (depth inversion at read sites, the never-refusing depth-bounded proposal, the never-binding maximum_depth limit), turning green when only the walk direction is corrected on a diff-verified scratch mutant. The implementer's claim that the pilot's own tests are blind to it was verified (their fixture relations are built inverted to production). STATE carried and ORIGIN CODE re-hover unchanged.
2. F2's technical content is confirmed verbatim this-to-that time: the reducer's admitted children are NOT the guard's structures literally (the controller's own normalisation adds parent_proposal), and the delivered test pins the diverging field as the wire-visible difference. The literal shape as written is falsified; the shipped behaviour is the single consistent reading. The deliverable itself is not at fault; the shape text is — but the implementer's `declined` state mislabels a live brief defect; see F2's carried re-assignment and the correct closeout treatment.
3. The slow-mark friction entry is substantively right AND objectively a brief defect (its mechanism belongs in FINDINGS, not friction). Verified: pytest.ini registers a true `slow` marker; `scripts/check-tests --fast` runs `-m "not slow"`; the oracle's internal gate invokes `scripts/check-tests --fast` (src/orchestrator/project_oracle.py:731) and stays GREEN with the slow-marked module present (5 passed, 229.11s and 227.74s). The unmarked counterfactual was not completed (NOT VERIFIED above). The implementer's OTHER friction item (the CLOSEOUT stanza's ownership) is genuine method-fill. See F3 and the second METHOD FRICTION note.
4. Both artifacts are implicated; the brief's `REV:` field is the false claim's origin, and the report's claim is a copy that was never declared against its source: measured, `check-scope 1a4c0a7 afc5316` fails and `check-scope 2b269fc afc5316` passes; the detection-a "precedent" passes for a different reason (its brief commit touches nothing else). Verdict recorded as a row-J-class claim not declared against its source. See F4.
5. F2 is a real defect in a frozen brief and the correct closeout treatment is `carried` (not declined): a carried finding's closeout goes to INHERITED (as the next implementer brief's obligation), the planner's "DECLINED:" CLOSEOUT line must not list it, and the shape's wording awaits an owner ruling. The brief text, as committed, still stands as written — no textual fix is in scope for the reviewer; my re-assignment is an output, not an edit. See F2.

CLOSEOUT
DECLINED: none
DIVERGENCES CLOSED: none
