<!-- task=m-iop-hot-path-one-shot-execution/08+02,04,06_workspace_binding plan=4 tag=REVIEW_REVIEW_REVIEW_API milestone-task=artifact-pair -->

# Code Review Reference - REVIEW_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.
> 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-03
task=m-iop-hot-path-one-shot-execution/08+02,04,06_workspace_binding, plan=4, tag=REVIEW_REVIEW_REVIEW_API

## Archive Evidence Snapshot

- Prior plan: `agent-task/m-iop-hot-path-one-shot-execution/08+02,04,06_workspace_binding/plan_cloud_G07_3.log`.
- Prior review: `agent-task/m-iop-hot-path-one-shot-execution/08+02,04,06_workspace_binding/code_review_cloud_G07_3.log`.
- Verdict: FAIL with 3 Required, 0 Suggested, and 0 Nit findings; `review_rework_count=3`, `evidence_integrity_failure=false`.
- Required scope: accept the actual `[]anthropicTool` decoder slice without manual `[]any` wrapping; reject command write templates that omit canonical content; and make containment guards honor parent-capable prepare/write operations while still rejecting existing symlink escapes.
- Affected files: `apps/edge/internal/openai/workspace_tool_binding.go`, `apps/edge/internal/openai/workspace_tool_codec.go`, and `apps/edge/internal/openai/workspace_tool_binding_test.go`.
- Fresh evidence: every planned dependency, focused, race, Edge-wide, vet, formatting, and diff command passes; a reviewer probe against an empty temporary workspace fails the generated parent-capable guard at the absent immediate parent, and static typing proves `[]anthropicTool` cannot be passed to the current `[]any` compiler parameter.
- Roadmap carryover: Milestone task `artifact-pair` and approved SDD scenario S06 remain unsatisfied for native endpoint admission, parent-capable write behavior, and complete command payload mapping.

## 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-G07.md` → `code_review_cloud_G07_4.log` and `PLAN-cloud-G07.md` → `plan_cloud_G07_4.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-iop-hot-path-one-shot-execution/08+02,04,06_workspace_binding/`. 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_REVIEW_API-1 Accept Native Tool Slices and Complete Command Payloads | [x] |
| REVIEW_REVIEW_REVIEW_API-2 Honor Parent-Capable Containment and Close Evidence | [x] |

## Implementation Checklist

