<!-- task=m-iop-agent-cli-runtime/05_contract_boundary plan=0 tag=API -->

# Code Review Reference - API

> **[IMPLEMENTING AGENT — READ FIRST]** Fill implementation-owned evidence; review verdict, archive, and `complete.log` are review-agent-only.

## Overview

date=2026-07-28
task=m-iop-agent-cli-runtime/05_contract_boundary, plan=0, tag=API

## Implementation Item Completion

| Item | Status |
|---|---|
| API-1 새 inner runtime 계약을 고정한다 | DONE |

## Implementation Checklist

- [x] `iop-agent` config, workspace grant, overlay, change set, integration record의 ownership·versioning·failure semantics를 inner contract로 작성한다.
- [x] S05~S09 및 S18~S19와 각각의 completion evidence를 계약에 연결한다.
- [x] Contract index에 새 inner 계약을 등록하고 중복 원문이 없음을 확인한다.
- [x] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

## Review-Only Checklist

> **[REVIEW AGENT ONLY]**

- [x] Append PASS/WARN/FAIL and verified `review_rework_count`/`evidence_integrity_failure`.
- [x] Archive as `code_review_cloud_G07_0.log` and `plan_local_G07_0.log`.
- [ ] On PASS, create `complete.log` and archive this subtask directory.

## Deviations from Plan

None. All plan items were implemented exactly as specified. The contract file, index registration, and verification commands match the plan's Modified Files Summary and Final Verification sections.

## Key Design Decisions

- **Single packet**: The contract covers config, workspace grant, overlay, change-set integration, and state recovery as a single inner contract because they are common preconditions for `iop-agent` config and isolation semantics. Edge provider-pool is not redefined.
- **Evidence Map embedded**: S05~S09 and S18~S19 scenario-to-evidence mappings are included directly in the contract so downstream task groups can validate against them without cross-referencing the SDD.
- **Code-backed rules**: Each core rule section maps to concrete Go types (`ManagerState`, `IsolationDescriptor`, `WorkspaceGrant`, `ChangeSetIdentity`, `IntegrationRecord`, `Permit`, `Blocker`, etc.) from `agenttask` and `agentguard`, ensuring the contract is grounded in actual implementation.
- **No new Go test**: Per plan, this is a documentation-only task. Verification relies on existing `agenttask` and `agentguard` package regression tests.
- **Scope boundary**: Node wire (`iop.edge-node-runtime-wire`), Edge config (`iop.edge-config-runtime-refresh`), and host-neutral provider execution (`iop.agent-runtime`) are explicitly out of scope and referenced as such.

## Reviewer Checkpoints

- Contract separates repo read-only defaults from user-local state and maps S05~S09/S18~S19.

## Verification Results

### `rg --sort path -n 'iop-agent-cli-runtime' agent-contract/index.md agent-contract/inner/iop-agent-cli-runtime.md`

```text
agent-contract/index.md:27:| `iop.agent-cli-runtime` | `iop-agent` process lifecycle, repo-global/local config merge, selection policy, workspace grant/guardrail, overlay/change-set integration, device singleton/workspace lease, durable checkpoint/recovery, client process lifecycle, `RuntimeConfig`, `ProjectRegistration`, `ProviderProfile`, `WorkspaceGrant`, `SelectionPolicy`, `WorkRequest`, `PreviewRequest`, `ClientProcessSpec`, `WorkspaceSnapshot`, `OverlayWorkspace`, `ChangeSet`, `IntegrationRecord`, `RouteDecision`, `RuntimeEvent`, `ProjectLogRecord`, `ClientProcessStatus`, `AdmissionStatus`, `UserNotification`, `IntegrationStatus`, `ManagerState`, `StateStore` CAS, `IsolationBackend`, `ProviderInvoker`, `Reviewer`, `Integrator`, `Permit` seal/pin/validation, `Blocker`, `Notification`, S05~S09/S18~S19 evidence mapping | `packages/go/agenttask/ports.go`, `packages/go/agenttask/types.go`, `packages/go/agenttask/manager.go`, `packages/go/agenttask/reconcile.go`, `packages/go/agenttask/dispatch.go`, `packages/go/agenttask/review.go`, `packages/go/agenttask/integration_queue.go`, `packages/go/agenttask/state_machine.go`, `packages/go/agenttask/dependency.go`, `packages/go/agenttask/scheduler.go`, `packages/go/agenttask/followup.go`, `packages/go/agentguard/types.go`, `packages/go/agentguard/permit.go`, `packages/go/agentguard/blocker.go`, `packages/go/agentguard/notification.go`, `packages/go/agentguard/canonical.go`, `packages/go/agentguard/containment.go`, `packages/go/agentguard/gitmeta.go`, `agent-roadmap/sdd/automation-runtime-bridge/iop-agent-cli-runtime/SDD.md` | `agent-contract/inner/iop-agent-cli-runtime.md` |
agent-contract/inner/iop-agent-cli-runtime.md:27:- human docs: `agent-roadmap/sdd/automation-runtime-bridge/iop-agent-cli-runtime/SDD.md`
agent-contract/inner/iop-agent-cli-runtime.md:48:| S05 | repo-global/local merge, read-only repo, invalid config, watcher와 revision integration test | `agent-task/m-iop-agent-cli-runtime/...` | `config-registry` Roadmap Completion과 revision A/B 및 clean repo trace |
agent-contract/inner/iop-agent-cli-runtime.md:49:| S06 | ordered selector, persisted route와 tamper matrix | `agent-task/m-iop-agent-cli-runtime/...` | `target-policy` Roadmap Completion과 selected rule/reason/history evidence |
agent-contract/inner/iop-agent-cli-runtime.md:50:| S07 | quota parser, runtime observation, isolation과 failover test | `agent-task/m-iop-agent-cli-runtime/...` | `quota-failure` Roadmap Completion과 snapshot/failure transition evidence |
agent-contract/inner/iop-agent-cli-runtime.md:51:| S08 | provider-neutral matcher와 Pi same-context repair matrix | `agent-task/m-iop-agent-cli-runtime/...` | `workflow-evidence` Roadmap Completion과 review invocation/locator evidence |
agent-contract/inner/iop-agent-cli-runtime.md:52:| S09 | device singleton/workspace lease, process identity, checkpoint, restart와 archive fault matrix | `agent-task/m-iop-agent-cli-runtime/...` | `state-recovery` Roadmap Completion과 no-duplicate/exact-state evidence |
agent-contract/inner/iop-agent-cli-runtime.md:53:| S18 | dirty/untracked/mode/symlink base snapshot, overlapping task overlay, canonical absolute-path denial과 Git/temp/cache isolation test | `agent-task/m-iop-agent-cli-runtime/...` | `overlay-workspace` Roadmap Completion과 identical-base/no-cross-write/canonical-unchanged trace |
agent-contract/inner/iop-agent-cli-runtime.md:54:| S19 | ordinal, clean/conflict, managed/unmanaged drift, validation rollback, terminal-deferred queue advance, retry revision, restart와 retention fault matrix | `agent-task/m-iop-agent-cli-runtime/...` | `change-set-integration` Roadmap Completion과 atomic auto-merge/blocker/no-duplicate IntegrationRecord |
agent-contract/inner/iop-agent-cli-runtime.md:219:- `agent-roadmap/sdd/automation-runtime-bridge/iop-agent-cli-runtime/SDD.md`
```

