<!-- task=m-iop-owned-single-request-agent-execution/01_preset_config plan=2 tag=API milestone-task=preset-binding -->

# Fixed Single-request Preset Policy

## For the Implementing Agent

Implement this plan exactly within the listed write boundary. Run every verification command, fill all implementation-owned sections of `CODE_REVIEW-cloud-G04.md` with actual notes and stdout/stderr, keep both active files in place, and report ready for review. Finalization belongs only to the code-review skill. If blocked, record the exact blocker, attempted commands/output, and resume condition in implementation-owned evidence fields; do not ask the user, call user-input tools, create control-plane stop files, classify the next state, archive logs, or write `complete.log`.

## Archive Evidence Snapshot

- Split parent pair: `plan_local_G07_1.log`, `code_review_cloud_G07_1.log`.
- The split parent contained no implementation evidence or review verdict; implementation has not started.
- This child retains only the typed schema, validation, and clone-isolation slice. Refresh classification and documentation moved to packet 04.

## Background

The execution-preset schema has generic `direct` and caller-continuation `light` forms but no operator-owned marker for the approved fixed single-request path. SDD S02 requires an opaque workspace capability and immutable request/stage limits while preserving existing preset compatibility.

## Analysis

### Files Read

- `packages/go/config/execution_preset_types.go`
- `packages/go/config/execution_preset_config_test.go`
- `agent-roadmap/phase/knowledge-tool-optimization-extension/milestones/iop-owned-single-request-agent-execution.md`
- `agent-roadmap/sdd/knowledge-tool-optimization-extension/iop-owned-single-request-agent-execution/SDD.md`

### SDD Criteria

- SDD status is approved and its implementation lock is released.
- First-line Milestone task: `preset-binding`; targeted Acceptance Scenario: S02.
- This child supplies fixed-light decode, validation, cloning, and compatibility evidence. Runtime authorization/model echo stays in packet 02, and refresh/schema publication stays in packet 04.

### Verification Context

- The parent packet selected repository-native focused/package config tests, package vet/regression, and `git diff --check`; this child preserves the config-owned subset.
- Preconditions: none. Ordinary presets remain compatible, and no external runner/provider is used.

### Test Coverage Gaps

- Existing config tests do not cover a fixed single-request marker, typed limits, legacy workspace-tool exclusion, dynamic-mode rejection, or deep-clone isolation.

### Symbol References

- No symbol is renamed or removed. `ExecutionPreset.Clone` and `CloneExecutionPresetCatalog` are existing consumers extended by this child.

### Split Judgment

- Stable result: a validated and deeply cloned typed preset independently passes config tests.
- Refresh classification and published schema form a second production slice after packet 02, avoiding concurrent edits to its config-refresh spec.

### Scope Rationale

- Exclude refresh classification, route resolution, handlers, provider execution, Node/workspace execution, protobuf, SSE, contract, and spec updates.
- Keep unmarked direct/light presets compatible. `workspace_ref` stays opaque; add no endpoint, credential, Node id, raw path, dynamic selection, or silent default.

### Final Routing

- `evaluation_mode=isolated-reassessment`; finalizer `finalize-task-policy.sh` in `pair` mode.
- Build closures scope/context/verification/evidence/ownership/decision are true; scores 1/0/1/1/1 = G04; base/final route `local-fit`; lane `local`; canonical filename `PLAN-local-G04.md`.
- Build signals: `large_indivisible_context=false`; positive loop risks `boundary_contract`, `structured_interpretation`, `variant_product` (3); `review_rework_count=0`; `evidence_integrity_failure=false`; no capability gap.
- Review closures are true; scores 1/0/1/1/1 = G04; route `official-review`; lane `cloud`; canonical filename `CODE_REVIEW-cloud-G04.md`.

## Implementation Checklist

- [ ] Add and validate the optional fixed single-request preset policy, deep-clone it, and prove valid, boundary, invalid, legacy, and clone-isolation cases.
- [ ] Run targeted config, package, vet, full package regression, and `git diff --check` verification.
- [ ] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

