<!-- 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 -->

# Integrated Response Identity Evidence Closure

## For the Implementing Agent

Implement every checklist item, run the exact verification commands, and fill the implementation-owned sections in `CODE_REVIEW-*-G??.md` with actual notes and stdout/stderr. Keep the active pair in place and report ready for official review. If blocked, record only the exact blocker, attempted commands/output, and resume condition in implementation-owned evidence fields. Do not ask the user, call user-input tools, create control-plane stop files, classify the next state, archive logs, or write `complete.log`.

## Background

The virtual-preset production path, public contracts, and broad regression suite pass fresh review verification. The integrated regressions still do not prove the exact provider response identities they claim, and the missing-provider-metadata matrix does not prove that its frame timestamp remains internal. This follow-up closes only those assertion gaps without changing production behavior or the settled contract.

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

## Dependencies and Execution Order

- `02+01_preset_generation` is satisfied by `agent-task/archive/2026/08/m-iop-hot-path-one-shot-execution/02+01_preset_generation/complete.log`.
- `04+02,03_preset_model_authorization` is satisfied by `agent-task/archive/2026/08/m-iop-hot-path-one-shot-execution/04+02,03_preset_model_authorization/complete.log`.
- `06+04,05_request_identity_ingress` is satisfied by `agent-task/archive/2026/08/m-iop-hot-path-one-shot-execution/06+04,05_request_identity_ingress/complete.log`.
- Complete REVIEW_API-1 and REVIEW_API-2 before the whole-plan verification block.

## Analysis

### Files Read

- `apps/edge/internal/openai/chat_handler.go`
- `apps/edge/internal/openai/anthropic_handler.go`
- `apps/edge/internal/openai/hot_path_dispatch.go`
- `apps/edge/internal/openai/hot_path_selector.go`
- `apps/edge/internal/openai/hot_path_direct.go`
- `apps/edge/internal/openai/principal_routes.go`
- `apps/edge/internal/openai/route_resolution.go`
- `apps/edge/internal/openai/anthropic_native.go`
- `apps/edge/internal/openai/hot_path_selector_test.go`
- `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`
- `agent-contract/outer/openai-compatible-api.md`
- `agent-contract/outer/anthropic-compatible-api.md`
- `agent-spec/input/openai-compatible-surface.md`
- `agent-roadmap/current.md`
- `agent-roadmap/phase/knowledge-tool-optimization-extension/PHASE.md`
- `agent-roadmap/phase/knowledge-tool-optimization-extension/milestones/iop-hot-path-one-shot-execution.md`
- `agent-roadmap/sdd/knowledge-tool-optimization-extension/iop-hot-path-one-shot-execution/SDD.md`
- `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/PLAN-cloud-G08.md`
- `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/CODE_REVIEW-cloud-G08.md`
- `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/plan_local_G07_0.log`
- `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/code_review_cloud_G08_0.log`
- `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/plan_cloud_G10_1.log`
- `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/code_review_cloud_G10_1.log`
- `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/plan_cloud_G08_2.log`
- `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/code_review_cloud_G08_2.log`

### SDD Criteria

- SDD: `agent-roadmap/sdd/knowledge-tool-optimization-extension/iop-hot-path-one-shot-execution/SDD.md`; status approved and SDD lock released.
- First-line tasks: `route-selector,direct-flow`.
- S03 requires `route-selector` to accept only structurally valid direct/light output under the preset allowlist and deterministic capability/health gate; its Evidence Map row requires structural output-shape, allowlist, and hard-gate table tests.
- S07 requires `direct-flow` text/high-thinking/tool completion without Plan/Review artifacts or `.iop/job/<request_id>` emission; its Evidence Map row requires direct integration and artifact-absence evidence.
- Exact provider identity and absence of run/frame transport metadata are part of the endpoint-native direct evidence carried by the approved S03/S07 boundary. The checklist therefore adds exact integrated identity and correlation assertions, then reruns the focused, race, and full Edge suites that exercise the real handler path.

### Verification Context

- No separate verification handoff was supplied. Repository-native evidence came from the active plan/review, the three planned tests, their production handlers/direct path, the public contracts, the living spec, the approved SDD, and the local test rules.
- Reviewer preflight established `/config/workspace/iop-s0` as the repository root, `/config/.local/bin/go` as Go `1.26.2 linux/arm64`, satisfied predecessor `complete.log` paths, and no external runner or network dependency for this follow-up.
- Fresh reviewer commands passed the focused integrated suite, selector/direct suite, common race suite, full Edge suite under an isolated `TMPDIR`, `go vet`, `gofmt -d`, and `git diff --check`.
- The remaining gap is assertion quality, not runtime availability: three success cases do not compare the decoded public ID with their fixture ID, and the missing-ID matrix does not reject its frame timestamp sentinel. Confidence is high because the omission is visible in the exact test assertions while all execution paths are locally reproducible.
- The worktree contains unrelated user/parallel changes. Implementation ownership is limited to the three test files and the active review evidence file listed in `Modified Files Summary`.

### Test Coverage Gaps

- `TestVirtualPresetModelHandlersPreservePublicIdentity/chat completions`: exercises the production path but checks only status and virtual model; exact `chatcmpl-public` identity is not asserted.
- `TestVirtualPresetModelHandlersPreservePublicIdentity/anthropic messages bridge`: decodes the response but checks only the virtual model; exact `chatcmpl-public` identity is not asserted.
- `TestAnthropicNativeVirtualPresetPreservesPublicModelIdentity/non-stream JSON`: decodes the response but checks only the virtual model; exact `msg-public` identity is not asserted.
- `TestHotPathPresetHandlersDirect/MissingProviderMetadataReturnsEndpointErrors`: rejects `run-should-not-leak` but does not reject the frame timestamp fixture in raw nanoseconds or endpoint-normalized seconds.
- Existing fragmented Messages SSE identity, direct terminalization, pre-start-frame rejection, selector gate, and ordinary-route raw-relay coverage already pass and remain unchanged.

