<!-- task=m-iop-hot-path-one-shot-execution/01_preset_schema plan=4 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=4, 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_G05_3.log` and `agent-task/m-iop-hot-path-one-shot-execution/01_preset_schema/code_review_cloud_G06_3.log`.
- Verdict: FAIL. Required 1, Suggested 0, Nit 0.
- Required: normalize route mode keys into the retained map, reject normalized duplicates, and enforce exact normalized equality with `allowed_modes`.
- Reviewer evidence: focused config tests, the full config package, config race, config vet, package-wide vet, formatting, and `git diff --check` passed. A temporary focused reviewer test failed because a preset containing both `direct` and `" direct "` route keys loaded successfully. The temporary test file was removed. Package-wide Go tests remain non-closure evidence because unrelated fake-CLI suites fail on this host's PATH and 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-G05.md` → `code_review_cloud_G05_4.log` and `PLAN-cloud-G04.md` → `plan_cloud_G04_4.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 Normalize route keys before exact correspondence checks | [x] |

## Implementation Checklist

- [x] Rebuild route maps under normalized mode keys, reject empty or duplicate normalized keys deterministically, and enforce exact normalized equality with `allowed_modes` without changing stage validation.
- [x] Add regression coverage for a valid whitespace-normalized route key and duplicate normalized route keys while preserving all existing preset and provider-only cases.
- [x] Run focused, fresh, race, vet, formatting, 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_G05_4.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G04_4.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-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.
- [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-hot-path-one-shot-execution/` 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.

## Key Design Decisions

- Rebuilt `p.Routes` into `normalizedRoutes` map using `strings.TrimSpace(rawKey)` before evaluating `allowed_modes` membership and stage rules.
- Preserved original key iteration order during map construction via `sortedRouteKeys(p.Routes)` for deterministic error reporting when encountering empty or duplicate normalized keys.
- Extended `TestLoadEdgeExecutionPresetCatalog` and `TestLoadEdgeExecutionPresetRejectsInvalidShape` to cover whitespace route normalization and normalized duplicate rejection.

## Reviewer Checkpoints

- The retained `Routes` map contains only normalized mode keys before exact allowlist correspondence is evaluated.
- Raw route keys that converge after trimming are rejected deterministically rather than silently overwriting or retaining an ambiguous entry.
- Existing canonical-reference, route-shape, workspace-descriptor, strict-decode, unsupported-handler, and provider-only regressions 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 route-key verification

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

_Actual stdout/stderr:_
```
ok  	iop/packages/go/config	0.065s
```

### Full config package verification

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

_Actual stdout/stderr:_
```
ok  	iop/packages/go/config	0.089s
```

### Race verification

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

_Actual stdout/stderr:_
```
ok  	iop/packages/go/config	1.494s
```

### Vet, formatting, and diff verification

```bash
go vet ./packages/go/config
go vet ./packages/go/...
gofmt -d packages/go/config/execution_preset_types.go packages/go/config/execution_preset_config_test.go
git diff --check
```

_Actual stdout/stderr:_
```
(clean 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

PASS

### Dimension Assessment

| Dimension | Result | Evidence |
|-----------|--------|----------|
| Correctness | Pass | Route keys are sorted, trimmed into a newly retained map, and rejected when empty or duplicated after normalization before exact `allowed_modes` correspondence and stage validation. |
| Completeness | Pass | The inherited Required finding is closed: normalized route keys are retained canonically, normalized collisions fail closed, and existing stage validation is preserved. |
| Test coverage | Pass | Regression cases cover successful whitespace normalization and rejection of duplicate normalized keys; existing direct/light, unsupported-handler, workspace-descriptor, canonical-reference, strict-decode, and provider-only cases remain passing. |
| API contract | Pass | The loaded preset descriptor now exposes one unambiguous normalized route per allowed mode, preserving the approved config boundary for downstream immutable generation publication. |
| Code quality | Pass | The change is localized, deterministic, formatted, and contains no debug output, dead code, or leftover TODOs. |
| Implementation deviation | Pass | No deviation from the active follow-up plan was found. |
| Verification trust | Pass | Every claimed focused test, package test, race test, vet command, formatting check, and diff check was rerun by the reviewer and matched the recorded successful result. |
| Spec conformance | Pass | The contribution satisfies the normalized descriptor and registered direct/light fail-closed boundary required by SDD S02/S04 for `preset-schema` and `hot-preset`; later generation/runtime evidence remains owned by later children. |

### Findings

None.

### Routing Signals

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

### Next Step

Archive the PASS pair, write `complete.log`, move the split task to the monthly archive, and emit milestone completion metadata for runtime aggregation.
