<!-- task=m-iop-hot-path-one-shot-execution/15+13,14_error_cancel plan=0 tag=API milestone-task=error-cancel -->

# 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 blocked, record exact blocker, attempted commands/output, and resume condition only.
> Do not ask the user, call user-input tools, classify the next state, archive files, or write `complete.log`.
> Finalization is review-agent-only.

## Overview

date=2026-08-03
task=m-iop-hot-path-one-shot-execution/15+13,14_error_cancel, plan=0, tag=API

## For the Review Agent

> **[REVIEW AGENT ONLY]** Compare implementation/output against the plan. Implementers must not finalize.

1. Append verdict and routing signals.
2. Archive `CODE_REVIEW-cloud-G10.md` → `code_review_cloud_G10_0.log` and `PLAN-cloud-G09.md` → `plan_cloud_G09_0.log`.
3. If PASS, write `complete.log` and move to `agent-task/archive/YYYY/MM/m-iop-hot-path-one-shot-execution/15+13,14_error_cancel/`; otherwise write the directed next state.
4. Preserve/report `milestone-task=error-cancel` on PASS.
5. Complete the review-only checklist at the final location.

## Implementation Item Completion

| Item | Status |
|---|---|
| API-1 Standard terminal disposition | [ ] |
| API-2 Endpoint outcome matrix | [ ] |

## Implementation Checklist

- [ ] [API-1] Centralize Hot Path terminal disposition so provider/config/context/timeout/cancel/output-cap outcomes stop hidden work and map to each endpoint's standard pre/post-commit shape exactly once.
- [ ] [API-2] Add the endpoint-by-outcome table and concurrent cancel/complete regressions, then run targeted plus SDD common verification.
- [ ] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

## Review-Only Checklist

- [ ] Append one PASS/WARN/FAIL verdict and verified routing signals.
- [ ] Verify verdict, dimensions, and finding classifications match.
- [ ] Archive `CODE_REVIEW-cloud-G10.md` to `code_review_cloud_G10_0.log`.
- [ ] Archive `PLAN-cloud-G09.md` to `plan_cloud_G09_0.log`.
- [ ] Verify the `.gitignore` managed block.
- [ ] On PASS write standard `complete.log` and leave no active `.md` files.
- [ ] On PASS move the task directory to dated archive and update this checklist there.
- [ ] On PASS preserve/report `milestone-task=error-cancel` without editing roadmap directly.
- [ ] Remove active parent only if empty.
- [ ] On WARN/FAIL write the next state and no `complete.log`.

## Deviations from Plan

_Implementer records actual deviations or `none`._

## Key Design Decisions

_Implementer records actual decisions._

## Reviewer Checkpoints

- Verify endpoint×commit-state×failure-source matrix uses only standard error/cancel/length meanings.
- Verify primary-error precedence, exactly-one terminal, CancelRun cardinality, and no hidden work after abort.
- Verify the exact active stage dispatch/cancel handle reaches the arbiter and endpoint codecs own post-commit error bytes.
- Verify output cap is native length terminal and no partial-success status exists.

## Verification Results

### Targeted

Command: `go test -race -count=1 ./apps/edge/internal/openai -run 'TestHotPath(EndpointTerminalMatrix|CancelCompleteRace|Cleanup)|Test(ChatCompletion|Responses|StreamChatCompletion).*(Cancel|Timeout)'`

_Paste actual stdout/stderr and exit status._

### SDD common

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

_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 modify or 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 |
