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

# 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.
> 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=1, tag=REVIEW_API

## Archive Evidence Snapshot

- Prior plan: `agent-task/m-iop-owned-single-request-agent-execution/16+14,15_observation_evidence/plan_local_G03_0.log`
- Prior review: `agent-task/m-iop-owned-single-request-agent-execution/16+14,15_observation_evidence/code_review_cloud_G03_0.log`
- Verdict: `FAIL` with Required findings R1 and R2.
- R1: the real-POST test does not install the production service observation logger, snapshot lifecycle metric families, assert closed lifecycle deltas, or correlate raw-free logs.
- R2: the runtime spec still defers raw-free cleanup observation while claiming it is tested, and the input-surface spec status conflicts with `agent-spec/index.md`.
- Verification evidence: fresh focused/package tests, vet, dependency checks, and `git diff --check` passed, but the claimed lifecycle/log assertions are absent and the recorded spec-search output is not the command's actual stdout.
- Roadmap carryover: keep `milestone-task=cleanup-observation`; deterministic S07 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-G05.md` → `code_review_cloud_G05_1.log` and `PLAN-cloud-G05.md` → `plan_cloud_G05_1.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_API-1 Repair lifecycle evidence and living-spec consistency | [x] |

## Implementation Checklist

- [x] Resolve R1 by proving exact ingress/request/stage/tool/cleanup/terminal deltas, closed labels, one shared bounded correlation, and raw-free public/log projections through the production observation adapter.
- [x] Resolve R2 by restoring the input-surface status to `부분` and removing only the stale cleanup-observation deferral while preserving external Claude/Mac and provider-driver deferrals.
- [x] Keep production lifecycle, metrics, log schemas, API/wire contracts, and Node behavior unchanged.
- [x] Run every dependency, focused, package, vet, deterministic spec-consistency, and whitespace command with cache disabled where specified.
- [x] Fill every implementation-owned section in `CODE_REVIEW-cloud-G05.md` with literal implementation notes and command 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-cloud-G05.md` to `code_review_cloud_G05_1.log`.
- [x] Archive active `PLAN-cloud-G05.md` to `plan_cloud_G05_1.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

Installed production service observation logger via SetSingleRequestObservationLogger with a zaptest observer in TestAnthropicSingleRequestObservation. Captured before/after metric snapshots for iop_edge_single_request_lifecycle_total and iop_edge_single_request_duration_seconds from prometheus.DefaultGatherer and asserted exact lifecycle deltas and closed labels across request, stage, tool, cleanup, and terminal events. Verified that all captured edge_single_request_observation log entries share one bounded non-empty correlation ID and exclude private tool names, raw arguments, results, workspace references, and request content. Restored status: 부분 in agent-spec/input/openai-compatible-surface.md and removed stale cleanup-observation deferral from agent-spec/runtime/edge-node-execution.md.

## Reviewer Checkpoints

- Confirm R1 installs the production service observation adapter in the real-POST test rather than replacing it with local fake lifecycle counters.
- Confirm exact request-total, terminal, stage, tool, and cleanup deltas are asserted from production lifecycle metrics using closed labels and process-global before/after snapshots.
- Confirm captured `edge_single_request_observation` entries share one non-empty bounded generated correlation and exclude internal tool names, raw arguments/results, workspace references, request content, and sentinels.
- Confirm the public terminal remains free of private tool protocol and the ingress metric remains strictly unlabeled.
- Confirm R2 restores `status: 부분`, removes only the stale cleanup-observation deferral, and preserves the provider-driver and actual Claude/Mac qualification deferrals.
- Confirm no production Go file, API/wire contract, metric/log schema, or Node behavior changed.
- Confirm every Verification Results block contains literal stdout/stderr rather than a reconstructed summary.

## Verification Results

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

```

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

```

### 3. Focused lifecycle evidence

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

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

### 4. OpenAI package regression

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

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

### 5. Vet

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

```text

```

### 6. Input-surface status consistency

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

```text

```

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

```

### 8. Scoped observation and external-smoke documentation

`rg --sort path -n 'single-request observation evidence|stage-pure|raw-free correlation|Claude/Mac timing evidence.*deferred.*claude-smoke' agent-spec/input/openai-compatible-surface.md agent-spec/runtime/edge-node-execution.md`

```text
agent-spec/input/openai-compatible-surface.md
56:    notes: Non-streaming real HTTP POST, multiple private Node tool round trips, exact ingress count, terminal acknowledgement, privacy, failure, cancellation, and count-tokens compatibility; linked ingress/lifecycle/privacy observation evidence with unlabeled metric and raw-free correlation assertion
149:| marked single-request observation evidence | A single real POST links ingress=1, request-total=1, terminal=1, stage/tool/cleanup counts, and raw-free correlation without public tool protocol. `iop_anthropic_single_request_ingress_total` is unlabeled (no request_id, stage_id, provider identity, or content). Internal tool names, raw arguments, private results, and workspace references are absent from the public terminal and from log projections. Stage-pure timing, cardinality-bounded labels, and privacy semantics are documented here; actual Claude/Mac timing evidence is explicitly deferred to `claude-smoke` (SDD S12). |
239:- Marked single-request observation evidence links ingress=1, request-total=1, terminal=1, stage/tool/cleanup counts, and raw-free correlation for one real POST. `iop_anthropic_single_request_ingress_total` is strictly unlabeled: no request_id, stage_id, provider identity, content, or workspace reference appears as a metric label. Internal tool names (`workspace_read`, `workspace_write`, etc.), raw arguments, private results, and workspace references are absent from the public terminal JSON and from log projections. Stage-pure timing, cardinality-bounded labels, and privacy semantics are documented here. Actual Claude/Mac timing evidence is explicitly deferred to `claude-smoke` (SDD S12); deterministic coordinator/tool-loop tests do not imply external qualification.
326:- 2026-08-08: Synchronized marked single-request observation evidence: one real POST links ingress=1, request-total=1, terminal=1, stage/tool/cleanup counts, and raw-free correlation without public tool protocol. The `iop_anthropic_single_request_ingress_total` counter remains unlabeled (no request_id, stage_id, or provider identity). External Claude/Mac timing evidence is explicitly deferred to `claude-smoke`. Deterministic internal tool privacy and lifecycle delta assertions cover the full single-request path.

