<!-- task=m-iop-hot-path-one-shot-execution/02+01_preset_generation plan=0 tag=API milestone-task=preset-schema,hot-preset -->

# Immutable Preset Generation Startup and Refresh

## For the Implementing Agent

Start only after predecessor 01 has `complete.log`. Implement this plan, run every command, and fill `CODE_REVIEW-cloud-G07.md` with actual notes/output. Keep active files for official review; finalization belongs to the code-review skill.

## Background

The preset schema needs an immutable runtime generation that is installed consistently at startup and live refresh without changing snapshots retained by active requests.

## Analysis

### Files Read

- `agent-roadmap/phase/knowledge-tool-optimization-extension/milestones/iop-hot-path-one-shot-execution.md`
- `agent-roadmap/sdd/knowledge-tool-optimization-extension/iop-hot-path-one-shot-execution/SDD.md`
- `packages/go/config/execution_preset_types.go`
- `apps/edge/internal/configrefresh/classify.go`
- `apps/edge/internal/configrefresh/node_runtime_classify_test.go`
- `apps/edge/internal/openai/server.go`
- `apps/edge/internal/input/manager.go`
- `apps/edge/internal/bootstrap/runtime.go`

### SDD Criteria

SDD scenarios S02/S04 require startup and refresh generation isolation and runtime agreement with the registered direct/light descriptor keys. This child covers that runtime publication boundary.

### Verification Context

Repository-native fresh/race Go tests are sufficient. No external provider, credential, port, or workspace runner is needed. Confidence: high.

### Test Coverage Gaps

No existing test covers preset refresh diffing, caller-owned mutation after set, or retained pre-refresh snapshots.

### Symbol References

New setters extend `input.Manager` and `openai.Server`; runtime assembly is their production caller.

### Split Judgment

This is the second refined child of the former preset catalog pair. It consumes the validated schema from child 01 and independently closes immutable startup/live-refresh propagation.

### Scope Rationale

Do not change preset schema semantics, add model-to-preset references, principal authorization, selector execution, or request state.

### Final Routing

`evaluation_mode=isolated-reassessment`; finalizer pair. Build closures are true; scores `(2,2,1,1,1)` yield G07/local-fit, `large_indivisible_context=false`, matched risks `concurrent_consistency,boundary_contract` (2), rework 0, evidence-integrity failure false; `PLAN-local-G07.md`. Review uses the same scores and official cloud G07 in `CODE_REVIEW-cloud-G07.md`.

## Implementation Checklist

- [ ] Publish a deeply cloned preset generation through startup and live config refresh.
- [ ] Preserve retained snapshots and reject unavailable runtime handlers before dispatch.
- [ ] Run dependency, focused, race, vet, and diff verification exactly as written.
- [ ] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual notes and output.

### [API-2] Publish immutable preset generations at startup and refresh

#### Problem

Startup and refresh only replace the model catalog, and refresh diffing does not index execution presets. Active requests could otherwise observe partially replaced policy.

#### Solution

Implement the preset deep-clone helpers with the runtime-generation owner, add a server snapshot containing a monotonically replaced cloned catalog, wire it through manager startup/refresh, classify preset changes as mutable for new requests, and ensure runtime handler keys agree with the config descriptors before dispatch.

#### Modified Files and Checklist

- [ ] `packages/go/config/execution_preset_types.go` — implement the nested preset clone helpers used by immutable generations.
- [ ] `apps/edge/internal/configrefresh/classify.go` — diff preset ids and classify live changes.
- [ ] `apps/edge/internal/configrefresh/execution_preset_classify_test.go` — verify applied paths and stable ordering.
- [ ] `apps/edge/internal/openai/server.go` — own atomic/deep-cloned execution catalog snapshots.
- [ ] `apps/edge/internal/input/manager.go` — provide one catalog replacement entry point.
- [ ] `apps/edge/internal/bootstrap/runtime.go` — wire startup and refresh replacement.
- [ ] `apps/edge/internal/bootstrap/runtime_execution_preset_test.go` — prove refresh affects new snapshots and not retained ones.

#### Test Strategy

Write `TestClassifyExecutionPresetLiveApply` and `TestRuntimeRefreshReplacesExecutionPresetGeneration`. Mutate caller-owned maps/slices after setting and assert snapshots do not change; retain a pre-refresh snapshot and assert only a post-refresh read sees the new generation.

#### Verification

Run `go test -count=1 ./packages/go/config ./apps/edge/internal/configrefresh ./apps/edge/internal/bootstrap ./apps/edge/internal/openai`; expect PASS.

## Modified Files Summary

| File | Items |
|------|-------|
| `packages/go/config/execution_preset_types.go` | API-2 |
| `apps/edge/internal/configrefresh/classify.go` | API-2 |
| `apps/edge/internal/configrefresh/execution_preset_classify_test.go` | API-2 |
| `apps/edge/internal/openai/server.go` | API-2 |
| `apps/edge/internal/input/manager.go` | API-2 |
| `apps/edge/internal/bootstrap/runtime.go` | API-2 |
| `apps/edge/internal/bootstrap/runtime_execution_preset_test.go` | API-2 |
| `agent-task/m-iop-hot-path-one-shot-execution/02+01_preset_generation/CODE_REVIEW-cloud-G07.md` | API-2 |

## Final Verification

```bash
test -f agent-task/m-iop-hot-path-one-shot-execution/01_preset_schema/complete.log
go test -count=1 ./packages/go/config ./apps/edge/internal/configrefresh ./apps/edge/internal/bootstrap ./apps/edge/internal/openai
go test -race -count=1 ./packages/go/streamgate ./packages/go/config ./apps/edge/internal/openai ./apps/edge/internal/service
go vet ./packages/go/config ./apps/edge/internal/configrefresh ./apps/edge/internal/bootstrap ./apps/edge/internal/openai
git diff --check
```

Expected: every command exits 0 and retained snapshots remain immutable while new requests see the new generation.
