<!-- task=m-iop-owned-single-request-agent-execution/08+03,07_workspace_admission plan=2 tag=REVIEW_REVIEW_API milestone-task=workspace-binding -->

# 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/08+03,07_workspace_admission, plan=2, tag=REVIEW_REVIEW_API

## Archive Evidence Snapshot

- Prior plan: `agent-task/m-iop-owned-single-request-agent-execution/08+03,07_workspace_admission/plan_cloud_G08_1.log`
- Prior review: `agent-task/m-iop-owned-single-request-agent-execution/08+03,07_workspace_admission/code_review_cloud_G09_1.log`
- Verdict: `FAIL`; routing signals: `review_rework_count=2`, `evidence_integrity_failure=true`.
- Required findings: R1 replace stale zero-value OpenAI public-service test fixtures with exact admitted workspace fixtures; R3 add deterministic reconnect/refresh handshakes and malformed/unsupported public rejection rows; R5 rerun and record complete full Edge evidence after those fixes.
- Fresh reviewer evidence: dependency, formatting, named registry/service race, focused node/service, vet, spec search, and whitespace checks passed. `go test ./apps/edge/internal/openai -count=1 -timeout=15s` reported eight single-request failures and timed out in `TestAnthropicSingleRequestCallerCancellationCancelsExecution`; the exact full Edge command did not complete in that package.
- Closed findings: R2 operation-specific zero limits and R4 living-spec synchronization are accepted and must not be reopened without a concrete regression.
- Roadmap carryover: `milestone-task=workspace-binding`; SDD S04 fail-closed workspace admission evidence remains the contribution target, while Node-private filesystem/symlink enforcement remains later work.

## 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_2.log` and `PLAN-cloud-G08.md` → `plan_cloud_G08_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/08+03,07_workspace_admission/`. 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 |
|------|---------|
| FIX-1 Restore admitted OpenAI public-service fixtures | [x] |
| FIX-2 Make admission race and rejection evidence deterministic | [x] |

## Implementation Checklist

