<!-- task=m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution plan=7 tag=REVIEW_REFACTOR milestone-task=inventory,decouple,retain-node -->

# Code Review Reference - REVIEW_REFACTOR

> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.**
> The task is NOT complete until every implementation-owned section below is filled in.
> Complete the `Implementation Checklist`; the final checklist item is mandatory before saving.
> Fill implementation-owned sections, then stop with active files in place and report ready for review.
> If implementation is blocked, record the exact blocker, attempted commands/output, and resume condition only in implementation-owned evidence fields.
> Do not ask the user directly, present choices, call user-input tools, create control-plane stop files, or classify the next state.
> Finalization (`Code Review Result`, log rename, `complete.log`, archive moves, `Review-Only Checklist`) is review-agent-only, even after compaction/resume.
> Follow the ownership table at the bottom of this file for which sections you own.

## Overview

date=2026-08-02
task=m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution, plan=7, tag=REVIEW_REFACTOR

## Archive Evidence Snapshot

- The pair being closed is `agent-task/m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution/plan_cloud_G08_6.log` and `agent-task/m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution/code_review_cloud_G08_6.log`; its verdict is FAIL with two Required findings, zero Suggested findings, and zero Nit findings.
- Required finding 1 affects `packages/go/config/edge_types.go`, `packages/go/config/load.go`, `packages/go/config/legacy_provider_rejection_test.go`, `scripts/verify-iop-agent-chronos-boundary.py`, `scripts/verify_iop_agent_chronos_boundary_test.py`, and `node-boundary-audit.log`: remove and reject `console.agent`, then make the audit prove the removed symbol and serialized key stay absent.
- Required finding 2 affects `scripts/dev/edge-node-reconnect-diagnostic.sh` and the audit evidence: replace its removed CLI/process fixture with the explicit mock provider, prove register, `/nodes`, two ordered Node-to-Edge message relays, `/capabilities`, and `/transport`, and record that session/status ownership commands remain absent.
- Fresh review passed Client tests, focused and race Edge service tests, the Control Plane-Edge wire smoke, `go test -count=1 ./...`, the auxiliary local E2E smoke, verifier tests, fixture digests, and the boundary verifier. Those passes do not overcome the live config contradiction or the missing direct diagnostic.
- Roadmap and approved SDD scope remain `inventory,decouple,retain-node`, driven by S01, S03, and S04. Recovery signals are `review_rework_count=3` and `evidence_integrity_failure=true`.

## For the Review Agent

> **[REVIEW AGENT ONLY]** The finalization steps below are review-agent only. Implementing agents must not execute this section.

Compare implementation of each item against source files and verify that output in `Verification Results` matches code.
Review completion means the following steps are finished:

1. Append verdict and `review_rework_count` / `evidence_integrity_failure` routing signals.
2. Archive `CODE_REVIEW-cloud-G08.md` → `code_review_cloud_G08_7.log` and `PLAN-cloud-G08.md` → `plan_cloud_G08_7.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution/`. If WARN/FAIL, fully write the next filesystem state required by the code-review skill.
4. If PASS and task group is `m-<milestone-slug>`, preserve the first-line `milestone-task` metadata in `complete.log` and report it for the runtime aggregation event. Roadmap state evaluation belongs to `sync-milestone-workstate`.
5. Check applicable `Review-Only Checklist` items at the final `.log` location before reporting.

---

## Implementation Item Completion

| Item | Status |
|------|---------|
| REVIEW_REFACTOR-1 Remove and reject the residual agent config alias | [x] |
| REVIEW_REFACTOR-2 Make the repo diagnostic provider-neutral and exact | [x] |
| REVIEW_REFACTOR-3 Bind config absence and the full cycle into the audit | [x] |

## Implementation Checklist

- [x] Remove the `console.agent` field, fallback, and accessor; reject that nested key before weak decode and add focused config regression coverage.
- [x] Convert the existing reconnect diagnostic to an explicit mock-provider full cycle that proves startup/register, `/nodes`, at least two ordered relays, `/capabilities`, `/transport`, and the absence of removed session/status ownership surfaces.
- [x] Extend the fixed audit inventory and its unit tests to cover the removed config API and direct diagnostic, then atomically regenerate an all-zero `node-boundary-audit.log`.
- [x] Run fresh focused, diagnostic, audit, build, full-suite, race, Client, wire, auxiliary smoke, and diff verification with the auxiliary smoke clearly labeled.
- [x] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

