<!-- task=m-multi-provider-protocol-profile-native-messages/03+02_responses_profile plan=3 tag=REVIEW_API -->

# 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 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-01
task=m-multi-provider-protocol-profile-native-messages/03+02_responses_profile, plan=3, tag=REVIEW_API

## Archive Evidence Snapshot

- Current loop archives after review finalization: `agent-task/m-multi-provider-protocol-profile-native-messages/03+02_responses_profile/plan_cloud_G07_02.log` and `agent-task/m-multi-provider-protocol-profile-native-messages/03+02_responses_profile/code_review_cloud_G07_02.log`.
- Verdict: FAIL. Required: 3; Suggested: 0; Nit: 0.
- Required finding 1: `SubmitProviderPool` still combines operation admission with request-local predicates and returns only `ErrProviderPoolCandidateRejected` during initial and live re-resolution.
- Required finding 2: `/v1/responses` still maps the generic sentinel to the output-validation message, the handler fake skips operation admission, and the unsupported regression still expects HTTP 502.
- Required finding 3: API-1 through API-3 remain unchecked and all eleven verification blocks still contain placeholders.
- The Messages predecessor remains satisfied by `agent-task/archive/2026/08/m-multi-provider-protocol-profile-native-messages/02+01_messages_ingress/complete.log`.
- Roadmap carryover: this split child supplies only the Responses profile/runtime portion of S08; Pi and contract/spec siblings remain responsible for the rest of `responses-regression`, so this plan intentionally has no `Roadmap Targets` section.

## 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-G06.md` → `code_review_cloud_G06_03.log` and `PLAN-cloud-G06.md` → `plan_cloud_G06_03.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-multi-provider-protocol-profile-native-messages/03+02_responses_profile/`. 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>`, report completion event metadata. Roadmap state check and `update-roadmap` calls are runtime responsibilities.
5. Check applicable `Review-Only Checklist` items at the final `.log` location before reporting.

---

## Implementation Item Completion

| Item | Status |
|------|---------|
| REVIEW_API-1 | [x] |
| REVIEW_API-2 | [x] |
| REVIEW_API-3 | [x] |

## Implementation Checklist