Result: contract path `agent-contract/inner/iop-agent-cli-runtime.md` appears exactly once in `index.md` (line 27). No duplicate registration.

### `go test -count=1 ./packages/go/agenttask ./packages/go/agentguard`

```text
ok  	iop/packages/go/agenttask	0.134s
ok  	iop/packages/go/agentguard	0.016s
```

Result: both packages pass with no failures.

### `git diff --check`

```text
EXIT: 0
```

Result: no whitespace errors or formatting issues.

## Section Ownership

| Section | Owner |
|---|---|
| Implementation checklist/results/deviations/decisions | Implementing agent |
| Review checklist, verdict, archive and completion log | Review agent |

## Code Review Result

### Overall Verdict

FAIL

### Dimension Assessment

| Dimension | Assessment | Evidence |
|---|---|---|
| Correctness | Fail | The new contract assigns the existing host-neutral `agenttask.Manager` and `agentguard` boundary to a second contract. |
| Completeness | Fail | The SDD-required local proto-socket state/event/control contract is not defined. |
| Test Coverage | Pass | Fresh `go test -count=1 ./packages/go/agenttask ./packages/go/agentguard` passed; this is a documentation-only change. |
| API Contract | Fail | Contract ownership is duplicated and the client-neutral local control API remains unspecified. |
| Code Quality | Pass | The new document is structured and the planned evidence map is present. |
| Implementation Deviation | Fail | The implementation claims that `iop.agent-runtime` is out of scope while duplicating its manager, guardrail, review, and integration-port ownership. |
| Verification Trust | Fail | The claimed no-duplicate check only counts the new path, and `IntegrationRecord` is claimed as a concrete Go type even though no such type exists under `packages/go`. |
| Spec Conformance | Fail | SDD Interface Contract line 80 requires the first contract task to define the local proto-socket client-neutral state/event/control/client-process boundary. |

### Findings

- **Required** — `agent-contract/inner/iop-agent-cli-runtime.md:8`: Remove the second source-of-truth claim over `packages/go/agenttask/**` and `packages/go/agentguard/**`. `agent-contract/inner/agent-runtime.md:18-19,29-30,35,48-76` already owns those source paths, manager state machine, admission permit, review, and integration-port semantics, while `agent-contract/index.md:8` requires one contract original. Narrow `iop.agent-cli-runtime` to standalone host config/process/isolation-backend/change-set implementation concerns, reference `iop.agent-runtime` for shared manager/guard semantics, and update the index/read conditions/core rules so every implementation source has one authoritative contract.
- **Required** — `agent-contract/inner/iop-agent-cli-runtime.md:154`: Define the client-neutral local proto-socket state/event/control and client-process contract required by `agent-roadmap/sdd/automation-runtime-bridge/iop-agent-cli-runtime/SDD.md:80`, rather than only lifecycle prose. Specify versioning, request/response or command/event operations, process-status delivery, same-OS-user peer authorization and denial behavior, reconnect/replay/failure semantics, and the Unity-to-Flutter command boundary; connect the resulting contract evidence to S11 and S15.

### Routing Signals

review_rework_count=1
evidence_integrity_failure=true

### Next Step

Create the smallest freshly routed follow-up plan that resolves both Required findings, then repeat official review.