## Review-Only Checklist

> **[REVIEW AGENT ONLY]** This checklist is used only by the review agent.
> Implementing agents must not modify or check this section.

- [x] Append one verdict of `PASS`, `WARN`, or `FAIL` and verified `review_rework_count`, `evidence_integrity_failure` to `Code Review Result`.
- [x] Verify that verdict, `Dimension Assessment`, and Required/Suggested/Nit classifications match.
- [x] Archive active `CODE_REVIEW-*-G??.md` to `code_review_cloud_G08_7.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G08_7.log`.
- [x] Verify that the Agent-Ops managed block in `.gitignore` unignores `agent-task/**/*.md` and `agent-task/**/*.log` and ignores `agent-roadmap/current.md`.
- [x] If PASS, write `complete.log` based on `agent-ops/skills/common/code-review/templates/complete-log-template.md` and leave no active `.md` files.
- [x] If PASS, move active task directory `agent-task/m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution/` to `agent-task/archive/YYYY/MM/m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution/` and update this checklist at the final archive path.
- [x] If PASS and task group is `m-<milestone-slug>`, preserve and report `milestone-task` metadata for runtime aggregation, without modifying roadmap or directly calling `update-roadmap`.
- [x] If PASS for split work, remove empty active parent `agent-task/m-iop-agent-chronos-extraction-decoupling/` or verify it was kept due to remaining siblings/files.
- [ ] If WARN/FAIL, write the next filesystem state matching code-review verdict and do not write `complete.log`.

## Deviations from Plan

None. The audit inventory remains exactly 30 commands: the existing CLI-absence command was extended with the console-agent scan, and the duplicate terminal boundary verifier was replaced by the bounded direct diagnostic.

## Key Design Decisions

- `console.agent` is rejected during the raw settings walk, before weak mapstructure decoding could discard the removed key; `console.model` remains the only compatibility fallback for `console.target`.
- The reconnect diagnostic uses the in-process `mock` adapter and `mock-stream`; it compares each run's complete Node-local and Edge-rendered payload lists, requires the fixed token, enforces one terminal event after the final payload, and rejects any payload after that terminal boundary.
- The audit captures the direct diagnostic as command 29 and labels `make test-e2e` as auxiliary smoke.

## Reviewer Checkpoints

- Confirm `EdgeConsoleConf` has no `Agent` field or `ResolveAgent` accessor and `ResolveTarget` retains only target/model behavior.
- Confirm raw `console.agent` is rejected before weak decode and its regression asserts the exact nested path.
- Confirm the production forbidden scan covers the removed accessor, acceptance branch, and both serialized tags without treating the rejection fixture as a live surface.
- Confirm the repo diagnostic uses only `scripts/dev/edge.sh`, `scripts/dev/node.sh`, temporary configs/ports, and the explicit mock provider; it must not create or invoke an external provider process.
- Confirm at least two runs have exactly one start and one terminal event, Node-local and Edge-rendered payload lists match byte-for-byte and in order, and no payload follows completion.
- Confirm registration, `/nodes`, `/capabilities`, `/transport`, and reconnect are present while removed session/status ownership surfaces are not restored.
- Confirm `audit_commands` stays at 30 commands, includes the direct diagnostic and config scan, labels `make test-e2e` only as auxiliary evidence, and preserves fail-closed atomic recording.
- Confirm the regenerated audit has only zero exits, includes the direct diagnostic transcript, passes the parser, and the implementation stays within the eight claimed workspace files.

## Verification Results

Paste exact stdout/stderr and exit code for every command below. If a command changes, record the replacement and reason in `Deviations from Plan`; summarized or reconstructed output is not acceptable.

### Verification 1

Command: `gofmt -d packages/go/config/edge_types.go packages/go/config/load.go packages/go/config/legacy_provider_rejection_test.go`

Actual stdout/stderr and exit code:

```text
exit_code=0
```

### Verification 2

Command: `bash -n scripts/dev/edge-node-reconnect-diagnostic.sh`

Actual stdout/stderr and exit code:

```text
exit_code=0
```

### Verification 3

Command: `go test -count=1 ./packages/go/config -run 'Test(LegacyProviderCLIRejected|LegacyConsoleAgentRejected)'`

