<!-- task=m-iop-owned-single-request-agent-execution/16+14,15_observation_evidence plan=2 tag=REVIEW_REVIEW_API milestone-task=cleanup-observation -->

# Code Review Reference - REVIEW_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.
> Execute the plan's selected root cause, scope, files, and dependency decisions as written. Do not choose another owner, narrow/expand the write boundary, or replace a fix with another verification attempt.
> 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-08
task=m-iop-owned-single-request-agent-execution/16+14,15_observation_evidence, plan=2, tag=REVIEW_REVIEW_API

## Archive Evidence Snapshot

- Prior plan: `agent-task/m-iop-owned-single-request-agent-execution/16+14,15_observation_evidence/plan_cloud_G05_1.log`
- Prior review: `agent-task/m-iop-owned-single-request-agent-execution/16+14,15_observation_evidence/code_review_cloud_G05_1.log`
- Verdict: `FAIL` with Required finding R1.
- R1: `snapshotSingleRequestMetrics` ignores unknown metric labels, and the captured-log loop does not enforce the production field allowlist or expected closed event/stage/operation/outcome/error tuples.
- R2 from the preceding loop is closed: `agent-spec/input/openai-compatible-surface.md` is `status: 부분`, and the stale runtime cleanup-observation deferral is removed while provider-driver and actual Claude/Mac qualification remain deferred.
- Fresh verification evidence: both predecessor checks, the focused real-POST test, the full OpenAI package, focused service observation tests, vet, deterministic spec checks, and `git diff --check` pass. The remaining defect is an assertion gap proven by direct inspection, not a production failure.
- Roadmap carryover: preserve `milestone-task=cleanup-observation`; deterministic S07 allowlist evidence remains in scope and actual Claude/Mac timing qualification remains deferred to S12 `claude-smoke`.

## 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_2.log` and `PLAN-cloud-G03.md` → `plan_cloud_G03_2.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-iop-owned-single-request-agent-execution/16+14,15_observation_evidence/`. If WARN/FAIL, fully write the next filesystem state required by the code-review skill.
4. If PASS and task group is `m-iop-owned-single-request-agent-execution`, preserve the first-line `milestone-task=cleanup-observation` metadata in `complete.log` and report it for runtime aggregation. 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_REVIEW_API-1 Enforce the production projection allowlists | [x] |

## Implementation Checklist

