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

# Complete - m-iop-hot-path-one-shot-execution/12+10,11_outer_turn_core

## Completed At

2026-08-03

## Summary

Hardened the Hot Path outer-turn core across two reviewed implementation loops; the final verdict is PASS after closing three inherited lifecycle, framing, and output-cap defects.

## Loop History

| Plan | Review | Verdict | Notes |
|------|--------|---------|-------|
| `plan_cloud_G08_2.log` | `code_review_cloud_G09_2.log` | FAIL | Required real attempt ownership, strict tunnel frame ordering, and a cap covering every public output channel. |
| `plan_cloud_G07_3.log` | `code_review_cloud_G08_3.log` | PASS | Corrective implementation and fresh focused/common race, vet, formatting, and diff evidence passed. |

## Implementation and Cleanup

- Injected an idempotent abort/graceful-close controller into each stage runtime so successful, error, and cancellation paths release the owned transport exactly once.
- Rejected tunnel `BODY` or `END` before `RESPONSE_START` and channel close before explicit completion with one sanitized provider-error stage terminal.
- Applied one Unicode-rune output budget across text, reasoning, and tool arguments for the entire outer turn, with atomic crossing-fragment suppression and a single `length` terminal.

## Final Verification

- `go test -race -count=1 ./apps/edge/internal/openai -run 'TestHotPath(StageTransportOwnership|StageTunnelFraming|StageRuntime|StageProtocolFragments|OuterTurnOutputCap|OuterTurnTerminalRace)'` - PASS; `ok iop/apps/edge/internal/openai 1.127s`.
- `go test -race -count=1 ./packages/go/streamgate ./packages/go/config ./apps/edge/internal/openai ./apps/edge/internal/service` - PASS; streamgate `2.201s`, config `1.930s`, openai `12.127s`, service `7.111s`.
- `go vet ./apps/edge/internal/openai` - PASS; no output.
- `gofmt -d apps/edge/internal/openai/hot_path_stage_stream.go apps/edge/internal/openai/hot_path_terminal_control.go apps/edge/internal/openai/hot_path_terminal_control_test.go` - PASS; no output.
- `git diff --check` - PASS; no output.
- Repository Edge-Node diagnostics, supplemental E2E smoke, full-cycle runtime execution, and credentialed provider smoke were not run because this corrective child is a deterministic pre-integration core; the active PLAN assigns live Hot Path coverage to S16.

## Remaining Nits

- None.

## Follow-up Work

- None for this child; sibling integration tasks connect the core to direct/light handlers and endpoint codecs.