### Symbol References

None. This follow-up changes assertions only and renames or removes no symbols.

### Split Judgment

Keep one compact plan. The four observed variants jointly prove one public identity/correlation invariant, and splitting them would leave the review claim only partially established. The dependent task path is unchanged; predecessor indices 02, 04, and 06 are satisfied by the exact archived `complete.log` paths listed above.

### Scope Rationale

Production handlers/direct codecs, public contracts, the living spec, selector tests, roadmap state, and external smoke are excluded because fresh review evidence found no behavior or documentation defect in those areas. S16 owns external Hot Path smoke; this follow-up is deterministic local test-evidence closure only.

### Final Routing

- `evaluation_mode=isolated-reassessment`; `finalizer=finalize-task-policy.sh`; `finalizer_mode=pair`.
- Build closures: scope, context, verification, evidence, ownership, and decision are all closed from the exact tests, production paths, contracts, SDD criteria, and fresh local commands; no capability gap.
- Build grade scores: scope coupling 1, state/concurrency 0, blast/irreversibility 0, evidence diagnosis 1, verification complexity 1; grade G03. Base route is `local-fit`.
- Build signals: `large_indivisible_context=false`; positive loop risks are `boundary_contract` and `variant_product` (`loop_risk_count=2`); `review_rework_count=4`; `evidence_integrity_failure=true`; recovery boundary matched and risk boundary did not match.
- Build route: `recovery-boundary`, cloud, `PLAN-cloud-G03.md`.
- Review closures are all closed with no capability gap. Review grade scores are 1/0/0/1/1 for G03; route is `official-review`, cloud, `CODE_REVIEW-cloud-G03.md`, adapter Codex, model `gpt-5.6-sol`, reasoning effort `xhigh`.

## Implementation Checklist

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

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

### [REVIEW_API-1] Assert exact integrated provider response identity

#### Problem

`apps/edge/internal/openai/principal_routes_test.go:1237` accepts the Chat fixture after checking only status and virtual model, while `apps/edge/internal/openai/principal_routes_test.go:1265` decodes the Anthropic bridge response but checks only its model. `apps/edge/internal/openai/anthropic_native_test.go:250` has the same gap for native non-stream Messages. These tests can pass if the direct encoder substitutes a different non-empty provider response ID.

#### Solution

Decode the Chat JSON response and compare its `id` with `chatcmpl-public`. Extend the Anthropic bridge assertion to require `response.ID == "chatcmpl-public"`, and extend the native non-stream assertion to require `response.ID == "msg-public"`. Keep the existing virtual-model, selector-binding, header-rewrite, reserved-path, and terminal assertions intact.

#### Modified Files and Checklist

- [ ] `apps/edge/internal/openai/principal_routes_test.go` — assert exact provider IDs for Chat JSON and the Anthropic bridge.
- [ ] `apps/edge/internal/openai/anthropic_native_test.go` — assert exact `msg-public` identity in native non-stream output.

#### Test Strategy

Modify existing integrated regressions rather than add parallel tests. `TestVirtualPresetModelHandlersPreservePublicIdentity` must fail when either Chat/bridge ID differs from `chatcmpl-public`, and `TestAnthropicNativeVirtualPresetPreservesPublicModelIdentity/non-stream JSON` must fail when the ID differs from `msg-public`.

#### Verification

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

### [REVIEW_API-2] Assert transport-correlation isolation in missing-ID errors

#### Problem

`apps/edge/internal/openai/hot_path_direct_test.go:171` rejects `run-should-not-leak` but does not reject the timestamp `1555000000000000000` supplied by every missing-ID fixture. A response that exposes that frame timestamp, including the endpoint-normalized `1555000000` seconds form, can pass the current matrix.

#### Solution

Give the run ID and frame timestamp stable test constants, reuse them in the fixtures, and require the serialized endpoint error to contain neither the run ID, the raw nanosecond timestamp, nor its normalized seconds representation. Keep the status, endpoint-standard error type, and terminal coordinator assertions unchanged.

#### Modified Files and Checklist

- [ ] `apps/edge/internal/openai/hot_path_direct_test.go` — reuse explicit transport-correlation sentinels and assert that neither timestamp representation is public.

#### Test Strategy

Strengthen the existing `TestHotPathPresetHandlersDirect/MissingProviderMetadataReturnsEndpointErrors` table so all Chat JSON/SSE and Messages JSON/SSE missing-ID variants share the same absence assertion. No separate test is needed because the existing matrix already exercises all four provider encodings.

#### Verification

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

## Modified Files Summary

| File | Items |
|------|-------|
| `apps/edge/internal/openai/principal_routes_test.go` | REVIEW_API-1 |
| `apps/edge/internal/openai/anthropic_native_test.go` | REVIEW_API-1 |
| `apps/edge/internal/openai/hot_path_direct_test.go` | REVIEW_API-2 |
| `agent-task/m-iop-hot-path-one-shot-execution/07+02,04,06_route_selector_direct/CODE_REVIEW-cloud-G03.md` | REVIEW_API-1, REVIEW_API-2 |

## Final 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)'
go test -race -count=1 ./packages/go/streamgate ./packages/go/config ./apps/edge/internal/openai ./apps/edge/internal/service
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; the exact provider response ID survives direct encoding, missing-ID errors contain no run/frame correlation value, existing selector/direct and ordinary-route behavior remains passing, and all changed tests are formatted. Cached test output is not acceptable.

After completing all code changes, fill implementation-owned sections in `CODE_REVIEW-*-G??.md`.