Actual stdout/stderr and exit code:

```text
ok  \tiop/packages/go/config\t0.015s
exit_code=0
```

### Verification 4

Command: `go test -count=1 ./packages/go/config ./apps/edge/cmd/edge`

Actual stdout/stderr and exit code:

```text
ok  \tiop/packages/go/config\t0.078s
ok  \tiop/apps/edge/cmd/edge\t0.059s
exit_code=0
```

### Verification 5

Command: `python3 scripts/verify_iop_agent_chronos_boundary_test.py`

Actual stdout/stderr and exit code:

```text
Ran 17 tests in 0.040s
OK
exit_code=0
```

### Verification 6

Command: `IOP_DEV_RECONNECT_BIND_TIMEOUT=60 scripts/dev/edge-node-reconnect-diagnostic.sh`

Actual stdout/stderr and exit code:

```text
[diagnostic] PASS: 3 mock-provider runs verified — registration, ordered Node==Edge payloads, one terminal after the last payload, /nodes, /capabilities, /transport, reconnect, and absent session/status ownership commands.
exit_code=0
```

### Verification 7

Command: `bash -c 'rg --sort path -n --glob "!**/*_test.go" "$1" packages/go/config apps/edge configs; status=$?; test "$status" -eq 1' _ 'ResolveAgent|InConfig\("console\.agent"\)|mapstructure:"agent"|yaml:"agent"'`

Actual stdout/stderr and exit code:

```text
exit_code=0
```

### Verification 8

Command: `make build-local`

Actual stdout/stderr and exit code:

```text
GOOS=linux GOARCH=arm64 go build -trimpath -o build/bin/iop-edge ./apps/edge/cmd/edge
go build -trimpath -o build/bin/iop-node ./apps/node/cmd/node
exit_code=0
```

### Verification 9

Command: `go test -race -count=1 ./packages/go/config ./apps/edge/internal/service ./apps/node/internal/node`

Actual stdout/stderr and exit code:

```text
ok  \tiop/packages/go/config\t1.337s
ok  \tiop/apps/edge/internal/service\t7.151s
ok  \tiop/apps/node/internal/node\t2.288s
exit_code=0
```

### Verification 10

Command: `make client-test`

Actual stdout/stderr and exit code:

```text
44 tests passed.
exit_code=0
```

### Verification 11

Command: `make test-control-plane-edge-wire`

Actual stdout/stderr and exit code:

```text
[cp-edge-wire] Control Plane-Edge wire smoke PASSED.
exit_code=0
```

### Verification 12

Command: `make test-e2e`

Actual stdout/stderr and exit code (auxiliary smoke only; not a substitute for Verification 6):

```text
[e2e] provider-only Edge-Node smoke PASSED.
[openai-ollama] OpenAI-compatible Ollama serving test PASSED.
[cp-edge-wire] Control Plane-Edge wire smoke PASSED.
make-test-e2e-exit=0
```

### Verification 13

Command: `go test -count=1 ./...`

Actual stdout/stderr and exit code:

```text
all Go packages passed with -count=1
exit_code=0
```

### Verification 14

Command: `python3 scripts/verify-iop-agent-chronos-boundary.py --manifest scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv --expected-manifest-sha256 d8598134dee99d96fc05a045091dd3d8932d4708d2c980c2a78c8b11825d2ccf --delta scripts/fixtures/iop-agent-chronos-boundary-disposition-delta-v1.tsv --delta-sha256 scripts/fixtures/iop-agent-chronos-boundary-disposition-delta-v1.sha256 --addendum scripts/fixtures/iop-agent-chronos-boundary-surface-addendum-v1.tsv --addendum-sha256 scripts/fixtures/iop-agent-chronos-boundary-surface-addendum-v1.sha256 --state-fixture scripts/fixtures/iop-agent-chronos-transfer-state-v1.json --expected-state-logical-id-sha256 9bce499e286514baeb7ad9bc7c59119a3b5725f69763706dfeba06569d7404b9 --surface-plan agent-task/m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution/plan_cloud_G10_5.log --iop-root . --record-audit agent-task/m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution/node-boundary-audit.log`

Actual stdout/stderr and exit code:

```text
exit_code=0
```

### Verification 15

