<!-- task=m-iop-hot-path-one-shot-execution/15+13_chat_gate plan=3 tag=REVIEW_REVIEW_API milestone-task=terminal-control,chat-gate -->

# Complete - m-iop-hot-path-one-shot-execution/15+13_chat_gate

## Completed At

2026-08-03

## Summary

The Chat gate task closed with PASS after one pre-implementation replacement and two FAIL rework loops; the final loop resolved event-scoped provider identity enforcement and provider-owned length terminal handling.

## Loop History

| Plan | Review | Verdict | Notes |
|------|--------|---------|-------|
| `plan_cloud_G09_0.log` | `code_review_cloud_G10_0.log` | INCOMPLETE | The initial pair was replaced by source reanalysis before implementation evidence or a verdict existed. |
| `plan_cloud_G09_1.log` | `code_review_cloud_G10_1.log` | FAIL | Progressive Chat release and provider-owned public response identity were required. |
| `plan_cloud_G10_2.log` | `code_review_cloud_G10_2.log` | FAIL | Per-event normalized identity and live provider length terminal propagation were required. |
| `plan_cloud_G09_3.log` | `code_review_cloud_G09_3.log` | PASS | All inherited findings were resolved and fresh deterministic verification passed. |

## Implementation and Cleanup

- Required every normalized visible and complete `RunEvent` to carry the stable provider `openai_response_id`, while preserving conflict detection on identity-bearing non-visible events.
- Preserved OpenAI `length`, Anthropic `max_tokens`, and normalized completion reasons as held stage terminal evidence.
- Ended a no-tool Light flow on provider output-limit terminals before local commit or review dispatch, emitted one caller-native `length` terminal, and removed logical and Light state.
- Added selector, live-source, decoder-projection, and progressive Chat regressions for the repaired identity and terminal invariants.

## Final Verification

- `go test -race -count=1 ./apps/edge/internal/openai -run 'TestHotPathPresetHandlersDirect|TestHotPathNormalizedStageSourceRequiresIdentity|TestHotPathChatProviderLength|TestHotPathLiveStageTerminalReason'` - PASS; `ok iop/apps/edge/internal/openai 1.342s`.
- `go test -race -count=1 ./apps/edge/internal/openai -run 'TestHotPathChat|TestHotPathDirect|TestHotPathOuterTurn|TestChatStreamSession'` - PASS; `ok iop/apps/edge/internal/openai 2.526s`.
- `go test -race -count=1 ./packages/go/streamgate ./packages/go/config ./apps/node/internal/adapters/openai_compat ./apps/edge/internal/openai ./apps/edge/internal/service` - PASS; all five packages passed with no race report.
- `go vet ./apps/node/internal/adapters/openai_compat ./apps/edge/...` - PASS; no output.
- `gofmt -l apps/edge/internal/openai/hot_path_stage_stream.go apps/edge/internal/openai/hot_path_dispatch.go apps/edge/internal/openai/hot_path_terminal_control.go apps/edge/internal/openai/hot_path_light.go apps/edge/internal/openai/hot_path_chat_gate_test.go apps/edge/internal/openai/hot_path_direct_test.go` - PASS; no output.
- `git diff --check` - PASS; no output.
- Repository Edge-Node diagnostics, supplemental E2E/provider smoke, and full-cycle Pi execution were not run because the active plan assigns credentialed live execution to the separate `hot-smoke` task; this task contributes deterministic S10/S12 evidence only.

## Remaining Nits

- None.

## Follow-up Work

- None.
