<!-- task=m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct plan=4 tag=REVIEW_API milestone-task=route-selector,direct-flow -->

# Code Review Reference - REVIEW_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 official 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, even after compaction/resume.
> Follow the ownership table at the bottom of this file for which sections you own.

## Overview

date=2026-08-03
task=m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct, plan=4, tag=REVIEW_API

## Archive Evidence Snapshot

- Prior plan: `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/plan_cloud_G08_3.log`.
- Prior review: `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/code_review_cloud_G08_3.log`.
- Verdict: FAIL with 1 Required, 0 Suggested, and 0 Nit findings.
- Required closure: assert the exact provider fixture IDs in the integrated Chat JSON, Anthropic bridge, and native non-stream success cases, and reject both run-ID and frame-timestamp sentinels in the missing-provider-metadata error matrix.
- Affected files: `apps/edge/internal/openai/principal_routes_test.go`, `apps/edge/internal/openai/anthropic_native_test.go`, and `apps/edge/internal/openai/hot_path_direct_test.go`.
- Verification evidence: fresh focused, selector/direct, common-race, full Edge, vet, formatting, and diff commands exited zero, but source inspection contradicted the review's claim that these cases assert provider identity and all transport correlation.
- Roadmap carryover: `route-selector,direct-flow`; SDD S03 requires structural hard-gate evidence and S07 requires endpoint-native direct completion without internal artifact or transport metadata exposure.

## For the Review Agent

> **[REVIEW AGENT ONLY]** The finalization steps below are review-agent only. Implementing agents must not execute this section.

Compare implementation of each item against source files and verify that output in `Verification Results` matches code.
Review completion means the following steps are finished:

1. Append verdict and `review_rework_count` / `evidence_integrity_failure` routing signals.
2. Archive `CODE_REVIEW-cloud-G03.md` → `code_review_cloud_G03_4.log` and `PLAN-cloud-G03.md` → `plan_cloud_G03_4.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/`. If WARN/FAIL, fully write the next filesystem state required by the code-review skill.
4. If PASS and task group is `m-<milestone-slug>`, preserve the first-line `milestone-task` metadata in `complete.log` and report it for the runtime aggregation event. Roadmap state evaluation belongs to `sync-milestone-workstate`.
5. Check applicable `Review-Only Checklist` items at the final `.log` location before reporting.

---

## Implementation Item Completion

| Item | Status |
|------|---------|
| REVIEW_API-1 Assert exact integrated provider response identity | [x] |
| REVIEW_API-2 Assert transport-correlation isolation in missing-ID errors | [x] |

## Implementation Checklist

- [x] Assert the exact provider fixture ID in integrated Chat JSON, Anthropic bridge, and native Messages non-stream success responses.
- [x] Assert that missing-provider-metadata endpoint errors expose neither the run-ID sentinel nor the frame-timestamp sentinel in raw or normalized form.
- [x] Run fresh focused, selector/direct, common-race, full Edge, vet, formatting, and diff verification with every required command exiting zero.
- [x] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

## Review-Only Checklist

> **[REVIEW AGENT ONLY]** This checklist is used only by the review agent.
> Implementing agents must not modify or check this section.

- [x] Append one verdict of `PASS`, `WARN`, or `FAIL` and verified `review_rework_count`, `evidence_integrity_failure` to `Code Review Result`.
- [x] Verify that verdict, `Dimension Assessment`, and Required/Suggested/Nit classifications match.
- [x] Archive active `CODE_REVIEW-*-G??.md` to `code_review_cloud_G03_4.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G03_4.log`.
- [x] Verify that the Agent-Ops managed block in `.gitignore` unignores `agent-task/**/*.md` and `agent-task/**/*.log` and ignores `agent-roadmap/current.md`.
- [x] If PASS, write `complete.log` based on `agent-ops/skills/common/code-review/templates/complete-log-template.md` and leave no active `.md` files.
- [x] If PASS, move active task directory `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/` to `agent-task/archive/YYYY/MM/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/` and update this checklist at the final archive path.
- [x] If PASS and task group is `m-<milestone-slug>`, preserve and report `milestone-task` metadata for runtime aggregation, without modifying roadmap or directly calling `update-roadmap`.
- [x] If PASS for split work, remove empty active parent `agent-task/m-iop-hot-path-one-shot-execution/` or verify it was kept due to remaining siblings/files.
- [ ] If WARN/FAIL, write the next filesystem state matching code-review verdict and do not write `complete.log`.

## Deviations from Plan

None.

## Key Design Decisions

Checked response.ID against exact fixture IDs ("chatcmpl-public" for Chat JSON and Anthropic bridge; "msg-public" for native Messages) in addition to virtual model ID assertions. Used explicit constants for run ID sentinel ("run-should-not-leak") and frame timestamp sentinels (nano int64 1_555_000_000_000_000_000, nano string "1555000000000000000", secs string "1555000000") and asserted that missing-ID endpoint errors contain none of them.

## Reviewer Checkpoints

- The three integrated success variants compare decoded public IDs against the exact provider fixture IDs, not merely non-empty values or virtual model identity.
- The missing-provider-metadata matrix rejects the run ID and both raw-nanosecond and endpoint-normalized-second forms of its frame timestamp fixture.
- Assertions exercise the existing production handlers/direct encoders without production or contract changes.
- Every focused, selector/direct, common-race, full Edge, vet, formatting, and diff command exits zero with uncached test evidence.

## Verification Results

Paste the actual stdout/stderr for every command. Do not summarize or reconstruct output. If a command changes, record the replacement and reason in `Deviations from Plan`.

### REVIEW_API-1 Exact provider identity assertions