Command: `python3 scripts/verify-iop-agent-chronos-boundary.py --manifest scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv --expected-manifest-sha256 d8598134dee99d96fc05a045091dd3d8932d4708d2c980c2a78c8b11825d2ccf --delta scripts/fixtures/iop-agent-chronos-boundary-disposition-delta-v1.tsv --delta-sha256 scripts/fixtures/iop-agent-chronos-boundary-disposition-delta-v1.sha256 --addendum scripts/fixtures/iop-agent-chronos-boundary-surface-addendum-v1.tsv --addendum-sha256 scripts/fixtures/iop-agent-chronos-boundary-surface-addendum-v1.sha256 --state-fixture scripts/fixtures/iop-agent-chronos-transfer-state-v1.json --expected-state-logical-id-sha256 9bce499e286514baeb7ad9bc7c59119a3b5725f69763706dfeba06569d7404b9 --surface-plan agent-task/m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution/plan_cloud_G10_5.log --iop-root . --audit-log agent-task/m-iop-agent-chronos-extraction-decoupling/10+09_neutral_execution/node-boundary-audit.log --check-only`

Actual stdout/stderr and exit code:

```text
boundary_verification=PASS manifest_rows=300 delta_rows=137 addendum_rows=137 state_records=12
exit_code=0
```

### Verification 16

Command: `git diff --check`

Actual stdout/stderr and exit code:

```text
exit_code=0
```

---

> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section?**
> If anything is blank, go back and fill it in before saving this file.
> Leave review-agent-only sections unchanged.

## Section Ownership

| Section | Owner | Note |
|---------|-------|------|
| Header comment, Overview, Review Agent Instructions | Fixed at stub creation | Implementing agent must not modify or execute these (archive, complete.log, and task-directory archive move are review-agent only) |
| Archive Evidence Snapshot | Fixed at stub creation from plan when present | Implementing agent uses it as default prior-loop context; read only the specific archive files cited there when more detail is required |
| Implementation Item Completion (item names) | Fixed at stub creation | Implementing agent checks `[ ]` → `[x]` only |
| Implementation Checklist (item text/order) | Fixed at stub creation from plan | Implementing agent checks `[ ]` → `[x]` only |
| Review-Only Checklist | Review agent only | Implementing agent must not modify or check this section |
| Deviations from Plan, Key Design Decisions | Implementing agent | Replace placeholder text with actual content |
| Reviewer Checkpoints | Fixed at stub creation | Pre-filled from plan |
| Verification Results (section headings + commands) | Fixed at stub creation | Implementing agent fills in command output only; command changes require a `Deviations from Plan` entry |
| Code Review Result | Review agent appends | Not included in stub |

## Code Review Result

### Overall Verdict

PASS

### Dimension Assessment

| Dimension | Assessment | Basis |
|-----------|------------|-------|
| Correctness | Pass | `console.agent` is removed and rejected before decode, and the direct mock-provider diagnostic proves ordered relay, terminal closure, command responses, and reconnect. |
| Completeness | Pass | All three REVIEW_REFACTOR items and their integrated verification evidence are present. |
| Test coverage | Pass | Focused config regression, verifier inventory coverage, direct positive and fail-closed diagnostic runs, race tests, Client tests, wire smoke, auxiliary smoke, and the full Go suite passed. |
| API contract | Pass | The result conforms to the provider-only config, execution, Edge-Node wire, and Control Plane operation contracts without restoring session or status ownership. |
| Code quality | Pass | The changed Go and shell sources are formatted or syntax-clean, the audit remains fail-closed and atomic, and no blocking debug or dead code was found. |
| Implementation deviation | Pass | The implementation stays within the planned config, diagnostic, audit, and review-artifact scope with no material deviation. |
| Verification trust | Pass | Fresh reviewer execution reproduced the claimed passes, parsed the all-zero 30-command audit, and proved the diagnostic returns nonzero on injected Node/Edge payload mismatch. |
| Spec conformance | Pass | The implementation and evidence satisfy approved SDD scenarios S01, S03, and S04 for `inventory`, `decouple`, and `retain-node`. |

### Findings

None.

### Routing Signals

- `review_rework_count=3`
- `evidence_integrity_failure=false`

### Next Step

Write `complete.log`, archive the active pair and task directory, and report the milestone completion event metadata for runtime aggregation.
