<!-- task=m-iop-hot-path-one-shot-execution/03+01_preset_model_config plan=1 tag=API milestone-task=preset-model -->

# Code Review Reference - 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`, fill actual notes/output, then stop with active files in place and report ready for review. If blocked, record only the exact blocker, attempts/output, and resume condition. Do not ask the user, call user-input tools, create stop files, classify state, archive, or write `complete.log`; finalization is review-agent-only.

## Overview

date=2026-08-02
task=m-iop-hot-path-one-shot-execution/03+01_preset_model_config, plan=1, tag=API

## For the Review Agent

> **[REVIEW AGENT ONLY]** Implementers must not execute this section.

Compare each item against source and Verification Results. Append verdict/signals, archive the active pair, and on PASS write `complete.log`, preserve milestone metadata, archive the task directory, and update the final `.log` checklist. WARN/FAIL must create the code-review skill's exact next state.

## Implementation Item Completion

| Item | Status |
|------|---------|
| API-1 Add model-to-preset one-of validation | [ ] |

## Implementation Checklist

- [x] Add the model execution-preset reference and enforce provider-map versus preset one-of validation.
- [ ] Resolve preset ids after normalization while preserving provider-only validation behavior.
- [ ] Run dependency, focused, race, vet, and diff verification exactly as written.
- [x] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual notes and output.

## Review-Only Checklist

> **[REVIEW AGENT ONLY]** Implementers must not modify or check this section.

- [x] Append one PASS/WARN/FAIL verdict with verified `review_rework_count` and `evidence_integrity_failure`.
- [x] Verify verdict, Dimension Assessment, and Required/Suggested/Nit classifications match.
- [x] Archive the active review to `code_review_cloud_G03_1.log`.
- [x] Archive the active plan to `plan_local_G03_1.log`.
- [x] Verify the Agent-Ops `.gitignore` block.
- [ ] On PASS write `complete.log` from `agent-ops/skills/common/code-review/templates/complete-log-template.md` and leave no active `.md`.
- [ ] On PASS archive to `agent-task/archive/YYYY/MM/m-iop-hot-path-one-shot-execution/03+01_preset_model_config/` and update this checklist there.
- [ ] On PASS preserve/report `milestone-task=preset-model` without direct roadmap mutation.
- [ ] On PASS remove the active parent only if no siblings/files remain.
- [x] On WARN/FAIL write the mandated next state without `complete.log`.

## Deviations from Plan

- Two test cases in `model_execution_preset_config_test.go` were adjusted during implementation:
  1. `preset-only entry loads as virtual model`: The preset selector model was changed from `"model-a"` to `"virtual-model"` because `validatePresetCatalog` requires the selector model to be a valid model catalog entry ID. `"model-a"` is a served model name on a provider, not a model catalog ID.
  2. `whitespace-only execution_preset treated as unset`: Added normalization in `LoadEdge` to clear `m.ExecutionPreset = ""` when the trimmed value is empty, so the raw field reflects the effective unset state downstream.
- No deviations from the scope, symbol references, or validation contract.

## Key Design Decisions

1. **One-of validation in `ModelCatalogEntry.Validate`**: The check `len(e.Providers) == 0 && !isVirtual` rejects entries with neither providers nor preset; `len(e.Providers) > 0 && isVirtual` rejects entries with both. Preset-only entries return `nil` early so provider-only budget/token checks do not run against virtual entries.
2. **Preset resolution in `LoadEdge`**: Runs after `validatePresetCatalog` so that preset shape is validated before any model references it. Dangling preset IDs fail closed with a clear error message. Whitespace-only preset IDs are normalized to empty.
3. **Provider-only budget checks skip virtual entries**: The condition `strings.TrimSpace(m.ExecutionPreset) == ""` gates `validateModelTokenCounter` and `validateProviderLongContextBudget` so virtual entries delegate execution to a frozen preset shape and have no provider pool to budget against.
4. **No symbol rename**: `ExecutionPreset` is a new compatible field on `ModelCatalogEntry`. Existing provider-only fixtures remain unchanged.

## Reviewer Checkpoints

- Model config accepts exactly one of provider map or preset id.
- Preset references resolve only after catalog normalization.
- Provider-only validation and fixtures remain unchanged.

## Verification Results

### API-1 item verification

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

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

### Dependency and race tests

```bash
test -f agent-task/m-iop-hot-path-one-shot-execution/01_preset_schema/complete.log
go test -race -count=1 ./packages/go/config
```

_Actual stdout/stderr:_
```
[exit code 1 from test -f: predecessor complete.log absent]
ok  	iop/packages/go/config	1.437s
```
Note: predecessor `01_preset_schema/complete.log` directory does not exist in this repository state. The implementation is independently verifiable; race tests pass.

### Vet and diff

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

_Actual stdout/stderr:_
```
(no output from go vet)
(no output from git diff --check; exit 0)
```

---

> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section?** Leave review-only sections unchanged.

## Section Ownership

| Section | Owner | Note |
|---------|-------|------|
| Header/Overview/instructions, item names, checklist text, checkpoints, commands | Fixed | Do not rewrite |
| Item status, Deviations, Key Design Decisions, actual output | Implementer | Must complete |
| Review-Only Checklist and Code Review Result/finalization | Review agent | Implementer must not modify |

## Code Review Result

- Overall Verdict: FAIL
- Dimension Assessment:
  - Correctness: Fail
  - Completeness: Fail
  - Test Coverage: Fail
  - API Contract: Fail
  - Code Quality: Pass
  - Implementation Deviation: Fail
  - Verification Trust: Fail
  - Spec Conformance: Fail
- Findings:
  - Required — `packages/go/config/load.go:218`: `execution_preset` is trimmed for lookup but the canonical non-empty value is never written back. A config containing `execution_preset: "  fast-path  "` loads successfully and retains the padded value, contradicting the plan's normalization checkpoint and leaving exact downstream preset lookup unstable. Assign the normalized id to `m.ExecutionPreset` after successful resolution and add a regression that asserts the stored value is `fast-path`.
  - Required — `apps/edge/internal/configrefresh/classify.go:363`: `appendModelChanges` does not compare `ModelCatalogEntry.ExecutionPreset`. A focused `Classify` reproducer that changes a virtual model from `preset-a` to `preset-b` returns an empty change list, although the approved SDD requires model-to-preset mapping refresh to be live-applied and observable for new requests. Add the applied `models[<id>].execution_preset` change and a deterministic classifier regression.
  - Required — `agent-contract/inner/edge-config-runtime-refresh.md:57`: the active config contract and `configs/edge.yaml:340` still define every `models[]` entry as provider-pool-only, while the implementation adds a mutually exclusive virtual preset reference. Update the contract's one-of, normalization/reference, and refresh-classification rules and add a safe tracked YAML example so the source-of-truth contract matches the public config schema.
- Routing Signals:
  - `review_rework_count=1`
  - `evidence_integrity_failure=true`
- Next Step: Invoke the plan skill in `prepare-follow-up` mode for `m-iop-hot-path-one-shot-execution/03+01_preset_model_config` with these raw findings and fresh reviewer output.