- [x] Accept actual endpoint-owned tool slices and reject command mappings that omit or ambiguously encode the canonical write content.
- [x] Make containment guards capability-aware, add fresh-parent and symlink-escape regressions, and obtain clean dependency, focused, race, all-Edge, vet, formatting, and diff evidence.
- [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_G07_4.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G07_4.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-hot-path-one-shot-execution/08+02,04,06_workspace_binding/` to `agent-task/archive/YYYY/MM/m-iop-hot-path-one-shot-execution/08+02,04,06_workspace_binding/` and update this checklist at the final archive path.
- [ ] 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`.
- [ ] If PASS for split work, remove empty active parent `agent-task/m-iop-hot-path-one-shot-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

- `compileWorkspaceBinding` now accepts only the explicit endpoint slice types `[]any` and `[]anthropicTool`; native Anthropic decoder values are normalized without reflection or caller-side wrapping.
- Command templates accept `{path}` and `{content}` only as whole argv tokens. `{path}` occurs once for every command and a write requires exactly one `{content}`, preventing unsupported interpolation and content omission.
- Parent-capable guards walk to and canonicalize the nearest existing ancestor, retain the validated missing suffix, and fence the reconstructed target. Existing targets, including symlinks, are canonicalized directly; non-parent-capable operations still require their immediate parent.
- Guard tests execute only the generated POSIX guard in `t.TempDir()` fixtures. They never invoke a caller workspace command.

## Reviewer Checkpoints

- The compiler accepts the actual OpenAI `[]any` and native Anthropic `[]anthropicTool` decoder slices directly through explicit type cases, with equivalent immutable schema fingerprints.
- Command mappings reject unsupported placeholder forms and cannot compile a canonical write that omits `{content}`.
- Parent-capable absent paths fence the nearest existing ancestor and preserve the validated nonexistent suffix; non-parent-capable missing parents and existing final/ancestor symlink escapes fail.
- Capability-derived guard output remains covered by the issued payload correlation digest, and mutation makes the receipt unmatched.
- Hermetic tests evaluate guards only against temporary fixtures and never execute a caller workspace tool.
- Every required verification command passes on one checkout and the recorded output is verbatim.

## Verification Results

### Dependency verification

```bash
test -f agent-task/m-iop-hot-path-one-shot-execution/02+01_preset_generation/complete.log || test -f agent-task/archive/2026/08/m-iop-hot-path-one-shot-execution/02+01_preset_generation/complete.log
test -f agent-task/m-iop-hot-path-one-shot-execution/04+02,03_preset_model_authorization/complete.log || test -f agent-task/archive/2026/08/m-iop-hot-path-one-shot-execution/04+02,03_preset_model_authorization/complete.log
test -f agent-task/m-iop-hot-path-one-shot-execution/06+04,05_request_identity_ingress/complete.log || test -f agent-task/archive/2026/08/m-iop-hot-path-one-shot-execution/06+04,05_request_identity_ingress/complete.log
```

_Actual stdout/stderr:_

```text
exit status: 0
stdout/stderr: empty
```

### Focused compiler, codec, operation, and containment verification

```bash
go test -count=1 ./apps/edge/internal/openai -run 'TestWorkspace(Tool|Command|Binding|Operation|Containment)'
```

_Actual stdout/stderr:_

```text
ok  	iop/apps/edge/internal/openai	0.404s
exit status: 0
```

### Race verification

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

_Actual stdout/stderr:_

```text
ok  	iop/apps/edge/internal/openai	9.530s
ok  	iop/apps/edge/internal/service	6.997s
exit status: 0
```

### Edge-wide verification

```bash
review_tmp_dir=$(mktemp -d /config/.tmp-iop-workspace-binding.XXXXXX)
TMPDIR="$review_tmp_dir" go test -count=1 ./apps/edge/...
review_status=$?
rmdir "$review_tmp_dir"
test "$review_status" -eq 0
```

_Actual stdout/stderr:_

```text
ok  	iop/apps/edge/cmd/edge	0.868s
ok  	iop/apps/edge/internal/authprojection	0.086s
ok  	iop/apps/edge/internal/bootstrap	8.563s
ok  	iop/apps/edge/internal/configrefresh	0.719s
ok  	iop/apps/edge/internal/controlplane	6.786s
ok  	iop/apps/edge/internal/edgecmd	0.407s
ok  	iop/apps/edge/internal/edgevalidate	0.113s
ok  	iop/apps/edge/internal/events	0.091s
ok  	iop/apps/edge/internal/input	0.190s
ok  	iop/apps/edge/internal/input/a2a	0.146s
ok  	iop/apps/edge/internal/node	0.145s
ok  	iop/apps/edge/internal/openai	13.958s
ok  	iop/apps/edge/internal/opsconsole	0.149s
ok  	iop/apps/edge/internal/service	6.040s
ok  	iop/apps/edge/internal/transport	4.984s
exit status: 0
```

### Static and formatting verification

```bash
go vet ./apps/edge/...
gofmt -d apps/edge/internal/openai/workspace_tool_binding.go apps/edge/internal/openai/workspace_tool_codec.go apps/edge/internal/openai/workspace_tool_binding_test.go
git diff --check
```

_Actual stdout/stderr:_

```text
exit status: 0
stdout/stderr: empty
```

---

> **[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 | Fail | The generated containment guard rejects valid targets when the canonical workspace root is `/`: existing targets and non-parent-capable targets canonicalize to a single-slash path, while the root-prefix pattern expects a double-slash form. |
| Completeness | Fail | Native Anthropic admission, complete command payloads, parent-capable fresh paths, and symlink escapes are covered, but canonical containment is not correct for every absolute workspace admitted by the API contract. |
| Test coverage | Fail | The permanent guard matrix omits the root-workspace existing-target and non-parent-capable variants that expose the prefix bug. |
| API contract | Fail | `metadata.workspace` accepts absolute paths and does not exclude `/`; the guard rejects operations within that valid workspace instead of enforcing containment. |
| Code quality | Pass | The owned implementation is localized, formatted, deterministic, and contains no debug or dead-code artifacts. |
| Implementation deviation | Pass | The implementation follows the active plan's explicit native-slice, command-content, fresh-parent, and symlink-escape repair scope. |
| Verification trust | Pass | All claimed dependency, focused, race, Edge-wide, vet, formatting, and diff checks pass on the unchanged reviewed sources; the defect is an uncovered behavioral variant rather than contradicted evidence. |
| Spec conformance | Fail | SDD S06 requires canonical workspace containment for the selected binding, but valid operations under the canonical root workspace are rejected. |

### Findings

- **Required** — `apps/edge/internal/openai/workspace_tool_codec.go:339`: the containment case pattern `"$IOP_WS_ROOT"/*` becomes a double-slash prefix when `realpath` canonicalizes the workspace root to `/`, while an existing target or resolved immediate parent becomes a single-slash path such as `/tmp`. The exact generated-guard probe with `IOP_WORKSPACE_CWD=/` and existing relative target `tmp` prints `iop: path escapes workspace root` and exits 1, even though `/tmp` is contained by `/`; non-parent-capable paths fail for the same reason. Normalize the root-aware join/prefix comparison (or reject `/` at the owning API boundary if that is the intended contract), and add hermetic root-workspace regressions for an existing target plus a non-parent-capable target while retaining the fresh-parent and symlink-escape cases.

### Reviewer Verification Evidence

- Exact predecessor completion probes: PASS with no output.
- `go test -count=1 ./apps/edge/internal/openai -run 'TestWorkspace(Tool|Command|Binding|Operation|Containment)'`: PASS (`ok`, 0.360s).
- SDD-expanded `go test -race -count=1 ./packages/go/streamgate ./packages/go/config ./apps/edge/internal/openai ./apps/edge/internal/service`: PASS (`streamgate` 2.114s, `config` 1.633s, `openai` 9.223s, `service` 7.073s).
- Executable-`TMPDIR` `go test -count=1 ./apps/edge/...`: PASS for every Edge package.
- `go vet ./apps/edge/...`, `gofmt -d` on the three owned files, and `git diff --check`: PASS with no output.
- Reviewed-source SHA-256 values were unchanged before and after verification: `463a5c6c...9577f`, `a31cc065...d9c3`, and `a49b547c...d588`.
- Generated-guard root-workspace probe: FAIL as a behavioral reproducer with `iop: path escapes workspace root` and `guard_status=1` for existing relative target `tmp` under `IOP_WORKSPACE_CWD=/`.
- Repository-native Edge/provider smoke, caller workspace command execution, and full-cycle external agent execution were not run because this child owns an isolated compiler/codec and its plan explicitly excludes production integration and caller workspace tool execution.

### Routing Signals

`review_rework_count=4`

`evidence_integrity_failure=false`

### Next Step

FAIL: invoke plan skill in prepare-follow-up mode; archive the current pair and materialize the freshly routed follow-up pair.