- [x] Resolve R1 by making both lifecycle metric snapshots reject missing, duplicate, or unexpected label names while retaining exact counter and histogram delta assertions.
- [x] Require every captured production observation log to have the exact field allowlist and types, the expected closed lifecycle tuple multiset, one shared bounded generated correlation, and no private sentinels.
- [x] Keep production lifecycle behavior, metric/log schemas, API/wire contracts, Node behavior, and the already-correct living-spec status/deferral text unchanged.
- [x] Run every dependency, focused, package, service-observation, vet, deterministic spec-consistency, and whitespace command with cache disabled where specified.
- [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_2.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G03_2.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-iop-owned-single-request-agent-execution/16+14,15_observation_evidence/` to `agent-task/archive/YYYY/MM/m-iop-owned-single-request-agent-execution/16+14,15_observation_evidence/` and update this checklist at the final archive path.
- [ ] If PASS and task group is `m-iop-owned-single-request-agent-execution`, preserve and report `milestone-task=cleanup-observation` metadata for runtime aggregation, without modifying roadmap or directly calling `update-roadmap`.
- [ ] If PASS for split work, remove empty active parent `agent-task/m-iop-owned-single-request-agent-execution/` 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

None.

## Key Design Decisions

Enforced exact 5-label name set and uniqueness validation in `singleRequestMetricKeyFromLabels` for both lifecycle counter and duration histogram metrics, and exact 9-key allowlist, types, and closed tuple multiset matching `wantDeltas` in `singleRequestLogKey` for captured observation log entries.

## Reviewer Checkpoints

- Confirm metric extraction for both `iop_edge_single_request_lifecycle_total` and `iop_edge_single_request_duration_seconds` rejects any missing, duplicate, or unknown label and requires exactly the five closed label names.
- Confirm the expected request, three stage, two tool, one cleanup, and one terminal lifecycle tuples and deltas remain exact.
- Confirm each captured `edge_single_request_observation` entry has exactly the production field keys and types and that its lifecycle tuple multiset matches the metric expectations.
- Confirm all entries share one non-empty bounded generated correlation and exclude internal tool names, arguments/results, workspace references, request content, and configured sentinels.
- Confirm the public terminal and unlabeled Anthropic ingress metric retain their privacy boundaries.
- Confirm no production Go file, API/wire contract, metric/log schema, Node behavior, or living spec changed.
- Confirm every Verification Results block contains literal stdout/stderr rather than a reconstructed summary.

## Verification Results

Paste actual stdout/stderr for every command; record replacements under deviations.

### 1. Packet 14 dependency

`test -f agent-task/m-iop-owned-single-request-agent-execution/14+05,12,13_observation_timing/complete.log || test "$(compgen -G 'agent-task/archive/*/*/m-iop-owned-single-request-agent-execution/14+05,12,13_observation_timing/complete.log' | wc -l)" -eq 1`

```text
(exited with code 0)
```

### 2. Packet 15 dependency

`test -f agent-task/m-iop-owned-single-request-agent-execution/15+14_observation_adapters/complete.log || test "$(compgen -G 'agent-task/archive/*/*/m-iop-owned-single-request-agent-execution/15+14_observation_adapters/complete.log' | wc -l)" -eq 1`

```text
(exited with code 0)
```

### 3. Focused lifecycle allowlist evidence

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

```text
ok  	iop/apps/edge/internal/openai	0.039s
```

### 4. OpenAI package regression

`go test ./apps/edge/internal/openai -count=1`

```text
ok  	iop/apps/edge/internal/openai	7.986s
```

### 5. Service observation regression

`go test ./apps/edge/internal/service -run 'TestSingleRequestMetrics|TestSingleRequestObservationLifecycleIntegration' -count=1`

```text
ok  	iop/apps/edge/internal/service	0.032s
```

### 6. Vet

`go vet ./apps/edge/internal/openai`

```text
(exited with code 0)
```

### 7. Input-surface status consistency

`test "$(sed -n 's/^status: //p' agent-spec/input/openai-compatible-surface.md | head -n 1)" = "부분"`

```text
(exited with code 0)
```

### 8. Removed stale cleanup-observation deferral

`! rg --fixed-strings 'Those drivers, raw-free cleanup observation, and actual Claude qualification remain separate work' agent-spec/runtime/edge-node-execution.md`

```text
(exited with code 0)
```

### 9. Whitespace

`git diff --check`

```text
(exited with code 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) |
| 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

| Dimension | Assessment | Evidence |
|-----------|------------|----------|
| Correctness | Pass | The production request path is unchanged, and fresh focused/package tests reproduce the expected lifecycle. |
| Completeness | Fail | The planned exact log-field/type oracle is incomplete because it validates a lossy map and accepts multiple numeric types. |
| Test Coverage | Fail | The real-POST test would still pass after duplicate log fields, numeric field-type drift, or a non-generated constant correlation. |
| API Contract | Pass | No public API, wire, metric schema, or production runtime change is introduced by this follow-up. |
| Code Quality | Fail | `singleRequestLogKey` labels its numeric expectation as `int64` while accepting `int`, `int64`, and `float64`, obscuring the actual schema. |
| Implementation Deviation | Fail | The active PLAN requires the exact nine production log fields and types plus a generated correlation shape; the implementation does not enforce those constraints. |
| Verification Trust | Fail | Every recorded command is reproducible and fresh reruns pass, but source inspection proves that the claimed exact schema assertion is weaker than reported. |
| Spec Conformance | Fail | SDD S07 requires trustworthy raw-free timing/log/metric allowlist evidence; the current real-POST log oracle does not fully establish that evidence. |

### Findings

- Required R1 — `apps/edge/internal/openai/single_request_handler_test.go:543`: `singleRequestLogKey` receives `entry.ContextMap()`, which collapses duplicate Zap keys before validation, and its numeric branch at lines 572-577 accepts `int`, `int64`, or `float64` for both `duration_ms` and `tool_count`. Production emits both as `zapcore.Int64Type`, so adding a duplicate field or changing either field to a float would still satisfy the claimed exact nine-field/type oracle. The correlation check at lines 789-790 also accepts any non-empty bounded constant instead of the production-generated `sr-...` shape required by the plan. Validate the raw `entry.Context` field list with exact cardinality, uniqueness, Zap field types, and closed keys before deriving the tuple; require the generated correlation format while retaining shared-correlation and private-sentinel checks.

### Routing Signals

- `review_rework_count=3`
- `evidence_integrity_failure=true`

### Next Step

Invoke the plan skill in `prepare-follow-up` mode for the same task path with Required finding R1, then archive this pair and materialize the freshly routed follow-up pair.
