<!-- task=m-iop-hot-path-one-shot-execution/09+06,08_artifact_pair plan=0 tag=API milestone-task=artifact-pair -->

# Exact Plan/Review Artifact Frontier

## For the Implementing Agent

Start only after predecessors 06 and 08 have `complete.log`. Implement, run every command, and fill `CODE_REVIEW-cloud-G09.md` with actual evidence. Keep active files for official review; finalization is review-agent-only.

## Background

The selected workspace binding must issue an optional directory prepare and exactly the Plan/Review write pair, then validate the immediately following result frontier exactly once without executing tools.

## Dependencies and Execution Order

- Required predecessors: `06+04,05_request_identity_ingress` and `08+02,04,06_workspace_binding`.

## Analysis

### Files Read

- `agent-roadmap/sdd/knowledge-tool-optimization-extension/iop-hot-path-one-shot-execution/SDD.md`
- `apps/edge/internal/openai/chat_types.go`
- `apps/edge/internal/openai/anthropic_types.go`
- `apps/edge/internal/openai/stream_gate_ingress_test.go`
- `agent-contract/outer/openai-compatible-api.md`
- `agent-contract/outer/anthropic-compatible-api.md`

### SDD Criteria

SDD scenario S06 requires exact reserved paths, optional prepare, two-write expected sets, reversed result order acceptance, missing/extra/duplicate/opaque result rejection, and one-frontier success before local eligibility.

### Verification Context

Deterministic fake tool frontiers for both endpoints are sufficient; no filesystem or external tool is executed. Fresh/race tests are mandatory. Confidence: high.

### Test Coverage Gaps

Existing tool validation does not own a cross-call expected set for reserved prepare and pair calls.

### Symbol References

This child consumes the immutable binding selected by child 08 and the request frontier owned by child 06/05.

### Split Judgment

This is the second refined child of the former artifact pair. It owns only the cross-call prepare/pair state and can be verified independently from binding compilation and later local/review execution.

### Scope Rationale

Exclude binding compilation, filesystem execution, local/review model dispatch, cleanup, manifests, revisions, sibling files, and server-side fallback.

### Final Routing

`evaluation_mode=isolated-reassessment`; finalizer pair. Build closures are true; scores `(1,2,2,1,2)` yield G08/local-fit base, matched risks `temporal_state,concurrent_consistency,boundary_contract,structured_interpretation,variant_product` (5) trigger `risk-boundary`, so build is cloud `PLAN-cloud-G08.md`. Review scores `(1,2,2,2,2)` yield official cloud G09 in `CODE_REVIEW-cloud-G09.md`. No large context/rework/evidence failure/capability gap.

## Implementation Checklist

- [ ] Issue only the reserved request directory prepare and exact Plan/Review write pair through the pinned binding.
- [ ] Enforce public/provider ids, paths, receipts, and one-frontier exactly-once result consumption before local eligibility.
- [ ] Run dependency, focused frontier, race, vet, and diff verification exactly as written.
- [ ] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual notes and output.

### [API-2] Validate directory prepare and exact pair continuation frontier

#### Problem

The SDD permits one prepare call or exactly two Plan/Review writes and requires their exact results in the immediately following frontier. Existing validation has no cross-call expected set.

#### Solution

Build paths only as `.iop/job/<request_id>/{plan.md,review.md}`. If needed emit one prepare and resume the same selector stage; then accept exactly the two mapped writes and store expected public/internal ids. Consume the next frontier order-independently and reject missing, unknown, duplicate, opaque, failed, mixed, traversal, alternate-request, and replayed results.

#### Modified Files and Checklist

- [ ] `apps/edge/internal/openai/artifact_pair.go` — issued paths, prepare/pair expected sets, and result consumption.
- [ ] `apps/edge/internal/openai/artifact_pair_test.go` — Chat/Messages reversed/missing/extra/duplicate/opaque result integration.

#### Test Strategy

Write `TestArtifactPairFrontierMatrix` with both endpoints and all S06 cases. Assert local eligibility remains false until both exact successes are consumed and no filesystem call occurs.

#### Verification

Run `go test -race -count=1 ./apps/edge/internal/openai -run 'Test(Workspace|ArtifactPair)'`; expect PASS.

## Modified Files Summary

| File | Items |
|------|-------|
| `apps/edge/internal/openai/artifact_pair.go` | API-2 |
| `apps/edge/internal/openai/artifact_pair_test.go` | API-2 |
| `agent-task/m-iop-hot-path-one-shot-execution/09+06,08_artifact_pair/CODE_REVIEW-cloud-G09.md` | API-2 |

## Final Verification

```bash
test -f agent-task/m-iop-hot-path-one-shot-execution/06+04,05_request_identity_ingress/complete.log
test -f agent-task/m-iop-hot-path-one-shot-execution/08+02,04,06_workspace_binding/complete.log
go test -race -count=1 ./apps/edge/internal/openai -run 'Test(Workspace|ArtifactPair)'
go test -race -count=1 ./packages/go/streamgate ./apps/edge/internal/openai ./apps/edge/internal/service
go vet ./apps/edge/internal/openai
git diff --check
```

Expected: all commands exit 0; unsafe/malformed/opaque paths dispatch no local stage and reversed exact pair success becomes eligible once.
