<!-- task=m-iop-hot-path-one-shot-execution/12+10,11_outer_turn_core plan=1 tag=API milestone-task=terminal-control -->

# 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`; 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.

## Overview

date=2026-08-03
task=m-iop-hot-path-one-shot-execution/12+10,11_outer_turn_core, plan=1, tag=API

## Archive Evidence Snapshot

- Archived predecessor 10: PASS.
- Archived predecessor 11: PASS.

## For the Review Agent

1. Append verdict and routing signals.
2. Archive `CODE_REVIEW-cloud-G09.md` → `code_review_cloud_G09_1.log` and `PLAN-cloud-G08.md` → `plan_cloud_G08_1.log`.
3. On PASS write `complete.log` and move to `agent-task/archive/YYYY/MM/m-iop-hot-path-one-shot-execution/12+10,11_outer_turn_core/`; otherwise write the directed next state.
4. Preserve/report `milestone-task=terminal-control` on PASS.
5. Complete the review-only checklist at the final location.

## Implementation Item Completion

| Item | Status |
|---|---|
| API-1 Protocol-neutral outer-turn core | [ ] |
| API-2 Core terminal-control evidence | [ ] |

## Implementation Checklist

- [ ] [API-1] Reuse Stream Evidence Gate with terminal/provider-error-only subscriptions and introduce the normalized outer-turn core with deterministic id, usage, cap, and terminal state.
- [ ] [API-2] Add Core release/hold, ordering, aggregation, cap, and exactly-once race tests and run the child verification commands.
- [ ] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

## Review-Only Checklist

- [ ] Append one verdict of `PASS`, `WARN`, or `FAIL` and verified `review_rework_count`, `evidence_integrity_failure`.
- [ ] Verify verdict, dimension assessment, and Required/Suggested/Nit classifications match.
- [ ] Archive `CODE_REVIEW-cloud-G09.md` to `code_review_cloud_G09_1.log`.
- [ ] Archive `PLAN-cloud-G08.md` to `plan_cloud_G08_1.log`.
- [ ] Verify the Agent-Ops managed block in `.gitignore`.
- [ ] If PASS, write `complete.log` from the standard template and leave no active `.md` files.
- [ ] If PASS, move the task directory to the dated archive and update this checklist at the final location.
- [ ] If PASS, preserve/report `milestone-task=terminal-control` without directly editing the roadmap.
- [ ] If PASS, remove the active parent only when no siblings/files remain.
- [ ] If WARN/FAIL, write the next filesystem state and do not write `complete.log`.

## Deviations from Plan

_Implementer records actual deviations or `none`._

## Key Design Decisions

_Implementer records actual decisions._

## Reviewer Checkpoints

- Confirm actual `streamgate.RequestRuntime` use and terminal/provider-error-only hold.
- Confirm ordered release, id/usage/cap aggregation, and exactly-one terminal/logical completion under race.
- Confirm endpoint-specific wire policy and direct/light integration remain outside this child.

## Verification Results

### Targeted

Command: `go test -race -count=1 ./apps/edge/internal/openai -run 'TestHotPath(TerminalOnlyCoreRelease|OuterTurnOrderingAndAggregation|OuterTurnOutputCap|OuterTurnTerminalRace)'`

_Paste actual stdout/stderr and exit status._

### Core regression

Command: `go test -race -count=1 ./packages/go/streamgate ./apps/edge/internal/openai`

_Paste actual stdout/stderr and exit status._

### Diff

Command: `git diff --check`

_Paste actual stdout/stderr and exit status._

---

> **[IMPLEMENTING AGENT — BEFORE SAVING]** Fill every implementation-owned section and leave review-only sections unchanged.

## Section Ownership

| Section | Owner | Note |
|---|---|---|
| Header, Overview, Review Agent Instructions | Fixed | Implementer must not finalize |
| Implementation Item Completion, Implementation Checklist | Implementer checks only | Text/order stays fixed |
| Review-Only Checklist | Review agent | Implementer must not modify |
| Deviations, Key Design Decisions | Implementer | Record actual content |
| Reviewer Checkpoints | Fixed | Reviewer verifies |
| Verification Results | Implementer fills output | Command changes require deviation |
| Code Review Result | Review agent appends | Not included in stub |