agent-spec/runtime/edge-node-execution.md
170:| single-request observation evidence | Stage-pure timing, tool/cleanup/total counts, cardinality-bounded labels, Node logs, and raw-free correlation are documented for the single-request path. `iop_anthropic_single_request_ingress_total` is strictly unlabeled. Internal tool names, raw arguments, and private results are absent from public output and log projections. Actual Claude/Mac timing evidence is explicitly deferred to `claude-smoke` (SDD S12); deterministic coordinator/tool-loop tests do not imply external qualification. |
204:Single-request lifecycle observation evidence links ingress=1, request-total=1, terminal=1, stage/tool/cleanup counts, and raw-free correlation for one real POST. `iop_anthropic_single_request_ingress_total` is strictly unlabeled (no request_id, stage_id, provider identity, content, or workspace reference). Internal tool names, raw arguments, and private results are absent from public output and log projections. Stage-pure timing, cardinality-bounded labels, and privacy semantics are documented here. Actual Claude/Mac timing evidence is explicitly deferred to `claude-smoke` (SDD S12); deterministic coordinator/tool-loop tests do not imply external qualification.
229:        Note over Edge: observation: ingress=1, request-total=1, terminal=1, stage/tool/cleanup counts, raw-free correlation
274:- `go test -count=1 ./apps/edge/internal/openai -run 'TestAnthropicSingleRequestObservation'` — deterministic single-request observation evidence: ingress=1, request-total=1, terminal=1, stage/tool/cleanup counts, raw-free correlation, and unlabeled metric assertion.
287:- Single-request observation evidence (ingress=1, request-total=1, terminal=1, stage/tool/cleanup counts, raw-free correlation) is documented and tested. `iop_anthropic_single_request_ingress_total` is strictly unlabeled. Internal tool names, raw arguments, and private results are absent from public output and log projections. Actual Claude/Mac timing evidence is explicitly deferred to `claude-smoke` (SDD S12); deterministic coordinator/tool-loop tests do not imply external qualification.
305:- 2026-08-08: Synchronized single-request lifecycle observation evidence: stage-pure timing (planning/working/reviewing/repairing/finalizing/completed/failed/cancelled), tool/cleanup/total counts, cardinality-bounded labels, Node logs, and raw-free correlation. External Claude/Mac timing evidence is explicitly deferred to `claude-smoke` (SDD S12). Deterministic coordinator/tool-loop tests cover the full single-request path without implying external qualification.
```

### 9. Whitespace

`git diff --check`

```text

```

---

> **[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 adapter is installed in the real-POST test, and fresh focused/package tests and vet pass without production changes. |
| Completeness | Fail | The remaining R1 acceptance requires exact metric-label and log-field allowlists, but the integration test silently ignores unknown metric labels and does not validate the captured log schema or closed lifecycle tuples. |
| Test Coverage | Fail | Exact request/stage/tool/cleanup/terminal deltas are covered, but request-derived lifecycle labels and unexpected log fields or values can be introduced without failing this test. |
| API Contract | Pass | No public API, wire contract, metric schema, or production runtime file was changed by this follow-up. |
| Code Quality | Pass | The test extension is localized and the fresh package, vet, and whitespace commands pass. |
| Implementation Deviation | Fail | The active PLAN explicitly requires closed metric labels and closed event/stage/operation/outcome log fields through the production adapter; those assertions are absent. |
| Verification Trust | Fail | The recorded commands are reproducible and pass, but the implementation claim that closed labels were asserted is contradicted by the snapshot and log-inspection code. |
| Spec Conformance | Fail | SDD S07 requires raw-free timing/log/metric allowlist evidence; the current real-POST test proves lifecycle counts and sentinel exclusion but not both projection allowlists. |

### Findings

- Required R1 — `apps/edge/internal/openai/single_request_handler_test.go:524`: `snapshotSingleRequestMetrics` switches over the five expected label names but silently ignores every unknown label, so a new request-derived label on either lifecycle metric family would still collapse into the same `singleRequestMetricKey` and pass the delta checks at lines 689-707. The log loop at lines 715-741 likewise checks only the message, shared bounded correlation, and selected private sentinels; it does not require the exact production field-key set or compare each entry's closed event/stage/operation/outcome/error tuple with the expected lifecycle multiset. This leaves the original R1 and SDD S07 metric/log allowlist requirement unresolved. Make the snapshot reject missing, duplicate, or unknown labels for both metric families, and make the real-POST log assertions enforce the exact allowed fields/types and expected closed lifecycle tuples while retaining the shared-correlation and raw-free checks.

### Routing Signals

- `review_rework_count=2`
- `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.
