<!-- task=m-iop-owned-single-request-agent-execution/03+02_single_request_coordinator plan=5 tag=REVIEW_REVIEW_API milestone-task=single-ingress -->

# 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-06
task=m-iop-owned-single-request-agent-execution/03+02_single_request_coordinator, plan=5, tag=REVIEW_REVIEW_API

## Archive Evidence Snapshot

- Current archived pair: `plan_cloud_G08_4.log` and `code_review_cloud_G08_4.log`; the review verdict is FAIL with stable Required R1 and R5, zero Suggested findings, and zero Nits.
- Required R2-R4 are closed by fresh race-tested executor-return, immutable binding/result storage, envelope ordering, and saved-stage validation.
- Fresh dependency, formatting, focused race, service, Edge vet, full Edge, and diff checks pass, but `TestSingleRequestProgressRedactionAndFinalCandidateDelivery` explicitly requires every progress result to be nil; `evidence_integrity_failure=true`.
- Roadmap carryover remains `milestone-task=single-ingress`: this packet supplies only the S01 coordinator foundation. Packet 05 still owns HTTP admission, the Edge ingress counter, endpoint tests, and outer/input documentation.

## 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-G08.md` → `code_review_cloud_G08_5.log` and `PLAN-cloud-G08.md` → `plan_cloud_G08_5.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/03+02_single_request_coordinator/`. 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>`, preserve the first-line `milestone-task` metadata in `complete.log` and report it for the runtime aggregation event. 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 Close final-candidate validation and surface delivery | [x] |

## Implementation Checklist

