<!-- task=m-principal-provider-credential-slot-routing/08+03,04,07_secure_delivery plan=0 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-08-01
task=m-principal-provider-credential-slot-routing/08+03,04,07_secure_delivery, plan=0, tag=API

## Roadmap Targets

- Milestone: `agent-roadmap/phase/operational-observability-provider-management/milestones/principal-provider-credential-slot-routing.md`
- Milestone link: [Milestone 문서](agent-roadmap/phase/operational-observability-provider-management/milestones/principal-provider-credential-slot-routing.md)
- Task ids:
  - `secure-transport`: credential-bearing peer 인증과 전송 기밀성
  - `credential-lease`: principal/slot/route/target/revision/expiry bounded lease
  - `adapter-injection`: request-local provider auth header 주입
  - `revocation`: rotation/revoke 이후 새 lease/dispatch/retry 차단
- Completion mode: check-on-pass

## Archive Evidence Snapshot

- `agent-task/archive/2026/08/m-principal-provider-credential-slot-routing/03+01,02_projection_auth/complete.log`: immutable generation/expiry cache와 managed auth foundation PASS; production transport activation은 제외됐다.
- `agent-task/archive/2026/08/m-principal-provider-credential-slot-routing/04+03_principal_routes/complete.log`: principal route/slot/profile/model binding과 no-fallback PASS; production delivery는 제외됐다.
- `agent-task/m-principal-provider-credential-slot-routing/07+01,02,05_secret_material/complete.log`: 현재 missing이다. 구현 전 반드시 이 exact path가 생겨 concrete decrypt/key-version contract가 완료되어야 한다.
- prior PASS에는 unresolved Required finding이 없었다. 03/04의 dormant contract를 보존하고 07의 keyring을 소비한다.

## 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-G10.md` → `code_review_cloud_G10_0.log` and `PLAN-cloud-G10.md` → `plan_cloud_G10_0.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-principal-provider-credential-slot-routing/08+03,04,07_secure_delivery/`. If WARN/FAIL, fully write the next filesystem state required by the code-review skill.
4. If PASS and task group is `m-principal-provider-credential-slot-routing`, 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 Credential-bearing TLS boundaries | [ ] |
| API-2 Projection activation and bounded lease issuer | [ ] |
| API-3 Candidate-bound delivery and last-moment injection | [ ] |
| API-4 Rotation/revocation ordering fence | [ ] |

## Implementation Checklist

- [ ] Add fail-closed TLS configuration and peer-identity tests for credential-bearing Client-Control Plane, Control Plane-Edge, and Edge-Node connections.
- [ ] Add dedicated projection/credential-lease wire messages and a Control Plane issuer that validates active principal/route/slot/revision before decrypting.
- [ ] Bind Edge lease acquisition/cache to the selected candidate and projection generation, and fence expiry, revocation, rotation, retry, and Control Plane outage deterministically.
- [ ] Deliver the secret only in a dedicated sensitive payload and inject the profile auth header inside the Node adapter immediately before the upstream request.
- [ ] Add three-process TLS/lease/upstream-header, tamper/scope, revocation-race, and secret-leak regression verification.
- [ ] 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.

- [ ] Append one verdict of `PASS`, `WARN`, or `FAIL` and verified `review_rework_count`, `evidence_integrity_failure` to `Code Review Result`.
- [ ] Verify that verdict, `Dimension Assessment`, and Required/Suggested/Nit classifications match.
- [ ] Archive active `CODE_REVIEW-*-G??.md` to `code_review_cloud_G10_0.log`.
- [ ] Archive active `PLAN-*-G??.md` to `plan_cloud_G10_0.log`.
- [ ] 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-principal-provider-credential-slot-routing/08+03,04,07_secure_delivery/` to `agent-task/archive/YYYY/MM/m-principal-provider-credential-slot-routing/08+03,04,07_secure_delivery/` and update this checklist at the final archive path.
- [ ] If PASS and task group is `m-principal-provider-credential-slot-routing`, 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-principal-provider-credential-slot-routing/` 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

_Record any deviations from the plan and the rationale here._

## Key Design Decisions

_Record key design decisions here._

## Reviewer Checkpoints

- Verify every credential-bearing hop rejects plaintext, no-cert, wrong-CA and wrong-name before sensitive parsing.
- Verify CP issuer reads one current route/slot snapshot and binds every lease dimension plus bounded expiry.
- Verify raw secret exists only in the dedicated sensitive field and request-local adapter buffer, never generic maps or observability.
- Verify candidate selection precedes lease acquisition and the selected profile/target exactly match issuer and Node validation.
- Verify revoke/rotate/out-of-order projection ordering: an already-started attempt may finish, but no queued/new/retry attempt uses the old revision.
- Verify generated Go/Dart protobufs are deterministic and all race tests pass.

## Verification Results

Paste actual stdout/stderr below each command. Do not summarize or reconstruct it. Replacement commands require a `Deviations from Plan` entry.

### API-1