```bash
go test -count=1 ./apps/edge/internal/openai -run 'Test(AnthropicNativeVirtualPresetPreservesPublicModelIdentity|VirtualPresetModelHandlersPreservePublicIdentity)'
```

Expected: PASS; all integrated success variants preserve the exact provider fixture response ID and virtual public model.

_Actual stdout/stderr:_
```
ok  	iop/apps/edge/internal/openai	0.055s
```

### REVIEW_API-2 Transport-correlation isolation assertions

```bash
go test -count=1 ./apps/edge/internal/openai -run 'TestHotPathPresetHandlersDirect/MissingProviderMetadataReturnsEndpointErrors'
```

Expected: PASS; every missing-ID variant returns its endpoint-standard sanitized error with no run/frame correlation value.

_Actual stdout/stderr:_
```
ok  	iop/apps/edge/internal/openai	0.118s
```

### Final dependency and integrated verification

```bash
test -f agent-task/archive/2026/08/m-iop-hot-path-one-shot-execution/02+01_preset_generation/complete.log
test -f agent-task/archive/2026/08/m-iop-hot-path-one-shot-execution/04+02,03_preset_model_authorization/complete.log
test -f agent-task/archive/2026/08/m-iop-hot-path-one-shot-execution/06+04,05_request_identity_ingress/complete.log
go test -count=1 ./apps/edge/internal/openai -run 'Test(AnthropicNativeVirtualPresetPreservesPublicModelIdentity|VirtualPresetModelHandlersPreservePublicIdentity|HotPathPresetHandlersDirect)'
go test -count=1 ./apps/edge/internal/openai -run 'TestHotPath(SelectorDecisionMatrix|PresetHandlersDirect|Direct)'
```

Expected: all commands exit 0; dependencies remain satisfied and all focused integrated/direct cases pass uncached.

_Actual stdout/stderr:_
```
ok  	iop/apps/edge/internal/openai	0.085s
ok  	iop/apps/edge/internal/openai	0.043s
```

### Final common-race verification

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

Expected: PASS with uncached race evidence across the shared packages and Edge request path.

_Actual stdout/stderr:_
```
ok  	iop/packages/go/streamgate	2.748s
ok  	iop/packages/go/config	1.944s
ok  	iop/apps/edge/internal/openai	9.016s
ok  	iop/apps/edge/internal/service	7.055s
```

### Final Edge, vet, formatting, and diff verification

```bash
route_selector_identity_tmp_dir="$(mktemp -d /config/.tmp-iop-route-selector-identity.XXXXXX)"
TMPDIR="$route_selector_identity_tmp_dir" go test -count=1 ./apps/edge/...
rmdir "$route_selector_identity_tmp_dir"
go vet ./apps/edge/...
gofmt -d apps/edge/internal/openai/anthropic_native_test.go apps/edge/internal/openai/principal_routes_test.go apps/edge/internal/openai/hot_path_direct_test.go
git diff --check
```

Expected: all commands exit 0; all Edge packages pass uncached, vet reports no issue, and formatting/diff checks produce no output.

_Actual stdout/stderr:_
```
ok  	iop/apps/edge/cmd/edge	0.696s
ok  	iop/apps/edge/internal/authprojection	0.062s
ok  	iop/apps/edge/internal/bootstrap	6.276s
ok  	iop/apps/edge/internal/configrefresh	0.501s
ok  	iop/apps/edge/internal/controlplane	6.641s
ok  	iop/apps/edge/internal/edgecmd	0.282s
ok  	iop/apps/edge/internal/edgevalidate	0.088s
ok  	iop/apps/edge/internal/events	0.059s
ok  	iop/apps/edge/internal/input	0.129s
ok  	iop/apps/edge/internal/input/a2a	0.106s
ok  	iop/apps/edge/internal/node	0.096s
ok  	iop/apps/edge/internal/openai	7.606s
ok  	iop/apps/edge/internal/opsconsole	0.065s
ok  	iop/apps/edge/internal/service	5.981s
ok  	iop/apps/edge/internal/transport	4.880s
```

---

> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section?**
> If anything is blank, go back and fill it in before saving this file.
> Leave review-agent-only sections unchanged.

## Section Ownership

| Section | Owner | Note |
|---------|-------|------|
| Header comment, Overview, Review Agent Instructions | Fixed at stub creation | Implementing agent must not modify or execute these (archive, complete.log, and task-directory archive move are review-agent only) |
| Archive Evidence Snapshot | Fixed at stub creation from plan when present | Implementing agent uses it as default prior-loop context; read only the specific archive files cited there when more detail is required |
| Implementation Item Completion (item names) | Fixed at stub creation | Implementing agent checks `[ ]` → `[x]` only |
| Implementation Checklist (item text/order) | Fixed at stub creation from plan | Implementing agent checks `[ ]` → `[x]` only |
| Review-Only Checklist | Review agent only | Implementing agent must not modify or check this section |
| Deviations from Plan, Key Design Decisions | Implementing agent | Replace placeholder text with actual content |
| Reviewer Checkpoints | Fixed at stub creation | Pre-filled from plan |
| Verification Results (section headings + commands) | Fixed at stub creation | Implementing agent fills in command output only; command changes require a `Deviations from Plan` entry |
| Code Review Result | Review agent appends | Not included in stub |

## Code Review Result

- Overall Verdict: PASS
- Dimension Assessment:
  - Correctness: Pass
  - Completeness: Pass
  - Test coverage: Pass
  - API contract: Pass
  - Code quality: Pass
  - Implementation deviation: Pass
  - Verification trust: Pass
  - Spec conformance: Pass
- Findings: None
- Routing Signals:
  - review_rework_count=4
  - evidence_integrity_failure=false
- Next Step: Archive the active pair, write `complete.log`, move the task to the monthly archive, and report the Milestone completion event metadata.
