<!-- task=m-multi-provider-protocol-profile-native-messages/02+01_messages_ingress plan=1 tag=API -->

# Code Review Reference - 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-07-31
task=m-multi-provider-protocol-profile-native-messages/02+01_messages_ingress, plan=1, tag=API

## Roadmap Targets

- Milestone: `agent-roadmap/phase/operational-observability-provider-management/milestones/multi-provider-protocol-profile-native-messages.md`
- Milestone link: [Milestone 문서](agent-roadmap/phase/operational-observability-provider-management/milestones/multi-provider-protocol-profile-native-messages.md)
- Task ids:
  - `messages-surface`: canonical/alias route, principal auth, Anthropic model schema, count-tokens
  - `messages-native`: native Messages raw tunnel 보존
  - `messages-chat-bridge`: Messages↔Chat 의미/stream bridge
- Completion mode: check-on-pass


## 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-G09.md` → `code_review_cloud_G09_01.log` and `PLAN-cloud-G09.md` → `plan_cloud_G09_01.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/02+01_messages_ingress/`. 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 |
|------|---------|
| API-1 | [ ] |
| API-2 | [ ] |
| API-3 | [ ] |
| API-4 | [ ] |

## Implementation Checklist

- [ ] Add canonical/alias Anthropic routes, shared bearer/x-api-key principal resolution, version-selected model schema, and native/local count-tokens behavior with S05 tests.
- [ ] Implement profile-selected native Messages tunneling with header allowlist, model rewrite, byte/SSE/error preservation, and exactly-once terminal evidence for S06.
- [ ] Implement strict Messages↔Chat non-stream/stream transformation for supported content, tools, thinking, usage, stop, and error semantics, rejecting unsupported inputs before dispatch for S07.
- [ ] Run focused direct-Edge fixtures and full Edge/Node regression with fresh Go test results.
- [ ] 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_G09_01.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G09_01.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`.
- [ ] If PASS, write `complete.log` based on `agent-ops/skills/common/code-review/templates/complete-log-template.md` and leave no active `.md` files.
- [ ] If PASS, move active task directory `agent-task/m-multi-provider-protocol-profile-native-messages/02+01_messages_ingress/` to `agent-task/archive/YYYY/MM/m-multi-provider-protocol-profile-native-messages/02+01_messages_ingress/` and update this checklist at the final archive path.
- [ ] If PASS and task group is `m-<milestone-slug>`, report completion event metadata for runtime, without modifying roadmap or directly calling `update-roadmap`.
- [ ] 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.
- [x] If WARN/FAIL, write the next filesystem state matching code-review verdict and do not write `complete.log`.

## Deviations from Plan

Implementation did not start because the required predecessor evidence file is absent. The plan explicitly prohibits implementation before this dependency exists. No source files or tests were changed or run.

Resume condition: `agent-task/m-multi-provider-protocol-profile-native-messages/01_protocol_core/complete.log` exists, after which implementation and the full verification sequence may begin.

## Key Design Decisions

None. The implementation gate failed before design or code changes began.

## Reviewer Checkpoints

- Confirm predecessor `01_protocol_core` PASS evidence existed before implementation.
- Confirm canonical and `/anthropic` aliases share handlers and principal context; unequal Authorization/X-Api-Key credentials fail without token disclosure.
- Confirm `anthropic-version`, never User-Agent/vendor inference, selects the Anthropic `/v1/models` shape.
- Confirm native Messages relay only documented model/header changes and preserve body/status/error/SSE order with one terminal.
- Confirm bridge rejects unsupported blocks/options/beta before dispatch and preserves tool ids/arguments, thinking, usage, stop reason and provider errors.
- Confirm count-tokens uses native capability or deterministic model counter and never substitutes an arbitrary Chat provider call.

## Verification Results

> **Implementation owner:** Run every command below exactly as written and paste actual stdout/stderr. If a command changes, record the replacement and reason in `Deviations from Plan` first. Long output may be saved to a deterministic file only when the exact save command and path are recorded.

### Verification 1

```bash
test -f agent-task/m-multi-provider-protocol-profile-native-messages/01_protocol_core/complete.log
```

```text
(no stdout/stderr; exit status 1)
```

### Verification 2

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

```text
Not run: Verification 1 failed because the required predecessor completion evidence is absent.
```

### Verification 3

```bash
go test -count=1 ./apps/edge/internal/openai -run 'TestAnthropic(Canonical|Principal|Models|CountTokens)'
```

```text
Not run: implementation is blocked by the missing predecessor completion evidence.
```

### Verification 4

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

```text
Not run: implementation is blocked by the missing predecessor completion evidence.
```

### Verification 5

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

```text
Not run: implementation is blocked by the missing predecessor completion evidence.
```

### Verification 6

```bash
go vet ./apps/edge/...
```

```text
Not run: implementation is blocked by the missing predecessor completion evidence.
```

### Verification 7

```bash
go test -count=1 ./apps/edge/...
```

```text
Not run: implementation is blocked by the missing predecessor completion evidence.
```

### Verification 8

```bash
go test -count=1 ./apps/node/...
```

```text
Not run: implementation is blocked by the missing predecessor completion evidence.
```

### Verification 9

```bash
rg -n --sort path '"/(anthropic/)?v1/(messages|models)' apps/edge/internal/openai
```

```text
Not run: implementation is blocked by the missing predecessor completion evidence.
```

### Verification 10

```bash
git diff --check
```

```text
Not run: implementation is blocked by the missing predecessor completion evidence.
```

---

> **[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: FAIL
- Dimension Assessment:
  - Correctness: Fail — none of the S05-S07 Messages surface, native tunnel, or Chat bridge behavior is present.
  - Completeness: Fail — API-1 through API-4 and every implementation checklist item remain incomplete.
  - Test Coverage: Fail — the required Anthropic route, native tunnel, bridge, and regression tests were not created or executed.
  - API Contract: Fail — the Edge still exposes only the existing OpenAI routes; the planned Anthropic-compatible contract is absent.
  - Code Quality: Pass — no scoped production implementation was added, so no new code-quality defect is attributable to this attempt.
  - Implementation Deviation: Fail — implementation stopped on a dependency probe that contradicted the split-task archive lookup contract.
  - Verification Trust: Pass — the reported active-path probe result is reproducible and skipped commands are explicitly identified as not run.
  - Spec Conformance: Fail — SDD Acceptance Scenarios S05-S07 and their Evidence Map rows have no implementation or verification evidence.
- Findings:
  - Required — `PLAN-cloud-G09.md:88`, `PLAN-cloud-G09.md:109-110`, and `PLAN-cloud-G09.md:352` require only the active predecessor path and explicitly prohibit the archive lookup required for a `02+01_*` dependent subtask. The predecessor PASS evidence exists at `agent-task/archive/2026/08/m-multi-provider-protocol-profile-native-messages/01_protocol_core/complete.log`, while the active-path probe correctly exits 1 because PASS finalization moved the predecessor directory. Replace the gate with the split-task active-then-archive lookup, cite the exact archived `complete.log` in the follow-up plan, then implement and verify API-1 through API-4.
  - Required — `CODE_REVIEW-cloud-G09.md:45-60` and `CODE_REVIEW-cloud-G09.md:121-188` show that API-1 through API-4, all production/test files, and all required verification beyond the invalid dependency gate are incomplete. Implement the S05-S07 surface/native/bridge behavior and provide fresh focused plus full Edge/Node evidence before requesting another review.
- Routing Signals:
  - `review_rework_count=1`
  - `evidence_integrity_failure=false`
- Next Step: Invoke the plan skill in `prepare-follow-up` mode with these raw findings, revalidate the archived predecessor completion evidence, rerun isolated task routing, and materialize the routed follow-up PLAN/CODE_REVIEW pair after archiving this pair.