- [x] Add typed unsupported-operation admission before request-local filtering and preserve generic terminal compatibility across initial and live re-resolution.
- [x] Map the typed Responses rejection to the sanitized 400 contract and make the handler fake/tests follow production admission ordering.
- [x] Run every deterministic focused, broad, full Edge/Node, vet, smoke, and diff command and record actual output.
- [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_G06_03.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G06_03.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-multi-provider-protocol-profile-native-messages/03+02_responses_profile/` to `agent-task/archive/YYYY/MM/m-multi-provider-protocol-profile-native-messages/03+02_responses_profile/` and update this checklist at the final archive path.
- [x] If PASS and task group is `m-<milestone-slug>`, report completion event metadata for runtime, without modifying roadmap or directly calling `update-roadmap`.
- [x] If PASS for split work, remove empty active parent `agent-task/m-multi-provider-protocol-profile-native-messages/` 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

Implemented `ProviderPoolOperationUnsupportedError` wrapping `ErrProviderPoolCandidateRejected` in `apps/edge/internal/service/provider_pool.go`. Ordered operation filtering before request-local predicate in `SubmitProviderPool` and live re-resolution closure. Mapped `ProviderPoolOperationUnsupportedError` in `responses_handler.go` to HTTP 400 `invalid_request_error` with message `"no provider profile supports the requested Responses operation"`. Aligned `providerFakeRunService` with production operation admission order before request policy/preparation.

## Reviewer Checkpoints

- Confirm initial all-unsupported and live re-resolution paths return `ProviderPoolOperationUnsupportedError` with operation `responses`, still satisfy `errors.Is(..., ErrProviderPoolCandidateRejected)`, terminate admission, and send no Node request.
- Confirm request-local/output-validation rejection remains distinguishable and retains its existing generic public message.
- Confirm `/v1/responses` maps only the typed operation rejection to HTTP 400, OpenAI `invalid_request_error`, and `no provider profile supports the requested Responses operation`.
- Confirm `providerFakeRunService` applies concrete-profile operation admission before candidate policy, tunnel preparation, request recording, or normalized dispatch, while nil-profile legacy behavior remains admitted.
- Confirm supported explicit-profile, legacy fallback, body/status/stream, provider-auth, and Node operation-over-Path behavior remain unchanged.
- Confirm every recorded Go command includes the deterministic `GOCACHE`/`GOTMPDIR` values, uses `-count=1` for tests, and contains actual stdout/stderr matching a fresh reviewer rerun.
- Confirm no contract/spec, Pi, roadmap, or central `agent-ops` file changed under this follow-up plan.

## Verification Results

### Verification 1 — Archived dependency

~~~bash
test -f agent-task/archive/2026/08/m-multi-provider-protocol-profile-native-messages/02+01_messages_ingress/complete.log
~~~

~~~text
exit status 0
~~~

### Verification 2 — Go toolchain

~~~bash
command -v go && go version && go env GOROOT
~~~

~~~text
/config/.local/bin/go
go version go1.26.2 linux/arm64
/config/opt/go
exit status 0
~~~

### Verification 3 — Deterministic cache/temp roots

~~~bash
mkdir -p /config/.cache/iop-responses-profile-g07 /config/workspace/iop-s0/.local/gotmp-responses-profile-g07
~~~

~~~text
exit status 0
~~~

### Verification 4 — Service operation admission

~~~bash
env GOCACHE=/config/.cache/iop-responses-profile-g07 GOTMPDIR=/config/workspace/iop-s0/.local/gotmp-responses-profile-g07 go test -count=1 ./apps/edge/internal/service -run 'TestProtocolProfileOperationAdmission'
~~~

~~~text
ok  	iop/apps/edge/internal/service	0.027s
exit status 0
~~~

### Verification 5 — Focused Responses profile suite

~~~bash
env GOCACHE=/config/.cache/iop-responses-profile-g07 GOTMPDIR=/config/workspace/iop-s0/.local/gotmp-responses-profile-g07 go test -count=1 ./apps/edge/internal/openai -run 'TestResponses(ProtocolProfile|LegacyProfileFallback)'
~~~

~~~text
ok  	iop/apps/edge/internal/openai	0.083s
exit status 0
~~~

### Verification 6 — Broad Responses and provider-auth suite

~~~bash
env GOCACHE=/config/.cache/iop-responses-profile-g07 GOTMPDIR=/config/workspace/iop-s0/.local/gotmp-responses-profile-g07 go test -count=1 ./apps/edge/internal/openai -run 'TestResponses|Test.*ProviderAuth'
~~~

~~~text
ok  	iop/apps/edge/internal/openai	0.075s
exit status 0
~~~

### Verification 7 — Node profile/Responses compatibility

~~~bash
env GOCACHE=/config/.cache/iop-responses-profile-g07 GOTMPDIR=/config/workspace/iop-s0/.local/gotmp-responses-profile-g07 go test -count=1 ./apps/node/internal/adapters/openai_compat -run 'TestProtocolProfile|TestLegacyEndpointPathFallback|TestOpenAICompatTunnelProvider_ResponsesPath'
~~~

~~~text
ok  	iop/apps/node/internal/adapters/openai_compat	0.024s
exit status 0
~~~

### Verification 8 — Full Edge suite

~~~bash
env GOCACHE=/config/.cache/iop-responses-profile-g07 GOTMPDIR=/config/workspace/iop-s0/.local/gotmp-responses-profile-g07 go test -count=1 ./apps/edge/...
~~~

~~~text
ok  	iop/apps/edge/cmd/edge	1.027s
ok  	iop/apps/edge/internal/bootstrap	5.244s
ok  	iop/apps/edge/internal/configrefresh	0.749s
ok  	iop/apps/edge/internal/controlplane	4.548s
ok  	iop/apps/edge/internal/edgecmd	0.423s
ok  	iop/apps/edge/internal/edgevalidate	0.075s
ok  	iop/apps/edge/internal/events	0.058s
ok  	iop/apps/edge/internal/input	0.169s
ok  	iop/apps/edge/internal/input/a2a	0.159s
ok  	iop/apps/edge/internal/node	0.131s
ok  	iop/apps/edge/internal/openai	7.780s
ok  	iop/apps/edge/internal/opsconsole	0.061s
ok  	iop/apps/edge/internal/service	5.921s
ok  	iop/apps/edge/internal/transport	4.791s
exit status 0
~~~

### Verification 9 — Edge vet

~~~bash
env GOCACHE=/config/.cache/iop-responses-profile-g07 GOTMPDIR=/config/workspace/iop-s0/.local/gotmp-responses-profile-g07 go vet ./apps/edge/...
~~~

~~~text
exit status 0
~~~

### Verification 10 — Credential-free Edge/Node/provider smoke

~~~bash
IOP_LEMONADE_MODE=fake IOP_LEMONADE_GOCACHE=/config/.cache/iop-responses-profile-g07 ./scripts/e2e-openai-lemonade.sh
~~~

~~~text
[openai-lemonade] OpenAI-compatible Lemonade serving test PASSED (mode=fake).
exit status 0
~~~

### Verification 11 — Diff validation

~~~bash
git diff --check
~~~

~~~text
exit status 0
~~~

---

> **[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) |
| Roadmap Targets | Fixed at stub creation from plan when present | Implementing agent must not modify; code-review copies it into `complete.log` as `Roadmap Completion` only on PASS |
| 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 — initial and live provider-pool resolution now distinguish unsupported protocol operations from request-local candidate rejection while preserving terminal sentinel compatibility and zero dispatch.
  - Completeness: Pass — REVIEW_API-1 through REVIEW_API-3, their implementation checklist, and every planned verification result are complete.
  - Test Coverage: Pass — focused service tests cover mixed, all-unsupported, legacy nil-profile, and live re-resolution cases; Responses handler tests cover exact public error mapping and preserved success/auth/stream behavior.
  - API Contract: Pass — only the typed Responses operation rejection maps to HTTP 400 `invalid_request_error` with the sanitized operation-specific message; generic request-local rejection keeps its existing mapping.
  - Code Quality: Pass — the implementation keeps operation admission service-owned, preserves the existing error sentinel through `Unwrap`, and leaves no stale helper, placeholder, debug output, or scoped TODO.
  - Implementation Deviation: Pass — the implementation matches the follow-up plan; unrelated shared-worktree contract/spec, Pi, and roadmap changes remain outside this selected split child.
  - Verification Trust: Pass — all eleven recorded commands were rerun against the current checkout with the declared deterministic cache/temp roots and passed; `git diff --check` remained clean.
- Findings: None.
- Routing Signals:
  - review_rework_count=2
  - evidence_integrity_failure=false
- Next Step: Archive the active plan/review pair, write `complete.log`, move this split task under the 2026/08 task archive, and report the Milestone completion event metadata without modifying the roadmap.
