<!-- task=m-iop-hot-path-one-shot-execution/01_preset_schema plan=3 tag=REVIEW_API milestone-task=preset-schema,hot-preset -->

# Code Review Reference - REVIEW_API

> **[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-hot-path-one-shot-execution/01_preset_schema, plan=3, tag=REVIEW_API

## Archive Evidence Snapshot

- The current pair will be archived as `agent-task/m-iop-hot-path-one-shot-execution/01_preset_schema/plan_cloud_G06_2.log` and `agent-task/m-iop-hot-path-one-shot-execution/01_preset_schema/code_review_cloud_G06_2.log`.
- Verdict: FAIL. Required 2, Suggested 0, Nit 0.
- Required: reject canonical selector/stage references when `models[]` is empty; reject `light` presets without complete workspace alternatives, normalize operation keys, and validate matcher/mapping/result descriptor payloads.
- Reviewer evidence: focused, full config, race, config vet, package-wide vet, and `git diff --check` passed. A temporary focused reproducer failed because both a missing-model selector with no model catalog and a `light` route with zero workspace alternatives loaded successfully. Package-wide tests remain non-closure evidence because unrelated `agentprovider/catalog` fake-CLI tests fail on this host's PATH/executable-temp restrictions.
- Roadmap carryover: `milestone-task=preset-schema,hot-preset`; approved SDD S02/S04 remain the acceptance boundary. Immutable generation publication, model-to-preset one-of, authorization, request coordination, and workspace binding compilation remain in later children.

## 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-G06.md` → `code_review_cloud_G06_3.log` and `PLAN-cloud-G05.md` → `plan_cloud_G05_3.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-iop-hot-path-one-shot-execution/01_preset_schema/`. 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_API-1 Close canonical-reference and workspace-binding fail-open paths | [x] |

## Implementation Checklist

- [x] Reject every selector/stage model absent from the canonical model catalog and require complete, normalized workspace binding alternatives for every `light` preset.
- [x] Add regression coverage for empty-catalog references, zero `light` alternatives, incomplete operation descriptors, and normalized operation keys while preserving all existing preset/provider compatibility cases.
- [x] Run focused, fresh, race, vet, and diff verification exactly as written.
- [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_G06_3.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G05_3.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`.
- [ ] If PASS, write `complete.log` based on `agent-ops/skills/common/code-review/templates/complete-log-template.md` and leave no active `.md` files.
- [ ] If PASS, move active task directory `agent-task/m-iop-hot-path-one-shot-execution/01_preset_schema/` to `agent-task/archive/YYYY/MM/m-iop-hot-path-one-shot-execution/01_preset_schema/` and update this checklist at the final archive path.
- [ ] 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`.
- [ ] If PASS for split work, remove empty active parent `agent-task/m-iop-hot-path-one-shot-execution/` or verify it was kept due to remaining siblings/files.
- [x] If WARN/FAIL, write the next filesystem state matching code-review verdict and do not write `complete.log`.

## Deviations from Plan

None. All implementation items, checklist tasks, and verification commands were executed as specified in the plan.

## Key Design Decisions

- Unconditionally validate selector and stage model references against `canonicalModelIDs`, removing the `len(canonicalModelIDs) > 0` bypass condition so an empty model catalog fails closed when presets reference any model.
- Require at least one `workspace_tools` alternative whenever `allowed_modes` includes `"light"`.
- Rebuild operation maps under normalized (trimmed) operation names, reject duplicate operations after key normalization, and validate that `schema_matcher`, `argument_map`, and `result_matcher` are present and non-empty for every declared workspace operation.

## Reviewer Checkpoints

- Every non-empty selector/stage model is rejected unless it exists in the canonical `models[]` catalog, including when that catalog is empty.
- Every `light` preset has at least one complete workspace alternative; operation keys are retained in normalized form, normalized duplicates fail, and required matcher/mapping/result descriptors are non-empty.
- Existing SDD-shaped direct/light fixtures, multi-mode route/option regressions, unsupported handler rejection, strict decode, and provider-only compatibility remain passing.

## Verification Results

Paste actual stdout/stderr below each exact command. Record any replacement and reason in `Deviations from Plan`.

### REVIEW_API-1 focused regression verification

```bash
go test -count=1 ./packages/go/config -run 'TestLoadEdgeExecutionPreset(Catalog|RejectsInvalidShape)$'
```

_Actual stdout/stderr:_

```
ok  	iop/packages/go/config	0.060s
```

### Full config package verification

```bash
go test -count=1 ./packages/go/config
```

_Actual stdout/stderr:_

```
ok  	iop/packages/go/config	0.120s
```

### Race verification

```bash
go test -race -count=1 ./packages/go/config
```

_Actual stdout/stderr:_

```
ok  	iop/packages/go/config	1.472s
```

### Vet and diff verification

```bash
go vet ./packages/go/config
go vet ./packages/go/...
git diff --check
```

_Actual stdout/stderr:_

```
(exit 0, no output)
```

---

> **[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

FAIL

### Dimension Assessment

- Correctness: Fail — route keys are compared after trimming but retained under their raw map keys, so two keys that normalize to the same registered mode are accepted.
- Completeness: Fail — the inherited requirement to normalize mode route keys in place and require a unique exact allowed-mode/route correspondence is not implemented.
- Test coverage: Fail — the suite covers extra raw route keys but not a valid normalized route key or a duplicate route key after normalization; the focused reviewer reproducer failed.
- API contract: Fail — a loaded preset can retain more than one route for the same normalized mode, leaving the data-only descriptor ambiguous for downstream generation publication.
- Code quality: Pass — the change is localized, formatted, and contains no debug output, dead code, or TODOs.
- Implementation deviation: Fail — the prior plan explicitly required normalized, unique route keys and exact route/allowlist correspondence, but the implementation validates only raw-key membership without recording a deviation.
- Verification trust: Fail — every claimed command reran successfully, but fresh reviewer evidence contradicts the claimed closed route-key normalization matrix.
- Spec conformance (SDD S02/S04 via `milestone-task=preset-schema,hot-preset`): Fail — direct/light shape validation is present, but the normalized preset descriptor is not unambiguous enough for S02 generation isolation or S04 fail-closed startup admission.

### Findings

- **Required** — `packages/go/config/execution_preset_types.go:151`: `validatePreset` trims each route key only for membership and then validates `p.Routes[m]`, so `routes` containing both `direct` and `" direct "` loads successfully and retains both entries. This violates the inherited plan requirement to normalize route mode keys in place, reject normalized duplicates, and make route keys exactly equal to `allowed_modes`. Rebuild `p.Routes` under trimmed keys before correspondence checks, reject a duplicate normalized key deterministically, and add valid spaced-key normalization plus duplicate-normalized-key regression cases in `packages/go/config/execution_preset_config_test.go`.

### Routing Signals

- `review_rework_count=3`
- `evidence_integrity_failure=true`

### Next Step

Prepare the smallest route-key normalization follow-up through the plan skill with the raw finding and fresh reviewer reproducer. No milestone-lock or external-execution user-review gate applies.