- [x] Restore every OpenAI coordinator test that uses the public service with an exact configured workspace catalog and ready owner, preserving buffered/streaming endpoint assertions and proving the frozen workspace reaches the executor.
- [x] Replace schedule-dependent registry/service race cases with deterministic transition handshakes and extend the public admission matrix through malformed and unsupported workspaces with zero executor calls.
- [x] Run exact dependency, formatting, stale-fixture search, named race, OpenAI, focused, full Edge, vet, documentation, and whitespace verification to completion.
- [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_2.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G08_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`.
- [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/08+03,07_workspace_admission/` to `agent-task/archive/YYYY/MM/m-iop-owned-single-request-agent-execution/08+03,07_workspace_admission/` 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

- Added `newAdmittedAnthropicSingleRequestService` in the handler test owner. It registers one ready `workspace-node`, configures the exact opaque workspace ref in `NodeStore`, and delegates through the public `Service.StartSingleRequest` path. Buffered, streaming, cancellation, and direct stream-pump fixtures use this helper; no production bypass was restored.
- `TestAnthropicSingleRequestUsesOnePost` now checks the executor-visible frozen projection: requested ref, configured Node id, nonzero ready generation, and the closed read operation. The projection contains no workspace root, command template, or environment values.
- Registry reconnect coverage uses two rendezvous per transition: the reader verifies the unavailable window after owner removal, then verifies a strictly newer ready generation after re-registration. Service refresh and reconnect actors run in separate goroutines and are released only from the pre-handoff test seam.
- The public admission matrix now rejects empty, duplicate, unsupported, and command-inconsistent workspace catalogs with zero executor calls, in addition to unapproved, foreign, and pending cases.

## Reviewer Checkpoints

- Confirm every OpenAI test that invokes public `Service.StartSingleRequest` configures the exact opaque workspace ref in `NodeStore` and one ready `Registry` generation.
- Confirm direct service-package coordinator tests still use `startSingleRequest` and no production zero-runtime bypass was restored.
- Confirm the captured endpoint request contains the expected ref, configured Node id, nonzero generation, closed read capability, and no raw root/template/environment values.
- Confirm registry and service race tests use explicit per-transition handshakes rather than sleeps or a start-only scheduling assumption.
- Confirm unapproved, foreign, pending, stale, malformed, and unsupported cases all reach public service rejection with zero executor calls.
- Confirm the exact full Edge command completes through OpenAI, service, transport, and all remaining packages with an actual exit 0.

## Verification Results

Paste actual stdout/stderr under each command. If a command changes, record the exact replacement and reason under `Deviations from Plan`.

### 1. Packet 03 dependency

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

```text
PASS (exit 0; no stdout/stderr)
```

### 2. Packet 07 dependency

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

```text
PASS (exit 0; no stdout/stderr)
```

### 3. Formatting

`test -z "$(gofmt -l apps/edge/internal/openai/single_request_handler_test.go apps/edge/internal/openai/single_request_anthropic_stream_test.go apps/edge/internal/node/registry_test.go apps/edge/internal/service/single_request_workspace_test.go)"`

```text
PASS (exit 0; no stdout/stderr)
```

### 4. Stale OpenAI fixture search

`test -z "$(rg --sort path -l 'svc := &edgeservice.Service\\{\\}' apps/edge/internal/openai/single_request_handler_test.go apps/edge/internal/openai/single_request_anthropic_stream_test.go)"`

```text
PASS (exit 0; no stdout/stderr)
```

### 5. Registry race

`go test -race ./apps/edge/internal/node -run 'TestRegistryReadyOwnerSnapshot' -count=1`

```text
ok  	iop/apps/edge/internal/node	1.029s
```

### 6. Workspace admission race

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

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

### 7. OpenAI single-request regression

`go test ./apps/edge/internal/openai -run '^(TestSingleRequestAnthropic|TestAnthropicSingleRequest)' -count=1 -timeout=30s`

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

### 8. OpenAI/service race regression

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

```text
ok  	iop/apps/edge/internal/openai	11.948s
ok  	iop/apps/edge/internal/service	7.040s
```

### 9. Focused node/service regression

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

```text
ok  	iop/apps/edge/internal/node	0.030s
ok  	iop/apps/edge/internal/service	6.016s
```

### 10. Full Edge regression

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

```text
ok  	iop/apps/edge/cmd/edge	0.142s
ok  	iop/apps/edge/internal/authprojection	0.030s
ok  	iop/apps/edge/internal/bootstrap	0.436s
ok  	iop/apps/edge/internal/configrefresh	0.080s
ok  	iop/apps/edge/internal/controlplane	6.603s
ok  	iop/apps/edge/internal/edgecmd	0.080s
ok  	iop/apps/edge/internal/edgevalidate	0.047s
ok  	iop/apps/edge/internal/events	0.039s
ok  	iop/apps/edge/internal/input	0.073s
ok  	iop/apps/edge/internal/input/a2a	0.059s
ok  	iop/apps/edge/internal/node	0.051s
ok  	iop/apps/edge/internal/openai	8.059s
ok  	iop/apps/edge/internal/opsconsole	0.059s
ok  	iop/apps/edge/internal/service	6.014s
ok  	iop/apps/edge/internal/transport	4.796s
```

### 11. Vet

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

```text
PASS (exit 0; no stdout/stderr)
```

### 12. Living spec search

`rg --sort path -n 'workspace_ref|connection generation|admission|reselect|defer' agent-spec/runtime/edge-node-execution.md`

```text
71:    notes: Credential preflight admission release regression
77:    notes: Exact configured workspace owner and ready-generation admission projection
80:    notes: Workspace admission rejection, effective-limit, refresh, and generation-fence regressions
105:Edge owns provider selection, queue admission, leases, and connection-generation fencing. Node owns local provider adapters and executes normalized runs or provider HTTP tunnels after a ready handshake.
115:| single-request coordinator | Immutable admission과 closed stage envelope을 service-owned state graph (`accepted`, `planning`, `working`, `reviewing`, `repairing`, `internal_tool`, `finalizing`, `completed`, `failed`, `cancelled`)로 처리하고 surface terminal acknowledgement 뒤에만 completed로 전이한다. |
116:| workspace admission | An opaque `workspace_ref` resolves only through the configured Node catalog. Edge freezes the exact configured owner, dispatch-ready connection generation, closed operation/command ids, and effective limits before executor startup; unavailable, foreign, pending, malformed, and stale candidates fail closed without fallback or reselection. |
124:| recovery candidate preference | `ProviderPoolDispatchRequest` carries `AvoidProviderID` and `AllowAvoidedProviderFallback`. Every admission (initial and queued re-resolution) prefers a runtime-eligible alternate over the avoided provider; only the explicit fallback flag (derived from exact probe-backed `available` evidence) permits re-selecting the avoided provider when no alternate exists. Zero values preserve current selection. This is selection policy only: no retry loop, slot reservation, priority change, persistence, or retry counter. |
125:| OpenAI typed-stall consumption | Every supported Chat/Responses normalized or tunnel request has one unconditional runtime liveness owner, independent of configured semantic activation. It converts only the Edge-confirmed typed stall handoff into a raw-free StreamGate event, owns pre-commit eligibility, and closes the already fenced old transport before re-admission; Node does not grant replay authority. |
129:| managed credential lease | Edge가 principal·route·slot·profile·target·Node·revision·generation을 binding한 sealed lease를 발급하고 Node가 capacity admission 후 provider 실행 직전에만 연다. |
135:- single-request coordinator owns the service-level workspace admission described above as well as executor envelope privacy and the service-owned state graph. It exposes no workspace root, command executable/template/arguments, or environment values to the coordinator-facing binding.
136:- Node-private workspace request/result wire translation, bounded filesystem path and symlink containment, process lifecycle cleanup, and concrete tool execution remain deferred. The Edge admission binding is not an executor or filesystem enforcement substitute.
199:- Edge owns reception-generation and immutable-lease validation, the generation-scoped runtime health overlay, `iop_edge_provider_health_evidence_total` / `iop_edge_provider_health_transitions_total` / `edge_provider_health_observation` projections with closed label values, effective admission/snapshot projection, and exact later CAPABILITIES recovery.
203:- Workspace admission fences a ready connection generation before the service executor handoff, but does not introduce an Edge-Node workspace wire message or expose filesystem data.
209:- 2026-08-04: Added the shared Node run/tunnel watchdog coordinator, serialized tunnel emission fence, pre-provider admission cleanup, disconnect-bound handler lifetime, and deterministic S01/S02 manual-clock evidence.
215:- 2026-08-06: Added implemented Edge workspace admission for single-request execution: an opaque `workspace_ref` binds to one configured ready Node generation and a closed capability projection before executor startup. Admission rejects unavailable, foreign, pending, malformed, and stale candidates without fallback or reselection; Node-private wire, executor, filesystem path, and symlink enforcement remain deferred.
```

### 13. Whitespace

`git diff --check`

```text
PASS (exit 0; no stdout/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:
  - Correctness: Pass — every public single-request fixture now enters the exact configured workspace and ready-generation admission path, and rejected ownership or malformed capability states reach the executor zero times.
  - Completeness: Pass — R1, R3, and R5 are implemented within the routed write boundary, including deterministic transition handshakes, the public rejection matrix, and complete fresh Edge evidence.
  - Test Coverage: Pass — focused OpenAI, registry, service, race, adjacent-package, and full Edge tests all execute named cases uncached and exit successfully.
  - API Contract: Pass — the endpoint still uses the public service capability, preserves the requested public model, and exposes no raw root, command template, environment, provider, route, or credential data.
  - Code Quality: Pass — the shared admitted-service fixture removes repeated setup while the transition tests use explicit rendezvous and retain focused assertions.
  - Implementation Deviation: Pass — the implementation matches the plan's four test-file boundary and records no unplanned production or contract changes in this follow-up.
  - Verification Trust: Pass — fresh reviewer execution reproduces all recorded commands, including the complete `go test ./apps/edge/... -count=1` package list and exit 0.
  - Spec Conformance: Pass — the evidence satisfies the Edge catalog-owner/generation contribution to SDD S04 while leaving Node-private path, symlink, wire, and executor enforcement to their later packets.
- Findings: None.
- Routing Signals:
  - `review_rework_count=2`
  - `evidence_integrity_failure=false`
- Next Step: Write `complete.log`, archive this task under `agent-task/archive/2026/08/`, and emit the milestone completion metadata for runtime aggregation.