```bash
go test -count=1 ./packages/go/auth ./packages/go/config ./apps/control-plane/internal/wire ./apps/edge/internal/controlplane ./apps/edge/internal/transport ./apps/node/internal/transport
```

_Actual output:_

### API-2

```bash
go test -count=1 -race ./apps/control-plane/internal/credentiallease ./apps/edge/internal/authprojection ./apps/edge/internal/service ./apps/edge/internal/controlplane
```

_Actual output:_

### API-3

```bash
make proto
make proto-dart
sha256sum proto/gen/iop/control.pb.go proto/gen/iop/runtime.pb.go apps/client/lib/gen/proto/iop/control.pb.dart apps/client/lib/gen/proto/iop/control.pbenum.dart apps/client/lib/gen/proto/iop/control.pbjson.dart apps/client/lib/gen/proto/iop/control.pbserver.dart apps/client/lib/gen/proto/iop/runtime.pb.dart apps/client/lib/gen/proto/iop/runtime.pbenum.dart apps/client/lib/gen/proto/iop/runtime.pbjson.dart apps/client/lib/gen/proto/iop/runtime.pbserver.dart > /tmp/iop-credential-proto-first.sha256
make proto
make proto-dart
sha256sum proto/gen/iop/control.pb.go proto/gen/iop/runtime.pb.go apps/client/lib/gen/proto/iop/control.pb.dart apps/client/lib/gen/proto/iop/control.pbenum.dart apps/client/lib/gen/proto/iop/control.pbjson.dart apps/client/lib/gen/proto/iop/control.pbserver.dart apps/client/lib/gen/proto/iop/runtime.pb.dart apps/client/lib/gen/proto/iop/runtime.pbenum.dart apps/client/lib/gen/proto/iop/runtime.pbjson.dart apps/client/lib/gen/proto/iop/runtime.pbserver.dart > /tmp/iop-credential-proto-second.sha256
diff -u /tmp/iop-credential-proto-first.sha256 /tmp/iop-credential-proto-second.sha256
go test -count=1 ./apps/edge/internal/openai ./apps/edge/internal/service ./apps/node/internal/node ./apps/node/internal/adapters/openai_compat
```

_Actual output:_

### API-4

```bash
go test -count=1 -race ./apps/control-plane/internal/credentiallease ./apps/edge/internal/service ./apps/node/internal/node
```

_Actual output:_

### Final Verification

```bash
command -v go && go version && go env GOROOT
command -v protoc && command -v flutter
git status --short --branch
make proto
make proto-dart
sha256sum proto/gen/iop/control.pb.go proto/gen/iop/runtime.pb.go apps/client/lib/gen/proto/iop/control.pb.dart apps/client/lib/gen/proto/iop/control.pbenum.dart apps/client/lib/gen/proto/iop/control.pbjson.dart apps/client/lib/gen/proto/iop/control.pbserver.dart apps/client/lib/gen/proto/iop/runtime.pb.dart apps/client/lib/gen/proto/iop/runtime.pbenum.dart apps/client/lib/gen/proto/iop/runtime.pbjson.dart apps/client/lib/gen/proto/iop/runtime.pbserver.dart > /tmp/iop-credential-proto-first.sha256
make proto
make proto-dart
sha256sum proto/gen/iop/control.pb.go proto/gen/iop/runtime.pb.go apps/client/lib/gen/proto/iop/control.pb.dart apps/client/lib/gen/proto/iop/control.pbenum.dart apps/client/lib/gen/proto/iop/control.pbjson.dart apps/client/lib/gen/proto/iop/control.pbserver.dart apps/client/lib/gen/proto/iop/runtime.pb.dart apps/client/lib/gen/proto/iop/runtime.pbenum.dart apps/client/lib/gen/proto/iop/runtime.pbjson.dart apps/client/lib/gen/proto/iop/runtime.pbserver.dart > /tmp/iop-credential-proto-second.sha256
diff -u /tmp/iop-credential-proto-first.sha256 /tmp/iop-credential-proto-second.sha256
go test -count=1 ./packages/go/auth ./packages/go/config
go test -count=1 ./apps/control-plane/internal/wire ./apps/control-plane/internal/credentiallease ./apps/control-plane/cmd/control-plane
go test -count=1 ./apps/edge/internal/authprojection ./apps/edge/internal/controlplane ./apps/edge/internal/transport ./apps/edge/internal/openai ./apps/edge/internal/service
go test -count=1 ./apps/node/internal/transport ./apps/node/internal/node ./apps/node/internal/adapters/openai_compat
go test -count=1 -race ./apps/control-plane/internal/credentiallease ./apps/edge/internal/authprojection ./apps/edge/internal/service ./apps/node/internal/node
go vet ./apps/control-plane/... ./apps/edge/... ./apps/node/... ./packages/go/...
rg --sort path -n 'ProviderSecret|credential.*secret|Authorization' proto/iop/control.proto proto/iop/runtime.proto apps/edge/internal/service apps/node/internal/node
```

_Actual output:_

---

> **[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 |