- [x] Require finalizing envelopes to carry a defensively copied candidate, reject result payloads on other stages, and guard successful acknowledgement against a missing retained candidate.
- [x] Publish a separately cloned candidate only in the reserved finalizing progress event while keeping executor messages/errors and non-final results redacted.
- [x] Add nil/stale candidate and saturated immutable surface-delivery regressions, then run dependency, formatting, focused race, package, vet, full Edge, and `git diff --check` verification.
- [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_G08_5.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G08_5.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-iop-owned-single-request-agent-execution/03+02_single_request_coordinator/` to `agent-task/archive/YYYY/MM/m-iop-owned-single-request-agent-execution/03+02_single_request_coordinator/` and update this checklist at the final archive path.
- [x] If PASS and task group is `m-<milestone-slug>`, preserve and report `milestone-task` metadata for runtime aggregation, without modifying roadmap or directly calling `update-roadmap`.
- [x] 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.
- [ ] 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

- Validate and clone a result before processing terminal errors or mutating state, so no non-finalizing envelope can retain a candidate and `finalizing` cannot be entered without one.
- Treat a successful acknowledgement with no retained candidate as an invalid-state failure that closes the execution fail-closed.
- Expose only a second clone of the retained final candidate on the reserved `finalizing` progress event; terminal, ordinary progress, executor messages, and executor errors remain redacted.
- Cover both invalid candidate placement and post-delivery copy isolation. The saturated progress regression mutates the surface copy before acknowledgement and proves `Wait()` returns the unchanged retained result.

## Reviewer Checkpoints

- Stable Required R1 and R5 each map to a production change and deterministic regression.
- Finalizing rejects a missing result, earlier-stage results cannot become the candidate, and successful acknowledgement requires the retained finalizing candidate.
- The finalizing progress event carries a separately cloned final result before acknowledgement; mutating it cannot affect `Wait()`.
- Executor-controlled messages/errors and every non-final result remain absent from surface progress.
- Reserved progress capacity keeps both the finalizing candidate and exactly one terminal event observable under saturation.
- R2-R4 executor-return, admission-copy, envelope-order, saved-stage, and terminal-race regressions remain passing.
- No HTTP/Anthropic ingress, concrete Node/workspace/provider runtime, contract/spec wording, or real Claude evidence is claimed.

## Verification Results

### Dependency

Command: `test -f agent-task/m-iop-owned-single-request-agent-execution/02+01_preset_binding/complete.log || test "$(compgen -G 'agent-task/archive/*/*/m-iop-owned-single-request-agent-execution/02+01_preset_binding/complete.log' | wc -l)" -eq 1`

_Actual output/status:_

Exit 0. No stdout or stderr.

### Formatting

Command: `test -z "$(gofmt -l apps/edge/internal/service/single_request.go apps/edge/internal/service/single_request_test.go)"`

_Actual output/status:_

Exit 0. No stdout or stderr.

### Focused race and candidate handoff

Command: `go test -race ./apps/edge/internal/service -run 'TestSingleRequest' -count=1`

_Actual output:_

```text
ok  \tiop/apps/edge/internal/service\t1.079s
```

### Service regression

Command: `go test ./apps/edge/internal/service -count=1`

_Actual output:_

```text
ok  \tiop/apps/edge/internal/service\t5.991s
```

### Edge vet

Command: `go vet ./apps/edge/...`

_Actual output:_

Exit 0. No stdout or stderr.

### Full Edge regression

Command: `go test ./apps/edge/... -count=1`

_Actual output:_

```text
ok  \tiop/apps/edge/cmd/edge\t0.149s
ok  \tiop/apps/edge/internal/authprojection\t0.044s
ok  \tiop/apps/edge/internal/bootstrap\t0.493s
ok  \tiop/apps/edge/internal/configrefresh\t0.097s
ok  \tiop/apps/edge/internal/controlplane\t6.625s
ok  \tiop/apps/edge/internal/edgecmd\t0.118s
ok  \tiop/apps/edge/internal/edgevalidate\t0.049s
ok  \tiop/apps/edge/internal/events\t0.038s
ok  \tiop/apps/edge/internal/input\t0.071s
ok  \tiop/apps/edge/internal/input/a2a\t0.194s
ok  \tiop/apps/edge/internal/node\t0.175s
ok  \tiop/apps/edge/internal/openai\t7.940s
ok  \tiop/apps/edge/internal/opsconsole\t0.037s
ok  \tiop/apps/edge/internal/service\t5.984s
ok  \tiop/apps/edge/internal/transport\t4.783s
```

### Diff check

Command: `git diff --check`

_Actual output:_

Exit 0. No stdout or stderr.

---

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

PASS

### Dimension Assessment

| Dimension | Assessment | Evidence |
|-----------|------------|----------|
| Correctness | Pass | Finalizing now requires and retains its own copied candidate, non-final stages reject result payloads, and successful acknowledgement fails closed without the retained candidate. |
| Completeness | Pass | Both stable Required R1 and R5 are closed within the planned service and regression-test boundary. |
| Test coverage | Pass | Nil/stale candidate, acknowledgement guard, saturated final-candidate delivery, copy isolation, redaction, prior lifecycle invariants, and terminal races pass under the focused race suite. |
| API contract | Pass | The surface can read an immutable final candidate before acknowledgement while executor-controlled message, error, and non-final result data remain private. |
| Code quality | Pass | The localized implementation is formatted and contains no relevant debug output, dead code, or unresolved TODOs. |
| Implementation deviation | Pass | The implementation matches the selected direct fixes and does not expand into HTTP ingress, concrete workspace execution, contract wording, or live provider evidence. |
| Verification trust | Pass | Fresh dependency, formatting, focused race, service, Edge vet, full Edge, and diff checks all exit successfully and agree with the checked production paths. |
| Spec conformance | Pass | The coordinator boundary conforms to SDD D02/D10 by retaining Edge-owned final output for surface commit and exposing only redacted progress plus the final user candidate. |

### Findings

None.

### Routing Signals

- `review_rework_count=2`
- `evidence_integrity_failure=false`

### Next Step

Archive the active pair, write `complete.log`, and move the completed split task to the monthly archive without modifying the roadmap.