## Implementation Plan

### [API-1] Add the typed fixed single-request policy

**Problem**

- `packages/go/config/execution_preset_types.go:13` defines no marker that distinguishes operator-owned single-request execution from generic caller-continuation light presets.
- `packages/go/config/execution_preset_types.go:61` has no policy pointer/nested map to clone, and `packages/go/config/execution_preset_types.go:281` cannot enforce the approved fixed shape.

**Solution**

Before (`packages/go/config/execution_preset_types.go:15`):

```go
ID string `mapstructure:"id" yaml:"id"`
Selector ExecutionModelBinding `mapstructure:"selector" yaml:"selector"`
AllowedModes []string `mapstructure:"allowed_modes" yaml:"allowed_modes"`
Routes map[string]ExecutionRoute `mapstructure:"routes" yaml:"routes"`
```

After:

```go
// Existing fields stay source-compatible.
SingleRequest *ExecutionSingleRequestPolicy `mapstructure:"single_request" yaml:"single_request,omitempty"`
```

Add typed workspace/limit structs and server-owned absolute caps: wall clock 30 minutes, each stage timeout 10 minutes, 64 tool iterations per stage, and 16 MiB output per stage. Require every configured value in `1..cap`, each stage timeout not to exceed the request wall clock, and the stage map to contain exactly `plan`, `work`, and `review`. A marked preset allows only `light`, binds selector/review to high reasoning, rejects high reasoning on work, and rejects legacy caller `workspace_tools`. Preserve unmarked validation. Deep-copy the pointer and nested stage map.

**Modified Files and Checklist**

- [ ] `packages/go/config/execution_preset_types.go` — add typed policy, named absolute caps, normalization, fail-closed validation, and deep cloning.
- [ ] `packages/go/config/single_request_execution_preset_config_test.go` — cover valid decode, cap/cap+1 and timeout-vs-wall-clock boundaries, missing/extra stages, dynamic modes, option leakage, legacy tools, unknown fields, and clone isolation.

**Test Strategy**

- Add `TestLoadEdgeSingleRequestExecutionPreset`, `TestLoadEdgeSingleRequestExecutionPresetRejectsInvalidShape`, and `TestCloneExecutionPresetSingleRequestIsolation` using Gemini plan/review, ornith-fast work, an opaque workspace ref, and explicit positive bounded limits.
- Include zero, exact cap, cap+1, and stage-timeout-greater-than-wall-clock rows for every limit family, then rerun existing generic catalog/rejection tests.

**Verification**

- `go test ./packages/go/config -run 'Test(LoadEdgeSingleRequestExecutionPreset|CloneExecutionPresetSingleRequestIsolation|LoadEdgeExecutionPresetCatalog|LoadEdgeExecutionPresetRejectsInvalidShape)$' -count=1`
- Expected: valid/exact-cap and legacy cases pass; zero/cap+1/cross-limit/malformed shapes fail; clone mutation cannot affect the source.

## Modified Files Summary

| File | Item |
|------|------|
| `packages/go/config/execution_preset_types.go` | API-1 |
| `packages/go/config/single_request_execution_preset_config_test.go` | API-1 |
| `agent-task/m-iop-owned-single-request-agent-execution/01_preset_config/CODE_REVIEW-cloud-G04.md` | API-1 |

## Final Verification

1. `go test ./packages/go/config -run 'Test(LoadEdgeSingleRequestExecutionPreset|CloneExecutionPresetSingleRequestIsolation|LoadEdgeExecutionPresetCatalog|LoadEdgeExecutionPresetRejectsInvalidShape)$' -count=1`
2. `go test ./packages/go/config -count=1`
3. `go vet ./packages/go/...`
4. `go test ./packages/go/... -count=1`
5. `git diff --check`

Expected: all commands exit 0; ordinary presets stay compatible; invalid marked shapes fail closed; policy clones are isolated. Refresh classification and schema publication remain packet 04.

**After completing all code changes, fill implementation-owned sections in `CODE_REVIEW-*-G??.md`.**
